Skip to content

Commit

Permalink
reorganized Horta UI esp. for clarity of sections
Browse files Browse the repository at this point in the history
  • Loading branch information
olbris committed May 3, 2024
1 parent fc55fb3 commit b64bb12
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
public class GoToLocationAction extends AbstractAction {

public GoToLocationAction() {
super("Go to...");
super("Go to location...");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.openide.windows.WindowManager;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
Expand Down Expand Up @@ -155,6 +156,7 @@ private void setupUI() {
// some people with small screens not seeing all the controls, especially the
// "new workspace" button
mainPanel = new JPanel();
mainPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
scrollPane = new JScrollPane(mainPanel);
setLayout(new BorderLayout());
add(scrollPane);
Expand All @@ -180,78 +182,17 @@ private void setupUI() {
cVert.gridy = GridBagConstraints.RELATIVE;
cVert.anchor = GridBagConstraints.PAGE_START;
cVert.fill = GridBagConstraints.HORIZONTAL;
cTop.weightx = 1.0;
cVert.weightx = 1.0;
cVert.weighty = 0.0;

// buttons for doing workspace things
JPanel workspaceButtonsPanel = new JPanel();
workspaceButtonsPanel.setLayout(new BoxLayout(workspaceButtonsPanel, BoxLayout.LINE_AXIS));
mainPanel.add(workspaceButtonsPanel, cVert);
JPanel workspaceButtonsPanel2 = new JPanel();
workspaceButtonsPanel2.setLayout(new BoxLayout(workspaceButtonsPanel2, BoxLayout.LINE_AXIS));
mainPanel.add(workspaceButtonsPanel2, cVert);

JPanel locationPanel = new JPanel();
locationPanel.setLayout(new BoxLayout(locationPanel, BoxLayout.LINE_AXIS));
mainPanel.add(locationPanel, cVert);

// testingFil
// showOutline(workspaceButtonsPanel, Color.green);

openLVV = new JCheckBox("Open 2D");
workspaceButtonsPanel.add(openLVV);
openLVV.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
TopComponent tc = WindowManager.getDefault().findTopComponent("LargeVolumeViewerTopComponent");
if (tc != null) {
if (!tc.isOpened()) {
tc.open();
} else {
tc.close();
}
tc.requestActive();
}
}
});

openHorta = new JCheckBox("Open 3D");
workspaceButtonsPanel.add(openHorta);
openHorta.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
TopComponent tc = WindowManager.getDefault().findTopComponent("NeuronTracerTopComponent");
if (tc != null) {
if (!tc.isOpened()) {
tc.open();
} else {
tc.close();
}
tc.requestActive();
}
}
});

openNeuronCam = new JCheckBox("Open Proofreader");
workspaceButtonsPanel.add(openNeuronCam);
openNeuronCam.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
TopComponent tc = WindowManager.getDefault().findTopComponent("TaskWorkflowViewTopComponent");
if (tc != null) {
if (!tc.isOpened()) {
tc.open();
} else {
tc.close();
}
tc.requestActive();
}
}
});

createWorkspaceButtonPlus = new JButton("+");
workspaceButtonsPanel2.add(createWorkspaceButtonPlus);
createWorkspaceAction.putValue(Action.NAME, "+");
createWorkspaceButtonPlus = new JButton("New workspace...");
workspaceButtonsPanel.add(createWorkspaceButtonPlus);
createWorkspaceAction.putValue(Action.NAME, "New workspace...");
createWorkspaceAction.putValue(Action.SHORT_DESCRIPTION, "Create a new workspace");
createWorkspaceButtonPlus.setAction(createWorkspaceAction);

Expand Down Expand Up @@ -350,7 +291,7 @@ public void itemStateChanged(ItemEvent itemEvent) {
workspaceToolButton.setIcon(gearIcon);
workspaceToolButton.setHideActionText(true);
workspaceToolButton.setMinimumSize(workspaceButtonsPanel.getPreferredSize());
workspaceButtonsPanel2.add(workspaceToolButton);
workspaceButtonsPanel.add(workspaceToolButton);
workspaceToolButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
workspaceToolMenu.show(workspaceToolButton,
Expand All @@ -359,7 +300,70 @@ public void actionPerformed(ActionEvent ev) {
}
});

JButton gotoLocationButton = new JButton("Go To..");
// VIEWS area
JLabel viewLabel = new JLabel("VIEWS", JLabel.LEADING);
Font font = viewLabel.getFont();
viewLabel.setFont(new Font(font.getName(), Font.BOLD, font.getSize()));
mainPanel.add(viewLabel, cVert);
JPanel viewButtonsPanel = new JPanel();
viewButtonsPanel.setLayout(new BoxLayout(viewButtonsPanel, BoxLayout.LINE_AXIS));
mainPanel.add(viewButtonsPanel, cVert);
JPanel locationPanel = new JPanel();
locationPanel.setLayout(new BoxLayout(locationPanel, BoxLayout.LINE_AXIS));
mainPanel.add(locationPanel, cVert);

openLVV = new JCheckBox("Open 2D");
viewButtonsPanel.add(openLVV);
openLVV.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
TopComponent tc = WindowManager.getDefault().findTopComponent("LargeVolumeViewerTopComponent");
if (tc != null) {
if (!tc.isOpened()) {
tc.open();
} else {
tc.close();
}
tc.requestActive();
}
}
});

openHorta = new JCheckBox("Open 3D");
viewButtonsPanel.add(openHorta);
openHorta.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
TopComponent tc = WindowManager.getDefault().findTopComponent("NeuronTracerTopComponent");
if (tc != null) {
if (!tc.isOpened()) {
tc.open();
} else {
tc.close();
}
tc.requestActive();
}
}
});

openNeuronCam = new JCheckBox("Open Proofreader");
viewButtonsPanel.add(openNeuronCam);
openNeuronCam.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
TopComponent tc = WindowManager.getDefault().findTopComponent("TaskWorkflowViewTopComponent");
if (tc != null) {
if (!tc.isOpened()) {
tc.open();
} else {
tc.close();
}
tc.requestActive();
}
}
});

JButton gotoLocationButton = new JButton("Go to location..");
gotoLocationButton.setAction(new GoToLocationAction());
locationPanel.add(gotoLocationButton);

Expand Down Expand Up @@ -492,18 +496,20 @@ public void actionPerformed(ActionEvent actionEvent) {
// buttons for acting on neurons (which are in the list immediately above):
JPanel neuronButtonsPanel = new JPanel();
neuronButtonsPanel.setLayout(new BoxLayout(neuronButtonsPanel, BoxLayout.LINE_AXIS));
mainPanel.add(neuronButtonsPanel, cVert);
// this is a little sketchy; I'm requesting a panel in the middle of the neuron list widget
// because that's where I want them; doing it right would require a lot of refactoring
workspaceNeuronList.getButtonPanel().add(neuronButtonsPanel);

JButton createNeuronButtonPlus = new JButton("+");
JButton createNeuronButtonPlus = new JButton("Add...");
neuronButtonsPanel.add(createNeuronButtonPlus);
createNeuronAction.putValue(Action.NAME, "+");
createNeuronAction.putValue(Action.NAME, "Add...");
createNeuronAction.putValue(Action.SHORT_DESCRIPTION, "Create a new neuron");
createNeuronButtonPlus.setAction(createNeuronAction);

JButton deleteNeuronButton = new JButton("-");
JButton deleteNeuronButton = new JButton("Remove");
neuronButtonsPanel.add(deleteNeuronButton);
deleteNeuronAction.putValue(Action.NAME, "-");
deleteNeuronAction.putValue(Action.SHORT_DESCRIPTION, "Delete current neuron");
deleteNeuronAction.putValue(Action.NAME, "Remove");
deleteNeuronAction.putValue(Action.SHORT_DESCRIPTION, "Remove current neuron");
deleteNeuronButton.setAction(deleteNeuronAction);

// this button pops up the tool menu
Expand Down Expand Up @@ -549,13 +555,6 @@ public void actionPerformed(ActionEvent ev) {
neuriteButtonsPanel.add(centerAnnotationButton);


// developer panel, only shown to me; used for various testing things
/*if (AccessManager.getAccessManager().getActualSubject().getName().equals("olbrisd")) {
//lvvDevPanel = new LVVDevPanel(annotationMgr, annotationModel, largeVolumeViewerTranslator);
//mainPanel.add(lvvDevPanel, cVert);
}*/


// the bilge...
GridBagConstraints cBottom = new GridBagConstraints();
cBottom.gridx = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import javax.swing.AbstractAction;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
Expand Down Expand Up @@ -71,6 +70,7 @@ public class FilteredAnnotationList extends JPanel {
private JTable filteredTable;
private JTextField filterField;
private TableRowSorter<FilteredAnnotationModel> sorter;
private JLabel mainLabel;

// data stuff
private NeuronManager neuronManager;
Expand Down Expand Up @@ -349,7 +349,11 @@ private void setupUI() {
c.insets = new Insets(10, 0, 0, 0);
c.weightx = 1.0;
c.weighty = 0.0;
add(new JLabel("Annotations", JLabel.LEADING), c);
//mainLabel = new JLabel("Annotations", JLabel.LEADING);
mainLabel = new JLabel("ANNOTATIONS", JLabel.LEADING);
Font font = mainLabel.getFont();
mainLabel.setFont(new Font(font.getName(), Font.BOLD, font.getSize()));
add(mainLabel, c);

// table
// implement tool tip while we're here
Expand Down Expand Up @@ -452,29 +456,15 @@ public void actionPerformed(ActionEvent e) {
defaultButton.setSelected(true);

JButton endsButton = new JButton();
filterButtons.add(endsButton);

JButton branchButton = new JButton();
filterButtons.add(branchButton);

ButtonGroup buttonGroup = new ButtonGroup();
buttonGroup.add(defaultButton);
buttonGroup.add(endsButton);
buttonGroup.add(branchButton);

// need a second row of these:
JPanel filterButtons2 = new JPanel();
filterButtons2.setLayout(new BoxLayout(filterButtons2, BoxLayout.LINE_AXIS));

JButton reviewButton = new JButton();
JButton unique1Button = new JButton();
JButton unique2Button = new JButton();
filterButtons2.add(reviewButton);
filterButtons2.add(unique1Button);
filterButtons2.add(unique2Button);

// same button group:
buttonGroup.add(reviewButton);
filterButtons.add(endsButton);
filterButtons.add(branchButton);
filterButtons.add(reviewButton);
filterButtons.add(unique1Button);
filterButtons.add(unique2Button);

GridBagConstraints c4 = new GridBagConstraints();
c4.gridx = 0;
Expand All @@ -483,8 +473,6 @@ public void actionPerformed(ActionEvent e) {
c4.anchor = GridBagConstraints.PAGE_START;
c4.fill = GridBagConstraints.HORIZONTAL;
add(filterButtons, c4);
add(filterButtons2, c4);


// hook buttons to filter menu
defaultButton.setAction(new AbstractAction("Default") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ public WorkspaceInfoPanel() {
private void setupUI() {
setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));

titleLabel = new JLabel("Workspace", JLabel.LEADING);

titleLabel = new JLabel("WORKSPACE", JLabel.LEADING);
Font font = titleLabel.getFont();
titleLabel.setFont(new Font(font.getName(), Font.BOLD, font.getSize()));


// workspace information; show name, whatever attributes
add(titleLabel);
add(Box.createRigidArea(new Dimension(0, 10)));
Expand All @@ -41,7 +44,7 @@ private void setupUI() {

@Override
public Dimension getPreferredSize() {
return new Dimension(250,100);
return new Dimension(250,60);
}

/**
Expand All @@ -57,22 +60,16 @@ public void loadWorkspace(TmWorkspace workspace) {
private void updateMetaData(final TmWorkspace workspace) {
if (TmModelManager.getInstance().getCurrentSample() == null) {
setSampleName("(no sample");
setWorkspaceName("(no workspace)");
setWorkspaceName("(no workspace)", false);
return;
} else {
setSampleName(TmModelManager.getInstance().getCurrentSample().getName());
}
if (workspace == null) {
setWorkspaceName("(no workspace)");
setWorkspaceName("(no workspace)", false);
}
else {
setWorkspaceName(workspace.getName());
if (ClientDomainUtils.hasWriteAccess(workspace)) {
setTitle("Workspace");
}
else {
setTitle("Workspace (read-only)");
}
setWorkspaceName(workspace.getName(), !ClientDomainUtils.hasWriteAccess(workspace));
}
}

Expand All @@ -82,20 +79,23 @@ private void setTitle(String title) {

private void setSampleName(String name) {
// if name is too wide, it messes up our panel width; tooltip has full name
// 2024: increased width; not sure what the limit is, but we have more width
// available than we used to
sampleNameLabel.setToolTipText(name);
if (name.length() > 22) {
name = name.substring(0, 20) + "...";
if (name.length() > 40) {
name = name.substring(0, 38) + "...";
}
sampleNameLabel.setText("Sample: " + name);
}

private void setWorkspaceName(String name) {
// if name is too wide, it messes up our panel width; tooltip has full name
workspaceNameLabel.setToolTipText(name);
if (name.length() > 24) {
name = name.substring(0, 22) + "...";
private void setWorkspaceName(String name, boolean readOnly) {
// see comment above on width
String displayName = (readOnly ? " (read-only) " : "") + name;
workspaceNameLabel.setToolTipText(displayName);
if (displayName.length() > 40) {
displayName = displayName.substring(0, 38) + "...";
}
workspaceNameLabel.setText("Name: " + name);
workspaceNameLabel.setText("Name: " + displayName);
}

}
Expand Down
Loading

0 comments on commit b64bb12

Please sign in to comment.