id
stringlengths 36
36
| text
stringlengths 1
1.25M
|
---|---|
833348e6-7894-4ea4-8817-673121615438 | public void processTry(int number); |
83159bc2-f9c2-4348-87f5-f786ed16d9a5 | public void setPresenterImpl(PresenterInterface presenterImpl) {
this.presenterImpl = presenterImpl;
} |
33bc446a-4766-4b3e-91e0-13148413b5d5 | abstract public Parent getViewRoot(); |
d7ad0391-31f9-4512-a585-0844b612d587 | @Override
public void initialize(URL url, ResourceBundle resourceBundle) {
attempts = tryHistory.getItems();
// ustawić w scene builderze dla przycisku nazwe _New game i wtedy ponizsze zadziala jako skrot alt-n,
// jesli sie nie myle to bedzie wywolane to co jest w SB w onAction lub ustawione jako onAction w kodzie
bNewGame.setMnemonicParsing(true);
animate();
} |
50597a6b-aca9-4aa1-b4e6-afcfc1846a67 | @Override
public Parent getViewRoot() {
return root;
} |
6001a818-0299-4d11-9432-438221b0e024 | @FXML
private void handleTextField() {
Integer n = null;
try {
n = Integer.parseInt(number_textfield.getText());
} catch (NumberFormatException e) {
return;
}
presenterImpl.processTry(n);
} |
118f9e08-64c9-4241-b92a-916caa9527ee | public void setFieldsActive(boolean state) {
number_textfield.clear();
number_textfield.setEditable(state);
number_textfield.setDisable(!state);
} |
f67e7d1e-94ba-4140-b223-12dfbffb7a9f | public void clearAtteptsHistory() {
attempts.clear();
} |
6a376cd6-5e55-4606-8e27-5f3f81442c3d | public void showInfo(String msg) {
info_label.setText(msg);
} |
2cc81db2-5e83-4e95-a927-b480a9093ea8 | public void addTryHistory(String m) {
attempts.add(m);
tryHistory.scrollTo(attempts.size());
} |
8815eeb4-ddbc-4ebd-8367-8f61fb4f01d4 | @FXML
private void handleKoniec() {
presenterImpl.applicationExitShowConfirmDialog();
} |
ad807110-7a9e-46e4-90f5-ba31d6139d57 | @FXML
private void handleNewGame() {
presenterImpl.newGame();
} |
4eac007d-60aa-4ddf-933a-a37df0aa1a54 | public void animate() {
// bNewGame.toFront();
bNewGame.getTransforms().add(new Shear(0.7, 0));
scaleTransition = ScaleTransitionBuilder.create()
.node(bNewGame)
.duration(Duration.seconds(2))
.toX(3)
.toY(3)
.cycleCount(Timeline.INDEFINITE)
.autoReverse(true)
.build();
scaleTransition.play();
} |
08199327-64ab-4fce-bd77-71742317a0e1 | public CloseAppDialog(Stage owner, String title){
root = new BorderPane();
stage = this;
this.owner = owner;
initModality( Modality.APPLICATION_MODAL );
initOwner( owner );
initStyle( StageStyle.UTILITY );
setTitle( title );
setContents();
} |
843ad84b-524d-4282-9e07-636572058386 | public void setContents(){
Scene scene = new Scene(root,150,150);
setScene(scene);
Group groupInDialog = new Group();
groupInDialog.getChildren().add( new Label("Really Exit ?") );
root.setCenter( groupInDialog );
Button yes = new Button( "Yes" );
yes.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent paramT) {
buttonOkPressed=true;
stage.close(); // Closing the pop up.
// owner.close(); // Closing the parent stage also.
presenterImpl.applicationExit();
}
});
Button no = new Button( "No" );
no.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent paramT) {
buttonOkPressed=false;
stage.close(); // Closing the pop up only
}
});
HBox buttonPane = new HBox();
buttonPane.setSpacing(10);
buttonPane.getChildren().addAll(yes,no);
root.setBottom(buttonPane);
stage.show();
} |
8f787062-45b6-4b33-89aa-9290f4ac802b | @Override
public void handle(ActionEvent paramT) {
buttonOkPressed=true;
stage.close(); // Closing the pop up.
// owner.close(); // Closing the parent stage also.
presenterImpl.applicationExit();
} |
a84f453d-c04f-4e2a-b60d-28e250f5e922 | @Override
public void handle(ActionEvent paramT) {
buttonOkPressed=false;
stage.close(); // Closing the pop up only
} |
e8caff04-0fbf-4668-8191-17bdaff0d227 | public boolean isButtonOkPressed() {
return buttonOkPressed;
} |
f53eb62a-b312-450c-8127-f3d0cfd1fdf7 | @Override
public Parent getViewRoot() {
return root;
} |
ab0aef62-3d15-4704-b21e-c62212ee3c87 | public void uploadAndUnzipFile (String directory,String uploadFile,String deployModel)
{
FileUpload fu = new FileUpload();
ChannelSftp sftp=fu.connect(server_ip, server_port, user_name, password);
System.out.println("开始上传文件");
fu.upload(directory, uploadFile, sftp);
System.out.println("上传文件结束");
File tempFile =new File( uploadFile.trim());
String fileName = tempFile.getName(); //获取文件名
System.out.println("fileName = " + fileName);
UnZipFile uzf = new UnZipFile();
Connection conn = uzf.establishConnection(server_ip);
uzf.unZipFile(conn,user_name,password,fileName,directory,deployModel);
} |
071dac3d-6a5e-4f82-aa39-c653457d4531 | public FileUploadThread (String directory,String uploadFile,String deployModel) {
this.directory = directory;
this.uploadFile = uploadFile;
this.deployModel = deployModel;
} |
e4819c7c-3fec-4881-b775-ed4cc373bb32 | public void run() {
try {
Thread.sleep(5000);
new AutoDeployment().uploadAndUnzipFile(directory,uploadFile,deployModel);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} |
86be47e1-7784-4f9e-93d9-d7888e2ece0b | public String getSERVER_IP() {
return SERVER_IP;
} |
55a1b9b6-9dee-4fa6-a459-a1711c569ac4 | public void setSERVER_IP(String SERVER_IP) {
this.SERVER_IP = SERVER_IP;
} |
120d5ac9-8a54-4d83-a784-48e6bd881f2c | public String getSERVER_POR() {
return SERVER_POR;
} |
e1607c7a-6fa6-46b6-b51f-8d7700bd5f2d | public void setSERVER_POR(String SERVER_POR) {
this.SERVER_POR = SERVER_POR;
} |
1b6738af-86e6-428e-b8b7-982dd72ecb36 | public String getUSER_NAME() {
return USER_NAME;
} |
28beb537-0fa2-4801-85bf-77123344679a | public void setUSER_NAME(String USER_NAME) {
this.USER_NAME = USER_NAME;
} |
6e3e383f-c7a1-4f90-83a3-b75a5ce8b825 | public String getPASSWORD() {
return PASSWORD;
} |
bd06bf86-b869-4157-a4bb-053a0cf06be0 | public void setPASSWORD(String PASSWORD) {
this.PASSWORD = PASSWORD;
} |
5fe7138c-28f8-4ab5-878d-8dc7b78fc25a | public Connection establishConnection(String server_ip){
Connection conn = null;
try {
conn = new Connection(server_ip);
conn.connect(); // 连接
}
catch (IOException e) {
e.printStackTrace();
}
finally {
}
return conn;
} |
afad7f74-7e7a-4c9a-9459-bcd4a71d5761 | public int unZipFile(Connection conn,String user_name,String password,String filename,String directory,String deployModel){
Session session = null;
int ret = -1;
try {
if (conn.authenticateWithPassword(user_name, password)) { // 认证
session = conn.openSession(); // 打开一个会话
}
System.out.println("username : "+user_name);
System.out.println("password: " +password);
System.out.println("开始解压文件……");
if(deployModel.equals("incDeploy"))
{
session.execCommand("cd " + directory + ";" + "tar xvf " + filename); //切换目录,解压文件 ,增量发版使用tar命令解压
}
else if (deployModel.equals("fullDeploy")){
session.execCommand("cd " + directory + ";" + "jar xvf " + filename); //切换目录,解压文件 ,全量发版使用jar命令解压
}
else{
System.out.println("发布方式参数错误,文件未解压!");
}
InputStream stdErr = new StreamGobbler(session.getStderr());
InputStream stdOut = new StreamGobbler(session.getStdout());
String line = null;
BufferedReader brError = new BufferedReader(new InputStreamReader(stdErr,"utf-8"));
BufferedReader brStdout = new BufferedReader(new InputStreamReader(stdOut,"utf-8"));
while ((line = brError.readLine()) != null){
System.out.println(line);
}
while ((line = brStdout.readLine()) != null){
System.out.println(line);
}
ret = session.getExitStatus();
session.close();
conn.close();
if(ret==0)
{
System.out.println("解压成功!");
}
else {
System.out.println("解压失败!");
}
return ret;
}
catch (IOException e)
{
e.printStackTrace();
}
return ret;
} |
d21c9f72-d3bd-4b84-afbc-3d606a44ea4e | public static void main (String args[]) throws Exception {
SystemParam param = new SystemParam();
param.setSERVER_IP("10.1.30.5");
param.setSERVER_POR("22");
param.setUSER_NAME("weblogic");
param.setPASSWORD("weblogic");
XMLEncoder encoder = new XMLEncoder(
new BufferedOutputStream(
new FileOutputStream("Sample.xml")));
encoder.writeObject(param);
encoder.close();
System.out.println(param);
XMLDecoder decoder = new XMLDecoder(
new BufferedInputStream(
new FileInputStream("Sample.xml")));
SystemParam sample2 = (SystemParam)decoder.readObject();
decoder.close();
System.out.println(sample2);
} |
03a9fd16-9492-44ac-85e4-bbe6cf61dc77 | public static boolean isNumeric(String str){
Pattern pattern = Pattern.compile("[0-9]*");
return pattern.matcher(str).matches();
} |
a0c6bb9c-c635-47ec-a858-19eafac83770 | public FileProgressMonitor(long fileSize) {
this.fileSize = fileSize;
} |
311b8770-b4fb-4ced-9f51-9b231336eb31 | @Override
public void run() {
if (!isEnd()) { // 判断传输是否已结束
System.out.println("Transfering is in progress.");
long transfered = getTransfered();
if (transfered != fileSize) { // 判断当前已传输数据大小是否等于文件总大小
System.out.println("Current transfered: " + transfered + " bytes");
sendProgressMessage(transfered);
} else {
System.out.println("File transfering is done.");
setEnd(true); // 如果当前已传输数据大小等于文件总大小,说明已完成,设置end
}
} else {
System.out.println("Transfering done. Cancel timer.");
stop(); // 如果传输结束,停止timer记时器
return;
}
} |
fa652784-7e4e-4709-aa35-3163ec199e74 | public void stop() {
System.out.println("Try to stop progress monitor.");
if (timer != null) {
timer.cancel();
timer.purge();
timer = null;
isScheduled = false;
}
System.out.println("Progress monitor stoped.");
} |
a28f038c-92ca-4d31-a4bd-6108bb9a1950 | public void start() {
System.out.println("Try to start progress monitor.");
if (timer == null) {
timer = new Timer();
}
timer.schedule(this, 1000, progressInterval);
isScheduled = true;
System.out.println("Progress monitor started.");
} |
626f2a27-a8b4-4e33-91c5-c1bc9d8d5f55 | private void sendProgressMessage(long transfered) {
if (fileSize != 0) {
double d = ((double)transfered * 100)/(double)fileSize;
DecimalFormat df = new DecimalFormat( "#.##");
System.out.println("Sending progress message: " + df.format(d) + "%");
} else {
System.out.println("Sending progress message: " + transfered);
}
} |
9f7d1f39-547f-4b61-80e7-67371cc448e8 | public boolean count(long count) {
if (isEnd()) return false;
if (!isScheduled) {
start();
}
add(count);
return true;
} |
2ca5fe50-20fe-479d-b0b0-098ebc944249 | public void end() {
setEnd(true);
System.out.println("transfering end.");
} |
264bc175-0269-4600-808d-8ee2b9078a2b | private synchronized void add(long count) {
transfered = transfered + count;
} |
a2e1d2b5-0341-4245-886d-244a0e0922e6 | private synchronized long getTransfered() {
return transfered;
} |
b96739f9-c678-4a06-a6d5-bc32d72f24e5 | public synchronized void setTransfered(long transfered) {
this.transfered = transfered;
} |
189e543f-b78c-48f6-acc3-49f9f0f225b8 | private synchronized void setEnd(boolean isEnd) {
this.isEnd = isEnd;
} |
bc44d7bd-3925-496a-a920-23230d1aadca | private synchronized boolean isEnd() {
return isEnd;
} |
ec4ae618-4296-43b9-8d30-b5548f5606b6 | public void init(int op, String src, String dest, long max) {
// Not used for putting InputStream
} |
ccbd1b4f-e6d9-4f0c-b1df-97eeb1f2f27c | public ConsoleTextArea(InputStream[] inStreams) {
for(int i = 0; i < inStreams.length; ++i)
startConsoleReaderThread(inStreams[i]);
} // ConsoleTextArea() |
da8c5c49-28bd-4b06-b0c1-6e0cfc349454 | public ConsoleTextArea() throws IOException {
final LoopedStreams ls = new LoopedStreams();
// 重定向System.out和System.err
PrintStream ps = new PrintStream(ls.getOutputStream());
System.setOut(ps);
System.setErr(ps);
startConsoleReaderThread(ls.getInputStream());
} // ConsoleTextArea() |
9a88728d-1a95-4ac5-80ef-8d4edc91d462 | private void startConsoleReaderThread(
InputStream inStream) {
final BufferedReader br =
new BufferedReader(new InputStreamReader(inStream));
new Thread(new Runnable() {
public void run() {
StringBuffer sb = new StringBuffer();
try {
String s;
Document doc = getDocument();
while((s = br.readLine()) != null) {
boolean caretAtEnd = false;
caretAtEnd = getCaretPosition() == doc.getLength() ?
true : false;
sb.setLength(0);
append(sb.append(s).append('\n').toString());
if(caretAtEnd)
setCaretPosition(doc.getLength());
}
}
catch(IOException e) {
JOptionPane.showMessageDialog(null,
"从BufferedReader读取错误:" + e);
System.exit(1);
}
}
}).start();
} // startConsoleReaderThread() |
e176de83-ddc9-435e-b441-accecfa84a93 | public void run() {
StringBuffer sb = new StringBuffer();
try {
String s;
Document doc = getDocument();
while((s = br.readLine()) != null) {
boolean caretAtEnd = false;
caretAtEnd = getCaretPosition() == doc.getLength() ?
true : false;
sb.setLength(0);
append(sb.append(s).append('\n').toString());
if(caretAtEnd)
setCaretPosition(doc.getLength());
}
}
catch(IOException e) {
JOptionPane.showMessageDialog(null,
"从BufferedReader读取错误:" + e);
System.exit(1);
}
} |
980233f5-c029-404f-a833-aaac51130cb4 | public ChannelSftp connect(String server_ip, int server_port, String user_name,
String password) {
ChannelSftp sftp = null;
try {
JSch jsch = new JSch();
jsch.getSession(user_name, server_ip, server_port);
Session sshSession = jsch.getSession(user_name, server_ip, server_port);
System.out.println("Session created.");
sshSession.setPassword(password);
Properties sshConfig = new Properties();
sshConfig.put("StrictHostKeyChecking", "no");
sshSession.setConfig(sshConfig);
sshSession.connect();
System.out.println("Session connected.");
System.out.println("Opening Channel.");
Channel channel = sshSession.openChannel("sftp");
channel.connect();
sftp = (ChannelSftp) channel;
System.out.println("Connected to " + server_ip + ".");
} catch (Exception e) {
}
return sftp;
} |
cf3d2a64-8f66-441f-8ad2-1856027ad43f | public void upload(String directory, String uploadFile, ChannelSftp sftp) {
try {
sftp.cd(directory);
File file=new File(uploadFile);
FileInputStream fis = new FileInputStream(file);
System.out.println("文件size:"+String.valueOf(fis.available()/1000)+"k");
sftp.put(new FileInputStream(file), file.getName(),new FileProgressMonitor(fis.available()), ChannelSftp.OVERWRITE);
}
catch (SftpException sftpException){
sftpException.printStackTrace();
return;
}
catch (Exception e) {
e.printStackTrace();
return;
}
} |
afb8e993-6165-4ae4-963f-447625c79444 | public void download(String directory, String downloadFile,String saveFile, ChannelSftp sftp) {
try {
sftp.cd(directory);
File file=new File(saveFile);
sftp.get(downloadFile, new FileOutputStream(file));
} catch (Exception e) {
e.printStackTrace();
}
} |
b82102a2-40cb-4fc6-9874-a12b84b59371 | public void delete(String directory, String deleteFile, ChannelSftp sftp) {
try {
sftp.cd(directory);
sftp.rm(deleteFile);
} catch (Exception e) {
e.printStackTrace();
}
} |
f64cdb4c-5650-40d6-9bda-44342bfc7f2b | public Vector listFiles(String directory, ChannelSftp sftp) throws SftpException{
return sftp.ls(directory);
} |
a5b5081d-a485-495d-a3c2-f9dfb0b70c45 | public void close() {
keepRunning = false;
try {
super.close();
pipedOS.close();
}
catch(IOException e) {
// 记录错误或其他处理
// 为简单计,此处我们直接结束
System.exit(1);
}
} |
b2c50aed-1887-4dc0-9881-e1cf534ff8c3 | public void close() {
keepRunning = false;
try {
super.close();
}
catch(IOException e) {
// 记录错误或其他处理
// 为简单计,此处我们直接结束
System.exit(1);
}
} |
24369e62-fdbd-4f6c-a911-bb9be46b69b5 | public LoopedStreams() throws IOException {
pipedOS.connect(pipedIS);
startByteArrayReaderThread();
} // LoopedStreams() |
edf87dde-d304-4a7c-8c5f-af0d99f573f0 | public InputStream getInputStream() {
return pipedIS;
} // getInputStream() |
610b90ea-ebd3-479d-baeb-c7957844569a | public OutputStream getOutputStream() {
return byteArrayOS;
} // getOutputStream() |
00c10d65-214e-43cb-84c8-d805f7d7ba3d | private void startByteArrayReaderThread() {
new Thread(new Runnable() {
public void run() {
while(keepRunning) {
// 检查流里面的字节数
if(byteArrayOS.size() > 0) {
byte[] buffer = null;
synchronized(byteArrayOS) {
buffer = byteArrayOS.toByteArray();
byteArrayOS.reset(); // 清除缓冲区
}
try {
// 把提取到的数据发送给PipedOutputStream
pipedOS.write(buffer, 0, buffer.length);
}
catch(IOException e) {
// 记录错误或其他处理
// 为简单计,此处我们直接结束
System.exit(1);
}
}
else // 没有数据可用,线程进入睡眠状态
try {
// 每隔1秒查看ByteArrayOutputStream检查新数据
Thread.sleep(1000);
}
catch(InterruptedException e) {}
}
}
}).start();
} // startByteArrayReaderThread() |
e1cc87cb-4bab-41c9-90da-f17f03a9e969 | public void run() {
while(keepRunning) {
// 检查流里面的字节数
if(byteArrayOS.size() > 0) {
byte[] buffer = null;
synchronized(byteArrayOS) {
buffer = byteArrayOS.toByteArray();
byteArrayOS.reset(); // 清除缓冲区
}
try {
// 把提取到的数据发送给PipedOutputStream
pipedOS.write(buffer, 0, buffer.length);
}
catch(IOException e) {
// 记录错误或其他处理
// 为简单计,此处我们直接结束
System.exit(1);
}
}
else // 没有数据可用,线程进入睡眠状态
try {
// 每隔1秒查看ByteArrayOutputStream检查新数据
Thread.sleep(1000);
}
catch(InterruptedException e) {}
}
} |
5533e2a8-1002-40d2-8b8b-d6a911be0b7b | public JTabbedPane SystemParmFrame() {
server_ip_label.setBounds(10, 10, 70, 20);
server_ip.setBounds(75, 10, 200, 20);
server_port_label.setBounds(10, 35, 70, 20);
server_port.setBounds(75, 35, 200, 20);
username_label.setBounds(10, 60, 70, 20);
username.setBounds(75, 60, 200, 20);
password_label.setBounds(10, 85, 70, 20);
password.setBounds(75, 85, 200, 20);
SaveButton.setBounds(280, 120, 50, 20);
con.add(server_ip_label);
con.add(server_ip);
con.add(server_port_label);
con.add(server_port);
con.add(username_label);
con.add(username);
con.add(password_label);
con.add(password);
con.add(SaveButton);
tabPane.add("自动化发布", con);// 添加布局1
return tabPane;
} |
4f048ac9-5a7e-4ca8-8751-e58a99889048 | public void actionPerformed(ActionEvent e) {
if (e.getSource().equals(SaveButton)) {
}
} |
e0dbf5f1-e107-44c5-9166-1b07387eb101 | public MainFrame() {
double lx = Toolkit.getDefaultToolkit().getScreenSize().getWidth();
double ly = Toolkit.getDefaultToolkit().getScreenSize().getHeight();
frame.setLocation(new Point((int) (lx / 2) - 150, (int) (ly / 2) - 150));// 设定窗口出现位置
frame.setSize(480, 370);// 设定窗口大小
frame.setResizable(false); //禁止最大化
Image icon = Toolkit.getDefaultToolkit().getImage(""); //去掉左上角java图标
frame.setIconImage(icon);
frame.setContentPane(tabPane);// 设置布局
//添加按钮事件监听
about.addActionListener(this);
help.add(about) ; //将菜单项目添加到菜单
menuBar.add(help) ; //将菜单增加到菜单工具栏
frame.setJMenuBar(menuBar) ; //为 窗体设置 菜单工具栏
frame.setVisible(true);// 窗口可见
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// 使能关闭窗口,结束程序
AutoDeploymentFrame autoDeployment = new AutoDeploymentFrame();
tabPane.add("自动化发布", autoDeployment.AutoDeploymentFrame());// 添加布局1
AppLogViewFrame logView = new AppLogViewFrame();
tabPane.add("日志截取",logView.AppLogViewFrame());
//SystemParmFrame sysPlane = new SystemParmFrame();
//tabPane.add("系统配置",sysPlane.SystemParmFrame());
} |
81d47630-bda1-4c7c-b5d9-fa906638963e | public void actionPerformed (ActionEvent e) {
if (e.getSource().equals(about)) {
JOptionPane.showMessageDialog(frame, "OpsPlat运维平台 V0.1 alpha", "关于", 2);
}
} |
69272dd0-fd73-4849-8de7-e0b80c609d42 | public static void main(String[] args){
new MainFrame();
} |
aa2d908b-0d64-49cc-a829-39ed9e489477 | public Container AutoDeploymentFrame() {
jfc.setCurrentDirectory(new File("d://"));// 文件选择器的初始目录定为d盘
//设定组件布局
choseFile.setBounds(10, 10, 70, 20);
filePath.setBounds(75, 10, 200, 20);
choseButton.setBounds(280, 10, 50, 20);
serverDir.setBounds(10, 35, 70, 20);
serverDirPath.setBounds(75, 35, 200, 20);
deployModelLabel.setBounds(10, 60, 70, 20);
incDeploy.setBounds(75,60,60,20);
fullDeploy.setBounds(190,60,60,20);
deployGroup.add(incDeploy);
deployGroup.add(fullDeploy);
OKButton.setBounds(360, 75, 70, 40);
//控制台输出框
try {
consoleTextArea = new ConsoleTextArea();
scrollPane = new JScrollPane(consoleTextArea);
//设置控制台输出信息自动滚动到底部 开始
int height = 10;
Point p = new Point();
p.setLocation(0,this.consoleTextArea.getLineCount()*height);
this.scrollPane.getViewport().setViewPosition(p);
//设置控制台输出信息自动滚动到底部 结束
}
catch(IOException e) {
System.err.println(
"不能创建LoopedStreams:" + e);
System.exit(1);
}
scrollPane.setBounds(0,120,470,150);
//添加按钮事件监听
choseButton.addActionListener(this); // 添加事件处理
OKButton.addActionListener(this); // 添加事件处理
//添加组件到容器
con.add(choseFile);
con.add(filePath);
con.add(choseButton);
con.add(serverDir);
con.add(serverDirPath);
con.add(deployModelLabel);
con.add(incDeploy);
con.add(fullDeploy);
con.add(scrollPane);
con.add(OKButton);
return con;
} |
8cebb3d3-39b7-407b-bd76-ce997695e364 | public void actionPerformed (ActionEvent e) {
// 绑定到选择文件,先择文件事件
if (e.getSource().equals(choseButton)) {
jfc.setFileSelectionMode(0);// 设定只能选择到文件
int state = jfc.showOpenDialog(null);// 此句是打开文件选择器界面的触发语句
if (state == 1) {
return; // 撤销则返回
} else {
File f = jfc.getSelectedFile();// f为选择到的文件
filePath.setText(f.getAbsolutePath());
}
}
if (e.getSource().equals(OKButton)) {
String directory = serverDirPath.getText();
String uploadFile = filePath.getText();
String deployModel = null;
if(directory.equals("")){
JOptionPane.showMessageDialog(con, "请指定服务器目录", "提示", 2);
return;
}
if(uploadFile.equals(""))
{
JOptionPane.showMessageDialog(con, "请选择本地文件", "提示", 2);
return;
}
if(incDeploy.isSelected()||fullDeploy.isSelected())
{
if(incDeploy.isSelected()){
deployModel = "incDeploy";
}
else {
deployModel = "fullDeploy";
}
}
else{
JOptionPane.showMessageDialog(con, "请选择发布模式(全量/增量)", "提示", 2);
return;
}
System.out.println("启动文件上传解压子线程……");
new Thread(new FileUploadThread(directory,uploadFile,deployModel)).start();
}
} |
e0d95441-b6d9-4ef5-ad0c-633b36a0c47d | public Container AppLogViewFrame() {
log_path_label.setBounds(10, 10, 70, 20);
log_path.setBounds(75, 10, 200, 20);
log_name_label.setBounds(10, 35, 70, 20);
log_name.setBounds(75, 35, 200, 20);
line_num_label.setBounds(10, 60, 70, 20);
line_num.setBounds(75, 60, 200, 20);
OKButton.setBounds(360, 75, 70, 40);
//控制台输出框
try {
consoleTextArea = new ConsoleTextArea();
scrollPane = new JScrollPane(consoleTextArea);
//设置控制台输出信息自动滚动到底部 开始
int height = 10;
Point p = new Point();
p.setLocation(0,this.consoleTextArea.getLineCount()*height);
this.scrollPane.getViewport().setViewPosition(p);
//设置控制台输出信息自动滚动到底部 结束
}
catch(IOException e) {
System.err.println(
"不能创建LoopedStreams:" + e);
System.exit(1);
}
scrollPane.setBounds(0,120,470,150);
con.add(log_path_label);
con.add(log_path);
con.add(log_name_label);
con.add(log_name);
con.add(line_num_label);
con.add(line_num);
con.add(OKButton);
con.add(scrollPane);
OKButton.addActionListener(this); // 添加事件处理
return con;
} |
be1bf2c8-16c4-4bb6-aa89-6c9c9146b7ab | public void actionPerformed(ActionEvent e) {
if (e.getSource().equals(OKButton)) {
String directory = log_path.getText();
String logFile = log_name.getText();
String lineNumStr = line_num.getText();
if(directory.equals("")){
JOptionPane.showMessageDialog(con, "请指定服务器目录", "提示", 2);
return;
}
if(logFile.equals(""))
{
JOptionPane.showMessageDialog(con, "请指定日志文件", "提示", 2);
return;
}
if(lineNumStr.equals("") || !utils.isNumeric(lineNumStr))
{
JOptionPane.showMessageDialog(con, "请输入截取行数(数字)", "提示", 2);
return;
}
int lineNum = Integer.parseInt(lineNumStr);
new Thread(new LogViewThread(directory,logFile,lineNum)).start();
}
} |
b8c2053a-1f73-44ac-ad7c-7f1c8ef6211f | public LogViewThread(String directory,String logFile,int lineNum){
this.directory = directory;
this.logFile = logFile;
this.lineNum = lineNum;
} |
da2466e4-69e4-446e-9921-6faf5721db81 | public void run() {
try {
Thread.sleep(5000);
InterceptLog lc = new InterceptLog();
Connection conn = lc.establishConnection(server_ip);
new InterceptLog().InterceptLog( conn, user_name, password, logFile, directory, lineNum);
} catch (InterruptedException e) {
e.printStackTrace();
}
} |
82bc01b4-d986-4b39-b455-5a04262c6e84 | public Connection establishConnection(String server_ip){
Connection conn = null;
try {
conn = new Connection(server_ip);
conn.connect(); // 连接
}
catch (IOException e) {
e.printStackTrace();
}
finally {
}
return conn;
} |
c3777790-7d25-403d-ab24-5697ea9fa00d | public int InterceptLog(Connection conn,String user_name,String password,String filename,String directory,int lineNum) {
Session session = null;
int ret = -1;
try {
if (conn.authenticateWithPassword(user_name, password)) { // 认证
session = conn.openSession(); // 打开一个会话
}
System.out.println("username : " + user_name);
System.out.println("password: " + password);
System.out.println("开始截取日志……");
session.execCommand("cd " + directory + ";" + "tail -"+lineNum +" " + filename); //切换目录,截取文件
InputStream stdErr = new StreamGobbler(session.getStderr());
InputStream stdOut = new StreamGobbler(session.getStdout());
String line = null;
BufferedReader brError = new BufferedReader(new InputStreamReader(stdErr, "utf-8"));
BufferedReader brStdout = new BufferedReader(new InputStreamReader(stdOut, "utf-8"));
while ((line = brError.readLine()) != null) {
System.out.println(line);
}
while ((line = brStdout.readLine()) != null) {
System.out.println(line);
}
ret = session.getExitStatus();
session.close();
conn.close();
if (ret == 0) {
System.out.println("截取日志成功!");
} else {
System.out.println("截取日志失败!");
}
return ret;
} catch (IOException e) {
e.printStackTrace();
}
return ret;
} |
9a066b9b-3d83-48af-bfc6-67a063d6e6d9 | public Element() {
this.poids = 1;
} |
ca57df00-4f3e-4569-9e6a-765be18a5093 | public void setPere(Noeud pere) {
this.pere = pere;
} |
a9286c6d-797d-4279-9a47-92bf593edda2 | public void setSuiv(Element suiv) {
this.suiv = suiv;
} |
7b5fe815-9abd-4647-971b-7d26eea156a5 | public Noeud getPere() {
return pere;
} |
fb072b97-d7f5-4d0d-928b-f950d3d4b6d9 | public int getPoids() {
return poids;
} |
48caaedb-9c11-4d94-af86-81a6cf06b660 | public void setPoids(int poids) {
this.poids = poids;
} |
77c30d3a-3bf6-4e88-9be8-acab6896abe8 | public Element getSuiv() {
return suiv;
} |
ff2fc5c9-67c3-45a2-a90f-072c823044b3 | public void incrPoids() {
this.poids++;
} |
b4da1b84-fcbb-40a0-b4c8-234b0ec9e464 | public boolean estFilsGauche() {
return this == this.getPere().getFilsGauche();
} |
9463871f-ab08-4bb8-a516-d179eb064340 | public static void compression(String texte, OutputStream out)
throws IOException {
// initialise l'arbre avec la feuille '#'
ArbreHuffman arbre = new ArbreHuffman();
GestionnaireBit gestion = new GestionnaireBit();
for (char symbole : texte.toCharArray()) {
if (arbre.estPresent(symbole) && symbole != '#') {
gestion.transmettreChemin(arbre.getCode(symbole)); //log n
} else {
gestion.transmettreChemin(arbre.getCode('#')); // log n
gestion.transmettreSymbole(symbole);
}
arbre.modification(symbole);
}
gestion.finirTransmission(arbre.getRacine().getPoids());
gestion.ecrireDansFichier(out);
System.out.println("[DEBUG] Arbre final compression : \n" + arbre);
System.out.println("[DEBUG] Nombre de caracteres transmis : "
+ arbre.getRacine().getPoids());
} |
c2e04fbc-811c-4313-8eff-bec8520bbffe | public static void compression(File file, OutputStream out)
throws IOException {
final int length = (int) file.length();
final char[] buffer = new char[length];
final FileReader fr = new FileReader(file);
int offset = 0;
while (offset < length) {
int read = fr.read(buffer, offset, length - offset);
offset += read;
}
compression(new String(buffer), out);
} |
c21d47c9-3098-4545-8c7f-6990aaf5f3dc | public static String decompression(InputStream in) throws IOException {
StringBuilder str = new StringBuilder();
ArbreHuffman arbre = new ArbreHuffman();
// lecture des 4 premiers octets pour connaitre la taille
int longueurDuTexte = 0;
for (int i = 0; i < 4; i++) {
longueurDuTexte += (in.read() << (24 - i * 8));
}
// Si il n'y a rien a lire, on s'arrete la
if (longueurDuTexte == 0)
return "";
// Premier octet = lettre
byte b = (byte) in.read();
str.append((char) b);
arbre.modification((char) b);
LinkedList<Boolean> buffer = new LinkedList<Boolean>();
int i = 1;
while (i < longueurDuTexte) {
// On lit les bits tant que le chemin n'est pas complet
while (!arbre.estCheminComplet(buffer)) {
buffer.addAll(GestionnaireBit.byteToBooleanList((byte) in
.read()));
}
// Modifie la liste des bits lus - enlève les bits du buffer
char symbole = arbre.recupererFeuille(buffer);
if (symbole == '#') {
// Si le prochain caractere inconnu n'est pas en memoire, on lit
// le suivant
if (buffer.size() < 8) {
buffer.addAll(GestionnaireBit.byteToBooleanList((byte) in
.read()));
}
symbole = GestionnaireBit.booleanListToChar(buffer);
}
str.append(symbole);
arbre.modification(symbole);
i++;
}
System.out.println("[DEBUG] Arbre final decompression : \n" + arbre);
System.out.println("[DEBUG] Nombre de caracteres lu : " + i);
return str.toString();
} |
6cb9d363-77a1-4281-bc04-73feb7b45653 | public static void decompression(InputStream in, File out)
throws IOException {
FileWriter fw = new FileWriter(out);
fw.write(decompression(in));
fw.flush();
} |
b7b50a7f-7cd4-48b9-ba9f-4674233a970c | public static void main(String[] args) throws IOException {
File f = new File("test.vbgz");
Huffman.compression("abrac###adabra", new FileOutputStream(f));
System.out.println(Huffman.decompression(new FileInputStream(new File("test.vbgz"))));
} |
323d3193-0be0-4f6e-b5d3-19abd3e2df4a | public GestionnaireBit() {
liste = new LinkedList<Byte>();
current = 0;
indexCurrent = 0;
} |
0bddc960-063c-499f-9494-6a103fb3282c | public void transmettreSymbole(char symbole) {
transmettreChemin(byteToBooleanList((byte) symbole));
} |
efb9f64b-897e-4afb-81e2-bcb6cba2f8dd | public void transmettreChemin(Collection<Boolean> chemin) {
for (Boolean b : chemin) {
if (b) {
Byte comp = (byte) (1 << (7 - indexCurrent));
current = (byte) (current.byteValue() | (byte) comp);
}
if (++indexCurrent == 8) {
liste.add(current);
indexCurrent = 0;
current = 0;
}
}
} |
e4a8af67-ff07-4be2-bf2c-7e354a1b1d1a | public void finirTransmission(int nbTransmissions) {
if (indexCurrent != 0) {
liste.add(current);
}
for (int i = 0; i < 4; i++) {
byte b = (byte) (nbTransmissions << (3 - i) * 8 >> 24);
liste.push(b);
}
} |
d4f11a3c-b2ba-4d11-b2bd-a2a6bcd225e9 | public void ecrireDansFichier(OutputStream out) throws IOException {
for (Byte b : liste) {
out.write(new byte[] { b });
}
out.close();
} |
599d5506-d154-4fff-ac45-69cff71ca02f | public static Collection<Boolean> byteToBooleanList(byte b) {
Collection<Boolean> tmp = new ArrayList<Boolean>();
// on parcourt le caract�re pour construire la liste
char comp = 1 << 7;
for (int i = 0; i < 8; i++) {
tmp.add((b & comp) != 0);
comp >>= 1;
}
return tmp;
} |
eb5d60d0-42ff-4d9b-ae18-cdb0fb9ccb7a | public static char booleanListToChar(LinkedList<Boolean> bitList) {
char c = 0;
for (int i = 0; i < 8; i++) {
boolean b = bitList.pop();
if (b)
c |= (1 << (7 - i));
}
return c;
} |
f67e1378-164e-4382-a436-88c116efc0b6 | public static void showBits(Collection<Boolean> bitList) {
for (boolean b : bitList) {
System.out.print(b ? "1" : "0");
}
} |
c8eeef20-837e-431f-8e1c-5f06f7e5ecab | public Feuille(char symbole) {
super();
this.symbole = symbole;
} |
c7cc611b-e6e7-4056-a9db-abdc4a9c7e77 | public char getSymbole() {
return symbole;
} |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.