Mercurial > hg > ConflictEditor
changeset 12:18e126f0070b
clean code: pull build/create methods apart
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Tue, 13 Sep 2011 04:10:29 +0200 |
parents | 1298f5b16ecf |
children | e99bb691f7ce |
files | conflict-editor/src/main/java/de/codedo/conflicteditor/gui/ConflictEditorFrame.java |
diffstat | 1 files changed, 60 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/conflict-editor/src/main/java/de/codedo/conflicteditor/gui/ConflictEditorFrame.java Tue Sep 13 03:29:11 2011 +0200 +++ b/conflict-editor/src/main/java/de/codedo/conflicteditor/gui/ConflictEditorFrame.java Tue Sep 13 04:10:29 2011 +0200 @@ -29,57 +29,72 @@ super(); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new GridBagLayout()); - buildGui(); + createGui(); } - private void buildGui() + private void createGui() { - buildDatabaseUrlPanel(); - buildConflictsListAndDifferencesTable(); + createDatabasePanel(); + createConflictsListAndDifferencesTable(); + } + + private void createDatabasePanel() + { + JPanel databasePanel = buildDatabasePanel(); + addDatabasePanel(databasePanel); } - private void buildDatabaseUrlPanel() + private JPanel buildDatabasePanel() { + JPanel databasePanel = new JPanel(); + FlowLayout layout = new FlowLayout(FlowLayout.LEFT); + databasePanel.setLayout(layout); + JLabel label = new JLabel("Database URL:"); - _databaseUrlTextField = new JTextField(40); - _findConflictsButton = new JButton("Find Conflicts"); + databasePanel.add(label); - JPanel databaseUrlPanel = new JPanel(); - FlowLayout layout = new FlowLayout(FlowLayout.LEFT); - databaseUrlPanel.setLayout(layout); - databaseUrlPanel.add(label); - databaseUrlPanel.add(_databaseUrlTextField); - databaseUrlPanel.add(_findConflictsButton); + _databaseUrlTextField = new JTextField(40); + databasePanel.add(_databaseUrlTextField); + + _findConflictsButton = new JButton("Find Conflicts"); + databasePanel.add(_findConflictsButton); + return databasePanel; + } + + private void addDatabasePanel(JPanel databasePanel) + { GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 0; - constraints.weightx = 0.5; - constraints.weighty = 0.1; + constraints.weightx = 1; + constraints.weighty = 0; constraints.anchor = GridBagConstraints.LINE_START; constraints.fill = GridBagConstraints.HORIZONTAL; - getContentPane().add(databaseUrlPanel, constraints); + getContentPane().add(databasePanel, constraints); } - private void buildConflictsListAndDifferencesTable() + private void createConflictsListAndDifferencesTable() { - buildConflictsList(); - buildDifferencesTable(); + JSplitPane splitPane = buildConflictsListAndDifferencesTableSplitPane(); + addConflictsListAndDifferencesTableSplitPane(splitPane); + } - JScrollPane conflictsScrollPane = new JScrollPane(_conflictsList); - JScrollPane differencesScrollPane = new JScrollPane(_differencesTable); + private JSplitPane buildConflictsListAndDifferencesTableSplitPane() + { + JScrollPane conflictsScrollPane = buildConflictsListScrollPane(); + JScrollPane differencesScrollPane = buildDifferencesScrollPane(); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.add(conflictsScrollPane); splitPane.add(differencesScrollPane); + return splitPane; + } - GridBagConstraints constraints = new GridBagConstraints(); - constraints.gridx = 0; - constraints.gridy = 1; - constraints.weightx = 0.5; - constraints.weighty = 0.9; - constraints.fill = GridBagConstraints.BOTH; - getContentPane().add(splitPane, constraints); + private JScrollPane buildConflictsListScrollPane() + { + buildConflictsList(); + return new JScrollPane(_conflictsList); } private void buildConflictsList() @@ -87,6 +102,12 @@ _conflictsList = new JList(); } + private JScrollPane buildDifferencesScrollPane() + { + buildDifferencesTable(); + return new JScrollPane(_differencesTable); + } + private void buildDifferencesTable() { _differencesTable = new JTable(); @@ -96,6 +117,17 @@ _differencesTable.setModel(model); } + private void addConflictsListAndDifferencesTableSplitPane(JSplitPane splitPane) + { + GridBagConstraints constraints = new GridBagConstraints(); + constraints.gridx = 0; + constraints.gridy = 1; + constraints.weightx = 1; + constraints.weighty = 0.9; + constraints.fill = GridBagConstraints.BOTH; + getContentPane().add(splitPane, constraints); + } + public JTextField getDatabaseUrlTextField() { return _databaseUrlTextField;