Skip to content

Commit

Permalink
Merge pull request #4326 from dominikl/metadata_panel_followup_1
Browse files Browse the repository at this point in the history
Metadata panel followup 1
  • Loading branch information
jburel committed Dec 11, 2015
2 parents 6ac465b + c7db305 commit caa3ba8
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 96 deletions.
Expand Up @@ -425,6 +425,7 @@ public void changedUpdate(DocumentEvent e) {
@Override
void onRelatedNodesSet() {
addButton.setEnabled(model.canAddAnnotationLink());
refreshUI();
}


Expand Down
Expand Up @@ -538,11 +538,7 @@ public void stateChanged(ChangeEvent e)
public void propertyChange(PropertyChangeEvent evt)
{
String name = evt.getPropertyName();
if (SAVE_PROPERTY.equals(name) ||
DataComponent.DATA_MODIFIED_PROPERTY.equals(name) ||
PreviewPanel.PREVIEW_EDITED_PROPERTY.equals(name)) {
view.setDataToSave(view.hasDataToSave());
} else if (MetadataViewer.SAVE_DATA_PROPERTY.equals(name)) {
if (MetadataViewer.SAVE_DATA_PROPERTY.equals(name)) {
Boolean b = (Boolean) evt.getNewValue();
view.saveData(b.booleanValue());
} else if (MetadataViewer.CLEAR_SAVE_DATA_PROPERTY.equals(name) ||
Expand Down
Expand Up @@ -2548,20 +2548,59 @@ int getTextualAnnotationCount()
Collection<TextualAnnotationData> getTextualAnnotations()
{
StructuredDataResults data = parent.getStructuredData();
if (data == null) return null;
if (data == null)
return null;

return data.getTextualAnnotations();
}

/**
* Get the comments of all selected objects
* @return See above
*/
Collection<TextualAnnotationData> getAllTextualAnnotations() {
Map<DataObject, StructuredDataResults>
r = parent.getAllStructuredData();
if (r == null)
return new ArrayList<TextualAnnotationData>();

Entry<DataObject, StructuredDataResults> e;
Iterator<Entry<DataObject, StructuredDataResults>>
i = r.entrySet().iterator();

Collection<TextualAnnotationData> others;
List<TextualAnnotationData> results = new ArrayList<TextualAnnotationData>();
List<Long> ids = new ArrayList<Long>();
Iterator<TextualAnnotationData> k;
TextualAnnotationData other;
while (i.hasNext()) {
e = i.next();
others = e.getValue().getTextualAnnotations();
if (others != null) {
k = others.iterator();
while (k.hasNext()) {
other = k.next();
if (!ids.contains(other.getId())) {
results.add(other);
ids.add(other.getId());
}
}
}
}
return results;
}

/**
* Returns the annotations ordered by date.
*
* @return See above.
*/
List getTextualAnnotationsByDate()
{
if (textualAnnotationsByDate != null)
return textualAnnotationsByDate;
textualAnnotationsByDate = (List) getTextualAnnotations();
// if (textualAnnotationsByDate != null)
// return textualAnnotationsByDate;
textualAnnotationsByDate = (List)
getAllTextualAnnotations();
sortAnnotationByDate(textualAnnotationsByDate);
return textualAnnotationsByDate;
}
Expand Down
Expand Up @@ -258,7 +258,6 @@ void layoutUI()
{
Object uo = model.getRefObject();
remove(component);
setDataToSave(false);
if (uo instanceof ExperimenterData) {
toolBar.buildUI();
userUI.buildUI();
Expand Down Expand Up @@ -326,11 +325,9 @@ void setRootObject(Object oldObject)
{
Object uo = model.getRefObject();
tabPane.setComponentAt(RND_INDEX, dummyPanel);
setDataToSave(false);
toolBar.buildUI();
tabPane.setToolTipTextAt(RND_INDEX, RENDERER_DESCRIPTION);
if (!(uo instanceof DataObject)) {
setDataToSave(false);
toolBar.setStatus(false);
toolBar.buildUI();
remove(component);
Expand Down Expand Up @@ -376,7 +373,6 @@ void setRootObject(Object oldObject)
void saveData(boolean async)
{
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
toolBar.setDataToSave(false);
if (model.getRefObject() instanceof ExperimenterData) {
Object exp = userUI.getExperimenterToSave();
model.fireAdminSaving(exp, async);
Expand All @@ -385,7 +381,6 @@ void saveData(boolean async)
AdminObject o = groupUI.getAdminObject();
if (o == null) {
setCursor(Cursor.getDefaultCursor());
toolBar.setDataToSave(true);
return;
}
model.fireAdminSaving(o, async);
Expand All @@ -407,14 +402,6 @@ void showChannelData()
acquisitionPane.setChannelData();
}

/**
* Enables the saving controls depending on the passed value.
*
* @param b Pass <code>true</code> to save the data,
* <code>false</code> otherwise.
*/
void setDataToSave(boolean b) { toolBar.setDataToSave(b); }

/**
* Returns <code>true</code> if data to save, <code>false</code>
* otherwise.
Expand Down Expand Up @@ -523,7 +510,6 @@ void removeObject(DataObject data)
private void removeLinks(int level, Collection l)
{
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
toolBar.setDataToSave(false);
Iterator<AnnotationData> i = l.iterator();
AnnotationData o;
List<Object> toRemove = new ArrayList<Object>();
Expand Down
Expand Up @@ -489,8 +489,6 @@ private MapTable createMapTable(MapAnnotationData m) {
public void tableChanged(TableModelEvent e) {
refreshButtonStates();
MapTableModel m = (MapTableModel) t.getModel();
if (m.isDirty())
view.setDataToSave(true);
if (m.isEmpty() && m.getMap().getId() >= 0) {
view.deleteAnnotation(m.getMap());
view.saveData(true);
Expand Down
Expand Up @@ -1025,7 +1025,7 @@ else if (rowIndex == PlateData.ASCENDING_NUMBER)
k = well.getColumn()+1;
String columnText = "";
if (columnIndex == PlateData.ASCENDING_LETTER)
columnText = UIUtilities.LETTERS.get(k+1);
columnText = UIUtilities.LETTERS.get(k);
else if (columnIndex == PlateData.ASCENDING_NUMBER)
columnText = ""+k;
String value = rowText+"-"+columnText;
Expand Down
Expand Up @@ -96,21 +96,9 @@ class ToolBar
/** The text associated to the export as OME-TIFF action. */
private static final String EXPORT_AS_OME_TIFF_TOOLTIP =
"Export the image as OME-TIFF.";

/** Button to save the annotations. */
private JButton saveButton;

/** Button to download the original image. */
private JButton downloadButton;

/** Button to load the rendering control for the primary select. */
private JButton rndButton;

/** Button to refresh the selected tab. */
private JButton refreshButton;

/** Button to bring up the analysis list. */
private JButton analysisButton;

/** Button to bring up the publishing list. */
private JButton publishingButton;
Expand Down Expand Up @@ -171,9 +159,7 @@ private void checkBinaryAvailability()
{
if (MetadataViewerAgent.isBinaryAvailable()) return;
downloadButton.setEnabled(false);
rndButton.setEnabled(false);
publishingButton.setEnabled(false);
analysisButton.setEnabled(false);
}

/** Creates or recycles the save as menu. */
Expand Down Expand Up @@ -272,12 +258,6 @@ private void initComponents()
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
IconManager icons = IconManager.getInstance();
saveButton = new JButton(icons.getIcon(IconManager.SAVE));
saveButton.setToolTipText("Save changes back to the server.");
saveButton.addActionListener(controller);
saveButton.setActionCommand(""+EditorControl.SAVE);
saveButton.setEnabled(false);
saveButton.setBackground(UIUtilities.BACKGROUND_COLOR);

downloadButton = new JButton(icons.getIcon(IconManager.DOWNLOAD));
downloadButton.setToolTipText("Download the Archived File(s).");
Expand All @@ -286,20 +266,6 @@ private void initComponents()
//downloadButton.setEnabled(false);
downloadButton.setBackground(UIUtilities.BACKGROUND_COLOR);

rndButton = new JButton(icons.getIcon(IconManager.RENDERER));
rndButton.setToolTipText("Rendering control for the first selected " +
"image.");
rndButton.addActionListener(controller);
rndButton.setActionCommand(""+EditorControl.RENDERER);
rndButton.setEnabled(false);
rndButton.setBackground(UIUtilities.BACKGROUND_COLOR);

refreshButton = new JButton(icons.getIcon(IconManager.REFRESH));
refreshButton.setToolTipText("Refresh.");
refreshButton.addActionListener(controller);
refreshButton.setActionCommand(""+EditorControl.REFRESH);
refreshButton.setBackground(UIUtilities.BACKGROUND_COLOR);

publishingButton = new JButton(icons.getIcon(IconManager.PUBLISHING));
publishingButton.setToolTipText("Display the publishing options.");
publishingButton.setEnabled(false);
Expand All @@ -316,22 +282,7 @@ public void mouseReleased(MouseEvent e)
MetadataViewer.PUBLISHING_OPTION);
}
});
analysisButton = new JButton(icons.getIcon(IconManager.ANALYSIS));
analysisButton.setToolTipText("Display the analysis options.");
analysisButton.setEnabled(false);
analysisButton.setBackground(UIUtilities.BACKGROUND_COLOR);
analysisButton.addMouseListener(new MouseAdapter() {

/**
* Launches the dialog when the user releases the mouse.
* MouseAdapter#mouseReleased(MouseEvent)
*/
public void mouseReleased(MouseEvent e)
{
launchOptions((Component) e.getSource(), e.getPoint(),
MetadataViewer.ANALYSIS_OPTION);
}
});

scriptsButton = new JButton(icons.getIcon(IconManager.ANALYSIS_RUN));
scriptsButton.setToolTipText("Display the available scripts.");
scriptsButton.setEnabled(false);
Expand Down Expand Up @@ -430,14 +381,10 @@ public void mousePressed(MouseEvent e) {
UIUtilities.unifiedButtonLookAndFeel(pathButton);
UIUtilities.unifiedButtonLookAndFeel(locationButton);
UIUtilities.unifiedButtonLookAndFeel(saveAsButton);
UIUtilities.unifiedButtonLookAndFeel(saveButton);
UIUtilities.unifiedButtonLookAndFeel(downloadButton);
UIUtilities.unifiedButtonLookAndFeel(rndButton);
UIUtilities.unifiedButtonLookAndFeel(refreshButton);
UIUtilities.unifiedButtonLookAndFeel(exportAsOmeTiffButton);
UIUtilities.unifiedButtonLookAndFeel(publishingButton);
UIUtilities.unifiedButtonLookAndFeel(uploadScriptButton);
UIUtilities.unifiedButtonLookAndFeel(analysisButton);
UIUtilities.unifiedButtonLookAndFeel(scriptsButton);

Dimension d = new Dimension(UIUtilities.DEFAULT_ICON_WIDTH,
Expand All @@ -463,8 +410,6 @@ private JComponent buildGeneralBar()

bar.add(viewButton);
bar.add(Box.createHorizontalGlue());
bar.add(saveButton);
bar.add(Box.createHorizontalStrut(5));
bar.add(publishingButton);
bar.add(Box.createHorizontalStrut(5));
bar.add(locationButton);
Expand Down Expand Up @@ -599,14 +544,6 @@ private JPopupMenu getScriptsMenu()
initComponents();
buildGUI();
}

/**
* Enables the {@link #saveButton} depending on the passed value.
*
* @param b Pass <code>true</code> to save the data,
* <code>false</code> otherwise.
*/
void setDataToSave(boolean b) { saveButton.setEnabled(b); }

/**
* Sets to <code>true</code> if loading data, to <code>false</code>
Expand All @@ -626,14 +563,10 @@ void buildUI()
{
saveAsMenu = null;
Object refObject = model.getRefObject();
rndButton.setEnabled(false);
downloadButton.setEnabled(false);
if (pathButton != null) pathButton.setEnabled(false);
if ((refObject instanceof ImageData) ||
(refObject instanceof WellSampleData)) {
rndButton.setEnabled(!model.isRendererLoaded());
if (model.isNumerousChannel())
rndButton.setEnabled(false);
if (refObject instanceof ImageData) {
downloadButton.setEnabled(model.isArchived());
}
Expand All @@ -653,7 +586,6 @@ private void setRootObject()
Object ref = model.getRefObject();
if (ref instanceof ExperimenterData || ref instanceof GroupData) {
publishingButton.setEnabled(false);
analysisButton.setEnabled(false);
scriptsButton.setEnabled(false);
return;
}
Expand All @@ -673,7 +605,6 @@ private void setRootObject()
}

publishingButton.setEnabled(true);
analysisButton.setEnabled(true);
scriptsButton.setEnabled(true);
if (publishingDialog != null)
publishingDialog.setRootObject();
Expand Down

0 comments on commit caa3ba8

Please sign in to comment.