Skip to content
Snippets Groups Projects
Commit 4a238ddd authored by Raphael GIRARDOT's avatar Raphael GIRARDOT Committed by Patrick MADELA
Browse files

- Use LogViewer instead of deprecated MessagePanelLogger (JAVAAPI-597)

- Exit on error at application start (CTRLDIFFRA-280)
- Obvious bug correction at Capoeira.setModel
parent afb1b2d1
No related branches found
No related tags found
No related merge requests found
......@@ -47,6 +47,10 @@
<url>${scm.url.svn.tango-ds}/Clients/java/Capoeira/trunk</url>
</scm>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.tango-controls</groupId>
......@@ -89,4 +93,5 @@
<artifactId>ApplicationUtilities</artifactId>
</dependency>
</dependencies>
</project>
......@@ -2,6 +2,7 @@ package fr.soleil.gui.capoeira;
import java.awt.BorderLayout;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Image;
import java.awt.Rectangle;
......@@ -28,25 +29,24 @@ import fr.soleil.bean.diffractometer.gui.DiffractometerBean;
import fr.soleil.bean.diffractometer.model.ContextModel;
import fr.soleil.comete.swing.TabbedPane;
import fr.soleil.gui.capoeira.action.PreferencesDisplayingAction;
import fr.soleil.gui.capoeira.log.ErrorPanel;
import fr.soleil.gui.capoeira.model.CapoeiraModel;
import fr.soleil.lib.project.application.Application;
import fr.soleil.lib.project.application.logging.LogViewer;
import fr.soleil.lib.project.application.logging.LogbackUtils;
public class Capoeira extends Application {
private static final long serialVersionUID = 6680214115151254433L;
private static final long serialVersionUID = -3959003027950888176L;
private static final Logger LOGGER = LoggerFactory.getLogger(Capoeira.class);
private static final LogViewer LOG_VIEWER = LogbackUtils.getConfiguredLogViewer(Capoeira.class.getName(), true);
static {
LOG_VIEWER.setAutoResizeColumns(true);
}
private static final String DEFAULT_DOC_URL = "http://ctrl/doc/HKL/";
private static final String URL_DOCUMENTATION = "URL_DOCUMENTATION";
private static final String GAP_REFLEXION = "GAP_REFLEXION";
private static final Logger LOGGER = LoggerFactory.getLogger(Capoeira.class);
private TabbedPane applicationTabbedPane = null;
private ControlBean controlBean = null;
private DiffractometerBean hklPanel = null;
protected CapoeiraModel model = null;
public static final int DEFAULT_WINDOW_X = 0;
public static final int DEFAULT_WINDOW_Y = 0;
......@@ -55,8 +55,13 @@ public class Capoeira extends Application {
public static final String DIFFRACTOMETER_DEVICE = "DiffractometerDevice";
public static final String DIFFRACTOMETER_PREPARE_DEVICE = "DiffractometerPrepareDevice";
public static final String COMPTER_DEVICE = "CompterDevice";
private TabbedPane applicationTabbedPane = null;
private ControlBean controlBean = null;
private DiffractometerBean hklPanel = null;
protected CapoeiraModel model = null;
private Preferences prefs = Preferences.userNodeForPackage(Capoeira.class);
private ErrorPanel errorPanel;
/**
* This is the default constructor
......@@ -77,25 +82,16 @@ public class Capoeira extends Application {
* @return TabbedPane
*/
private TabbedPane getApplicationTabbedPane() {
if (this.applicationTabbedPane == null) {
this.applicationTabbedPane = new TabbedPane();
this.applicationTabbedPane.setSize(new java.awt.Dimension(1237, 702));
this.applicationTabbedPane.setSize(new Dimension(1237, 702));
this.applicationTabbedPane.addTab(ContextModel.PILOT_LABEL, null, this.getControlBean(), null);
this.applicationTabbedPane.addTab(ContextModel.PREPARE_LABEL, null, this.getHklPanel(), null);
this.applicationTabbedPane.addTab("Error", null, this.getErrorPanel(), "Error log");
this.applicationTabbedPane.addTab("Logs", null, LOG_VIEWER, "Application logs");
}
return this.applicationTabbedPane;
}
private ErrorPanel getErrorPanel() {
if (this.errorPanel == null) {
this.errorPanel = new ErrorPanel();
}
return this.errorPanel;
}
/**
* This method initializes controlBean
*
......@@ -183,7 +179,7 @@ public class Capoeira extends Application {
* @throws DevFailed
*/
public void setModel(final CapoeiraModel model) throws DevFailed {
if (this.model == null || this.model.equals(model)) {
if (this.model == null || !this.model.equals(model)) {
if (this.model != null) {
// Unregistering listener from model
......@@ -299,11 +295,12 @@ public class Capoeira extends Application {
}
} catch (final DevFailed e) {
application.getSplash().setVisible(false);
final String error = DevFailedUtils.toString(e);
final String error = "Capoeira error at application start:\n" + DevFailedUtils.toString(e);
LOGGER.error(error);
JOptionPane.showMessageDialog(null, error);
JOptionPane.showMessageDialog(null, error, Capoeira.class.getSimpleName() + " Error!",
JOptionPane.ERROR_MESSAGE);
System.exit(1);
}
});
}
......
......@@ -23,6 +23,11 @@ import org.jdesktop.swingx.decorator.ColorHighlighter;
import org.jdesktop.swingx.decorator.HighlightPredicate;
import org.jdesktop.swingx.decorator.SearchPredicate;
/**
* @deprecated This class is never used to trace errors.
* A common logging UI should be used instead, as proposed in JAVAAPI-597.
*/
@Deprecated
public class ErrorPanel extends JPanel {
private static final long serialVersionUID = -3338873459440106972L;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment