commit 588c1be66edaa09e2bb8365855a61b61d3679fc3 Author: weberni69795 Date: Sun Nov 10 10:39:39 2019 +0100 Version 1.0 fertige Aufgabe diff --git a/src/autogui/AutoGUI.java b/src/autogui/AutoGUI.java new file mode 100644 index 0000000..ed16a74 --- /dev/null +++ b/src/autogui/AutoGUI.java @@ -0,0 +1,74 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package autogui; + +import commands.CommandInvoker; +import controller.C_MenuListener; +import controller.C_MenuListener_undo; +import java.util.prefs.Preferences; +import javax.swing.UIManager; +import model.model; +import view.gui; + +/** + * AutoGUI + * enthält alle wichtigen Parameter wie View, Model, CommandInvoker, Controller + * @author matthias + */ +public class AutoGUI { + + /** + * @param args the command line arguments + */ + private gui frm; + //C_FileDialogOpen cfdo; + //C_SaveFile csf; + private Preferences prf; + private final String PathID = "LastUsedPath"; + private final String FILE_ID = "LastUsedFile"; + private C_MenuListener cml; + private C_MenuListener_undo cmlu; + private model mdl; + private CommandInvoker invoker; + + /** + * Konstruktor initialisiert alle Parameter und registriert die Events und Commands + */ + public AutoGUI() + { + this.prf = Preferences.userRoot().node(this.getClass().getName()); + //String test = this.prf.get(this.PathID, "abc"); // Leerer String falls get leer. + this.frm = new gui(); + this.frm.setVisible(true); + String lastPath = "Last used path: " + this.prf.get(this.PathID, "/"); + this.frm.getLblFilePath().setText(lastPath); + + this.mdl = new model(); + this.invoker = new CommandInvoker(); + + this.cml = new C_MenuListener(this.frm, this.PathID, this.FILE_ID, this.prf, this.mdl, this.invoker); + this.cml.registerEvents(); + this.cml.registerCommands(); /**INVOKER einfügen!!!!*/ + + this.cmlu = new C_MenuListener_undo(this.frm, this.PathID, this.FILE_ID, this.prf, this.mdl, this.invoker); + this.cmlu.registerEvents(); + } + + /** + * Main erstellt AutoGUI und setzt LookAndFeel + * @param args (String[]) + */ + public static void main(String[] args) { + // TODO code application logic here + new AutoGUI(); + try + { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } + catch(Exception ex){} + } + +} diff --git a/src/commands/CommandAdd.java b/src/commands/CommandAdd.java new file mode 100644 index 0000000..5ca910f --- /dev/null +++ b/src/commands/CommandAdd.java @@ -0,0 +1,57 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package commands; + +import java.io.File; +import java.util.prefs.Preferences; +import model.model; +import view.gui; + +/** + * Add Command + * @author matthias + */ +public class CommandAdd implements CommandInterface { + private File data; + private gui g; + private model mdl; + private Preferences prfs; + private String pid; + + + public CommandAdd(gui G, Preferences p, model mdl, String pid) + { + this.g = G; + this.mdl = mdl; + this.prfs = p; + this.pid = pid; + this.data = null; + } + + /** + * overrides execute vom CommandInterface + * hier wird eintragHinzufügen vom Model aufgerufen + */ + @Override + public void execute() { + try + { + this.mdl.eintragHinzufuegen(); + } + catch(Exception ex) + { + System.err.println(ex); + } + //System.out.println(this.pref.get(PATH_ID, "xyz")); + + + } + + @Override + public void undo() { + } + +} diff --git a/src/commands/CommandDelete.java b/src/commands/CommandDelete.java new file mode 100644 index 0000000..ecdd913 --- /dev/null +++ b/src/commands/CommandDelete.java @@ -0,0 +1,85 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package commands; + +import java.io.File; +import java.util.Stack; +import java.util.prefs.Preferences; +import model.model; +import view.gui; + +/** + * Delete Command + * @author matthias + */ +public class CommandDelete implements CommandInterface { + private File data; + private gui g; + private model mdl; + private Preferences prfs; + private String pid; + private Stack adressEintraegeDaten; + private Stack pos; + + + public CommandDelete(gui G, Preferences p, model mdl, String pid) + { + this.g = G; + this.mdl = mdl; + this.prfs = p; + this.pid = pid; + this.data = null; + adressEintraegeDaten = new Stack(); + this.pos = new Stack(); + } + /** + * overrides execute vom CommandInterface + * hier wird eeintragLoeschen vom Model aufgerufen + * davor werden die gelöschten Daten im Stack gespeichert + */ + @Override + @SuppressWarnings("unchecked") + public void execute() { + + try + { + int sel = this.g.getContentTable1().getjTable().getSelectedRow(); + + for(int i = 0; i < mdl.getColumnCount(); i++) + { + Object v = mdl.getValueAt(sel, i); + this.adressEintraegeDaten.push(v); + } + this.pos.push(sel); + this.mdl.eintragLoeschen(sel); + } + catch(Exception ex) + { + System.err.println(ex); + } + + //System.out.println(this.pref.get(PATH_ID, "xyz")); + + + } + /** + * overrides undo vom CommandInterface + * hier werden die gelöschten Daten wieder ins Modell geschrieben + */ + @Override + public void undo() { + System.out.println("del_undo"); + int pos_i = (int) this.pos.pop(); + + this.mdl.eintragHinzufuegenAt(pos_i); + for(int i = mdl.getColumnCount()-1; i >= 0; i--) + { + this.mdl.setValueAt(this.adressEintraegeDaten.pop(), pos_i, i); + } + this.mdl.fireTableDataChanged(); + } + +} diff --git a/src/commands/CommandInterface.java b/src/commands/CommandInterface.java new file mode 100644 index 0000000..8a2feaa --- /dev/null +++ b/src/commands/CommandInterface.java @@ -0,0 +1,17 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package commands; + +/** + * CommandInterface + * Interface for commands + * @author matthias + */ +public interface CommandInterface { + public void execute(); + public void undo(); + //public void redo +} diff --git a/src/commands/CommandInvoker.java b/src/commands/CommandInvoker.java new file mode 100644 index 0000000..167831f --- /dev/null +++ b/src/commands/CommandInvoker.java @@ -0,0 +1,52 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package commands; + +import java.awt.Component; +import java.util.HashMap; +import java.util.Stack; + +/** + * Command Invoker + * ordnet den verschiedenen Events die Kommandos zu + * speichert die letzten Kommandos im Stack + * @author matthias + */ +public class CommandInvoker { + private HashMap commands; + private Stack undoStack; + + public CommandInvoker() + { + this.commands = new HashMap<>(); + this.undoStack = new Stack<>(); + } + + public void addCommand(Component key, CommandInterface val) + { + this.commands.put(key, val); + } + + /** + * führt das zugehörige Kommand zum Key(Object) aus + * @param key (Objekt) + */ + public void executeCommand(Component key) + { + this.commands.get(key).execute(); + this.undoStack.push(this.commands.get(key)); + } + /** + * führt das zugehörige undo vom letzten Kommand aus + */ + public void undoCommand() + { + if (!this.undoStack.isEmpty()) + { + this.undoStack.pop().undo(); + } + } +} diff --git a/src/commands/CommandOpen.java b/src/commands/CommandOpen.java new file mode 100644 index 0000000..265c714 --- /dev/null +++ b/src/commands/CommandOpen.java @@ -0,0 +1,76 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package commands; + +import java.io.File; +import java.util.prefs.Preferences; +import javax.swing.JFileChooser; +import model.model; +import view.gui; + + +/** + * Open Command + * @author matthias + */ +public class CommandOpen implements CommandInterface { + private File data; + private gui g; + private Preferences pref; + private String PATH_ID; + private String FILE_ID; + private model mdl; + + public CommandOpen(gui G, Preferences p, String pid, String fid, model m) + { + this.g = G; + this.pref = p; + this.PATH_ID = pid; + this.FILE_ID = fid; + this.data = null; + this.mdl = m; + } + + /** + * overrides execute vom CommandInterface + * Öffnet den File Dialog und führt dann die Funktion datenLesen aus dem Modell aus + */ + @Override + public void execute() { + System.out.println("opening a file..."); + //System.out.println(this.pref.get(PATH_ID, "xyz")); + JFileChooser fc = this.g.getFileChooser(); + try + { + fc.setCurrentDirectory(new File(this.pref.get(PATH_ID, ""))); + } + catch(Exception ex) + { + System.err.println(ex); + } + if(fc.showOpenDialog(g) == JFileChooser.APPROVE_OPTION) + { + this.data = fc.getSelectedFile(); + this.g.getLblFilePath().setText(this.data.getAbsolutePath()); + this.pref.put(this.PATH_ID, this.data.getAbsolutePath()); + + //System.out.println(this.pref.get(PATH_ID, "xyz")); + try + { + this.mdl.datenLesen(this.data); + } + catch(Exception ex) + { + System.err.println(ex); + } + } + } + + @Override + public void undo() { + } + +} diff --git a/src/commands/CommandSave.java b/src/commands/CommandSave.java new file mode 100644 index 0000000..15d332d --- /dev/null +++ b/src/commands/CommandSave.java @@ -0,0 +1,74 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package commands; + +import java.io.File; +import java.util.prefs.Preferences; +import javax.swing.JFileChooser; +import model.model; +import view.gui; + +/** + * Save Command + * @author matthias + */ +public class CommandSave implements CommandInterface { + private File data; + private gui g; + private model mdl; + private Preferences prfs; + private String pid; + + + public CommandSave(gui G, Preferences p, model mdl, String pid) + { + this.g = G; + this.mdl = mdl; + this.prfs = p; + this.pid = pid; + this.data = null; + } + + /** + * overrides execute vom CommandInterface + * Öffnet den File Dialog und führt dann die Funtkion DatenSpeichern aus dem Modell aus + */ + @Override + public void execute() { + System.out.println("save..."); + JFileChooser fc = this.g.getFileChooser(); + try + { + fc.setCurrentDirectory(new File(this.prfs.get(this.pid, ""))); + } + catch(Exception ex) + { + System.err.println(ex); + } + if(fc.showSaveDialog(g) == JFileChooser.APPROVE_OPTION) + { + this.data = fc.getSelectedFile(); + this.g.getLblFilePath().setText(this.data.getAbsolutePath()); + this.prfs.put(this.pid, this.data.getAbsolutePath()); + + try + { + this.mdl.datenSpeichern(this.data); + } + catch(Exception ex) + { + System.err.println(ex); + } + //System.out.println(this.pref.get(PATH_ID, "xyz")); + + } + } + + @Override + public void undo() { + } + +} diff --git a/src/controller/C_FileDialogOpen.java b/src/controller/C_FileDialogOpen.java new file mode 100644 index 0000000..fccd51e --- /dev/null +++ b/src/controller/C_FileDialogOpen.java @@ -0,0 +1,60 @@ +/* ALT + + + + + + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + * +package controller; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.util.prefs.Preferences; +import javax.swing.JFileChooser; +import view.gui; + +/** + * + * @author endresma66479 + * +public class C_FileDialogOpen implements ActionListener +{ + gui frm; + File data; + String PATH_ID; + Preferences pref; + public C_FileDialogOpen(gui g, String ID, Preferences p) + { + this.frm = g; + this.data = null; + this.PATH_ID = ID; + this.pref = p; + } + + public void registerEvents() + { + this.frm.getBtnOpen().addActionListener(this); + this.frm.getMiOpen().addActionListener(this); + this.frm.getMiOpen_popup().addActionListener(this); + } + + @Override + public void actionPerformed(ActionEvent ae) + { + System.out.println("opening a file..."); + System.out.println(this.pref.get(PATH_ID, "xyz")); + JFileChooser fc = this.frm.getFileChooser(); + if(fc.showOpenDialog(frm) == JFileChooser.APPROVE_OPTION) + { + this.data = fc.getSelectedFile(); + this.frm.getLblFilePath().setText(this.data.getAbsolutePath()); + this.pref.put(this.PATH_ID, this.data.getAbsolutePath()); + System.out.println(this.pref.get(PATH_ID, "xyz")); + } + } +} + */ \ No newline at end of file diff --git a/src/controller/C_MenuListener.java b/src/controller/C_MenuListener.java new file mode 100644 index 0000000..d209df9 --- /dev/null +++ b/src/controller/C_MenuListener.java @@ -0,0 +1,93 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package controller; + +import commands.CommandAdd; +import commands.CommandDelete; +import commands.CommandInvoker; +import commands.CommandOpen; +import commands.CommandSave; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.prefs.Preferences; +import model.model; +import view.gui; + +/** + * Command Controller execute + * @author matthias + */ +public class C_MenuListener implements ActionListener{ + private gui view; + private CommandInvoker invoker; + private String PathID; + private String FildID; + private Preferences prfs; + private model mdl; + + public C_MenuListener(gui g, String pid, String fid, Preferences p, model m, CommandInvoker inv) + { + this.view = g; + this.invoker = inv; + this.PathID = pid; + this.FildID = fid; + this.prfs = p; + this.mdl = m; + + this.view.getContentTable1().getjTable().setModel(this.mdl); + } + + /** + * regestriert alle Events mit dem Command Controller als Listener + */ + public void registerEvents() + { + this.view.getBtnSave().addActionListener(this); + this.view.getMiSave().addActionListener(this); + this.view.getMiSave_popup().addActionListener(this); + + this.view.getBtnOpen().addActionListener(this); + this.view.getMiOpen().addActionListener(this); + this.view.getMiOpen_popup().addActionListener(this); + + this.view.getContentTable1().getBtnAdd().addActionListener(this); + this.view.getContentTable1().getBtnDel().addActionListener(this); + this.view.getContentTable1().getCtmiAdd_popup().addActionListener(this); + this.view.getContentTable1().getCtmiDelRow_popup().addActionListener(this); + } + + /** + * fügt alle Commands mit zugehörigem Event dem Invoker zu + */ + public void registerCommands() + { + this.invoker.addCommand(this.view.getBtnSave(), new CommandSave(this.view, this.prfs, this.mdl, this.PathID)); + this.invoker.addCommand(this.view.getMiSave(), new CommandSave(this.view,this.prfs, this.mdl, this.PathID)); + this.invoker.addCommand(this.view.getMiSave_popup(), new CommandSave(this.view, this.prfs, this.mdl, this.PathID)); + + this.invoker.addCommand(this.view.getBtnOpen(), new CommandOpen(this.view, this.prfs,this.PathID, this.FildID, this.mdl)); + this.invoker.addCommand(this.view.getMiOpen(), new CommandOpen(this.view, this.prfs,this.PathID, this.FildID, this.mdl)); + this.invoker.addCommand(this.view.getMiOpen_popup(), new CommandOpen(this.view, this.prfs,this.PathID, this.FildID, this.mdl)); + + this.invoker.addCommand(this.view.getContentTable1().getBtnAdd(), new CommandAdd(this.view, this.prfs, this.mdl, this.PathID)); + this.invoker.addCommand(this.view.getContentTable1().getCtmiAdd_popup(), new CommandAdd(this.view, this.prfs, this.mdl, this.PathID)); + + this.invoker.addCommand(this.view.getContentTable1().getCtmiDelRow_popup(), new CommandDelete(this.view, this.prfs, this.mdl, this.PathID)); + this.invoker.addCommand(this.view.getContentTable1().getBtnDel(), new CommandDelete(this.view, this.prfs, this.mdl, this.PathID)); + } + + /** + * ausführen vom executeCommand aus dem Invoker + * @param ae (AktionEvent) + */ + @Override + public void actionPerformed(ActionEvent ae) { + Component key = (Component) ae.getSource(); + this.invoker.executeCommand(key); + } + +} diff --git a/src/controller/C_MenuListener_undo.java b/src/controller/C_MenuListener_undo.java new file mode 100644 index 0000000..44d55ec --- /dev/null +++ b/src/controller/C_MenuListener_undo.java @@ -0,0 +1,62 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package controller; + +import commands.CommandInvoker; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.prefs.Preferences; +import model.model; +import view.gui; + +/** + * Command Controller undo + * @author matthias + */ +public class C_MenuListener_undo implements ActionListener{ + private gui view; + private CommandInvoker invoker; + private String PathID; + private String FildID; + private Preferences prfs; + private model mdl; + + public C_MenuListener_undo(gui g, String pid, String fid, Preferences p, model m, CommandInvoker inv) + { + this.view = g; + this.invoker = inv; + this.PathID = pid; + this.FildID = fid; + this.prfs = p; + this.mdl = m; + + this.view.getContentTable1().getjTable().setModel(this.mdl); + } + + /** + * registriert undo event + */ + public void registerEvents() + { + this.view.getBtnUndo().addActionListener(this); + + } + + public void registerCommands() + { + //this.invoker.addCommand(this.view.getBtnUndo(), ); + } + + /** + * führt undoCommand vom Invoker aus + * @param ae (AktionEvent) + */ + @Override + public void actionPerformed(ActionEvent ae) { + this.invoker.undoCommand(); + } + +} diff --git a/src/controller/C_SaveFile.java b/src/controller/C_SaveFile.java new file mode 100644 index 0000000..7213497 --- /dev/null +++ b/src/controller/C_SaveFile.java @@ -0,0 +1,45 @@ +/* ALT + + + + + + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + * +package controller; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import view.ContentTable; +import view.gui; + +/** + * + * @author endresma66479 + * +public class C_SaveFile implements ActionListener +{ + gui frm; + + public C_SaveFile(gui g) + { + this.frm = g; + } + + public void registerEvents() + { + this.frm.getBtnSave().addActionListener(this); + this.frm.getMiSave().addActionListener(this); + this.frm.getMiSave_popup().addActionListener(this); + ContentTable ct = this.frm.getContentTable1(); + } + @Override + public void actionPerformed(ActionEvent ae) + { + System.out.println("save..."); + } +} + +*/ \ No newline at end of file diff --git a/src/model/model.java b/src/model/model.java new file mode 100644 index 0000000..53855c0 --- /dev/null +++ b/src/model/model.java @@ -0,0 +1,124 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package model; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.ArrayList; +import javax.swing.table.AbstractTableModel; + + +public class model extends AbstractTableModel +{ + private ArrayList> daten; + private ArrayList adressEintraegeDaten; + private ArrayList adressEintraegeNamen; + + public model() + { + adressEintraegeDaten = new ArrayList<>(); + adressEintraegeNamen = new ArrayList<>(); + daten = new ArrayList<>(); + adressEintraegeNamen.add("Name"); + adressEintraegeDaten.add("Lehner"); + adressEintraegeNamen.add("Telefon"); + adressEintraegeDaten.add("122345"); + daten.add(adressEintraegeDaten); + } + + @Override + public int getRowCount() + { + return daten.size(); + } + + @Override + public int getColumnCount() + { + return adressEintraegeDaten.size(); + } + + @Override + public Object getValueAt(int row, int col) + { + return daten.get(row).get(col); + } + @Override + public void setValueAt(Object value, int row, int col) + { + daten.get(row).set(col, (String)value); + } + + @Override + public boolean isCellEditable(int row, int col) + { + return true; + } + + @Override + public String getColumnName(int col) + { + return adressEintraegeNamen.get(col); + } + + public void eintragHinzufuegen() + { + adressEintraegeDaten = new ArrayList<>(); + adressEintraegeNamen.forEach(s -> adressEintraegeDaten.add(s)); + daten.add(adressEintraegeDaten); + this.fireTableDataChanged(); + } + + public void eintragHinzufuegenAt(int pos) + { + adressEintraegeDaten = new ArrayList<>(); + adressEintraegeNamen.forEach(s -> adressEintraegeDaten.add(s)); + daten.add(pos, adressEintraegeDaten); + this.fireTableDataChanged(); + } + + public void eintragLoeschen(int row) + { + daten.remove(row); + this.fireTableDataChanged(); + } + + public void spalteHinzufuegen(String name) + { + adressEintraegeNamen.add(name); + } + + public void datenSpeichern(File datei) throws FileNotFoundException, IOException + { + FileOutputStream fos = new FileOutputStream(datei); + BufferedOutputStream bos = new BufferedOutputStream(fos); + ObjectOutputStream oos = new ObjectOutputStream(bos); + oos.writeObject(daten); + oos.writeObject(adressEintraegeNamen); + oos.flush(); + oos.close(); + } + + public void datenLesen(File datei) throws FileNotFoundException, IOException, ClassNotFoundException + { + FileInputStream fis = new FileInputStream(datei); + BufferedInputStream bis = new BufferedInputStream(fis); + ObjectInputStream ois = new ObjectInputStream(bis); + daten = (ArrayList>)ois.readObject(); + adressEintraegeNamen = (ArrayList)ois.readObject(); + adressEintraegeDaten = daten.get(daten.size()-1); + ois.close(); + this.fireTableDataChanged(); + } + +} diff --git a/src/view/ContentTable.form b/src/view/ContentTable.form new file mode 100644 index 0000000..8e40731 --- /dev/null +++ b/src/view/ContentTable.form @@ -0,0 +1,153 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + </TableColumnModel> + </Property> + <Property name="componentPopupMenu" type="javax.swing.JPopupMenu" editor="org.netbeans.modules.form.ComponentChooserEditor"> + <ComponentRef name="jPopupMenu1"/> + </Property> + <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> + <TableHeader reorderingAllowed="true" resizingAllowed="true"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JToolBar" name="jToolBar1"> + <Properties> + <Property name="rollover" type="boolean" value="true"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Last"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/> + <SubComponents> + <Component class="javax.swing.JButton" name="btnAdd"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/view/icons/RowInsertAfter24.gif"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="add entry"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="horizontalTextPosition" type="int" value="0"/> + <Property name="verticalTextPosition" type="int" value="3"/> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="btnDel"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/view/icons/RowDelete24.gif"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="delete entry"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="horizontalTextPosition" type="int" value="0"/> + <Property name="verticalTextPosition" type="int" value="3"/> + </Properties> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/view/ContentTable.java b/src/view/ContentTable.java new file mode 100644 index 0000000..c1bf8f2 --- /dev/null +++ b/src/view/ContentTable.java @@ -0,0 +1,157 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package view; + +/** + * + * @author endresma66479 + */ +public class ContentTable extends javax.swing.JPanel +{ + /** + * @return the jTable + */ + public javax.swing.JTable getjTable() + { + return jTable; + } + /** + * @return the ctmiAdd_popup + */ + public javax.swing.JMenuItem getCtmiAdd_popup() + { + return ctmiAdd_popup; + } + + /** + * @return the ctmiDelRow_popup + */ + public javax.swing.JMenuItem getCtmiDelRow_popup() + { + return ctmiDelRow_popup; + } + /** + * @return the btnAdd + */ + public javax.swing.JButton getBtnAdd() + { + return btnAdd; + } + + /** + * @return the btnDel + */ + public javax.swing.JButton getBtnDel() + { + return btnDel; + } + + + /** + * Creates new form ContentTable + */ + public ContentTable() + { + initComponents(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() + { + + jPopupMenu1 = new javax.swing.JPopupMenu(); + ctmiAdd_popup = new javax.swing.JMenuItem(); + ctmiDelRow_popup = new javax.swing.JMenuItem(); + jScrollPane1 = new javax.swing.JScrollPane(); + jTable = new javax.swing.JTable(); + jToolBar1 = new javax.swing.JToolBar(); + btnAdd = new javax.swing.JButton(); + btnDel = new javax.swing.JButton(); + + ctmiAdd_popup.setMnemonic('a'); + ctmiAdd_popup.setText("add a line"); + ctmiAdd_popup.setToolTipText("add a line"); + jPopupMenu1.add(ctmiAdd_popup); + + ctmiDelRow_popup.setMnemonic('d'); + ctmiDelRow_popup.setText("delete"); + ctmiDelRow_popup.setToolTipText("delete this line"); + jPopupMenu1.add(ctmiDelRow_popup); + + setPreferredSize(new java.awt.Dimension(600, 300)); + setLayout(new java.awt.BorderLayout()); + + jTable.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] + { + {null, null, null, null, null, null}, + {null, null, null, null, null, null}, + {null, null, null, null, null, null}, + {null, null, null, null, null, null}, + {null, null, null, null, null, null}, + {null, null, null, null, null, null}, + {null, null, null, null, null, null}, + {null, null, null, null, null, null}, + {null, null, null, null, null, null}, + {null, null, null, null, null, null}, + {null, null, null, null, null, null}, + {null, null, null, null, null, null}, + {null, null, null, null, null, null}, + {null, null, null, null, null, null}, + {null, null, null, null, null, null}, + {null, null, null, null, null, null}, + {null, null, null, null, null, null}, + {null, null, null, null, null, null}, + {null, null, null, null, null, null}, + {null, null, null, null, null, null} + }, + new String [] + { + "Nachname", "Name", "Strasse, Nr.", "PLZ", "Ort", "Telefonnr." + } + )); + jTable.setComponentPopupMenu(jPopupMenu1); + jScrollPane1.setViewportView(jTable); + + add(jScrollPane1, java.awt.BorderLayout.CENTER); + + jToolBar1.setRollover(true); + + btnAdd.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/icons/RowInsertAfter24.gif"))); // NOI18N + btnAdd.setToolTipText("add entry"); + btnAdd.setFocusable(false); + btnAdd.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + btnAdd.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jToolBar1.add(btnAdd); + + btnDel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/icons/RowDelete24.gif"))); // NOI18N + btnDel.setToolTipText("delete entry"); + btnDel.setFocusable(false); + btnDel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + btnDel.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jToolBar1.add(btnDel); + + add(jToolBar1, java.awt.BorderLayout.PAGE_END); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnAdd; + private javax.swing.JButton btnDel; + private javax.swing.JMenuItem ctmiAdd_popup; + private javax.swing.JMenuItem ctmiDelRow_popup; + private javax.swing.JPopupMenu jPopupMenu1; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JTable jTable; + private javax.swing.JToolBar jToolBar1; + // End of variables declaration//GEN-END:variables +} diff --git a/src/view/gui.form b/src/view/gui.form new file mode 100644 index 0000000..cc59c6f --- /dev/null +++ b/src/view/gui.form @@ -0,0 +1,255 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> + <NonVisualComponents> + <Container class="javax.swing.JPopupMenu" name="jPopupMenu1"> + <Properties> + <Property name="componentPopupMenu" type="javax.swing.JPopupMenu" editor="org.netbeans.modules.form.ComponentChooserEditor"> + <ComponentRef name="jPopupMenu1"/> + </Property> + </Properties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="true"/> + </Layout> + <SubComponents> + <MenuItem class="javax.swing.JMenuItem" name="miSave_popup"> + <Properties> + <Property name="mnemonic" type="int" value="115"/> + <Property name="text" type="java.lang.String" value="save"/> + <Property name="toolTipText" type="java.lang.String" value="save this file"/> + </Properties> + </MenuItem> + <MenuItem class="javax.swing.JMenuItem" name="miOpen_popup"> + <Properties> + <Property name="mnemonic" type="int" value="111"/> + <Property name="text" type="java.lang.String" value="open"/> + <Property name="toolTipText" type="java.lang.String" value="open a file"/> + </Properties> + </MenuItem> + </SubComponents> + </Container> + <Container class="javax.swing.JDialog" name="FileDialog"> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="400" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="FileDialogP1" min="-2" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="300" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="FileDialogP1" min="-2" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="FileDialogP1"> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="FileChooser" min="-2" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="FileChooser" min="-2" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JFileChooser" name="FileChooser"> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Menu class="javax.swing.JMenuBar" name="jMenuBar1"> + <SubComponents> + <Menu class="javax.swing.JMenu" name="jmFile"> + <Properties> + <Property name="text" type="java.lang.String" value="File"/> + </Properties> + <SubComponents> + <MenuItem class="javax.swing.JMenuItem" name="miSave"> + <Properties> + <Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor"> + <KeyStroke key="Ctrl+S"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/view/icons/Save24.gif"/> + </Property> + <Property name="mnemonic" type="int" value="115"/> + <Property name="text" type="java.lang.String" value="Save"/> + <Property name="toolTipText" type="java.lang.String" value="Save current file"/> + </Properties> + </MenuItem> + <Menu class="javax.swing.JMenu" name="jmOpenPU"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/view/icons/Open24.gif"/> + </Property> + <Property name="mnemonic" type="int" value="79"/> + <Property name="text" type="java.lang.String" value="Open"/> + </Properties> + <SubComponents> + <MenuItem class="javax.swing.JMenuItem" name="miNewFile"> + <Properties> + <Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor"> + <KeyStroke key="Ctrl+N"/> + </Property> + <Property name="mnemonic" type="int" value="110"/> + <Property name="text" type="java.lang.String" value="new"/> + <Property name="toolTipText" type="java.lang.String" value="create a new file"/> + </Properties> + </MenuItem> + <MenuItem class="javax.swing.JMenuItem" name="miOpen"> + <Properties> + <Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor"> + <KeyStroke key="Ctrl+O"/> + </Property> + <Property name="mnemonic" type="int" value="111"/> + <Property name="text" type="java.lang.String" value="open"/> + <Property name="toolTipText" type="java.lang.String" value="open a existing file"/> + </Properties> + </MenuItem> + </SubComponents> + </Menu> + </SubComponents> + </Menu> + <Menu class="javax.swing.JMenu" name="jmEdit"> + <Properties> + <Property name="text" type="java.lang.String" value="Edit"/> + </Properties> + </Menu> + </SubComponents> + </Menu> + </NonVisualComponents> + <Properties> + <Property name="defaultCloseOperation" type="int" value="3"/> + <Property name="title" type="java.lang.String" value="Adressverwalter"/> + <Property name="size" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[600, 600]"/> + </Property> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar1"/> + <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-87,0,0,2,52"/> + <SyntheticProperty name="formSizePolicy" type="int" value="0"/> + <SyntheticProperty name="generateSize" type="boolean" value="true"/> + <SyntheticProperty name="generateCenter" type="boolean" value="true"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JToolBar" name="jToolBar1"> + <Properties> + <Property name="rollover" type="boolean" value="true"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="First"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/> + <SubComponents> + <Component class="javax.swing.JButton" name="btnOpen"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/view/icons/Open24.gif"/> + </Property> + <Property name="mnemonic" type="int" value="79"/> + <Property name="toolTipText" type="java.lang.String" value="Open a file"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="horizontalTextPosition" type="int" value="0"/> + <Property name="verticalTextPosition" type="int" value="3"/> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="btnSave"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/view/icons/Save24.gif"/> + </Property> + <Property name="mnemonic" type="int" value="83"/> + <Property name="toolTipText" type="java.lang.String" value="Save this file"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="horizontalTextPosition" type="int" value="0"/> + <Property name="verticalTextPosition" type="int" value="3"/> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="btnUndo"> + <Properties> + <Property name="text" type="java.lang.String" value="undo"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="horizontalTextPosition" type="int" value="0"/> + <Property name="verticalTextPosition" type="int" value="3"/> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="lblFilePath"> + <Properties> + <Property name="text" type="java.lang.String" value="/"/> + <Property name="toolTipText" type="java.lang.String" value="File location"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Last"/> + </Constraint> + </Constraints> + </Component> + <Component class="view.ContentTable" name="contentTable1"> + <Properties> + <Property name="componentPopupMenu" type="javax.swing.JPopupMenu" editor="org.netbeans.modules.form.ComponentChooserEditor"> + <ComponentRef name="jPopupMenu1"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> +</Form> diff --git a/src/view/gui.java b/src/view/gui.java new file mode 100644 index 0000000..696a308 --- /dev/null +++ b/src/view/gui.java @@ -0,0 +1,328 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package view; + +/** + * + * @author matthias + */ +public class gui extends javax.swing.JFrame { + /** + * @return the btnUndo + */ + public javax.swing.JButton getBtnUndo() + { + return btnUndo; + } + /** + * @return the contentTable1 + */ + public view.ContentTable getContentTable1() + { + return contentTable1; + } + /** + * @return the FileChooser + */ + public javax.swing.JFileChooser getFileChooser() + { + return FileChooser; + } + /** + * @return the lblFilePath + */ + public javax.swing.JLabel getLblFilePath() + { + return lblFilePath; + } + + /** + * @return the miNewFile + */ + public javax.swing.JMenuItem getMiNewFile() + { + return miNewFile; + } + + /** + * @return the miOpen + */ + public javax.swing.JMenuItem getMiOpen() + { + return miOpen; + } + + /** + * @return the miOpen_popup + */ + public javax.swing.JMenuItem getMiOpen_popup() + { + return miOpen_popup; + } + /** + * @return the FileDialog + */ + public javax.swing.JDialog getFileDialog() + { + return FileDialog; + } + + /** + * @return the btnOpen + */ + public javax.swing.JButton getBtnOpen() + { + return btnOpen; + } + + /** + * @return the btnSave + */ + public javax.swing.JButton getBtnSave() + { + return btnSave; + } + + /** + * @return the miSave + */ + public javax.swing.JMenuItem getMiSave() + { + return miSave; + } + + /** + * @return the miSave_popup + */ + public javax.swing.JMenuItem getMiSave_popup() + { + return miSave_popup; + } + + /** + * Creates new form NewJFrame + */ + public gui() { + initComponents(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() + { + + jPopupMenu1 = new javax.swing.JPopupMenu(); + miSave_popup = new javax.swing.JMenuItem(); + miOpen_popup = new javax.swing.JMenuItem(); + FileDialog = new javax.swing.JDialog(); + FileDialogP1 = new javax.swing.JPanel(); + FileChooser = new javax.swing.JFileChooser(); + jToolBar1 = new javax.swing.JToolBar(); + btnOpen = new javax.swing.JButton(); + btnSave = new javax.swing.JButton(); + btnUndo = new javax.swing.JButton(); + lblFilePath = new javax.swing.JLabel(); + contentTable1 = new view.ContentTable(); + jMenuBar1 = new javax.swing.JMenuBar(); + jmFile = new javax.swing.JMenu(); + miSave = new javax.swing.JMenuItem(); + jmOpenPU = new javax.swing.JMenu(); + miNewFile = new javax.swing.JMenuItem(); + miOpen = new javax.swing.JMenuItem(); + jmEdit = new javax.swing.JMenu(); + + jPopupMenu1.setComponentPopupMenu(jPopupMenu1); + + miSave_popup.setMnemonic('s'); + miSave_popup.setText("save"); + miSave_popup.setToolTipText("save this file"); + jPopupMenu1.add(miSave_popup); + + miOpen_popup.setMnemonic('o'); + miOpen_popup.setText("open"); + miOpen_popup.setToolTipText("open a file"); + jPopupMenu1.add(miOpen_popup); + + javax.swing.GroupLayout FileDialogP1Layout = new javax.swing.GroupLayout(FileDialogP1); + FileDialogP1.setLayout(FileDialogP1Layout); + FileDialogP1Layout.setHorizontalGroup( + FileDialogP1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 0, Short.MAX_VALUE) + .addGroup(FileDialogP1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(FileDialogP1Layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(FileChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + FileDialogP1Layout.setVerticalGroup( + FileDialogP1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 0, Short.MAX_VALUE) + .addGroup(FileDialogP1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(FileDialogP1Layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(FileChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + + javax.swing.GroupLayout FileDialogLayout = new javax.swing.GroupLayout(FileDialog.getContentPane()); + FileDialog.getContentPane().setLayout(FileDialogLayout); + FileDialogLayout.setHorizontalGroup( + FileDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 400, Short.MAX_VALUE) + .addGroup(FileDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(FileDialogLayout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(FileDialogP1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + FileDialogLayout.setVerticalGroup( + FileDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 300, Short.MAX_VALUE) + .addGroup(FileDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(FileDialogLayout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(FileDialogP1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setTitle("Adressverwalter"); + setSize(new java.awt.Dimension(600, 600)); + + jToolBar1.setRollover(true); + + btnOpen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/icons/Open24.gif"))); // NOI18N + btnOpen.setMnemonic('O'); + btnOpen.setToolTipText("Open a file"); + btnOpen.setFocusable(false); + btnOpen.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + btnOpen.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jToolBar1.add(btnOpen); + + btnSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/icons/Save24.gif"))); // NOI18N + btnSave.setMnemonic('S'); + btnSave.setToolTipText("Save this file"); + btnSave.setFocusable(false); + btnSave.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + btnSave.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jToolBar1.add(btnSave); + + btnUndo.setText("undo"); + btnUndo.setFocusable(false); + btnUndo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + btnUndo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jToolBar1.add(btnUndo); + + getContentPane().add(jToolBar1, java.awt.BorderLayout.PAGE_START); + + lblFilePath.setText("/"); + lblFilePath.setToolTipText("File location"); + getContentPane().add(lblFilePath, java.awt.BorderLayout.PAGE_END); + + contentTable1.setComponentPopupMenu(jPopupMenu1); + getContentPane().add(contentTable1, java.awt.BorderLayout.CENTER); + + jmFile.setText("File"); + + miSave.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK)); + miSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/icons/Save24.gif"))); // NOI18N + miSave.setMnemonic('s'); + miSave.setText("Save"); + miSave.setToolTipText("Save current file"); + jmFile.add(miSave); + + jmOpenPU.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/icons/Open24.gif"))); // NOI18N + jmOpenPU.setMnemonic('O'); + jmOpenPU.setText("Open"); + + miNewFile.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK)); + miNewFile.setMnemonic('n'); + miNewFile.setText("new"); + miNewFile.setToolTipText("create a new file"); + jmOpenPU.add(miNewFile); + + miOpen.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK)); + miOpen.setMnemonic('o'); + miOpen.setText("open"); + miOpen.setToolTipText("open a existing file"); + jmOpenPU.add(miOpen); + + jmFile.add(jmOpenPU); + + jMenuBar1.add(jmFile); + + jmEdit.setText("Edit"); + jMenuBar1.add(jmEdit); + + setJMenuBar(jMenuBar1); + + setSize(new java.awt.Dimension(564, 425)); + setLocationRelativeTo(null); + }// </editor-fold>//GEN-END:initComponents + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> + /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. + * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html + */ + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (ClassNotFoundException ex) { + java.util.logging.Logger.getLogger(gui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(gui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(gui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(gui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + //</editor-fold> + //</editor-fold> + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new gui().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JFileChooser FileChooser; + private javax.swing.JDialog FileDialog; + private javax.swing.JPanel FileDialogP1; + private javax.swing.JButton btnOpen; + private javax.swing.JButton btnSave; + private javax.swing.JButton btnUndo; + private view.ContentTable contentTable1; + private javax.swing.JMenuBar jMenuBar1; + private javax.swing.JPopupMenu jPopupMenu1; + private javax.swing.JToolBar jToolBar1; + private javax.swing.JMenu jmEdit; + private javax.swing.JMenu jmFile; + private javax.swing.JMenu jmOpenPU; + private javax.swing.JLabel lblFilePath; + private javax.swing.JMenuItem miNewFile; + private javax.swing.JMenuItem miOpen; + private javax.swing.JMenuItem miOpen_popup; + private javax.swing.JMenuItem miSave; + private javax.swing.JMenuItem miSave_popup; + // End of variables declaration//GEN-END:variables +} diff --git a/src/view/icons/Open24.gif b/src/view/icons/Open24.gif new file mode 100644 index 0000000..2086bc2 Binary files /dev/null and b/src/view/icons/Open24.gif differ diff --git a/src/view/icons/RowDelete24.gif b/src/view/icons/RowDelete24.gif new file mode 100644 index 0000000..8cf2438 Binary files /dev/null and b/src/view/icons/RowDelete24.gif differ diff --git a/src/view/icons/RowInsertAfter24.gif b/src/view/icons/RowInsertAfter24.gif new file mode 100644 index 0000000..0e32f21 Binary files /dev/null and b/src/view/icons/RowInsertAfter24.gif differ diff --git a/src/view/icons/Save24.gif b/src/view/icons/Save24.gif new file mode 100644 index 0000000..bfa98a8 Binary files /dev/null and b/src/view/icons/Save24.gif differ