Skip to content

Commit

Permalink
More UI improvements (two more dialogs)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrtannus committed May 27, 2015
1 parent c65450e commit f7410b8
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@

package org.genemania.plugin.data.lucene.view;

import static javax.swing.GroupLayout.DEFAULT_SIZE;
import static javax.swing.GroupLayout.PREFERRED_SIZE;

import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;

import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
Expand All @@ -51,14 +52,15 @@ public class EditNetworkDialog extends AbstractEditDialog {
private final JTextArea descriptionField;
private final JTextField groupNameField;

public EditNetworkDialog(final Frame owner, final boolean modality, final UiUtils uiUtils) {
super(owner, Strings.editNetwork_title, modality);
public EditNetworkDialog(final Frame owner, final UiUtils uiUtils) {
super(owner, Strings.editNetwork_title, true);
setModalityType(ModalityType.APPLICATION_MODAL);

final JPanel contents = uiUtils.createJPanel();
contents.setBorder(BorderFactory.createEmptyBorder(16, 16, 16, 16));
contents.setLayout(new GridBagLayout());

DocumentListener listener = new DocumentListener() {
final JLabel label1 = new JLabel(Strings.importNetworkGroup_label);
final JLabel label2 = new JLabel(Strings.importNetworkName_label);
final JLabel label3 = new JLabel(Strings.importNetworkDescription_label);
final DocumentListener listener = new DocumentListener() {
@Override
public void removeUpdate(DocumentEvent e) {
validateSettings();
Expand Down Expand Up @@ -87,14 +89,11 @@ public void actionPerformed(ActionEvent event) {
descriptionField = new JTextArea();
descriptionField.setRows(3);
descriptionField.getDocument().addDocumentListener(listener);
final JScrollPane scrollPane = new JScrollPane(descriptionField);

JPanel buttonPanel = createButtonPanel(uiUtils);
JScrollPane scrollPane = new JScrollPane(descriptionField);

JPanel groupPanel = uiUtils.createJPanel();
groupPanel.setLayout(new GridBagLayout());
final JPanel buttonPanel = createButtonPanel(uiUtils);

FocusListener focusListener = new FocusListener() {
final FocusListener focusListener = new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
validateSettings();
Expand All @@ -108,27 +107,48 @@ public void focusGained(FocusEvent e) {
groupNameField.getDocument().addDocumentListener(listener);
groupNameField.addFocusListener(focusListener);

groupPanel.add(groupCombo, new GridBagConstraints(0, 0, 1, 1, Double.MIN_VALUE, 0, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
groupPanel.add(groupNameField, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

int row = 0;
contents.add(new JLabel(Strings.importNetworkGroup_label), new GridBagConstraints(0, row, 1, 1, 0, 0, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.NONE, new Insets(0, 0, 0 ,0), 0, 0));
contents.add(groupPanel, new GridBagConstraints(1, row, 1, 1, 1, 0, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
row++;

contents.add(new JLabel(Strings.importNetworkName_label), new GridBagConstraints(0, row, 1, 1, 0, 0, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.NONE, new Insets(0, 0, 0 ,0), 0, 0));
contents.add(nameField, new GridBagConstraints(1, row, 1, 1, 1, 0, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
row++;

contents.add(new JLabel(Strings.importNetworkDescription_label), new GridBagConstraints(0, row, 1, 1, 0, 0, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.NONE, new Insets(0, 0, 0 ,0), 0, 0));
contents.add(scrollPane, new GridBagConstraints(1, row, 1, 1, 1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
row++;
final JPanel contents = uiUtils.createJPanel();
final GroupLayout layout = new GroupLayout(contents);
contents.setLayout(layout);
layout.setAutoCreateGaps(true);
layout.setAutoCreateContainerGaps(true);

contents.add(buttonPanel, new GridBagConstraints(0, row, 2, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
row++;
layout.setHorizontalGroup(layout.createParallelGroup(Alignment.CENTER, true)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(Alignment.TRAILING, false)
.addComponent(label1)
.addComponent(label2)
.addComponent(label3)
)
.addGroup(layout.createParallelGroup(Alignment.LEADING, true)
.addGroup(layout.createSequentialGroup()
.addComponent(groupCombo, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)
.addComponent(groupNameField, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE)
)
.addComponent(nameField)
.addComponent(scrollPane)
)
)
.addComponent(buttonPanel, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(Alignment.CENTER, false)
.addComponent(label1)
.addComponent(groupCombo)
.addComponent(groupNameField)
)
.addGroup(layout.createParallelGroup(Alignment.CENTER, false)
.addComponent(label2)
.addComponent(nameField)
)
.addGroup(layout.createParallelGroup(Alignment.LEADING, true)
.addComponent(label3, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)
.addComponent(scrollPane, DEFAULT_SIZE, 160, Short.MAX_VALUE)
)
.addComponent(buttonPanel, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)
);

setLayout(new GridBagLayout());
add(contents, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
getContentPane().add(contents);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
*/
package org.genemania.plugin.data.lucene.view;

import static javax.swing.GroupLayout.DEFAULT_SIZE;
import static javax.swing.GroupLayout.PREFERRED_SIZE;

import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
Expand All @@ -45,15 +46,18 @@ public class EditOrganismDialog extends AbstractEditDialog {
private final JTextArea descriptionField;
private final OrganismValidator validator;

public EditOrganismDialog(Frame frame, boolean modality, UiUtils uiUtils, OrganismValidator validator) {
super(frame, Strings.editOrganism_title, modality);
public EditOrganismDialog(Frame frame, UiUtils uiUtils, OrganismValidator validator) {
super(frame, Strings.editOrganism_title, true);
setModalityType(ModalityType.APPLICATION_MODAL);

this.validator = validator;

JPanel contents = uiUtils.createJPanel();
contents.setBorder(BorderFactory.createEmptyBorder(16, 16, 16, 16));
contents.setLayout(new GridBagLayout());

DocumentListener listener = new DocumentListener() {
final JLabel label1 = new JLabel(Strings.importOrganismName_label);
final JLabel label2 = new JLabel(Strings.importOrganismAlias_label);
final JLabel label3 = new JLabel(Strings.importOrganismTaxonomyId_label);
final JLabel label4 = new JLabel(Strings.importOrganismDescription_label);

final DocumentListener listener = new DocumentListener() {
@Override
public void removeUpdate(DocumentEvent e) {
validateSettings();
Expand All @@ -68,43 +72,65 @@ public void changedUpdate(DocumentEvent e) {
}
};

Insets insets = new Insets(0, 0, 0, 0);
int row = 0;

nameField = new JTextField(30);
nameField.getDocument().addDocumentListener(listener);

contents.add(new JLabel(Strings.importOrganismName_label), new GridBagConstraints(0, row, 1, 1, 0, 0, GridBagConstraints.LINE_END, GridBagConstraints.NONE, insets, 0, 0));
contents.add(nameField, new GridBagConstraints(1, row, 2, 1, 1, 0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, insets, 0, 0));
row++;

aliasField = new JTextField(30);
aliasField.getDocument().addDocumentListener(listener);

contents.add(new JLabel(Strings.importOrganismAlias_label), new GridBagConstraints(0, row, 1, 1, 0, 0, GridBagConstraints.LINE_END, GridBagConstraints.NONE, insets, 0, 0));
contents.add(aliasField, new GridBagConstraints(1, row, 2, 1, 1, 0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, insets, 0, 0));
row++;

taxIdField = new JTextField(30);
taxIdField.getDocument().addDocumentListener(listener);

contents.add(new JLabel(Strings.importOrganismTaxonomyId_label), new GridBagConstraints(0, row, 1, 1, 0, 0, GridBagConstraints.LINE_END, GridBagConstraints.NONE, insets, 0, 0));
contents.add(taxIdField, new GridBagConstraints(1, row, 2, 1, 1, 0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, insets, 0, 0));
row++;

descriptionField = new JTextArea();
descriptionField.getDocument().addDocumentListener(listener);
final JScrollPane scrollPane = new JScrollPane(descriptionField);

final JPanel buttonPanel = createButtonPanel(uiUtils);

final JPanel contents = uiUtils.createJPanel();
final GroupLayout layout = new GroupLayout(contents);
contents.setLayout(layout);
layout.setAutoCreateGaps(true);
layout.setAutoCreateContainerGaps(true);

contents.add(new JLabel(Strings.importOrganismDescription_label), new GridBagConstraints(0, row, 1, 1, 0, 0, GridBagConstraints.FIRST_LINE_END, GridBagConstraints.NONE, insets, 0, 0));
contents.add(new JScrollPane(descriptionField), new GridBagConstraints(1, row, 2, 1, 1, 1, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, insets, 0, 0));
row++;
layout.setHorizontalGroup(layout.createParallelGroup(Alignment.CENTER, true)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(Alignment.TRAILING, false)
.addComponent(label1)
.addComponent(label2)
.addComponent(label3)
.addComponent(label4)
)
.addGroup(layout.createParallelGroup(Alignment.LEADING, true)
.addComponent(nameField)
.addComponent(aliasField)
.addComponent(taxIdField)
.addComponent(scrollPane)
)
)
.addComponent(buttonPanel, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(Alignment.CENTER, false)
.addComponent(label1)
.addComponent(nameField)
)
.addGroup(layout.createParallelGroup(Alignment.CENTER, false)
.addComponent(label2)
.addComponent(aliasField)
)
.addGroup(layout.createParallelGroup(Alignment.CENTER, false)
.addComponent(label3)
.addComponent(taxIdField)
)
.addGroup(layout.createParallelGroup(Alignment.LEADING, true)
.addComponent(label4, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)
.addComponent(scrollPane, DEFAULT_SIZE, 160, Short.MAX_VALUE)
)
.addComponent(buttonPanel, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)
);

JPanel buttonPanel = createButtonPanel(uiUtils);
contents.add(buttonPanel, new GridBagConstraints(0, row, 3, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
row++;

setLayout(new GridBagLayout());
add(contents, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
getContentPane().add(contents);
}

public void setDescription(String description) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ private void editOrganisms(DataSet data) {

try {
validator.setCurrentOrganism(organism);
dialog = new EditOrganismDialog(uiUtils.getFrame(this), true, uiUtils, validator);
dialog = new EditOrganismDialog(uiUtils.getFrame(this), uiUtils, validator);
dialog.setLocationByPlatform(true);
dialog.setOrganismName(organism.getName());
dialog.setAlias(organism.getAlias());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ private void editNetworks(DataSet data) {
for (int index : selection) {
final UserNetworkEntry entry = installedModel.get(index);
final InteractionNetwork network = entry.network;
final EditNetworkDialog dialog = new EditNetworkDialog(uiUtils.getFrame(this), true, uiUtils);
final EditNetworkDialog dialog = new EditNetworkDialog(uiUtils.getFrame(this), uiUtils);
dialog.setLocationByPlatform(true);
dialog.setOrganism(entry.organism);
dialog.setGroup(entry.group);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ public JEditorPane createEditorPane(String text) {
pane.setEditorKit(new HTMLEditorKit());
pane.setEditable(false);
pane.setText(text);

if (isAquaLAF())
pane.setOpaque(false);
pane.setOpaque(false);

return pane;
}
Expand All @@ -136,9 +134,7 @@ public void hyperlinkUpdate(HyperlinkEvent e) {
}
};
pane.addHyperlinkListener(linkListener);

if (isAquaLAF())
pane.setOpaque(false);
pane.setOpaque(false);

return pane;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ deleteNetworkButton_label = Delete
deleteNetwork_status = Deleting Network
editNetworkButton_label = Edit...
editNetwork_status = Updating Network
editNetwork_title = Update Network Details
editNetwork_title = Network Details

netmaniaInstalledDataList_title = Installed Data
netmaniaAvailableDataList_title = Available for Download
Expand Down Expand Up @@ -124,7 +124,7 @@ importOrganismImportButton_label = Import
importOrganismNameColumn_name = Name
importOrganismDescriptionColumn_name = Description

editOrganism_title = Edit Organism
editOrganism_title = Organism Details

importOrganismDelete_title = Deleting organism(s)
importOrganismUpdate_title = Editing organism
Expand Down

0 comments on commit f7410b8

Please sign in to comment.