Mercurial > hg > ConflictEditor
changeset 9:e7d9a9176e08
Clean up connecting the widgets
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Tue, 13 Sep 2011 02:20:11 +0200 |
parents | fca19925366c |
children | a5ef4fbfd90c |
files | conflict-editor/src/main/java/de/codedo/conflicteditor/gui/ConflictEditor.java conflict-editor/src/main/java/de/codedo/conflicteditor/gui/ConflictEditorFrame.java |
diffstat | 2 files changed, 52 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/conflict-editor/src/main/java/de/codedo/conflicteditor/gui/ConflictEditor.java Tue Sep 13 02:07:14 2011 +0200 +++ b/conflict-editor/src/main/java/de/codedo/conflicteditor/gui/ConflictEditor.java Tue Sep 13 02:20:11 2011 +0200 @@ -15,7 +15,6 @@ import javax.swing.ListModel; import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; import javax.swing.table.TableModel; import org.codehaus.jackson.JsonNode; @@ -42,47 +41,66 @@ private void run() { _frame = new ConflictEditorFrame(); - connectListeners(_frame); + connectListeners(); _frame.pack(); _frame.setVisible(true); } - private void connectListeners(ConflictEditorFrame frame) + private void connectListeners() { - frame.getConnectButton().addActionListener( - new ExceptionHandlingActionListener(new Executable<ActionEvent>() - { - @Override - public void execute(ActionEvent event) throws Exception - { - connectAndFindConflicts(); - } - })); + connectFindConflictsButton(); + connectConflictsList(); + connectDifferencesTable(); + } - frame.getConflictsList().addListSelectionListener( - new ExceptionHandlingListSelectionListener(new Executable<ListSelectionEvent>() - { - @Override - public void execute(ListSelectionEvent event) throws Exception - { - if (event.getValueIsAdjusting() == false) - { - selectConflictDocument(event.getFirstIndex()); - } - } - })); - - frame.getDifferencesTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() + private void connectFindConflictsButton() + { + Executable<ActionEvent> executable = new Executable<ActionEvent>() { @Override - public void valueChanged(ListSelectionEvent e) + public void execute(ActionEvent event) throws Exception + { + findConflicts(); + } + }; + ExceptionHandlingActionListener listener = new ExceptionHandlingActionListener(executable); + _frame.getFindConflictsButton().addActionListener(listener); + } + + private void connectConflictsList() + { + Executable<ListSelectionEvent> executable = new Executable<ListSelectionEvent>() + { + @Override + public void execute(ListSelectionEvent event) throws Exception + { + if (event.getValueIsAdjusting() == false) + { + selectConflictDocument(event.getFirstIndex()); + } + } + }; + ExceptionHandlingListSelectionListener listener = new ExceptionHandlingListSelectionListener( + executable); + _frame.getConflictsList().addListSelectionListener(listener); + } + + private void connectDifferencesTable() + { + Executable<ListSelectionEvent> executable = new Executable<ListSelectionEvent>() + { + @Override + public void execute(ListSelectionEvent event) throws Exception { selectDifference(); } - }); + }; + ExceptionHandlingListSelectionListener listener = new ExceptionHandlingListSelectionListener( + executable); + _frame.getDifferencesTable().getSelectionModel().addListSelectionListener(listener); } - protected void connectAndFindConflicts() throws Exception + protected void findConflicts() throws Exception { String dbUrl = _frame.getDatabaseUrl(); _database = new CouchDb(dbUrl);
--- a/conflict-editor/src/main/java/de/codedo/conflicteditor/gui/ConflictEditorFrame.java Tue Sep 13 02:07:14 2011 +0200 +++ b/conflict-editor/src/main/java/de/codedo/conflicteditor/gui/ConflictEditorFrame.java Tue Sep 13 02:20:11 2011 +0200 @@ -19,7 +19,7 @@ public class ConflictEditorFrame extends JFrame { private JTextField _databaseUrlTextField; - private JButton _connectButton; + private JButton _findConflictsButton; private JList _conflictsList; private JTable _differencesTable; @@ -41,13 +41,13 @@ { JLabel label = new JLabel("Database URL:"); _databaseUrlTextField = new JTextField(40); - _connectButton = new JButton("Find Conflicts"); + _findConflictsButton = new JButton("Find Conflicts"); JPanel databaseUrlPanel = new JPanel(); databaseUrlPanel.setLayout(new FlowLayout()); databaseUrlPanel.add(label); databaseUrlPanel.add(_databaseUrlTextField); - databaseUrlPanel.add(_connectButton); + databaseUrlPanel.add(_findConflictsButton); getContentPane().add(databaseUrlPanel, BorderLayout.NORTH); } @@ -85,9 +85,9 @@ return _databaseUrlTextField.getText(); } - public JButton getConnectButton() + public JButton getFindConflictsButton() { - return _connectButton; + return _findConflictsButton; } public JList getConflictsList()