Skip to content
Snippets Groups Projects
Commit a2201eb4 authored by gpawel's avatar gpawel
Browse files

[LMS-2198] Web Start Data Set Upload: Errors returned by Jython-based...

[LMS-2198] Web Start Data Set Upload: Errors returned by Jython-based validation are now shown in main window.

SVN: 20969
parent ffed2695
No related branches found
No related tags found
No related merge requests found
...@@ -21,8 +21,10 @@ import static ch.systemsx.cisd.openbis.dss.client.api.gui.DataSetUploadClient.BU ...@@ -21,8 +21,10 @@ import static ch.systemsx.cisd.openbis.dss.client.api.gui.DataSetUploadClient.BU
import static ch.systemsx.cisd.openbis.dss.client.api.gui.DataSetUploadClient.LABEL_WIDTH; import static ch.systemsx.cisd.openbis.dss.client.api.gui.DataSetUploadClient.LABEL_WIDTH;
import java.awt.CardLayout; import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Font;
import java.awt.Frame; import java.awt.Frame;
import java.awt.GridBagConstraints; import java.awt.GridBagConstraints;
import java.awt.GridBagLayout; import java.awt.GridBagLayout;
...@@ -40,6 +42,7 @@ import java.util.HashMap; ...@@ -40,6 +42,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import javax.swing.AbstractButton; import javax.swing.AbstractButton;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup; import javax.swing.ButtonGroup;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JComboBox; import javax.swing.JComboBox;
...@@ -48,7 +51,10 @@ import javax.swing.JFrame; ...@@ -48,7 +51,10 @@ import javax.swing.JFrame;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JRadioButton; import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField; import javax.swing.JTextField;
import javax.swing.ScrollPaneConstants;
import ch.systemsx.cisd.openbis.dss.client.api.gui.DataSetUploadClientModel.NewDataSetInfo; import ch.systemsx.cisd.openbis.dss.client.api.gui.DataSetUploadClientModel.NewDataSetInfo;
import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.NewDataSetDTO.DataSetOwnerType; import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.NewDataSetDTO.DataSetOwnerType;
...@@ -92,6 +98,10 @@ public class DataSetMetadataPanel extends JPanel ...@@ -92,6 +98,10 @@ public class DataSetMetadataPanel extends JPanel
private final HashMap<String, DataSetPropertiesPanel> propertiesPanels = private final HashMap<String, DataSetPropertiesPanel> propertiesPanels =
new HashMap<String, DataSetPropertiesPanel>(); new HashMap<String, DataSetPropertiesPanel>();
private final JTextArea validationErrors = new JTextArea("Błędy");
private final JScrollPane validationErrorsPane = new JScrollPane(validationErrors);
private NewDataSetInfo newDataSetInfo; private NewDataSetInfo newDataSetInfo;
public DataSetMetadataPanel(DataSetUploadClientModel clientModel, JFrame mainWindow) public DataSetMetadataPanel(DataSetUploadClientModel clientModel, JFrame mainWindow)
...@@ -121,6 +131,16 @@ public class DataSetMetadataPanel extends JPanel ...@@ -121,6 +131,16 @@ public class DataSetMetadataPanel extends JPanel
dataSetFileButton = new JButton("Browse..."); dataSetFileButton = new JButton("Browse...");
dataSetFileLabel = new JLabel("File:", JLabel.TRAILING); dataSetFileLabel = new JLabel("File:", JLabel.TRAILING);
validationErrors.setEditable(false);
validationErrors.setBackground(getBackground());
validationErrors.setFont(new Font(getFont().getName(), Font.BOLD, getFont().getSize()));
validationErrors.setForeground(Color.RED);
validationErrors.setLineWrap(true);
validationErrors.setWrapStyleWord(true);
validationErrorsPane.setBorder(BorderFactory.createEmptyBorder());
validationErrorsPane
.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
createGui(); createGui();
} }
...@@ -329,6 +349,7 @@ public class DataSetMetadataPanel extends JPanel ...@@ -329,6 +349,7 @@ public class DataSetMetadataPanel extends JPanel
createDataSetTypePanel(); createDataSetTypePanel();
addRow(4, dataSetTypePanel); addRow(4, dataSetTypePanel);
addRow(5, validationErrorsPane);
} }
private void setDataSetType(String dataSetType) private void setDataSetType(String dataSetType)
...@@ -455,7 +476,7 @@ public class DataSetMetadataPanel extends JPanel ...@@ -455,7 +476,7 @@ public class DataSetMetadataPanel extends JPanel
c.gridy = rowy; c.gridy = rowy;
c.gridwidth = GridBagConstraints.REMAINDER; c.gridwidth = GridBagConstraints.REMAINDER;
c.weightx = 0; c.weightx = 0;
c.weighty = 0; c.weighty = 1;
c.insets = new Insets((rowy > 0) ? 5 : 0, 0, 0, 5); c.insets = new Insets((rowy > 0) ? 5 : 0, 0, 0, 5);
add(comp, c); add(comp, c);
} }
...@@ -504,8 +525,8 @@ public class DataSetMetadataPanel extends JPanel ...@@ -504,8 +525,8 @@ public class DataSetMetadataPanel extends JPanel
public void syncErrors() public void syncErrors()
{ {
// Clear all errors first // Clear all errors first
clearError(ownerIdLabel, ownerIdText); clearError(ownerIdLabel, ownerIdText, null);
clearError(dataSetFileLabel, dataSetFileComboBox); clearError(dataSetFileLabel, dataSetFileComboBox, validationErrors);
List<ValidationError> errors = newDataSetInfo.getValidationErrors(); List<ValidationError> errors = newDataSetInfo.getValidationErrors();
for (ValidationError error : errors) for (ValidationError error : errors)
...@@ -513,7 +534,7 @@ public class DataSetMetadataPanel extends JPanel ...@@ -513,7 +534,7 @@ public class DataSetMetadataPanel extends JPanel
switch (error.getTarget()) switch (error.getTarget())
{ {
case DATA_SET_OWNER: case DATA_SET_OWNER:
displayError(ownerIdLabel, ownerIdText, error); displayError(ownerIdLabel, ownerIdText, null, error);
break; break;
case DATA_SET_TYPE: case DATA_SET_TYPE:
...@@ -521,7 +542,7 @@ public class DataSetMetadataPanel extends JPanel ...@@ -521,7 +542,7 @@ public class DataSetMetadataPanel extends JPanel
break; break;
case DATA_SET_FILE: case DATA_SET_FILE:
displayError(dataSetFileLabel, dataSetFileComboBox, error); displayError(dataSetFileLabel, dataSetFileComboBox, validationErrors, error);
break; break;
case DATA_SET_PROPERTY: case DATA_SET_PROPERTY:
...@@ -536,19 +557,20 @@ public class DataSetMetadataPanel extends JPanel ...@@ -536,19 +557,20 @@ public class DataSetMetadataPanel extends JPanel
} }
} }
private void displayError(JLabel label, JComponent component, ValidationError error) private void displayError(JLabel label, JComponent component, JTextArea errorAreaOrNull,
ValidationError error)
{ {
// Not all errors are applicable to this panel // Not all errors are applicable to this panel
if (null == label || null == component) if (null == label || null == component)
{ {
return; return;
} }
UiUtilities.displayError(label, component, error); UiUtilities.displayError(label, component, errorAreaOrNull, error);
} }
private void clearError(JLabel label, JComponent component) private void clearError(JLabel label, JComponent component, JTextArea errorAreaOrNull)
{ {
UiUtilities.clearError(label, component); UiUtilities.clearError(label, component, errorAreaOrNull);
component.setToolTipText(label.getToolTipText()); component.setToolTipText(label.getToolTipText());
} }
......
...@@ -358,12 +358,12 @@ public class DataSetPropertiesPanel extends JPanel ...@@ -358,12 +358,12 @@ public class DataSetPropertiesPanel extends JPanel
{ {
return; return;
} }
UiUtilities.displayError(label, component, error); UiUtilities.displayError(label, component, null, error);
} }
private void clearError(JLabel label, JComponent component) private void clearError(JLabel label, JComponent component)
{ {
UiUtilities.clearError(label, component); UiUtilities.clearError(label, component, null);
component.setToolTipText(label.getToolTipText()); component.setToolTipText(label.getToolTipText());
} }
......
...@@ -270,7 +270,7 @@ public class DataSetUploadClient extends AbstractSwingGUI ...@@ -270,7 +270,7 @@ public class DataSetUploadClient extends AbstractSwingGUI
spacer.setPreferredSize(new Dimension(15, 15)); spacer.setPreferredSize(new Dimension(15, 15));
window.add(spacer, BorderLayout.SOUTH); window.add(spacer, BorderLayout.SOUTH);
window.pack(); window.pack();
window.setBounds(20, 40, 600, 400); window.setBounds(20, 40, 600, 450);
window.setLocationByPlatform(true); window.setLocationByPlatform(true);
window.setVisible(true); window.setVisible(true);
......
...@@ -20,6 +20,7 @@ import java.awt.Color; ...@@ -20,6 +20,7 @@ import java.awt.Color;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JTextArea;
import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.validation.ValidationError; import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.validation.ValidationError;
...@@ -29,16 +30,27 @@ import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.validation.ValidationE ...@@ -29,16 +30,27 @@ import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.validation.ValidationE
public class UiUtilities public class UiUtilities
{ {
public static void displayError(JLabel label, JComponent component, ValidationError error) public static void displayError(JLabel label, JComponent component, JTextArea errorAreaOrNull,
ValidationError error)
{ {
component.setToolTipText(error.getErrorMessage()); component.setToolTipText(error.getErrorMessage());
label.setForeground(Color.RED); label.setForeground(Color.RED);
if (errorAreaOrNull != null)
{
errorAreaOrNull.setText("File validation error: " + error.getErrorMessage());
errorAreaOrNull.setToolTipText(error.getErrorMessage());
}
} }
public static void clearError(JLabel label, JComponent component) public static void clearError(JLabel label, JComponent component, JTextArea errorAreaOrNull)
{ {
component.setToolTipText(null); component.setToolTipText(null);
label.setForeground(Color.BLACK); label.setForeground(Color.BLACK);
if (errorAreaOrNull != null)
{
errorAreaOrNull.setText(null);
errorAreaOrNull.setToolTipText(null);
}
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment