public class UpdateMappingInterface extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
JList configuration;
JList updatedItems;
JTextField newValue, oldValue, selectedFiles;
JButton update, select, chose;
JLabel finish,trenner;
Container c;
JPanel jp1, jp1a, jp1b, jp2, jp2a, jp2b;
String [] checkconfig;
String helfer;
public UpdateMappingInterface(String auswahl){
c = getContentPane();
c.setLayout(new GridLayout(2,1));
class selectListener implements ActionListener{
public void actionPerformed (ActionEvent e){
String helfer = (updatedItems.getSelectedValue()).toString();
newValue.setText(helfer);
updatedItems.clearSelection();
}
}
class ChoseListener implements ActionListener{
public void actionPerformed (ActionEvent e){
helfer ="";
Object [] h = configuration.getSelectedValues();
checkconfig = new String [h.length];
for(int i=0; i<h.length; i++){
checkconfig [i] = h[i].toString();
helfer = helfer + "\t" + h[i].toString();
}
selectedFiles.setText(helfer);
}
}
class UpdateListener implements ActionListener{
public void actionPerformed (ActionEvent e){
String [] ueberpruefen = checkconfig;
String alt = oldValue.getText();
String neu = newValue.getText();
finish.setVisible(true);
for(int i=0; i<ueberpruefen.length; i++){
try {
File auffangen =Update.updaten(ueberpruefen[i], alt, neu);
if(auffangen.exists()){
}
} catch (NumberFormatException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
}
dispose();
}
}
String[][] tafel = null;;
try {
tafel = ExcelConverterConfiguration.convert(auswahl);
} catch (IOException e) {
e.printStackTrace();
}
String [] uebersichtstafel = new String [tafel.length];
for(int i=0; i<uebersichtstafel.length;i++){
uebersichtstafel [i] = tafel [i] [0];
}
updatedItems = new JList(uebersichtstafel);
updatedItems.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JScrollPane spuI = new JScrollPane(updatedItems);
spuI.setVisible(true);
File folder = new File("D:\\TOOLConfiguration");
String [] uebersicht = folder.list();
LinkedList<String> helfer = new LinkedList<String>();
for(int i=0; i<uebersicht.length; i++){
if(uebersicht[i].endsWith(".txt")){
helfer.add(uebersicht [i]);
}
}
String [] dateien = new String [helfer.size()];
Iterator iterator = helfer.iterator();
int zaehler =0;
while(iterator.hasNext()){
String h = (iterator.next()).toString();
dateien [zaehler] = h;
zaehler++;
}
configuration = new JList (dateien);
configuration.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
JScrollPane spc = new JScrollPane(configuration);
spc.setVisible(true);
newValue = new JTextField();
newValue.setVisible(true);
oldValue = new JTextField("Insert old value here.");
oldValue.setVisible(true);
select = new JButton("SELECT");
select.setVisible(true);
selectListener sl = new selectListener();
select.addActionListener(sl);
chose = new JButton("CHOSE");
chose.setVisible(true);
ChoseListener cl = new ChoseListener();
chose.addActionListener(cl);
selectedFiles = new JTextField();
selectedFiles.setVisible(true);
JScrollPane spsF = new JScrollPane(selectedFiles);
spsF.setVisible(true);
update = new JButton("UPDATE");
update.setVisible(true);
UpdateListener ul = new UpdateListener();
update.addActionListener(ul);
update.setBackground(Color.ORANGE);
finish = new JLabel("Operation completed.");
finish.setVisible(false);
trenner = new JLabel();
trenner.setVisible(true);
trenner.setBackground(Color.BLACK);
jp1 = new JPanel();
jp2 = new JPanel();
jp1a = new JPanel();
jp1b = new JPanel();
jp2a = new JPanel();
jp2b = new JPanel();
jp1.setLayout(new GridLayout(1,2));
jp2.setLayout(new GridLayout(1,2));
jp1a.setLayout(new BorderLayout());
jp2a.setLayout(new GridLayout(1,1));
jp1b.setLayout(new GridLayout(4,1));
jp2b.setLayout(new GridLayout(4,1));
jp1a.add(spuI, BorderLayout.CENTER);
JTextField ui = new JTextField();
ui.setBackground(Color.ORANGE);
jp1a.add(ui , BorderLayout.SOUTH);
jp1a.setVisible(true);
jp1b.add(select);
jp1b.add(newValue);
jp1b.add(oldValue);
jp1b.add(trenner);
jp1b.setVisible(true);
jp1.add(jp1a);
jp1.add(jp1b);
jp1.setVisible(true);
c.add(jp1);
jp2a.add(spc);
jp2a.setVisible(true);
jp2b.add(chose);
jp2b.add(spsF);
jp2b.add(update);
jp2b.add(finish);
jp2b.setVisible(true);
jp2.add(jp2a);
jp2.add(jp2b);
c.add(jp2);
c.setVisible(true);
}