Merge "Issue #2303 Fixed CAVE status messaging by fixing the setting of the UFStatus factory handler." into development
Former-commit-id:b17fc59a5a
[formerly 757ee730af2455ac88f2b5a666e23d32e3e068ef] Former-commit-id:b1244552e4
This commit is contained in:
commit
803c9a8217
9 changed files with 185 additions and 265 deletions
|
@ -27,6 +27,8 @@ import java.util.Map;
|
|||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.DisposeEvent;
|
||||
import org.eclipse.swt.events.DisposeListener;
|
||||
import org.eclipse.swt.events.MouseEvent;
|
||||
import org.eclipse.swt.events.MouseTrackAdapter;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
|
@ -97,6 +99,7 @@ import com.raytheon.uf.viz.alertviz.ui.dialogs.ConfigurationFileDlg.Function;
|
|||
* item update;
|
||||
* 07 Feb 2013 15490 Xiaochuan Past this object to LayoutControlsComp.
|
||||
* 26 Aug 2013 #2293 lvenable Fixed color memory leak and cleaned up some code.
|
||||
* 23 Oct 2013 2303 bgonzale Old patch to fix tool tip layout.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -392,6 +395,11 @@ public class AlertVisConfigDlg extends Dialog implements
|
|||
mttLayout = new MonitorToolTip(layoutGroup, true);
|
||||
layoutControls = new LayoutControlsComp(layoutGroup, configData, this,
|
||||
this);
|
||||
layoutGroup.addMouseTrackListener(new MouseTrackAdapter() {
|
||||
public void mouseHover(MouseEvent e) {
|
||||
mttLayout.open();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -409,6 +417,11 @@ public class AlertVisConfigDlg extends Dialog implements
|
|||
|
||||
mttCommonSetting = new MonitorToolTip(commonSettingsGroup, true);
|
||||
|
||||
commonSettingsGroup.addMouseTrackListener(new MouseTrackAdapter() {
|
||||
public void mouseHover(MouseEvent e) {
|
||||
mttCommonSetting.open();
|
||||
}
|
||||
});
|
||||
createCommonSettingsControls(commonSettingsGroup);
|
||||
}
|
||||
|
||||
|
@ -616,7 +629,13 @@ public class AlertVisConfigDlg extends Dialog implements
|
|||
sourcesLbl.setData(MonitorToolTip.tooltipTextKey,
|
||||
getSourcesToolTipText());
|
||||
|
||||
mttSource = new MonitorToolTip(sourcesLbl, true);
|
||||
mttSource = new MonitorToolTip(sourcesLbl, false);
|
||||
|
||||
sourcesLbl.addMouseTrackListener(new MouseTrackAdapter() {
|
||||
public void mouseHover(MouseEvent e) {
|
||||
mttSource.open();
|
||||
}
|
||||
});
|
||||
|
||||
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
gd.widthHint = 125;
|
||||
|
@ -842,13 +861,13 @@ public class AlertVisConfigDlg extends Dialog implements
|
|||
priorityLbl.setData(MonitorToolTip.tooltipTextKey,
|
||||
getPrioritiesToolTipText());
|
||||
|
||||
mttPriorities = new MonitorToolTip(priorityLbl, true);
|
||||
mttPriorities = new MonitorToolTip(priorityLbl, false);
|
||||
|
||||
// priorityLbl.addMouseTrackListener(new MouseTrackAdapter() {
|
||||
// public void mouseHover(MouseEvent e) {
|
||||
// mttPriorities.open();
|
||||
// }
|
||||
// });
|
||||
priorityLbl.addMouseTrackListener(new MouseTrackAdapter() {
|
||||
public void mouseHover(MouseEvent e) {
|
||||
mttPriorities.open();
|
||||
}
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// Put the priority canvases on the display
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
package com.raytheon.uf.viz.alertviz.ui.dialogs;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.graphics.GC;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.layout.FillLayout;
|
||||
|
@ -37,6 +33,7 @@ public class MonitorToolTip {
|
|||
* 17Jan2011 5150 cjeanbap Adjusted tooltip location and fix IllegalArgumentException.
|
||||
* 18Jan2011 5449 cjeanbap Fixed NullPointerException.
|
||||
* 24Jan 2011 1978 cjeanbap Removed unused variables.
|
||||
* 23Oct 2011 2303 bgonzale Old patch to fix tool tip layout.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -44,8 +41,6 @@ public class MonitorToolTip {
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
private Pattern LinePattern = Pattern.compile("^(.*)$", Pattern.MULTILINE);
|
||||
|
||||
private Display display;
|
||||
|
||||
private Shell parentShell;
|
||||
|
@ -54,7 +49,7 @@ public class MonitorToolTip {
|
|||
|
||||
public static final String tooltipTextKey = "tooltiptext";
|
||||
|
||||
private boolean useBorderWidth = true;
|
||||
private boolean ignoreDisplayPos = true;
|
||||
|
||||
public MonitorToolTip(Control control) {
|
||||
this.control = control;
|
||||
|
@ -62,7 +57,7 @@ public class MonitorToolTip {
|
|||
|
||||
public MonitorToolTip(Control control, boolean ignoreDisplayPos) {
|
||||
this.control = control;
|
||||
this.useBorderWidth = ignoreDisplayPos;
|
||||
this.ignoreDisplayPos = ignoreDisplayPos;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -144,33 +139,7 @@ public class MonitorToolTip {
|
|||
}
|
||||
label.addListener(SWT.MouseExit, labelListener);
|
||||
label.addListener(SWT.MouseDown, labelListener);
|
||||
Point size = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT);
|
||||
Rectangle rect = Display.getCurrent().getBounds();
|
||||
Point pt = Display.getCurrent()
|
||||
.map(control, null, 0, 0);
|
||||
|
||||
final int borderEstimate = (useBorderWidth ? (control
|
||||
.getBorderWidth() * 2 + 1) : 9);
|
||||
String labelText = label.getText();
|
||||
GC gc = new GC(control);
|
||||
int fontHeight = gc.getFontMetrics().getHeight();
|
||||
gc.dispose();
|
||||
Matcher m = LinePattern.matcher(labelText);
|
||||
int numberOfTextLines = 0; // m.groupCount();
|
||||
while (m.find()) {
|
||||
++numberOfTextLines;
|
||||
}
|
||||
numberOfTextLines = numberOfTextLines > 1 ? numberOfTextLines + 1
|
||||
: numberOfTextLines;
|
||||
int yAdj = fontHeight * numberOfTextLines
|
||||
+ borderEstimate + (useBorderWidth ? 4 : 0);
|
||||
if (pt.y + yAdj + fontHeight > rect.height) {
|
||||
pt.y -= yAdj;
|
||||
} else {
|
||||
pt.y += control.getSize().y + borderEstimate;
|
||||
}
|
||||
|
||||
tip.setBounds(pt.x, pt.y, size.x, size.y);
|
||||
setToolTipBounds(label, tip);
|
||||
tip.setVisible(true);
|
||||
textFont.dispose();
|
||||
}
|
||||
|
@ -184,4 +153,28 @@ public class MonitorToolTip {
|
|||
ctrl.addListener(SWT.MouseExit, tableListener);
|
||||
ctrl.addListener(SWT.Paint, tableListener);
|
||||
}
|
||||
|
||||
private void setToolTipBounds(Label label, Shell tip) {
|
||||
// size of tool tip
|
||||
Point tipSize = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT);
|
||||
// bounds of the current display
|
||||
Rectangle displayBounds = Display.getCurrent().getBounds();
|
||||
// x screen coordinate
|
||||
int xCoord = Display.getCurrent().map(control, null, 0, 0).x;
|
||||
// y coordinate of widget that the tool tip is next to
|
||||
Control widget = ignoreDisplayPos ? control : control.getParent();
|
||||
int widgetYCoord = Display.getCurrent().map(widget, null, 0, 0).y;
|
||||
Point widgetSize = widget.computeSize(SWT.DEFAULT,
|
||||
SWT.DEFAULT);
|
||||
|
||||
int yCoord = widgetYCoord;
|
||||
// check if the tip extends past the end of the display
|
||||
if (yCoord + widgetSize.y + tipSize.y > displayBounds.height) {
|
||||
yCoord = yCoord - tipSize.y - control.getParent().getBorderWidth();
|
||||
} else {
|
||||
yCoord = yCoord + widgetSize.y;
|
||||
}
|
||||
tip.setBounds(xCoord, yCoord, tipSize.x, tipSize.y);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,177 +0,0 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.viz.core.status;
|
||||
|
||||
import org.eclipse.ui.statushandlers.StatusManager;
|
||||
|
||||
import com.raytheon.uf.common.status.AbstractHandlerFactory;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
||||
/**
|
||||
* Sends StatusMessages into the Eclipse Status Manager
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 6, 2008 1433 chammack Initial creation
|
||||
* </pre>
|
||||
*
|
||||
* @author chammack
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class VizStatusHandler implements IUFStatusHandler {
|
||||
|
||||
private final String category;
|
||||
|
||||
private String source;
|
||||
|
||||
private final String pluginId;
|
||||
|
||||
private final AbstractHandlerFactory factory;
|
||||
|
||||
public VizStatusHandler(AbstractHandlerFactory factory, String pluginId,
|
||||
String category) {
|
||||
this.factory = factory;
|
||||
this.category = category;
|
||||
this.pluginId = pluginId;
|
||||
}
|
||||
|
||||
public VizStatusHandler(String pluginId, String category, String source) {
|
||||
this.category = category;
|
||||
this.source = source;
|
||||
this.pluginId = pluginId;
|
||||
this.factory = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPriorityEnabled(Priority p) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.status.IUFStatusHandler#handle(com.raytheon.uf
|
||||
* .common.status.UFStatus)
|
||||
*/
|
||||
@Override
|
||||
public void handle(UFStatus status) {
|
||||
handle(status, this.category);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(UFStatus status, String category) {
|
||||
if (this.source == null) {
|
||||
if (factory != null) {
|
||||
this.source = factory.getSource(source, pluginId);
|
||||
}
|
||||
}
|
||||
|
||||
VizStatusInternal vizStatus = new VizStatusInternal(status, category,
|
||||
source, pluginId);
|
||||
StatusManager.getManager().handle(vizStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(Priority p, String msg) {
|
||||
handle(new UFStatus(p, msg));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(Priority priority, String category, String message) {
|
||||
handle(priority, category, message, (Throwable) null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(Priority p, String msg, Throwable t) {
|
||||
handle(new UFStatus(p, msg, t));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(Priority p, String category, String msg, Throwable t) {
|
||||
handle(new UFStatus(p, msg, t), category);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String message) {
|
||||
handle(Priority.DEBUG, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String category, String message) {
|
||||
handle(Priority.DEBUG, category, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String message) {
|
||||
handle(Priority.INFO, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String category, String message) {
|
||||
handle(Priority.INFO, category, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String message) {
|
||||
handle(Priority.WARN, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String category, String message) {
|
||||
handle(Priority.WARN, category, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String message) {
|
||||
handle(Priority.ERROR, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String category, String message) {
|
||||
handle(Priority.ERROR, category, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String message, Throwable throwable) {
|
||||
handle(Priority.ERROR, message, throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String message, String category, Throwable throwable) {
|
||||
handle(Priority.ERROR, category, message, throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fatal(String message, Throwable throwable) {
|
||||
handle(Priority.FATAL, message, throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fatal(String message, String category, Throwable throwable) {
|
||||
handle(Priority.FATAL, category, message, throwable);
|
||||
}
|
||||
|
||||
}
|
|
@ -25,6 +25,8 @@ import java.util.MissingResourceException;
|
|||
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
import org.eclipse.ui.statushandlers.StatusManager;
|
||||
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
|
@ -34,6 +36,8 @@ import com.raytheon.uf.common.localization.PathManagerFactory;
|
|||
import com.raytheon.uf.common.status.AbstractHandlerFactory;
|
||||
import com.raytheon.uf.common.status.FilterPatternContainer;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.StatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
||||
/**
|
||||
|
@ -45,6 +49,8 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 25, 2010 rjpeter Initial creation
|
||||
* Oct 23, 2013 2303 bgonzale Merged VizStatusHandler and SysErrStatusHandler into StatusHandler.
|
||||
* Implemented log method from base class.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -56,8 +62,8 @@ public class VizStatusHandlerFactory extends AbstractHandlerFactory {
|
|||
|
||||
private static final String CATEGORY = "WORKSTATION";
|
||||
|
||||
private static final VizStatusHandler instance = new VizStatusHandler(
|
||||
VizStatusHandler.class.getPackage().getName(), CATEGORY, CATEGORY);
|
||||
private static final StatusHandler instance = new StatusHandler(
|
||||
StatusHandler.class.getPackage().getName(), CATEGORY, CATEGORY);
|
||||
|
||||
public VizStatusHandlerFactory() {
|
||||
super(CATEGORY);
|
||||
|
@ -77,13 +83,14 @@ public class VizStatusHandlerFactory extends AbstractHandlerFactory {
|
|||
@Override
|
||||
public IUFStatusHandler createInstance(String pluginId, String category,
|
||||
String source) {
|
||||
return new VizStatusHandler(pluginId, category, source);
|
||||
return new StatusHandler(pluginId, category, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IUFStatusHandler createInstance(AbstractHandlerFactory factory,
|
||||
String pluginId, String category) {
|
||||
return new VizStatusHandler(factory, pluginId, category);
|
||||
return new StatusHandler(pluginId, category, getSource(
|
||||
null, pluginId));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -103,7 +110,7 @@ public class VizStatusHandlerFactory extends AbstractHandlerFactory {
|
|||
if (locFile == null) {
|
||||
throw new MissingResourceException(
|
||||
"Unable to retrieve the localization file",
|
||||
VizStatusHandler.class.getName(),
|
||||
VizStatusHandlerFactory.class.getName(),
|
||||
LocalizationType.COMMON_STATIC.name() + File.separator
|
||||
+ LocalizationLevel.BASE.name() + File.separator
|
||||
+ "configuredHandlers.xml");
|
||||
|
@ -118,4 +125,13 @@ public class VizStatusHandlerFactory extends AbstractHandlerFactory {
|
|||
}
|
||||
return FilterPatternContainer.createDefault();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void log(Priority priority, String pluginId, String category,
|
||||
String source, String message, Throwable throwable) {
|
||||
VizStatusInternal vizStatus = new VizStatusInternal(new UFStatus(
|
||||
priority, message, throwable), category, source, pluginId);
|
||||
StatusManager.getManager().handle(vizStatus);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@ import java.util.Map;
|
|||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
||||
/**
|
||||
* Abstract implementation of the Handler Factories.
|
||||
*
|
||||
|
@ -215,6 +217,38 @@ public abstract class AbstractHandlerFactory implements
|
|||
getSourceFilters();
|
||||
}
|
||||
|
||||
public void log(Priority priority, StatusHandler statusHandler,
|
||||
String message, Throwable throwable) {
|
||||
String source = statusHandler.getSource();
|
||||
String pluginId = statusHandler.getPluginId();
|
||||
if (source == null) {
|
||||
source = getSource(source, pluginId);
|
||||
statusHandler.setSource(source);
|
||||
}
|
||||
this.log(priority, pluginId, statusHandler.getCategory(), source,
|
||||
message, throwable);
|
||||
}
|
||||
|
||||
protected void log(Priority priority, String pluginId, String category,
|
||||
String source, String message, Throwable throwable) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(priority).append(' ');
|
||||
sb.append(pluginId).append(": ");
|
||||
if (category != null) {
|
||||
sb.append(category);
|
||||
if (source != null) {
|
||||
sb.append(": ");
|
||||
sb.append(source);
|
||||
}
|
||||
sb.append(" - ");
|
||||
}
|
||||
sb.append(message);
|
||||
System.err.println(sb.toString());
|
||||
if (throwable != null) {
|
||||
throwable.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract IUFStatusHandler createMonitorInstance(String pluginId,
|
||||
String monitorSource);
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
**/
|
||||
package com.raytheon.uf.common.status;
|
||||
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
|
@ -29,6 +30,7 @@ package com.raytheon.uf.common.status;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 15, 2011 randerso Initial creation
|
||||
* Oct 23, 2013 2303 bgonzale Merged VizStatusHandler and SysErrStatusHandler into StatusHandler.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -36,13 +38,15 @@ package com.raytheon.uf.common.status;
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class DefaultStatusHandlerFactory extends AbstractHandlerFactory {
|
||||
private static final IUFStatusHandler handler = new SysErrStatusHandler(
|
||||
public class DefaultStatusHandlerFactory extends
|
||||
AbstractHandlerFactory {
|
||||
private static final IUFStatusHandler handler = new StatusHandler(
|
||||
DefaultStatusHandlerFactory.class.getPackage().getName(),
|
||||
"DEFAULT", "DEFAULT");
|
||||
|
||||
private static final String CATEGORY = "DEFAULT";
|
||||
|
||||
|
||||
public DefaultStatusHandlerFactory() {
|
||||
super(CATEGORY);
|
||||
}
|
||||
|
@ -90,7 +94,8 @@ public class DefaultStatusHandlerFactory extends AbstractHandlerFactory {
|
|||
@Override
|
||||
protected IUFStatusHandler createInstance(String pluginId, String category,
|
||||
String source) {
|
||||
return new SysErrStatusHandler(pluginId, category, source);
|
||||
return new StatusHandler(category, source,
|
||||
pluginId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -101,7 +106,8 @@ public class DefaultStatusHandlerFactory extends AbstractHandlerFactory {
|
|||
@Override
|
||||
public IUFStatusHandler createInstance(AbstractHandlerFactory factory,
|
||||
String pluginId, String category) {
|
||||
return new SysErrStatusHandler(pluginId, category, CATEGORY);
|
||||
return new StatusHandler(category, CATEGORY,
|
||||
pluginId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
**/
|
||||
package com.raytheon.uf.common.status;
|
||||
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
||||
|
||||
/**
|
||||
* Describes a method of creating UFStatusHandlerFactory
|
||||
*
|
||||
|
@ -27,6 +30,7 @@ package com.raytheon.uf.common.status;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 17, 2010 3265 rjpeter Initial creation
|
||||
* Oct 23, 2013 2303 bgonzale Added method for logging.
|
||||
* </pre>
|
||||
*
|
||||
* @author rjpeter
|
||||
|
@ -97,4 +101,7 @@ public interface IUFStatusHandlerFactory {
|
|||
public IUFStatusHandler createInstance(AbstractHandlerFactory factory,
|
||||
String pluginId, String category);
|
||||
|
||||
public void log(Priority priority, StatusHandler statusHandler,
|
||||
String message, Throwable throwable);
|
||||
|
||||
}
|
|
@ -22,7 +22,8 @@ package com.raytheon.uf.common.status;
|
|||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* Status handler for status messages. Outputs via the UFStatus configured
|
||||
* factory.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -31,6 +32,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 15, 2011 randerso Initial creation
|
||||
* Oct 22, 2013 2303 bgonzale Merged VizStatusHandler and SysErrStatusHandler.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -38,15 +40,16 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class SysErrStatusHandler implements IUFStatusHandler {
|
||||
public class StatusHandler implements IUFStatusHandler {
|
||||
|
||||
private final String pluginId;
|
||||
|
||||
private final String category;
|
||||
|
||||
private final String source;
|
||||
private String source;
|
||||
|
||||
public SysErrStatusHandler(String pluginId, String category, String source) {
|
||||
public StatusHandler(String pluginId,
|
||||
String category, String source) {
|
||||
this.pluginId = pluginId;
|
||||
this.category = category;
|
||||
this.source = source;
|
||||
|
@ -128,25 +131,7 @@ public class SysErrStatusHandler implements IUFStatusHandler {
|
|||
@Override
|
||||
public void handle(Priority priority, String category, String message,
|
||||
Throwable throwable) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(priority).append(' ');
|
||||
sb.append(this.pluginId).append(": ");
|
||||
|
||||
if (this.category != null) {
|
||||
sb.append(this.category);
|
||||
|
||||
if (this.source != null) {
|
||||
sb.append(": ");
|
||||
sb.append(this.source);
|
||||
}
|
||||
sb.append(" - ");
|
||||
}
|
||||
|
||||
sb.append(message);
|
||||
System.err.println(sb.toString());
|
||||
if (throwable != null) {
|
||||
throwable.printStackTrace(System.err);
|
||||
}
|
||||
UFStatus.log(priority, this, message, throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -209,4 +194,32 @@ public class SysErrStatusHandler implements IUFStatusHandler {
|
|||
handle(Priority.FATAL, category, message, throwable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pluginId
|
||||
*/
|
||||
public String getPluginId() {
|
||||
return pluginId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the category
|
||||
*/
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the source
|
||||
*/
|
||||
public String getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the source
|
||||
*/
|
||||
public void setSource(String source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
}
|
|
@ -21,6 +21,7 @@ package com.raytheon.uf.common.status;
|
|||
|
||||
import java.util.Iterator;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
||||
|
@ -57,6 +58,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 6, 2008 1433 chammack Initial creation
|
||||
* Apr 17, 2013 1786 mpduff Allow setting of Handler Factory.
|
||||
* Oct 23, 2013 2303 bgonzale Fixed setting of Handler Factory.
|
||||
* </pre>
|
||||
*
|
||||
* @author chammack
|
||||
|
@ -101,9 +103,9 @@ public class UFStatus {
|
|||
protected final String message;
|
||||
|
||||
/** handler factory */
|
||||
private static IUFStatusHandlerFactory handlerFactory = createHandlerFactory();
|
||||
private static AtomicReference<IUFStatusHandlerFactory> handlerFactoryRef = createHandlerFactory();
|
||||
|
||||
private static final IUFStatusHandlerFactory createHandlerFactory() {
|
||||
private static final AtomicReference<IUFStatusHandlerFactory> createHandlerFactory() {
|
||||
ServiceLoader<IUFStatusHandlerFactory> loader = ServiceLoader.load(
|
||||
IUFStatusHandlerFactory.class,
|
||||
IUFStatusHandlerFactory.class.getClassLoader());
|
||||
|
@ -128,7 +130,7 @@ public class UFStatus {
|
|||
+ IUFStatusHandlerFactory.class.getName()
|
||||
+ " handlers defined");
|
||||
}
|
||||
return factory;
|
||||
return new AtomicReference<IUFStatusHandlerFactory>(factory);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -204,14 +206,14 @@ public class UFStatus {
|
|||
* @return
|
||||
*/
|
||||
public static IUFStatusHandler getHandler() {
|
||||
return handlerFactory.getInstance();
|
||||
return handlerFactoryRef.get().getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the handlerfactory
|
||||
*/
|
||||
public static IUFStatusHandlerFactory getHandlerfactory() {
|
||||
return handlerFactory;
|
||||
return handlerFactoryRef.get();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -222,7 +224,7 @@ public class UFStatus {
|
|||
* @return
|
||||
*/
|
||||
public static IUFStatusHandler getHandler(Class<?> cls) {
|
||||
return handlerFactory.getInstance(cls);
|
||||
return handlerFactoryRef.get().getInstance(cls);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -234,7 +236,7 @@ public class UFStatus {
|
|||
* @return
|
||||
*/
|
||||
public static IUFStatusHandler getHandler(Class<?> cls, String source) {
|
||||
return handlerFactory.getInstance(cls, source);
|
||||
return handlerFactoryRef.get().getInstance(cls, source);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -246,7 +248,7 @@ public class UFStatus {
|
|||
* @return
|
||||
*/
|
||||
public static IUFStatusHandler getHandler(String pluginId, String source) {
|
||||
return handlerFactory.getInstance(pluginId, source);
|
||||
return handlerFactoryRef.get().getInstance(pluginId, source);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -261,7 +263,7 @@ public class UFStatus {
|
|||
*/
|
||||
public static IUFStatusHandler getHandler(String pluginId, String category,
|
||||
String source) {
|
||||
return handlerFactory.getInstance(pluginId, category, source);
|
||||
return handlerFactoryRef.get().getInstance(pluginId, category, source);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -275,7 +277,7 @@ public class UFStatus {
|
|||
*/
|
||||
public static IUFStatusHandler getHandler(Class<?> cls, String category,
|
||||
String source) {
|
||||
return handlerFactory.getInstance(cls, category, source);
|
||||
return handlerFactoryRef.get().getInstance(cls, category, source);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -287,7 +289,7 @@ public class UFStatus {
|
|||
* @return
|
||||
*/
|
||||
public static IUFStatusHandler getNamedHandler(String name) {
|
||||
return handlerFactory.getInstance(name);
|
||||
return handlerFactoryRef.get().getInstance(name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -299,7 +301,7 @@ public class UFStatus {
|
|||
* @return
|
||||
*/
|
||||
public static IUFStatusHandler getMonitorHandler(Class<?> cls) {
|
||||
return handlerFactory.getMonitorInstance(cls);
|
||||
return handlerFactoryRef.get().getMonitorInstance(cls);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -313,7 +315,7 @@ public class UFStatus {
|
|||
*/
|
||||
public static IUFStatusHandler getMonitorHandler(Class<?> cls,
|
||||
String monitorSource) {
|
||||
return handlerFactory.getMonitorInstance(cls, monitorSource);
|
||||
return handlerFactoryRef.get().getMonitorInstance(cls, monitorSource);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -323,6 +325,13 @@ public class UFStatus {
|
|||
* the handler factory
|
||||
*/
|
||||
public static void setHandlerFactory(IUFStatusHandlerFactory factory) {
|
||||
handlerFactory = factory;
|
||||
handlerFactoryRef.set(factory);
|
||||
}
|
||||
|
||||
static void log(Priority priority, StatusHandler statusHandler,
|
||||
String message, Throwable throwable) {
|
||||
handlerFactoryRef.get()
|
||||
.log(priority, statusHandler, message, throwable);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue