Author: rob.stryker(a)jboss.com
Date: 2012-03-21 01:23:58 -0400 (Wed, 21 Mar 2012)
New Revision: 39678
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/icons/errorMarker.gif
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/ModulePublishDecorator.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/ServerLog.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/ServerLogger.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/LocalCopyCallback.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/JBossServerUISharedImages.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
Log:
JBIDE-11035 adding decorators
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/ServerLog.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/ServerLog.java 2012-03-20
20:14:13 UTC (rev 39677)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/ServerLog.java 2012-03-21
05:23:58 UTC (rev 39678)
@@ -18,14 +18,21 @@
import org.eclipse.osgi.framework.log.FrameworkLogEntry;
public class ServerLog extends DeprecatedEclipseLog {
+ private ArrayList<IStatus> log;
public ServerLog(File file) {
super(file);
+ log = new ArrayList<IStatus>();
}
public void log(IStatus status) {
+ log.add(status);
log(getLog(status));
}
+ public IStatus[] getLogStatusObjects() {
+ return (IStatus[]) log.toArray(new IStatus[log.size()]);
+ }
+
// Hard Copied from PlatformLogWriter. You'd think
// they'd make that method static or some shit.
protected FrameworkLogEntry getLog(IStatus status) {
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/ServerLogger.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/ServerLogger.java 2012-03-20
20:14:13 UTC (rev 39677)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/ServerLogger.java 2012-03-21
05:23:58 UTC (rev 39678)
@@ -75,6 +75,13 @@
}
}
+ public IStatus[] getLog(IServer server) {
+ ServerLog log = map.get(server.getId());
+ if( log == null )
+ return new IStatus[]{};
+ return log.getLogStatusObjects();
+ }
+
public static boolean shouldDoubleLogErrors() {
IEclipsePreferences prefs = new
InstanceScope().getNode(JBossServerCorePlugin.PLUGIN_ID);
return prefs.getBoolean(RELOG_ERROR_PREF_KEY, true);
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/LocalCopyCallback.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/LocalCopyCallback.java 2012-03-20
20:14:13 UTC (rev 39677)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/LocalCopyCallback.java 2012-03-21
05:23:58 UTC (rev 39678)
@@ -57,6 +57,10 @@
DeployableServerBehavior beh = ServerConverter.getDeployableServerBehavior(server);
shouldRestartModule |= beh.changedFileRequiresModuleRestart(mf);
if( file != null ) {
+ if( !file.exists()) {
+ return new IStatus[] {new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID,
IEventCodes.JST_PUB_FAIL,
+ NLS.bind(Messages.errorReading, file.getAbsolutePath()), null)};
+ }
InputStream in = null;
try {
in = new FileInputStream(file);
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/icons/errorMarker.gif
===================================================================
(Binary files differ)
Property changes on: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/icons/errorMarker.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/JBossServerUISharedImages.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/JBossServerUISharedImages.java 2012-03-20
20:14:13 UTC (rev 39677)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/JBossServerUISharedImages.java 2012-03-21
05:23:58 UTC (rev 39678)
@@ -51,6 +51,7 @@
public static final String XPATH_LEVEL_2 = "xpath_level_2"; //$NON-NLS-1$
public static final String XPATH_LEVEL_3 = "xpath_level_3"; //$NON-NLS-1$
public static final String CONSOLE = "console"; //$NON-NLS-1$
+ public static final String ERROR_MARKER = "errorMarker"; //$NON-NLS-1$
private static JBossServerUISharedImages instance;
@@ -77,6 +78,7 @@
descriptors.put(XPATH_LEVEL_3, createImageDescriptor(pluginBundle,
"icons/xpath_level_3.gif")); //$NON-NLS-1$
descriptors.put(CONSOLE, createImageDescriptor(pluginBundle,
"/icons/console.gif")); //$NON-NLS-1$
+ descriptors.put(ERROR_MARKER, createImageDescriptor(pluginBundle,
"/icons/errorMarker.gif")); //$NON-NLS-1$
Iterator<String> iter = descriptors.keySet().iterator();
while (iter.hasNext()) {
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/ModulePublishDecorator.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/ModulePublishDecorator.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/ModulePublishDecorator.java 2012-03-21
05:23:58 UTC (rev 39678)
@@ -0,0 +1,56 @@
+package org.jboss.ide.eclipse.as.ui.views.server.extensions;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IDecoration;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ILightweightLabelDecorator;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.ui.IServerModule;
+import org.jboss.ide.eclipse.as.core.Messages;
+import org.jboss.ide.eclipse.as.core.extensions.events.IEventCodes;
+import org.jboss.ide.eclipse.as.core.extensions.events.ServerLogger;
+import org.jboss.ide.eclipse.as.ui.JBossServerUISharedImages;
+
+public class ModulePublishDecorator implements ILightweightLabelDecorator {
+
+ public void addListener(ILabelProviderListener listener) {
+ }
+ public void dispose() {
+ }
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+ public void removeListener(ILabelProviderListener listener) {
+ }
+ public void decorate(Object element, IDecoration decoration) {
+ if( recentPublishFailed(element)) {
+ ImageDescriptor id =
JBossServerUISharedImages.getImageDescriptor(JBossServerUISharedImages.ERROR_MARKER);
+ decoration.addOverlay(id, IDecoration.BOTTOM_LEFT);
+ }
+ }
+
+ protected boolean recentPublishFailed(Object element) {
+ if( element instanceof IServerModule ) {
+ IServer s = ((IServerModule)element).getServer();
+ IModule[] m = ((IServerModule)element).getModule();
+ String name = m[m.length-1].getName();
+ IStatus[] all = ServerLogger.getDefault().getLog(s);
+
+ // This really isn't the best. But I need string comparisons to know it's the
same module
+ // I can compare on status code like IEventCodes.JST_PUB_FULL_FAIL but this won't
tell me what module
+ // For now I will stick with this method.
+ for( int i = all.length-1; i >= 0; i-- ) {
+ String success = NLS.bind(Messages.ModulePublished, name);
+ if(all[i].getMessage().equals(success))
+ return false;
+ String fail = NLS.bind(Messages.FullPublishFail, name);
+ if( all[i].getMessage().equals(fail))
+ return true;
+ }
+ }
+ return false;
+ }
+}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2012-03-20 20:14:13 UTC (rev
39677)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2012-03-21 05:23:58 UTC (rev
39678)
@@ -469,6 +469,22 @@
</decorator>
</extension>
+ <extension point="org.eclipse.ui.decorators">
+ <decorator
+
class="org.jboss.ide.eclipse.as.ui.views.server.extensions.ModulePublishDecorator"
+ id="org.jboss.ide.eclipse.as.ui.module.publish.decorator"
+ label="Module Publish Error Decorator"
+ lightweight="true"
+ location="BOTTOM_LEFT"
+ state="true">
+ <enablement>
+ <objectClass
+ name="org.eclipse.wst.server.ui.IServerModule">
+ </objectClass>
+ </enablement>
+ </decorator>
+ </extension>
+
<!-- JMX Stuff
<extension
point="org.jboss.tools.jmx.ui.providerUI">