From 497cffca52b0d14e7f3fb4aeca4d39b7e31ed260 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 27 Aug 2015 16:49:40 +0200 Subject: [client] Change color of wizard message for warnings and errors --- .../main/java/org/openslx/dozmod/gui/wizard/Wizard.java | 7 +++++++ .../java/org/openslx/dozmod/gui/wizard/WizardPage.java | 15 +++++++++++++-- .../openslx/dozmod/gui/wizard/page/ImageUploadPage.java | 17 +++++++++-------- 3 files changed, 29 insertions(+), 10 deletions(-) (limited to 'dozentenmodul/src/main/java/org/openslx') diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/Wizard.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/Wizard.java index c1a2c361..c86e384d 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/Wizard.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/Wizard.java @@ -10,11 +10,13 @@ import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; +import javax.swing.Icon; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JFrame; @@ -22,13 +24,17 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JSeparator; import javax.swing.SwingConstants; +import javax.swing.UIManager; +import org.apache.log4j.Logger; import org.openslx.dozmod.gui.Gui; import org.openslx.dozmod.gui.helper.GridManager; @SuppressWarnings("serial") public abstract class Wizard extends JDialog { + private static final Logger LOGGER = Logger.getLogger(Wizard.class); + private final JLabel titleLabel; private final JLabel messageLabel; private final List pages = new ArrayList<>(); @@ -169,6 +175,7 @@ public abstract class Wizard extends JDialog { titleLabel.setText(pageTitle); messageLabel.setText(pageDesc); messageLabel.setIcon(page.getMessageIcon()); + messageLabel.setForeground(page.getMessageColor()); messageLabel.validate(); setTitle(getWindowTitle() + " - " + pageTitle); } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/WizardPage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/WizardPage.java index 3468ee83..ec77de90 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/WizardPage.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/WizardPage.java @@ -1,5 +1,6 @@ package org.openslx.dozmod.gui.wizard; +import java.awt.Color; import java.awt.Dialog; import javax.swing.Icon; @@ -9,6 +10,8 @@ import javax.swing.UIManager; @SuppressWarnings("serial") public abstract class WizardPage extends JPanel { + private static final Color WARNING_COLOR = new Color(200, 100, 0); + private final String title; private String description = null; @@ -125,8 +128,16 @@ public abstract class WizardPage extends JPanel { if (message == null) return null; if (isError) - return (Icon) UIManager.get("OptionPane.errorIcon"); - return (Icon) UIManager.get("OptionPane.warningIcon"); + return UIManager.getIcon("OptionPane.errorIcon"); + return UIManager.getIcon("OptionPane.warningIcon"); + } + + public Color getMessageColor() { + if (message == null) + return Color.BLACK; + if (isError) + return Color.RED; + return WARNING_COLOR; } } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java index 985544c8..47c5b8d1 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java @@ -38,7 +38,8 @@ public class ImageUploadPage extends ImageUploadPageLayout { private String lastDetectedName = null; private ImageDetailsRead existingImage = null; - public ImageUploadPage(Wizard wizard, UploadWizardState uploadWizardState, final ImageDetailsRead existingImage) { + public ImageUploadPage(Wizard wizard, UploadWizardState uploadWizardState, + final ImageDetailsRead existingImage) { super(wizard); setPageComplete(false); this.canComeBack = false; @@ -121,7 +122,7 @@ public class ImageUploadPage extends ImageUploadPageLayout { if (vmDiskFileInfo.canRead()) { state.diskFile = vmDiskFileInfo; } else { - setErrorMessage("'" + vmDiskFileInfo.getPath() + "' kann nicht gelesen werden!"); + setErrorMessage("'" + vmDiskFileInfo.getName() + "' kann nicht gelesen werden!"); setPageComplete(false); return; } @@ -134,7 +135,7 @@ public class ImageUploadPage extends ImageUploadPageLayout { String imageName = imageNameTextField.getText(); if (imageName.isEmpty() || imageName.equals(lastDetectedName)) { imageNameTextField.setText(state.meta.getDisplayName()); - } + } } lastDetectedName = state.meta.getDisplayName(); state.detectedOs = state.meta.getOs(); @@ -163,8 +164,7 @@ public class ImageUploadPage extends ImageUploadPageLayout { // are we creating a new image? then either: // get the image name either auto filled by VmwareMetaData or by user // get the image name from the image we are uploading a new version of - state.name = existingImage != null ? - existingImage.getImageName() : imageNameTextField.getText(); + state.name = existingImage != null ? existingImage.getImageName() : imageNameTextField.getText(); // -- create image to get uuid -- if (existingImage == null) { @@ -172,7 +172,7 @@ public class ImageUploadPage extends ImageUploadPageLayout { state.uuid = ThriftActions.createImage(JOptionPane.getFrameForComponent(this), state.name); if (state.uuid == null) return false; - + imageNameTextField.setEnabled(false); imageFileBrowseButton.setEnabled(false); imageFileTextField.setEnabled(false); @@ -182,8 +182,9 @@ public class ImageUploadPage extends ImageUploadPageLayout { } // -- request upload for that uuid -- if (state.transferInformation == null) { - state.transferInformation = ThriftActions.requestVersionUpload(JOptionPane.getFrameForComponent(this), - state.uuid, state.diskFile.length(), null, state.meta.getFilteredDefinition()); + state.transferInformation = ThriftActions.requestVersionUpload( + JOptionPane.getFrameForComponent(this), state.uuid, state.diskFile.length(), null, + state.meta.getFilteredDefinition()); if (state.transferInformation == null) return false; } -- cgit v1.2.3-55-g7522