-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtensionSettingsGui.java
More file actions
152 lines (137 loc) · 4.99 KB
/
ExtensionSettingsGui.java
File metadata and controls
152 lines (137 loc) · 4.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
package file_organizer_gui;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import java.awt.Color;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import java.awt.Font;
import javax.swing.JButton;
public class ExtensionSettingsGui {
protected JFrame frmExtensionsSetUp;
private JTextField wordDocButton;
private JTextField pdfButton;
private JTextField textFileButton;
private JTextField powerPointButton;
private JTextField imageButton;
private JTextField excelButton;
private JTextField otherFileButton;
/**
* Create the application.
*/
public ExtensionSettingsGui() {
initialize();
}
public JFrame getFrame() {
return frmExtensionsSetUp;
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frmExtensionsSetUp = new JFrame();
frmExtensionsSetUp.setTitle("Extensions Set Up");
frmExtensionsSetUp.setBounds(100, 100, 450, 300);
frmExtensionsSetUp.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frmExtensionsSetUp.getContentPane().setLayout(null);
wordDocButton = new JTextField();
wordDocButton.setText("Word Document");
wordDocButton.setBounds(56, 48, 136, 22);
frmExtensionsSetUp.getContentPane().add(wordDocButton);
wordDocButton.setColumns(10);
wordDocButton.addActionListener(new FileTypeSettingsListener(wordDocButton.getText()));
pdfButton = new JTextField();
pdfButton.setText("PDF File");
pdfButton.setBounds(56, 83, 136, 22);
frmExtensionsSetUp.getContentPane().add(pdfButton);
pdfButton.setColumns(10);
pdfButton.addActionListener(new FileTypeSettingsListener(pdfButton.getText()));
textFileButton = new JTextField();
textFileButton.setText("Text File");
textFileButton.setBounds(56, 118, 136, 22);
frmExtensionsSetUp.getContentPane().add(textFileButton);
textFileButton.setColumns(10);
textFileButton.addActionListener(new FileTypeSettingsListener(textFileButton.getText()));
powerPointButton = new JTextField();
powerPointButton.setText("Powerpoint");
powerPointButton.setBounds(56, 154, 136, 22);
frmExtensionsSetUp.getContentPane().add(powerPointButton);
powerPointButton.setColumns(10);
powerPointButton.addActionListener(new FileTypeSettingsListener(powerPointButton.getText()));
imageButton = new JTextField();
imageButton.setText("JPeg,GIF,PNG(Image)");
imageButton.setBounds(244, 48, 136, 22);
frmExtensionsSetUp.getContentPane().add(imageButton);
imageButton.setColumns(10);
imageButton.addActionListener(new FileTypeSettingsListener(imageButton.getText()));
excelButton = new JTextField();
excelButton.setText("Excel File");
excelButton.setBounds(244, 83, 136, 22);
frmExtensionsSetUp.getContentPane().add(excelButton);
excelButton.setColumns(10);
excelButton.addActionListener(new FileTypeSettingsListener(excelButton.getText()));
JLabel lblNewLabel = new JLabel("New label");
lblNewLabel.setBounds(53, 153, 56, 16);
frmExtensionsSetUp.getContentPane().add(lblNewLabel);
JLabel lblInputWhereCertain = new JLabel("Input Where Certain file types should Go");
lblInputWhereCertain.setFont(new Font("Tahoma", Font.PLAIN, 16));
lblInputWhereCertain.setBounds(68, 19, 301, 16);
frmExtensionsSetUp.getContentPane().add(lblInputWhereCertain);
otherFileButton = new JTextField();
otherFileButton.setText("Other File Types");
otherFileButton.setBounds(244, 118, 136, 22);
frmExtensionsSetUp.getContentPane().add(otherFileButton);
otherFileButton.setColumns(10);
otherFileButton.addActionListener(new FileTypeSettingsListener(otherFileButton.getText()));
}
private class FileTypeSettingsListener implements ActionListener{
String fileType;
String buttonText;
public FileTypeSettingsListener(String buttonText){//figures out which button it is
this.buttonText=buttonText;
}
@Override
public void actionPerformed(ActionEvent e) {
switch(buttonText) {
case("Word Document"):
fileType = "Word";
break;
case("PDF File"):
fileType = "PDF";
break;
case("Text File"):
fileType = "Text";
break;
case("Powerpoint"):
fileType = "Powerpoint";
break;
case("JPeg,GIF,PNG(Image)"):
fileType = "Image";
break;
case("Excel File"):
fileType = "Excel";
break;
case("Other File Types"):
fileType = "Other";
break;
}
JTextField cast = (JTextField)e.getSource();
Path path = Paths.get(cast.getText());
try {
DirectoryValidator.validate(path);
new ConfigFileStreamer(path,fileType);
JOptionPane.showMessageDialog(null, "Directory Registered Successfully", "Success", JOptionPane.INFORMATION_MESSAGE);
}
catch(DirectoryNotFoundException f) {
f.getExceptionPopUp();
}
}
}
}