JBoss Tools SVN: r12230 - workspace/examples.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-12-02 19:55:51 -0500 (Tue, 02 Dec 2008)
New Revision: 12230
Modified:
workspace/examples/projectExamples.xml
Log:
JBIDE-3304 After download the project examples should be able to do a custom action (i.e. show a downloaded readme.txt or cheatsheet)
Modified: workspace/examples/projectExamples.xml
===================================================================
--- workspace/examples/projectExamples.xml 2008-12-03 00:47:34 UTC (rev 12229)
+++ workspace/examples/projectExamples.xml 2008-12-03 00:55:51 UTC (rev 12230)
@@ -56,6 +56,7 @@
<url>
http://anonsvn.jboss.org/repos/jbosstools/workspace/snjeza/portlet-exampl...
</url>
+ <welcome type="cheatsheets" url="/testjavaportlet/javaportletcs.xml"/>
</project>
<project>
17 years
JBoss Tools SVN: r12229 - in trunk/jmx/plugins: org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/editors and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-12-02 19:47:34 -0500 (Tue, 02 Dec 2008)
New Revision: 12229
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/MBeanAttributeInfoWrapper.java
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/editors/AttributeDetails.java
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/tables/AttributesLabelProvider.java
Log:
JBIDE-3285
Modified: trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/MBeanAttributeInfoWrapper.java
===================================================================
--- trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/MBeanAttributeInfoWrapper.java 2008-12-03 00:41:45 UTC (rev 12228)
+++ trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/MBeanAttributeInfoWrapper.java 2008-12-03 00:47:34 UTC (rev 12229)
@@ -26,12 +26,8 @@
}
public Object getValue() throws Exception {
- try {
- MBeanServerConnection mbsc = getMBeanServerConnection();
- return mbsc.getAttribute(getObjectName(), info.getName());
- } catch( Exception e ) {
- return e;
- }
+ MBeanServerConnection mbsc = getMBeanServerConnection();
+ return mbsc.getAttribute(getObjectName(), info.getName());
}
public int hashCode() {
Modified: trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/editors/AttributeDetails.java
===================================================================
--- trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/editors/AttributeDetails.java 2008-12-03 00:41:45 UTC (rev 12228)
+++ trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/editors/AttributeDetails.java 2008-12-03 00:47:34 UTC (rev 12229)
@@ -192,9 +192,6 @@
attrControl.setLayoutData(gd);
attrControl.pack(true);
} catch (Throwable t) {
- JMXUIActivator.log(IStatus.ERROR, NLS.bind(
- Messages.MBeanAttributeValue_Warning, attrInfo.getName()),
- t);
Label errorLabel = toolkit.createLabel(valueComposite,
Messages.unavailable);
errorLabel.setForeground(valueComposite.getDisplay()
Modified: trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/tables/AttributesLabelProvider.java
===================================================================
--- trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/tables/AttributesLabelProvider.java 2008-12-03 00:41:45 UTC (rev 12228)
+++ trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/tables/AttributesLabelProvider.java 2008-12-03 00:47:34 UTC (rev 12229)
@@ -36,9 +36,6 @@
try {
return StringUtils.toString(wrapper.getValue(), false);
} catch (Throwable t) {
- JMXUIActivator.log(IStatus.ERROR, NLS.bind(
- Messages.MBeanAttributeValue_Warning,
- attrInfo.getName()), t);
return Messages.unavailable;
}
}
17 years
JBoss Tools SVN: r12228 - trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-12-02 19:41:45 -0500 (Tue, 02 Dec 2008)
New Revision: 12228
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/MBeanAttributeInfoWrapper.java
Log:
JBIDE-3285
Modified: trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/MBeanAttributeInfoWrapper.java
===================================================================
--- trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/MBeanAttributeInfoWrapper.java 2008-12-03 00:22:02 UTC (rev 12227)
+++ trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/MBeanAttributeInfoWrapper.java 2008-12-03 00:41:45 UTC (rev 12228)
@@ -26,8 +26,12 @@
}
public Object getValue() throws Exception {
- MBeanServerConnection mbsc = getMBeanServerConnection();
- return mbsc.getAttribute(getObjectName(), info.getName());
+ try {
+ MBeanServerConnection mbsc = getMBeanServerConnection();
+ return mbsc.getAttribute(getObjectName(), info.getName());
+ } catch( Exception e ) {
+ return e;
+ }
}
public int hashCode() {
17 years
JBoss Tools SVN: r12227 - in trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core: util and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-12-02 19:22:02 -0500 (Tue, 02 Dec 2008)
New Revision: 12227
Added:
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/util/EqualsUtil.java
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/MBeanInfoWrapper.java
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/MBeanOperationInfoWrapper.java
Log:
MORE NPE's because of nonconforming MBeans on the jboss server side >=[
Modified: trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/MBeanInfoWrapper.java
===================================================================
--- trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/MBeanInfoWrapper.java 2008-12-03 00:13:55 UTC (rev 12226)
+++ trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/MBeanInfoWrapper.java 2008-12-03 00:22:02 UTC (rev 12227)
@@ -8,6 +8,8 @@
package org.jboss.tools.jmx.core;
+import java.util.Arrays;
+
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanInfo;
import javax.management.MBeanNotificationInfo;
@@ -17,6 +19,7 @@
import javax.management.ObjectName;
import org.eclipse.core.runtime.Assert;
+import org.jboss.tools.jmx.core.util.EqualsUtil;
public class MBeanInfoWrapper implements Comparable {
private final ObjectName on;
@@ -142,22 +145,24 @@
return false;
final MBeanInfoWrapper other = (MBeanInfoWrapper) obj;
if (info == null) {
- if (other.info != null)
- return false;
+ return other.info == null;
} else if (other.info == null ) {
return false;
- } else if (!info.equals(other.info))
- return false;
+ }
if (mbsc == null) {
- if (other.mbsc != null)
- return false;
+ return other.mbsc == null;
} else if (!mbsc.equals(other.mbsc))
return false;
if (on == null) {
- if (other.on != null)
- return false;
+ return other.on == null;
} else if (!on.equals(other.on))
return false;
- return true;
+ try {
+ return info.equals(other.info);
+ } catch( NullPointerException npe ) {
+ return EqualsUtil.infoEquals(info, other.info);
+ }
}
+
+
}
Modified: trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/MBeanOperationInfoWrapper.java
===================================================================
--- trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/MBeanOperationInfoWrapper.java 2008-12-03 00:13:55 UTC (rev 12226)
+++ trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/MBeanOperationInfoWrapper.java 2008-12-03 00:22:02 UTC (rev 12227)
@@ -9,9 +9,9 @@
package org.jboss.tools.jmx.core;
import javax.management.MBeanOperationInfo;
-import javax.management.MBeanParameterInfo;
import org.eclipse.core.runtime.Assert;
+import org.jboss.tools.jmx.core.util.EqualsUtil;
public class MBeanOperationInfoWrapper extends MBeanFeatureInfoWrapper {
@@ -52,56 +52,8 @@
if (info == null) {
if (other.info != null)
return false;
- } else if (!equals2(other.info))
+ } else if (!EqualsUtil.operationEquals(info, other.info))
return false;
return true;
}
-
- private boolean equals2(MBeanOperationInfo o) {
- if (o == info)
- return true;
- if (!(o instanceof MBeanOperationInfo))
- return false;
- MBeanOperationInfo p = (MBeanOperationInfo) o;
- return (p.getName().equals(info.getName()) &&
- p.getReturnType().equals(info.getReturnType()) &&
- p.getDescription().equals(info.getDescription()) &&
- p.getImpact() == info.getImpact() &&
- arrayEquals(p.getSignature(), info.getSignature()) /*&&
- p.getDescriptor().equals(info.getDescriptor()*/);
-
- }
-
- private boolean arrayEquals(MBeanParameterInfo[] a, MBeanParameterInfo[] a2) {
- if (a==a2)
- return true;
- if (a==null || a2==null)
- return false;
-
- int length = a.length;
- if (a2.length != length)
- return false;
-
- for (int i=0; i<length; i++) {
- MBeanParameterInfo o1 = a[i];
- MBeanParameterInfo o2 = a2[i];
- if (!(o1==null ? o2==null : paramEquals(o1,o2)))
- return false;
- }
-
- return true;
- }
-
- private boolean paramEquals(MBeanParameterInfo o1, MBeanParameterInfo o2) {
- if (o1 == o2)
- return true;
- return (o1.getName().equals(o2.getName()) &&
- o1.getType().equals(o2.getType()) &&
- safeEquals(o1.getDescription(), o2.getDescription()) /*&&
- o1.getDescriptor().equals(o2.getDescriptor())*/);
- }
-
- private boolean safeEquals(Object o1, Object o2) {
- return o1 == o2 || !(o1 == null || o2 == null) || o1.equals(o2);
- }
}
Added: trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/util/EqualsUtil.java
===================================================================
--- trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/util/EqualsUtil.java (rev 0)
+++ trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/util/EqualsUtil.java 2008-12-03 00:22:02 UTC (rev 12227)
@@ -0,0 +1,69 @@
+package org.jboss.tools.jmx.core.util;
+
+import javax.management.MBeanInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+
+public class EqualsUtil {
+
+
+ public static boolean operationEquals(MBeanOperationInfo one, MBeanOperationInfo two) {
+ if (one == two)
+ return true;
+ return (one.getName().equals(two.getName()) &&
+ one.getReturnType().equals(two.getReturnType()) &&
+ one.getDescription().equals(two.getDescription()) &&
+ one.getImpact() == two.getImpact() &&
+ infoArrayEquals(one.getSignature(), two.getSignature()) /*&&
+ p.getDescriptor().equals(info.getDescriptor()*/);
+
+ }
+
+ public static boolean infoArrayEquals(MBeanParameterInfo[] a, MBeanParameterInfo[] a2) {
+ if (a==a2)
+ return true;
+ if (a==null || a2==null)
+ return false;
+
+ int length = a.length;
+ if (a2.length != length)
+ return false;
+
+ for (int i=0; i<length; i++) {
+ MBeanParameterInfo o1 = a[i];
+ MBeanParameterInfo o2 = a2[i];
+ if (!(o1==null ? o2==null : paramEquals(o1,o2)))
+ return false;
+ }
+
+ return true;
+ }
+
+ public static boolean paramEquals(MBeanParameterInfo o1, MBeanParameterInfo o2) {
+ if (o1 == o2)
+ return true;
+ return (o1.getName().equals(o2.getName()) &&
+ o1.getType().equals(o2.getType()) &&
+ safeEquals(o1.getDescription(), o2.getDescription()) /*&&
+ o1.getDescriptor().equals(o2.getDescriptor())*/);
+ }
+
+ public static boolean safeEquals(Object o1, Object o2) {
+ return o1 == o2 || !(o1 == null || o2 == null) || o1.equals(o2);
+ }
+
+ public static boolean infoEquals(MBeanInfo one, MBeanInfo two) {
+ if (one == two )
+ return true;
+ if (!safeStringEquals(one.getClassName(), two.getClassName()) ||
+ !safeStringEquals(one.getDescription(),two.getDescription()))
+ return false;
+ return true;
+ }
+
+ public static boolean safeStringEquals(String one, String two) {
+ if( one == null )
+ return two == null;
+ return one.equals(two);
+ }
+}
17 years
JBoss Tools SVN: r12226 - in trunk/examples/plugins/org.jboss.tools.project.examples: src/org/jboss/tools/project/examples and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-12-02 19:13:55 -0500 (Tue, 02 Dec 2008)
New Revision: 12226
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/Messages.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/filetransfer/ECFExamplesTransport.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/messages.properties
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/Project.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java
Log:
JBIDE-3304 After download the project examples should be able to do a custom action (i.e. show a downloaded readme.txt or cheatsheet)
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF 2008-12-02 23:46:57 UTC (rev 12225)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF 2008-12-03 00:13:55 UTC (rev 12226)
@@ -19,6 +19,7 @@
org.eclipse.equinox.p2.core,
org.eclipse.ui.ide,
org.eclipse.wst.validation,
- org.eclipse.ui.views
+ org.eclipse.ui.views,
+ org.eclipse.ui.cheatsheets
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/Messages.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/Messages.java 2008-12-02 23:46:57 UTC (rev 12225)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/Messages.java 2008-12-03 00:13:55 UTC (rev 12226)
@@ -16,7 +16,6 @@
private static final String BUNDLE_NAME = "org.jboss.tools.project.examples.messages"; //$NON-NLS-1$
public static String Category_Other;
public static String ECFExamplesTransport_Downloading;
- public static String ECFExamplesTransport_Internal_error;
public static String ECFExamplesTransport_Internal_Error;
public static String ECFExamplesTransport_IO_error;
public static String ECFExamplesTransport_Loading;
@@ -33,6 +32,7 @@
public static String NewProjectExamplesWizard_Detail;
public static String NewProjectExamplesWizard_Downloading;
public static String NewProjectExamplesWizard_Error;
+ public static String NewProjectExamplesWizard_File_does_not_exist;
public static String NewProjectExamplesWizard_Importing;
public static String NewProjectExamplesWizard_New_Project_Example;
public static String NewProjectExamplesWizard_OverwriteProject;
@@ -47,6 +47,7 @@
public static String NewProjectExamplesWizardPage_URL;
public static String ProjectExamplesActivator_Waiting;
public static String ProjectUtil_Invalid_URL;
+ public static String ProjectUtil_Invalid_welcome_element;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/filetransfer/ECFExamplesTransport.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/filetransfer/ECFExamplesTransport.java 2008-12-02 23:46:57 UTC (rev 12225)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/filetransfer/ECFExamplesTransport.java 2008-12-03 00:13:55 UTC (rev 12226)
@@ -399,10 +399,10 @@
prefNode.put(IRepository.PROP_PASSWORD, loginDetails.getPassword(), true);
prefNode.flush();
} catch (StorageException e1) {
- String msg = Messages.ECFExamplesTransport_Internal_error;
+ String msg = Messages.ECFExamplesTransport_Internal_Error;
throw new CoreException(new Status(IStatus.ERROR, ProjectExamplesActivator.PLUGIN_ID, msg, e1));
} catch (IOException e) {
- String msg = Messages.ECFExamplesTransport_Internal_error;
+ String msg = Messages.ECFExamplesTransport_Internal_Error;
throw new CoreException(new Status(IStatus.ERROR, ProjectExamplesActivator.PLUGIN_ID, msg, e));
}
}
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/messages.properties
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/messages.properties 2008-12-02 23:46:57 UTC (rev 12225)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/messages.properties 2008-12-03 00:13:55 UTC (rev 12226)
@@ -1,6 +1,5 @@
Category_Other=Other
ECFExamplesTransport_Downloading=Downloading
-ECFExamplesTransport_Internal_error=Internal error
ECFExamplesTransport_Internal_Error=Internal Error
ECFExamplesTransport_IO_error=IO error
ECFExamplesTransport_Loading=Loading
@@ -17,6 +16,7 @@
NewProjectExamplesWizard_Detail=Detail
NewProjectExamplesWizard_Downloading=Downloading...
NewProjectExamplesWizard_Error=Error
+NewProjectExamplesWizard_File_does_not_exist=The {0} does not exist.
NewProjectExamplesWizard_Importing=Importing...
NewProjectExamplesWizard_New_Project_Example=New Project Example
NewProjectExamplesWizard_OverwriteProject=Overwrite project ''{0}''
@@ -31,3 +31,4 @@
NewProjectExamplesWizardPage_URL=URL:
ProjectExamplesActivator_Waiting=Waiting...
ProjectUtil_Invalid_URL=Invalid URL\: {0}
+ProjectUtil_Invalid_welcome_element=The welcome element has invalid the url attribute
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/Project.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/Project.java 2008-12-02 23:46:57 UTC (rev 12225)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/Project.java 2008-12-03 00:13:55 UTC (rev 12226)
@@ -26,12 +26,16 @@
private long size;
private Category category;
private List<String> includedProjects;
-
+ private boolean welcome;
+ private String type;
+ private String welcomeURL;
+
public Project() {
name=""; //$NON-NLS-1$
shortDescription=""; //$NON-NLS-1$
description=""; //$NON-NLS-1$
url=""; //$NON-NLS-1$
+ welcome=false;
setCategory(Category.OTHER);
}
@@ -105,4 +109,28 @@
public void setIncludedProjects(List<String> includedProjects) {
this.includedProjects = includedProjects;
}
+
+ public boolean isWelcome() {
+ return welcome;
+ }
+
+ public void setWelcome(boolean welcome) {
+ this.welcome = welcome;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getWelcomeURL() {
+ return welcomeURL;
+ }
+
+ public void setWelcomeURL(String welcomeURL) {
+ this.welcomeURL = welcomeURL;
+ }
}
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java 2008-12-02 23:46:57 UTC (rev 12225)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java 2008-12-03 00:13:55 UTC (rev 12226)
@@ -47,6 +47,10 @@
*/
public class ProjectUtil {
+ private static final String EDITOR = "editor"; //$NON-NLS-1$
+
+ public static final String CHEATSHEETS = "cheatsheets"; //$NON-NLS-1$
+
private static final String PROTOCOL_FILE = "file"; //$NON-NLS-1$
private static final String PROJECT_EXAMPLES_XML_EXTENSION_ID = "org.jboss.tools.project.examples.projectExamplesXml"; //$NON-NLS-1$
@@ -180,6 +184,22 @@
.setIncludedProjects(projectList);
}
}
+ if (nodeName.equals("welcome")) { //$NON-NLS-1$
+ project.setWelcome(true);
+ String attribute = child.getAttribute("type"); //$NON-NLS-1$
+ if (attribute != null && CHEATSHEETS.equals(attribute.trim())) {
+ project.setType(attribute.trim());
+ } else {
+ project.setType(EDITOR);
+ }
+ attribute = child.getAttribute("url"); //$NON-NLS-1$
+ if (attribute == null || attribute.trim().length() <= 0) {
+ project.setWelcome(false);
+ ProjectExamplesActivator.log(Messages.ProjectUtil_Invalid_welcome_element);
+ } else {
+ project.setWelcomeURL(attribute.trim());
+ }
+ }
}
}
}
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java 2008-12-02 23:46:57 UTC (rev 12225)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java 2008-12-03 00:13:55 UTC (rev 12226)
@@ -27,14 +27,19 @@
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.resources.WorkspaceJob;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.IJobChangeListener;
@@ -49,9 +54,14 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.browser.IWebBrowser;
+import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
import org.eclipse.ui.dialogs.IOverwriteQuery;
-import org.eclipse.ui.internal.services.SourceProviderService;
+import org.eclipse.ui.internal.cheatsheets.state.DefaultStateManager;
+import org.eclipse.ui.internal.cheatsheets.views.CheatSheetView;
+import org.eclipse.ui.internal.cheatsheets.views.ViewUtilities;
import org.eclipse.ui.wizards.datatransfer.IImportStructureProvider;
import org.eclipse.ui.wizards.datatransfer.ImportOperation;
import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider;
@@ -178,7 +188,6 @@
.schedule();
ProjectExamplesActivator.waitForBuildAndValidation
.join();
-
} catch (InterruptedException e) {
return;
}
@@ -189,6 +198,7 @@
showQuickFix();
}
}
+ openWelcome();
}
public void running(IJobChangeEvent event) {
@@ -204,10 +214,70 @@
}
});
+ } else {
+ openWelcome();
}
return true;
}
+ private void openWelcome() {
+ for(final Project project:projects) {
+ if (project.isWelcome()) {
+ String urlString = project.getWelcomeURL();
+ URL url = null;
+ if (urlString.startsWith("/")) { //$NON-NLS-1$
+ IPath path = new Path(urlString);
+ IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
+ if (resource instanceof IFile && resource.isAccessible()) {
+ try {
+ url = resource.getRawLocationURI().toURL();
+ } catch (MalformedURLException e) {
+ ProjectExamplesActivator.log(e);
+ }
+ } else {
+ ProjectExamplesActivator.log(NLS.bind(Messages.NewProjectExamplesWizard_File_does_not_exist,urlString));
+ }
+ } else {
+ try {
+ url = new URL(urlString);
+ } catch (MalformedURLException e) {
+ ProjectExamplesActivator.log(e);
+ }
+ }
+ if (url!=null) {
+ final URL finalURL = url;
+ Display.getDefault().asyncExec(new Runnable() {
+
+ public void run() {
+ if (ProjectUtil.CHEATSHEETS.equals(project.getType())) {
+ CheatSheetView view = ViewUtilities.showCheatSheetView();
+ if (view == null) {
+ return;
+ }
+ IPath filePath = new Path(finalURL.getPath());
+ String id = filePath.lastSegment();
+ if (id == null) {
+ id = ""; //$NON-NLS-1$
+ }
+ view.getCheatSheetViewer().setInput(id, id, finalURL, new DefaultStateManager(), true);
+ } else {
+ try {
+ IWorkbenchBrowserSupport browserSupport = ProjectExamplesActivator.getDefault().getWorkbench().getBrowserSupport();
+ IWebBrowser browser = browserSupport.createBrowser(IWorkbenchBrowserSupport.LOCATION_BAR | IWorkbenchBrowserSupport.NAVIGATION_BAR, null, null, null);
+ browser.openURL(finalURL);
+ } catch (PartInitException e) {
+ ProjectExamplesActivator.log(e);
+ }
+ }
+ }
+
+ });
+
+ }
+ }
+ }
+ }
+
private void showQuickFix() {
Display.getDefault().asyncExec(new Runnable() {
17 years
JBoss Tools SVN: r12225 - trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-12-02 18:46:57 -0500 (Tue, 02 Dec 2008)
New Revision: 12225
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/MBeanInfoWrapper.java
Log:
NPE
Modified: trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/MBeanInfoWrapper.java
===================================================================
--- trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/MBeanInfoWrapper.java 2008-12-02 22:39:35 UTC (rev 12224)
+++ trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/MBeanInfoWrapper.java 2008-12-02 23:46:57 UTC (rev 12225)
@@ -144,6 +144,8 @@
if (info == null) {
if (other.info != null)
return false;
+ } else if (other.info == null ) {
+ return false;
} else if (!info.equals(other.info))
return false;
if (mbsc == null) {
17 years
JBoss Tools SVN: r12224 - workspace/snjeza/portlet-examples.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-12-02 17:39:35 -0500 (Tue, 02 Dec 2008)
New Revision: 12224
Added:
workspace/snjeza/portlet-examples/javaportletcs.xml
Log:
JBIDE-3304 After download the project examples should be able to do a custom action (i.e. show a downloaded readme.txt or cheatsheet)
Added: workspace/snjeza/portlet-examples/javaportletcs.xml
===================================================================
--- workspace/snjeza/portlet-examples/javaportletcs.xml (rev 0)
+++ workspace/snjeza/portlet-examples/javaportletcs.xml 2008-12-02 22:39:35 UTC (rev 12224)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<cheatsheet title="Java Portlet Project">
+ <intro>
+ <description>This example demonstrates the use of JBoss Java
+ Portlet.
+ </description>
+ </intro>
+ <item title="Java Portlet Project">
+ <description>This example demonstrates the use of JBoss Java
+ Portlet. It runs on JBoss Portal 2.7.0.
+ </description>
+ </item>
+
+</cheatsheet>
\ No newline at end of file
17 years
JBoss Tools SVN: r12223 - trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-12-02 17:29:47 -0500 (Tue, 02 Dec 2008)
New Revision: 12223
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/EventDetailsDialog.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/LogLabelProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/ServerLogView.java
Log:
JBIDE-3307 - added icons, double-click to explore
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/EventDetailsDialog.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/EventDetailsDialog.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/EventDetailsDialog.java 2008-12-02 22:29:47 UTC (rev 12223)
@@ -0,0 +1,255 @@
+package org.jboss.ide.eclipse.as.ui.views;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.StringTokenizer;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.TrayDialog;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.internal.views.log.Messages;
+
+/**
+ * Displays details about Log Entry.
+ * Event information is split in three sections: details, stack trace and session. Details
+ * contain event date, message and severity. Stack trace is displayed if an exception is bound
+ * to event. Stack trace entries can be filtered.
+ */
+public class EventDetailsDialog extends TrayDialog {
+
+ private AbstractEntry entry;
+ private LogLabelProvider labelProvider;
+ private TreeViewer provider;
+
+ private static int COPY_ID = 22;
+
+
+ private Label dateLabel;
+ private Label severityImageLabel;
+ private Label severityLabel;
+ private Text msgText;
+ private Text stackTraceText;
+ private Clipboard clipboard;
+ private Button copyButton;
+
+ // patterns for filtering stack traces
+ private String[] stackFilterPatterns = null;
+
+ /**
+ *
+ * @param parentShell shell in which dialog is displayed
+ * @param selection entry initially selected and to be displayed
+ * @param provider viewer
+ * @param comparator comparator used to order all entries
+ */
+ protected EventDetailsDialog(Shell parentShell, AbstractEntry selection, TreeViewer provider) {
+ super(parentShell);
+ this.provider = provider;
+ labelProvider = (LogLabelProvider) this.provider.getLabelProvider();
+ this.entry = selection;
+ setShellStyle(SWT.MODELESS | SWT.MIN | SWT.MAX | SWT.RESIZE | SWT.CLOSE | SWT.BORDER | SWT.TITLE);
+ clipboard = new Clipboard(parentShell.getDisplay());
+ }
+
+ private boolean isChild(AbstractEntry entry) {
+ return entry.getParent(entry) != null;
+ }
+
+ public void create() {
+ super.create();
+ getShell().setSize(500, 550);
+ applyDialogFont(buttonBar);
+ getButton(IDialogConstants.OK_ID).setFocus();
+ }
+
+ protected void buttonPressed(int buttonId) {
+ if (IDialogConstants.OK_ID == buttonId)
+ okPressed();
+ else if (IDialogConstants.CANCEL_ID == buttonId)
+ cancelPressed();
+ else if (COPY_ID == buttonId)
+ copyPressed();
+ }
+
+
+ protected void copyPressed() {
+ StringWriter writer = new StringWriter();
+ PrintWriter pwriter = new PrintWriter(writer);
+
+ entry.write(pwriter);
+ pwriter.flush();
+ String textVersion = writer.toString();
+ try {
+ pwriter.close();
+ writer.close();
+ } catch (IOException e) { // do nothing
+ }
+ // set the clipboard contents
+ clipboard.setContents(new Object[] {textVersion}, new Transfer[] {TextTransfer.getInstance()});
+ }
+
+
+ public void updateProperties() {
+ if (entry instanceof LogEntry) {
+ LogEntry logEntry = (LogEntry) entry;
+
+ String strDate = logEntry.getFormattedDate();
+ dateLabel.setText(strDate);
+ severityImageLabel.setImage(labelProvider.getColumnImage(entry, 0));
+ severityLabel.setText(logEntry.getSeverityText());
+ msgText.setText(logEntry.getMessage() != null ? logEntry.getMessage() : ""); //$NON-NLS-1$
+ String stack = logEntry.getStack();
+
+ if (stack != null) {
+ stack = filterStack(stack);
+ stackTraceText.setText(stack);
+ } else {
+ stackTraceText.setText(Messages.EventDetailsDialog_noStack);
+ }
+ } else {
+ dateLabel.setText(""); //$NON-NLS-1$
+ severityImageLabel.setImage(null);
+ severityLabel.setText(""); //$NON-NLS-1$
+ msgText.setText(""); //$NON-NLS-1$
+ stackTraceText.setText(""); //$NON-NLS-1$
+ }
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ Composite container = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ container.setLayout(layout);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ container.setLayoutData(gd);
+
+ createDetailsSection(container);
+ createStackSection(container);
+ updateProperties();
+ Dialog.applyDialogFont(container);
+ return container;
+ }
+
+ private void createToolbarButtonBar(Composite parent) {
+ Composite comp = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = layout.marginHeight = 0;
+ //layout.numColumns = 1;
+ comp.setLayout(layout);
+ comp.setLayoutData(new GridData(GridData.FILL_VERTICAL));
+ ((GridData) comp.getLayoutData()).verticalAlignment = SWT.BOTTOM;
+
+ Composite container = new Composite(comp, SWT.NONE);
+ layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ container.setLayout(layout);
+ container.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ copyButton = createButton(container, COPY_ID, "", false); //$NON-NLS-1$
+ GridData gd = new GridData();
+ copyButton.setLayoutData(gd);
+ copyButton.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_COPY));
+ copyButton.setToolTipText(Messages.EventDetailsDialog_copy);
+
+ // set numColumns at the end, after all createButton() calls, which change this value
+ layout.numColumns = 2;
+ }
+
+ protected void createButtonsForButtonBar(Composite parent) {
+ // create OK button only by default
+ createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
+ }
+
+ private void createDetailsSection(Composite parent) {
+ Composite container = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = layout.marginHeight = 0;
+ layout.numColumns = 2;
+ container.setLayout(layout);
+ container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ createTextSection(container);
+ createToolbarButtonBar(container);
+ }
+
+ private void createTextSection(Composite parent) {
+ Composite textContainer = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 3;
+ layout.marginHeight = layout.marginWidth = 0;
+ textContainer.setLayout(layout);
+ textContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Label label = new Label(textContainer, SWT.NONE);
+ label.setText(Messages.EventDetailsDialog_date);
+ dateLabel = new Label(textContainer, SWT.NULL);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ dateLabel.setLayoutData(gd);
+
+ label = new Label(textContainer, SWT.NONE);
+ label.setText(Messages.EventDetailsDialog_severity);
+ severityImageLabel = new Label(textContainer, SWT.NULL);
+ severityLabel = new Label(textContainer, SWT.NULL);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ severityLabel.setLayoutData(gd);
+
+ label = new Label(textContainer, SWT.NONE);
+ label.setText(Messages.EventDetailsDialog_message);
+ gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
+ label.setLayoutData(gd);
+ msgText = new Text(textContainer, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP | SWT.BORDER);
+ msgText.setEditable(false);
+ gd = new GridData(GridData.FILL_BOTH | GridData.VERTICAL_ALIGN_BEGINNING | GridData.GRAB_VERTICAL);
+ gd.horizontalSpan = 2;
+ gd.heightHint = 44;
+ gd.grabExcessVerticalSpace = true;
+ msgText.setLayoutData(gd);
+ }
+
+ private void createStackSection(Composite parent) {
+ Composite container = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 6;
+ container.setLayout(layout);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.heightHint = 100;
+ container.setLayoutData(gd);
+
+ Label label = new Label(container, SWT.NONE);
+ label.setText(Messages.EventDetailsDialog_exception);
+ gd = new GridData();
+ gd.verticalAlignment = SWT.BOTTOM;
+ label.setLayoutData(gd);
+
+ stackTraceText = new Text(container, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
+ gd = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL);
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalSpan = 2;
+ stackTraceText.setLayoutData(gd);
+ stackTraceText.setEditable(false);
+ }
+
+ private String filterStack(String stack) {
+ return stack;
+ }
+
+}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/LogLabelProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/LogLabelProvider.java 2008-12-02 18:59:43 UTC (rev 12222)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/LogLabelProvider.java 2008-12-02 22:29:47 UTC (rev 12223)
@@ -4,6 +4,7 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.ISharedImages;
@@ -16,7 +17,7 @@
import org.jboss.ide.eclipse.as.ui.JBossServerUISharedImages;
import org.jboss.ide.eclipse.as.ui.views.ServerLogView.EventCategory;
-public class LogLabelProvider extends LabelProvider {
+public class LogLabelProvider extends LabelProvider implements ITableLabelProvider {
public Image getImage(Object element) {
if( element instanceof EventCategory ) {
int type = ((EventCategory)element).getType();
@@ -80,38 +81,54 @@
public String getText(Object element) {
if( element instanceof EventCategory ) {
int type = ((EventCategory)element).getType();
+ if( type == 0 )
+ return "Unknown Event Type";
if( type == IEventCodes.POLLING_CODE)
return "Server Startup / Shutdown";
if( type == IEventCodes.PUBLISHING_CODE)
return "Publishing";
}
-
if( element instanceof LogEntry ) {
- // queue for Decoration
- String message = ((LogEntry)element).getMessage();
- return message + addSuffix((LogEntry)element);
+ return ((LogEntry)element).getMessage();
}
return element == null ? "" : element.toString();//$NON-NLS-1$
}
- protected String addSuffix(LogEntry entry) {
- long diff = new Date().getTime() - entry.getDate().getTime();
- long sec = diff / 1000;
- long minutes = sec / 60;
- if( minutes > 0 )
- sec -= (minutes * 60);
- long hours = minutes / 60;
- if( hours > 0 ) {
- minutes -= (hours * 60);
- sec -= (hours * 60 * 60);
+ protected String getSuffix(Object entry2) {
+ if( entry2 instanceof LogEntry ) {
+ LogEntry entry = (LogEntry)entry2;
+ long diff = new Date().getTime() - entry.getDate().getTime();
+ long sec = diff / 1000;
+ long minutes = sec / 60;
+ if( minutes > 0 )
+ sec -= (minutes * 60);
+ long hours = minutes / 60;
+ if( hours > 0 ) {
+ minutes -= (hours * 60);
+ sec -= (hours * 60 * 60);
+ }
+ if( hours > 0 ) {
+ return hours + " hours, " + minutes + " minutes ago";
+ } else if( minutes > 0 ) {
+ return minutes + " minutes, " + sec + " seconds ago";
+ } else {
+ return sec + " seconds ago";
+ }
}
- if( hours > 0 ) {
- return " [" + hours + " hours, " + minutes + " minutes ago]";
- } else if( minutes > 0 ) {
- return " [" + minutes + " minutes, " + sec + " seconds ago]";
- } else {
- return " [" + sec + " seconds ago]";
- }
+ return "";
}
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ if( columnIndex == 0 )
+ return getImage(element);
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ if(columnIndex == 0)
+ return getText(element);
+ else
+ return getSuffix(element);
+ }
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/ServerLogView.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/ServerLogView.java 2008-12-02 18:59:43 UTC (rev 12222)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/ServerLogView.java 2008-12-02 22:29:47 UTC (rev 12223)
@@ -1,8 +1,18 @@
package org.jboss.ide.eclipse.as.ui.views;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.io.Writer;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
+import java.util.Comparator;
import java.util.List;
import org.eclipse.core.filesystem.EFS;
@@ -15,20 +25,30 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.util.Policy;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IMemento;
@@ -38,6 +58,7 @@
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.XMLMemento;
import org.eclipse.ui.ide.FileStoreEditorInput;
import org.eclipse.ui.internal.views.log.Messages;
import org.eclipse.ui.internal.views.log.SharedImages;
@@ -51,12 +72,28 @@
public class ServerLogView extends ViewPart implements IServerLogListener {
public static final String VIEW_ID = "org.jboss.ide.eclipse.as.ui.view.serverLogView";
+ public final static byte MESSAGE = 0x0;
+ public final static byte DATE = 0x1;
+ public static int ASCENDING = 1;
+ public static int DESCENDING = -1;
+
+ private int MESSAGE_ORDER;
+ private int DATE_ORDER;
+ private static final String P_COLUMN_1 = "column1"; //$NON-NLS-1$
+ private static final String P_COLUMN_2 = "column2"; //$NON-NLS-1$
+ public static final String P_ORDER_TYPE = "orderType"; //$NON-NLS-1$
+ public static final String P_ORDER_VALUE = "orderValue"; //$NON-NLS-1$
private IServer server;
private TreeViewer viewer;
private File fInputFile;
+ private String fDirectory;
private IMemento fMemento;
- private Action fDeleteLogAction, fOpenLogAction;
+ private Action fDeleteLogAction, fOpenLogAction,
+ fReadLogAction, fExportLogAction;
+ private TreeColumn fColumn1;
+ private TreeColumn fColumn2;
+ private Comparator fComparator;
private List<AbstractEntry> elements;
public ServerLogView() {
super();
@@ -65,16 +102,49 @@
public void init(IViewSite site, IMemento memento) throws PartInitException {
super.init(site, memento);
- fMemento = memento;
+ if (memento == null)
+ this.fMemento = XMLMemento.createWriteRoot("SERVERLOGVIEW"); //$NON-NLS-1$
+ else
+ this.fMemento = memento;
+ fMemento.putInteger(P_COLUMN_1, fMemento.getInteger(P_COLUMN_1) != null && fMemento.getInteger(P_COLUMN_1) > 0 ? fMemento.getInteger(P_COLUMN_1) : 350);
+ fMemento.putInteger(P_COLUMN_2, fMemento.getInteger(P_COLUMN_2) != null && fMemento.getInteger(P_COLUMN_2) > 0 ? fMemento.getInteger(P_COLUMN_2) : 150);
+ fMemento.putInteger(P_ORDER_VALUE, fMemento.getInteger(P_ORDER_VALUE) != null && fMemento.getInteger(P_ORDER_VALUE) != 0 ? fMemento.getInteger(P_ORDER_VALUE) : DESCENDING);
+ fMemento.putInteger(P_ORDER_TYPE, fMemento.getInteger(P_ORDER_TYPE) != null && fMemento.getInteger(P_ORDER_TYPE) != 0 ? fMemento.getInteger(P_ORDER_TYPE) : DATE);
+
+ // initialize column ordering
+ final byte type = this.fMemento.getInteger(P_ORDER_TYPE).byteValue();
+ switch (type) {
+ case DATE :
+ DATE_ORDER = this.fMemento.getInteger(P_ORDER_VALUE).intValue();
+ MESSAGE_ORDER = DESCENDING;
+ break;
+ case MESSAGE :
+ MESSAGE_ORDER = this.fMemento.getInteger(P_ORDER_VALUE).intValue();
+ DATE_ORDER = DESCENDING;
+ break;
+ default :
+ DATE_ORDER = DESCENDING;
+ MESSAGE_ORDER = DESCENDING;
+ }
+ setComparator(fMemento.getInteger(P_ORDER_TYPE).byteValue());
}
+ public void saveState(IMemento memento) {
+ if (this.fMemento == null || memento == null)
+ return;
+ this.fMemento.putInteger(P_COLUMN_1, fColumn1.getWidth());
+ this.fMemento.putInteger(P_COLUMN_2, fColumn2.getWidth());
+ memento.putMemento(this.fMemento);
+ }
+
public void createPartControl(Composite parent) {
Composite child = new Composite(parent, SWT.NONE);
child.setLayout(new FillLayout());
viewer = new TreeViewer(child);
+ createColumns(viewer);
viewer.setContentProvider(new LogContentProvider());
viewer.setLabelProvider(new LogLabelProvider());
viewer.setInput(this);
-
+ viewer.setAutoExpandLevel(2);
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = (IStructuredSelection)event.getSelection();
@@ -83,15 +153,71 @@
}
});
- IToolBarManager toolbar = getViewSite().getActionBars().getToolBarManager();
+ viewer.addDoubleClickListener(new IDoubleClickListener() {
+ public void doubleClick(DoubleClickEvent event) {
+ Object[] o = ((IStructuredSelection)viewer.getSelection()).toArray();
+ if( o != null && o.length > 0 && o[0] != null && o[0] instanceof AbstractEntry)
+ new EventDetailsDialog(viewer.getTree().getShell(), (AbstractEntry)o[0], viewer).open();
+ }
+ });
+
+ IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager();
+
+ fExportLogAction = createExportLogAction();
+ toolBarManager.add(fExportLogAction);
+ toolBarManager.add(new Separator());
+ final Action clearAction = createClearAction();
+ toolBarManager.add(clearAction);
fDeleteLogAction = createDeleteLogAction();
- toolbar.add(fDeleteLogAction);
+ toolBarManager.add(fDeleteLogAction);
fOpenLogAction = createOpenLogAction();
- toolbar.add(fOpenLogAction);
-
+ toolBarManager.add(fOpenLogAction);
+ fReadLogAction = createReadLogAction();
+ toolBarManager.add(fReadLogAction);
+
setLogFile(null);
}
+ protected void createColumns(final TreeViewer viewer) {
+ fColumn1 = new TreeColumn(viewer.getTree(), SWT.LEFT);
+ fColumn1.setText(Messages.LogView_column_message);
+ fColumn1.setWidth(fMemento.getInteger(P_COLUMN_1).intValue());
+ fColumn1.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ MESSAGE_ORDER *= -1;
+ ViewerComparator comparator = getViewerComparator(MESSAGE);
+ viewer.setComparator(comparator);
+ setComparator(MESSAGE);
+ fMemento.putInteger(P_ORDER_VALUE, MESSAGE_ORDER);
+ fMemento.putInteger(P_ORDER_TYPE, MESSAGE);
+ setColumnSorting(fColumn1, MESSAGE_ORDER);
+ }
+ });
+
+
+ fColumn2 = new TreeColumn(viewer.getTree(), SWT.LEFT);
+ fColumn2.setText(Messages.LogView_column_date);
+ fColumn2.setWidth(fMemento.getInteger(P_COLUMN_2).intValue());
+ fColumn2.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ DATE_ORDER *= -1;
+ ViewerComparator comparator = getViewerComparator(DATE);
+ viewer.setComparator(comparator);
+ setComparator(DATE);
+ fMemento.putInteger(P_ORDER_VALUE, DATE_ORDER);
+ fMemento.putInteger(P_ORDER_TYPE, DATE);
+ setColumnSorting(fColumn2, DATE_ORDER);
+ }
+ });
+
+ viewer.getTree().setHeaderVisible(true);
+ }
+
+ private void setColumnSorting(TreeColumn column, int order) {
+ viewer.getTree().setSortColumn(column);
+ viewer.getTree().setSortDirection(order == ASCENDING ? SWT.UP : SWT.DOWN);
+ }
+
public void setServer(IServer server) {
if( this.server != null )
ServerLogger.getDefault().removeListener(this.server, this);
@@ -106,7 +232,12 @@
protected void setLogFile(File file) {
fInputFile = file;
+ fDirectory = fInputFile == null ? null : fInputFile.getParent();
elements.clear();
+ reloadLog();
+ }
+
+ protected void reloadLog() {
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) {
monitor.beginTask("Importing Server Log", IProgressMonitor.UNKNOWN);
@@ -122,14 +253,15 @@
} catch (InterruptedException e) { // do nothing
} finally {
asyncRefresh(false);
+ updateButtons();
}
- updateButtons();
}
private void updateButtons() {
- fDeleteLogAction.setEnabled(fInputFile != null && fInputFile.exists());
- fOpenLogAction.setEnabled(fInputFile != null && fInputFile.exists());
+ fDeleteLogAction.setEnabled(exists(fInputFile));
+ fOpenLogAction.setEnabled(exists(fInputFile));
+ fExportLogAction.setEnabled(exists(fInputFile));
}
private void asyncRefresh(final boolean activate) {
@@ -156,6 +288,10 @@
}
}
+ protected boolean exists(File f) {
+ return f != null && f.exists();
+ }
+
public void logging(IStatus status, IServer server) {
if( server != null && server.equals(this.server)) {
LogEntry entry = new LogEntry(status);
@@ -237,6 +373,9 @@
public boolean equals(Object other) {
return other instanceof EventCategory && ((EventCategory)other).getType() == val;
}
+ public int hashCode() {
+ return val;
+ }
}
public boolean shouldSort() {
@@ -250,6 +389,31 @@
/* Stolen from log view and can be changed but in a rush */
+ private Action createReadLogAction() {
+ Action action = new Action(Messages.LogView_readLog_restore) {
+ public void run() {
+ reloadLog();
+ }
+ };
+ action.setToolTipText(Messages.LogView_readLog_restore_tooltip);
+ action.setImageDescriptor(SharedImages.getImageDescriptor(SharedImages.DESC_READ_LOG));
+ action.setDisabledImageDescriptor(SharedImages.getImageDescriptor(SharedImages.DESC_READ_LOG_DISABLED));
+ return action;
+ }
+
+ private Action createClearAction() {
+ Action action = new Action(Messages.LogView_clear) {
+ public void run() {
+ handleClear();
+ }
+ };
+ action.setImageDescriptor(SharedImages.getImageDescriptor(SharedImages.DESC_CLEAR));
+ action.setDisabledImageDescriptor(SharedImages.getImageDescriptor(SharedImages.DESC_CLEAR_DISABLED));
+ action.setToolTipText(Messages.LogView_clear_tooltip);
+ action.setText(Messages.LogView_clear);
+ return action;
+ }
+
private Action createOpenLogAction() {
Action action = new Action() {
public void run() {
@@ -264,6 +428,18 @@
return action;
}
+ private Action createExportLogAction() {
+ Action action = new Action(Messages.LogView_export) {
+ public void run() {
+ handleExport();
+ }
+ };
+ action.setToolTipText(Messages.LogView_export_tooltip);
+ action.setImageDescriptor(SharedImages.getImageDescriptor(SharedImages.DESC_EXPORT));
+ action.setDisabledImageDescriptor(SharedImages.getImageDescriptor(SharedImages.DESC_EXPORT_DISABLED));
+ action.setEnabled(fInputFile != null && fInputFile.exists());
+ return action;
+ }
private void openLog() {
try {
IWorkbench wb = PlatformUI.getWorkbench();
@@ -328,5 +504,141 @@
}
});
}
+
+ private void handleExport() {
+ FileDialog dialog = new FileDialog(getViewSite().getShell(), SWT.SAVE);
+ dialog.setFilterExtensions(new String[] {"*.log"}); //$NON-NLS-1$
+ if (fDirectory != null)
+ dialog.setFilterPath(fDirectory);
+ String path = dialog.open();
+ if (path != null) {
+ if (path.indexOf('.') == -1 && !path.endsWith(".log")) //$NON-NLS-1$
+ path += ".log"; //$NON-NLS-1$
+ File outputFile = new Path(path).toFile();
+ fDirectory = outputFile.getParent();
+ if (outputFile.exists()) {
+ String message = NLS.bind(Messages.LogView_confirmOverwrite_message, outputFile.toString());
+ if (!MessageDialog.openQuestion(getViewSite().getShell(),Messages.LogView_exportLog, message))
+ return;
+ }
+ Reader in = null;
+ Writer out = null;
+ try {
+ out = new OutputStreamWriter(new FileOutputStream(outputFile), "UTF-8"); //$NON-NLS-1$
+ in = new InputStreamReader(new FileInputStream(fInputFile), "UTF-8"); //$NON-NLS-1$
+ copy(in, out);
+ } catch (IOException ex) {
+ try {
+ if (in != null)
+ in.close();
+ if (out != null)
+ out.close();
+ } catch (IOException e1) { // do nothing
+ }
+ }
+ }
+ }
+
+ private void copy(Reader input, Writer output) {
+ BufferedReader reader = null;
+ BufferedWriter writer = null;
+ try {
+ reader = new BufferedReader(input);
+ writer = new BufferedWriter(output);
+ String line;
+ while (reader.ready() && ((line = reader.readLine()) != null)) {
+ writer.write(line);
+ writer.newLine();
+ }
+ } catch (IOException e) { // do nothing
+ } finally {
+ try {
+ if (reader != null)
+ reader.close();
+ if (writer != null)
+ writer.close();
+ } catch (IOException e1) {
+ // do nothing
+ }
+ }
+ }
+
+ private void setComparator(byte sortType) {
+ if (sortType == DATE) {
+ fComparator = new Comparator() {
+ public int compare(Object e1, Object e2) {
+ long date1 = 0;
+ long date2 = 0;
+ if ((e1 instanceof LogEntry) && (e2 instanceof LogEntry)) {
+ date1 = ((LogEntry) e1).getDate().getTime();
+ date2 = ((LogEntry) e2).getDate().getTime();
+ } else if ((e1 instanceof LogSession) && (e2 instanceof LogSession)) {
+ date1 = ((LogSession) e1).getDate() == null ? 0 : ((LogSession) e1).getDate().getTime();
+ date2 = ((LogSession) e2).getDate() == null ? 0 : ((LogSession) e2).getDate().getTime();
+ }
+ if (date1 == date2) {
+ int result = elements.indexOf(e2) - elements.indexOf(e1);
+ if (DATE_ORDER == DESCENDING)
+ result *= DESCENDING;
+ return result;
+ }
+ if (DATE_ORDER == DESCENDING)
+ return date1 > date2 ? DESCENDING : ASCENDING;
+ return date1 < date2 ? DESCENDING : ASCENDING;
+ }
+ };
+ } else {
+ fComparator = new Comparator() {
+ public int compare(Object e1, Object e2) {
+ if ((e1 instanceof LogEntry) && (e2 instanceof LogEntry)) {
+ LogEntry entry1 = (LogEntry) e1;
+ LogEntry entry2 = (LogEntry) e2;
+ return Policy.getComparator().compare(entry1.getMessage(), entry2.getMessage()) * MESSAGE_ORDER;
+ }
+ return 0;
+ }
+ };
+ }
+ }
+
+ private ViewerComparator getViewerComparator(byte sortType) {
+ if (sortType == MESSAGE) {
+ return new ViewerComparator() {
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ if ((e1 instanceof LogEntry) && (e2 instanceof LogEntry)) {
+ LogEntry entry1 = (LogEntry) e1;
+ LogEntry entry2 = (LogEntry) e2;
+ return getComparator().compare(entry1.getMessage(), entry2.getMessage()) * MESSAGE_ORDER;
+ }
+ return 0;
+ }
+ };
+ } else {
+ return new ViewerComparator() {
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ long date1 = 0;
+ long date2 = 0;
+ if ((e1 instanceof LogEntry) && (e2 instanceof LogEntry)) {
+ date1 = ((LogEntry) e1).getDate().getTime();
+ date2 = ((LogEntry) e2).getDate().getTime();
+ } else if ((e1 instanceof LogSession) && (e2 instanceof LogSession)) {
+ date1 = ((LogSession) e1).getDate() == null ? 0 : ((LogSession) e1).getDate().getTime();
+ date2 = ((LogSession) e2).getDate() == null ? 0 : ((LogSession) e2).getDate().getTime();
+ }
+
+ if (date1 == date2) {
+ int result = elements.indexOf(e2) - elements.indexOf(e1);
+ if (DATE_ORDER == DESCENDING)
+ result *= DESCENDING;
+ return result;
+ }
+ if (DATE_ORDER == DESCENDING)
+ return date1 > date2 ? DESCENDING : ASCENDING;
+ return date1 < date2 ? DESCENDING : ASCENDING;
+ }
+ };
+ }
+ }
+
}
17 years
JBoss Tools SVN: r12222 - trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-12-02 13:59:43 -0500 (Tue, 02 Dec 2008)
New Revision: 12222
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploySection.java
Log:
organized import
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploySection.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploySection.java 2008-12-02 18:55:44 UTC (rev 12221)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploySection.java 2008-12-02 18:59:43 UTC (rev 12222)
@@ -61,7 +61,6 @@
import org.jboss.ide.eclipse.as.core.server.IJBossServerConstants;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
import org.jboss.ide.eclipse.as.core.server.internal.DeployableServer;
-import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
import org.jboss.ide.eclipse.as.core.server.internal.ServerAttributeHelper;
import org.jboss.ide.eclipse.as.ui.Messages;
17 years
JBoss Tools SVN: r12221 - in trunk/common/plugins/org.jboss.tools.common.kb: images and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2008-12-02 13:55:44 -0500 (Tue, 02 Dec 2008)
New Revision: 12221
Added:
trunk/common/plugins/org.jboss.tools.common.kb/images/
trunk/common/plugins/org.jboss.tools.common.kb/images/ca/
trunk/common/plugins/org.jboss.tools.common.kb/images/ca/icons_Enumeration.gif
Modified:
trunk/common/plugins/org.jboss.tools.common.kb/build.properties
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbPlugin.java
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbProposal.java
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldStore.java
Log:
JBIDE-3133 New icons for proposals in JSF/Seam Code Assist.
The icons support and a set of common icons are added to the KB.
Modified: trunk/common/plugins/org.jboss.tools.common.kb/build.properties
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.kb/build.properties 2008-12-02 18:40:04 UTC (rev 12220)
+++ trunk/common/plugins/org.jboss.tools.common.kb/build.properties 2008-12-02 18:55:44 UTC (rev 12221)
@@ -7,7 +7,8 @@
docs/,\
about.html,\
META-INF/,\
- kb.jar
+ kb.jar,\
+ images/
jars.compile.order = kb.jar
output.kb.jar = bin/
source.kb.jar = src/,\
Added: trunk/common/plugins/org.jboss.tools.common.kb/images/ca/icons_Enumeration.gif
===================================================================
(Binary files differ)
Property changes on: trunk/common/plugins/org.jboss.tools.common.kb/images/ca/icons_Enumeration.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbPlugin.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbPlugin.java 2008-12-02 18:40:04 UTC (rev 12220)
+++ trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbPlugin.java 2008-12-02 18:55:44 UTC (rev 12221)
@@ -12,9 +12,13 @@
import java.io.File;
import java.io.IOException;
+import java.util.HashMap;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.jboss.tools.common.kb.configuration.KbConfigurationFactory;
import org.jboss.tools.common.log.BaseUIPlugin;
import org.jboss.tools.common.log.IPluginLog;
@@ -31,6 +35,11 @@
// The shared instance
private static KbPlugin plugin;
+ // A Map to save a descriptor for each image
+ private HashMap fImageDescRegistry = null;
+
+ public static final String CA_ENUMERATION_IMAGE_PATH = "images/ca/icons_Enumeration.gif";
+
public KbPlugin() {
}
@@ -86,4 +95,104 @@
public static IPluginLog getPluginLog() {
return getDefault();
}
+
+ /**
+ * Creates an image from the given resource and adds the image to the
+ * image registry.
+ *
+ * @param resource
+ * @return Image
+ */
+ private Image createImage(String resource) {
+ ImageDescriptor desc = getImageDescriptorFromRegistry(resource);
+ Image image = null;
+
+ if (desc != null) {
+ image = desc.createImage();
+ // dont add the missing image descriptor image to the image
+ // registry
+ if (!desc.equals(ImageDescriptor.getMissingImageDescriptor())) {
+ getImageRegistry().put(resource, image);
+ }
+ }
+ return image;
+ }
+
+ /**
+ * Creates an image descriptor from the given imageFilePath and adds the
+ * image descriptor to the image descriptor registry. If an image
+ * descriptor could not be created, the default "missing" image descriptor
+ * is returned but not added to the image descriptor registry.
+ *
+ * @param imageFilePath
+ * @return ImageDescriptor image descriptor for imageFilePath or default
+ * "missing" image descriptor if resource could not be found
+ */
+ private ImageDescriptor createImageDescriptor(String imageFilePath) {
+ ImageDescriptor imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, imageFilePath);
+ if (imageDescriptor != null) {
+ getImageDescriptorRegistry().put(imageFilePath, imageDescriptor);
+ }
+ else {
+ imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
+ }
+
+ return imageDescriptor;
+ }
+
+ /**
+ * Retrieves the image associated with resource from the image registry.
+ * If the image cannot be retrieved, attempt to find and load the image at
+ * the location specified in resource.
+ *
+ * @param resource
+ * the image to retrieve
+ * @return Image the image associated with resource or null if one could
+ * not be found
+ */
+ public Image getImage(String resource) {
+ Image image = getImageRegistry().get(resource);
+ if (image == null) {
+ // create an image
+ image = createImage(resource);
+ }
+ return image;
+ }
+
+ /**
+ * Retrieves the image descriptor associated with resource from the image
+ * descriptor registry. If the image descriptor cannot be retrieved,
+ * attempt to find and load the image descriptor at the location specified
+ * in resource.
+ *
+ * @param resource
+ * the image descriptor to retrieve
+ * @return ImageDescriptor the image descriptor assocated with resource or
+ * the default "missing" image descriptor if one could not be
+ * found
+ */
+ public ImageDescriptor getImageDescriptorFromRegistry(String resource) {
+ ImageDescriptor imageDescriptor = null;
+ Object o = getImageDescriptorRegistry().get(resource);
+ if (o == null) {
+ // create a descriptor
+ imageDescriptor = createImageDescriptor(resource);
+ }
+ else {
+ imageDescriptor = (ImageDescriptor) o;
+ }
+ return imageDescriptor;
+ }
+
+ /**
+ * Returns the image descriptor registry for this plugin.
+ *
+ * @return HashMap - image descriptor registry for this plugin
+ */
+ private HashMap getImageDescriptorRegistry() {
+ if (fImageDescRegistry == null) {
+ fImageDescRegistry = new HashMap();
+ }
+ return fImageDescRegistry;
+ }
}
\ No newline at end of file
Modified: trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbProposal.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbProposal.java 2008-12-02 18:40:04 UTC (rev 12220)
+++ trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbProposal.java 2008-12-02 18:55:44 UTC (rev 12221)
@@ -12,6 +12,8 @@
import java.io.Serializable;
+import org.eclipse.swt.graphics.Image;
+
/**
* Describes a proposal for content assistants
* @author igels
@@ -32,6 +34,8 @@
private String label;
private String contextInfo;
+ private Image image;
+ private boolean emptyImage = true;
private String replacementString;
private boolean emptyContextInfo = true;
private int relevance = R_NONE;
@@ -67,6 +71,13 @@
}
/**
+ * @return
+ */
+ public Image getImage() {
+ return image;
+ }
+
+ /**
* @return
*/
public String getLabel() {
@@ -93,6 +104,16 @@
/**
* @param string
*/
+ public void setImage(Image img) {
+ this.image = img;
+ if(this.image != null) {
+ emptyImage = false;
+ }
+ }
+
+ /**
+ * @param string
+ */
public void setLabel(String string) {
label = string;
}
@@ -114,6 +135,13 @@
/**
* @return
*/
+ public boolean hasImage() {
+ return !emptyImage;
+ }
+
+ /**
+ * @return
+ */
public int getPosition() {
if(position==-1 && getReplacementString()!=null) {
return getReplacementString().length();
Modified: trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldStore.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldStore.java 2008-12-02 18:40:04 UTC (rev 12220)
+++ trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldStore.java 2008-12-02 18:55:44 UTC (rev 12221)
@@ -796,7 +796,7 @@
proposal.setReplacementString(value);
proposal.setContextInfo(null);
proposal.setPosition(value.length());
-
+ proposal.setImage(KbPlugin.getDefault().getImage(KbPlugin.CA_ENUMERATION_IMAGE_PATH));
enumeration.add(proposal);
}
}
17 years