Skip to content

Commit

Permalink
Add edit config functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
Oren Bissick committed May 25, 2017
1 parent 9b8b41c commit 493dcda
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
17 changes: 8 additions & 9 deletions src/jmaxscale/EditConfGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public EditConfGUI(){
fileRead();
panels();
}

private TransferFile ssh = new TransferFile();
private String storeAllString="";
private JButton saveCloseBtn = new JButton("Save Changes and Close");
private JButton closeButton = new JButton("Exit Without Saving");
private JFrame frame=new JFrame("Viewing All Program Details");
private JFrame frame=new JFrame("Edit MaxScale Config");
// private JTextArea textArea = new JTextArea(storeAllString,0,70);
private JTextArea textArea = new JTextArea();

Expand All @@ -37,10 +37,9 @@ private JButton getCloseButton(){
}

private void fileRead(){
TransferFile ssh = new TransferFile();
ssh.download("MaxScale.cnf", ui.getHost(), ui.getUser(), ui.getPass());
ssh.download("maxscale.cnf", ui.getHost(), ui.getUser(), ui.getPass());
try{
FileReader read = new FileReader("MaxScale.cnf");
FileReader read = new FileReader("maxscale.cnf");
Scanner scan = new Scanner(read);
while(scan.hasNextLine()){
String temp=scan.nextLine()+"\n";
Expand Down Expand Up @@ -83,10 +82,9 @@ public void actionPerformed(ActionEvent e) {

}
});
frame.setSize(1000, 700);
frame.setSize(700, 500);
frame.setVisible(true);
frame.setLocationRelativeTo(null);


}

private void saveBtn(){
Expand All @@ -95,10 +93,11 @@ private void saveBtn(){


try {
file = new File("MaxScale.cnf");
file = new File("maxscale.cnf");
out = new FileWriter(file);
out.write(textArea.getText());
out.close();
ssh.upload("maxscale.cnf", ui.getHost(), ui.getUser(), ui.getPass());
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
Expand Down
5 changes: 3 additions & 2 deletions src/jmaxscale/TransferFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ public void download(String file, String host,String user, String password){
channelSftp = (ChannelSftp) channel;
channelSftp.cd(SFTPWORKINGDIR);
byte[] buffer = new byte[1024];
BufferedInputStream bis = new BufferedInputStream(channelSftp.get("MaxScale.cnf"));
File newFile = new File("MaxScale.cnf");
BufferedInputStream bis = new BufferedInputStream(channelSftp.get("maxscale.cnf"));
File newFile = new File("maxscale.cnf");
OutputStream os = new FileOutputStream(newFile);
BufferedOutputStream bos = new BufferedOutputStream(os);
int readCount;
Expand All @@ -80,6 +80,7 @@ public void download(String file, String host,String user, String password){
bis.close();
bos.close();
} catch (JSchException | SftpException | IOException ex) {
System.out.println(ex.toString());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/jmaxscale/ui.form
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
<Component id="passwordLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="password" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="26" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="26" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="runButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="comLabel" alignment="3" min="-2" max="-2" attributes="0"/>
Expand Down
4 changes: 2 additions & 2 deletions src/jmaxscale/ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addComponent(userName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(passwordLabel)
.addComponent(password, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 26, Short.MAX_VALUE)
.addGap(26, 26, 26)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(runButton)
.addComponent(comLabel)
Expand Down Expand Up @@ -321,7 +321,7 @@ private void configButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
thread.start();*/

EditConfGUI editWin = new EditConfGUI();

editWin.setLocation(this.getLocation());
}//GEN-LAST:event_configButtonActionPerformed

private void maxUserFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_maxUserFocusLost
Expand Down

0 comments on commit 493dcda

Please sign in to comment.