Author: objectiser
Date: 2010-09-22 11:04:06 -0400 (Wed, 22 Sep 2010)
New Revision: 422
Added:
branches/1.1.x/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/editor/SCNEditorManager.java
branches/1.1.x/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/model/SCNNotation.java
branches/1.1.x/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/resolutions/
branches/1.1.x/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/resolutions/MarkerResolutionGenerator.java
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/editor/SCNEditorManager.java
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/model/SCNNotation.java
trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/resolutions/
trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/resolutions/MarkerResolutionGenerator.java
Removed:
branches/1.1.x/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/action/
trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/action/ValidateAction.java
Modified:
branches/1.1.x/tools/plugins/org.jboss.savara.pi4soa.cdm/META-INF/MANIFEST.MF
branches/1.1.x/tools/plugins/org.jboss.savara.tap.eclipse/src/java/org/jboss/savara/tap/eclipse/actions/ValidateAction.java
branches/1.1.x/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/TAPValidator.java
branches/1.1.x/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/osgi/Activator.java
branches/1.1.x/tools/plugins/org.scribble.core/src/java/org/scribble/model/resolutions/ShowReferencedDescription.java
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/META-INF/MANIFEST.MF
trunk/tools/plugins/org.jboss.savara.tap.eclipse/src/java/org/jboss/savara/tap/eclipse/actions/ValidateAction.java
trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/TAPValidator.java
trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/osgi/Activator.java
trunk/tools/plugins/org.scribble.core/src/java/org/scribble/model/resolutions/ShowReferencedDescription.java
Log:
Adding marker resolution back in with support for showing referenced descriptions.
Modified: branches/1.1.x/tools/plugins/org.jboss.savara.pi4soa.cdm/META-INF/MANIFEST.MF
===================================================================
---
branches/1.1.x/tools/plugins/org.jboss.savara.pi4soa.cdm/META-INF/MANIFEST.MF 2010-09-22
11:07:50 UTC (rev 421)
+++
branches/1.1.x/tools/plugins/org.jboss.savara.pi4soa.cdm/META-INF/MANIFEST.MF 2010-09-22
15:04:06 UTC (rev 422)
@@ -23,7 +23,9 @@
Scribble-Extensions: org.jboss.savara.pi4soa.cdm.parser.CDMTokenizer,
org.jboss.savara.pi4soa.cdm.parser.CDMModelParserRule,
org.jboss.savara.pi4soa.cdm.model.CDMNotation,
+ org.jboss.savara.pi4soa.cdm.model.SCNNotation,
org.jboss.savara.pi4soa.cdm.validation.TypeReferenceValidationRule,
- org.jboss.savara.pi4soa.cdm.editor.CDMEditorManager
+ org.jboss.savara.pi4soa.cdm.editor.CDMEditorManager,
+ org.jboss.savara.pi4soa.cdm.editor.SCNEditorManager
Export-Package: org.jboss.savara.pi4soa.cdm.model,
org.jboss.savara.pi4soa.cdm.parser
Added:
branches/1.1.x/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/editor/SCNEditorManager.java
===================================================================
---
branches/1.1.x/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/editor/SCNEditorManager.java
(rev 0)
+++
branches/1.1.x/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/editor/SCNEditorManager.java 2010-09-22
15:04:06 UTC (rev 422)
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * 19 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.editor;
+
+import org.eclipse.emf.ecore.EValidator;
+import org.jboss.savara.pi4soa.cdm.model.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.ModelReference;
+import org.scribble.model.SourceRef;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.editor.*;
+
+/**
+ * This is the CDM designer's implementation of the EditorManager
+ * interface.
+ */
+(a)RegistryInfo(extension=EditorManager.class,notation=SCNNotation.NOTATION_CODE)
//preference=10,
+public class SCNEditorManager extends AbstractEditorManager {
+
+ /**
+ * This method focuses the editor on the specified source,
+ * identified by the model reference and source reference.
+ *
+ * @param mref The model reference
+ * @param sref The component source reference
+ * @param prop Additional properties
+ */
+ public void focus(ModelReference mref, SourceRef sref,
+ java.util.Map<String,Object> props) {
+ String uri=null;
+ org.eclipse.core.resources.IFile file=
+ org.scribble.eclipse.model.admin.OSGIModelRepository.getFile(mref);
+
+ if (file == null || file.exists() == false) {
+ file = org.scribble.eclipse.model.admin.OSGIModelRepository.getGlobalFile(mref);
+ }
+
+ if (file != null && file.exists()) {
+ uri = file.getFullPath().toPortableString();
+ }
+
+ if (uri != null) {
+ org.eclipse.ui.IWorkbenchPage page=
+ org.eclipse.ui.PlatformUI.getWorkbench().
+ getActiveWorkbenchWindow().getActivePage();
+
+ org.eclipse.core.resources.IResource res=
+ org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().findMember(uri);
+
+ if (res instanceof org.eclipse.core.resources.IFile) {
+ org.eclipse.ui.part.FileEditorInput input=
+ new org.eclipse.ui.part.FileEditorInput(
+ (org.eclipse.core.resources.IFile)res);
+
+ try {
+ org.eclipse.ui.IEditorPart part=page.openEditor(input,
+ "org.pi4soa.scenario.designer.Pi4SOAScenarioDesignerID");
+
+ if (part instanceof org.pi4soa.designer.editor.ChoreographyDescriptionEditor) {
+ org.pi4soa.designer.editor.ChoreographyDescriptionEditor editor=
+ (org.pi4soa.designer.editor.ChoreographyDescriptionEditor)part;
+
+ /* Other approach using marker - can be used if editor does not
+ * provide alternative way to focus on component.
+ org.eclipse.core.resources.IMarker marker=res.createMarker(EValidator.MARKER);
+ marker.setAttribute(EValidator.URI_ATTRIBUTE, ref.getComponentURI());
+ editor.gotoMarker(marker);
+ marker.delete();
+ */
+
+ editor.showComponent(sref.getComponentURI());
+ }
+
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ /**
+ * This method enriches the set of properties required
+ * by the editor, using the properties associated with
+ * the model issue.
+ *
+ * @param issue The model issue
+ */
+ @Override
+ public void enrich(ModelIssue issue) {
+
+ if (issue.getModelObject() != null) {
+ // Set the EMF URI attribute
+ issue.getProperties().put(EValidator.URI_ATTRIBUTE,
+ issue.getModelObject().getSource().getComponentURI());
+ }
+ }
+}
Added:
branches/1.1.x/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/model/SCNNotation.java
===================================================================
---
branches/1.1.x/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/model/SCNNotation.java
(rev 0)
+++
branches/1.1.x/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/model/SCNNotation.java 2010-09-22
15:04:06 UTC (rev 422)
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * 17 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.model;
+
+import org.scribble.extensions.*;
+import org.scribble.model.ModelReference;
+import org.scribble.model.Notation;
+
+/**
+ * This class represents the SCN notation implementation.
+ */
+(a)RegistryInfo(extension=org.scribble.model.Notation.class)
+public class SCNNotation extends org.scribble.model.AbstractNotation {
+
+ public static final String NOTATION_CODE="scn";
+
+ /**
+ * This is the constructor for the CDM notation.
+ */
+ public SCNNotation() {
+ super(NOTATION_CODE, "SCN", false);
+ }
+
+ /**
+ * This method returns the initial description associated
+ * with the supplied reference.
+ *
+ * @param ref The reference
+ * @return The initial description, or null if no description
+ */
+ public String getInitialDescription(ModelReference ref) {
+ StringBuffer buf=new StringBuffer();
+
+ return(buf.toString());
+ }
+
+ /**
+ * This method returns the optional 'super' notation.
+ * If defined, then this notation is a derived notation
+ * from the 'super' notation.
+ *
+ * @return The optional 'super' notation
+ */
+ @Override
+ public Notation getSuperNotation() {
+ return(m_superNotation);
+ }
+
+ private Notation m_superNotation=new
org.scribble.conversation.model.ConversationNotation();
+}
Modified:
branches/1.1.x/tools/plugins/org.jboss.savara.tap.eclipse/src/java/org/jboss/savara/tap/eclipse/actions/ValidateAction.java
===================================================================
---
branches/1.1.x/tools/plugins/org.jboss.savara.tap.eclipse/src/java/org/jboss/savara/tap/eclipse/actions/ValidateAction.java 2010-09-22
11:07:50 UTC (rev 421)
+++
branches/1.1.x/tools/plugins/org.jboss.savara.tap.eclipse/src/java/org/jboss/savara/tap/eclipse/actions/ValidateAction.java 2010-09-22
15:04:06 UTC (rev 422)
@@ -100,6 +100,8 @@
}
}
+ e.printStackTrace();
+
error(e.getMessage());
}
Modified:
branches/1.1.x/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/TAPValidator.java
===================================================================
---
branches/1.1.x/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/TAPValidator.java 2010-09-22
11:07:50 UTC (rev 421)
+++
branches/1.1.x/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/TAPValidator.java 2010-09-22
15:04:06 UTC (rev 422)
@@ -43,8 +43,10 @@
import org.jboss.savara.tap.model.Relationship;
import org.jboss.savara.tap.model.Resource;
import org.jboss.savara.tap.model.admin.ResourceLoader;
+import org.scribble.model.ModelReference;
import org.scribble.model.admin.ModelIssue;
import org.scribble.model.admin.ModelListener;
+import org.scribble.model.resolutions.ShowReferencedDescription;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
@@ -168,39 +170,43 @@
Resource toResource=(Resource)rel.getRef();
if (toResource !=null) {
- for (RelationshipValidator rv : m_relationshipValidators) {
+ // Obtain input stream for resource
+ ResourceLoader fromRL=getResourceLoader(resource);
+ ResourceLoader toRL=getResourceLoader(toResource);
+
+ if (fromRL == null) {
+ l.error(new ModelIssue(null,
+ MessageFormat.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.savara.tap.validation.Messages").
+ getString("SAVARATAPV-00001"), resource.getId())));
+ } else if (toRL == null) {
+ l.error(new ModelIssue(null,
+ MessageFormat.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.savara.tap.validation.Messages").
+ getString("SAVARATAPV-00001"), toResource.getId())));
+ } else if (!fromRL.exists(resource)) {
+ l.error(new ModelIssue(null,
+ MessageFormat.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.savara.tap.validation.Messages").
+ getString("SAVARATAPV-00002"), resource.getId())));
+ } else if (!toRL.exists(toResource)) {
+ l.error(new ModelIssue(null,
+ MessageFormat.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.savara.tap.validation.Messages").
+ getString("SAVARATAPV-00002"), toResource.getId())));
+ } else {
+ ModelReference ref=toRL.getModelReference(toResource);
- if (rv.isSupported(rel, resource, toResource)) {
- // Obtain input stream for resource
- ResourceLoader fromRL=getResourceLoader(resource);
- ResourceLoader toRL=getResourceLoader(toResource);
+ ModelListener proxyml=new InnerModelListener(ref, ml);
+
+ for (RelationshipValidator rv : m_relationshipValidators) {
- if (fromRL == null) {
- l.error(new ModelIssue(null,
- MessageFormat.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.savara.tap.validation.Messages").
- getString("SAVARATAPV-00001"), resource.getId())));
- } else if (toRL == null) {
- l.error(new ModelIssue(null,
- MessageFormat.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.savara.tap.validation.Messages").
- getString("SAVARATAPV-00001"), toResource.getId())));
- } else if (!fromRL.exists(resource)) {
- l.error(new ModelIssue(null,
- MessageFormat.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.savara.tap.validation.Messages").
- getString("SAVARATAPV-00002"), resource.getId())));
- } else if (!toRL.exists(toResource)) {
- l.error(new ModelIssue(null,
- MessageFormat.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.savara.tap.validation.Messages").
- getString("SAVARATAPV-00002"), toResource.getId())));
- } else {
- rv.validate(rel, resource, fromRL, toResource, toRL, ml);
+ if (rv.isSupported(rel, resource, toResource)) {
+ rv.validate(rel, resource, fromRL, toResource, toRL, proxyml);
break;
}
@@ -316,4 +322,39 @@
}
}
}
+
+ public class InnerModelListener implements ModelListener {
+
+ private ModelListener m_listener=null;
+ private ModelReference m_reference=null;
+
+ public InnerModelListener(ModelReference ref, ModelListener l) {
+ m_reference = ref;
+ m_listener = l;
+ }
+
+ public void error(ModelIssue issue) {
+
+ ShowReferencedDescription res=new ShowReferencedDescription();
+ res.setModel(m_reference);
+
+ if (issue.getModelObject() != null) {
+ res.setSourceReference(issue.getModelObject().getSource());
+ }
+
+ issue.getResolutions().add(res);
+
+ m_listener.error(issue);
+ }
+
+ public void warning(ModelIssue issue) {
+ ShowReferencedDescription res=new ShowReferencedDescription();
+ res.setModel(m_reference);
+ res.setSourceReference(issue.getModelObject().getSource());
+
+ issue.getResolutions().add(res);
+
+ m_listener.warning(issue);
+ }
+ }
}
Modified:
branches/1.1.x/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/osgi/Activator.java
===================================================================
---
branches/1.1.x/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/osgi/Activator.java 2010-09-22
11:07:50 UTC (rev 421)
+++
branches/1.1.x/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/osgi/Activator.java 2010-09-22
15:04:06 UTC (rev 422)
@@ -7,7 +7,6 @@
import org.jboss.savara.tap.validation.RelationshipValidator;
import org.jboss.savara.tap.validation.ResourceValidator;
import org.jboss.savara.tap.validation.TAPValidator;
-import org.jboss.savara.tap.validation.action.ValidateAction;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
Modified:
branches/1.1.x/tools/plugins/org.scribble.core/src/java/org/scribble/model/resolutions/ShowReferencedDescription.java
===================================================================
---
branches/1.1.x/tools/plugins/org.scribble.core/src/java/org/scribble/model/resolutions/ShowReferencedDescription.java 2010-09-22
11:07:50 UTC (rev 421)
+++
branches/1.1.x/tools/plugins/org.scribble.core/src/java/org/scribble/model/resolutions/ShowReferencedDescription.java 2010-09-22
15:04:06 UTC (rev 422)
@@ -127,9 +127,15 @@
SourceRef sref=new SourceRef();
sref.setComponentURI((String)getProperties().get(SOURCE_REF_COMPONENT_URI));
sref.setModelObjectURI((String)getProperties().get(SOURCE_REF_MODEL_OBJECT_URI));
- sref.setStartPosition((Integer)getProperties().get(SOURCE_REF_START_POSITION));
- sref.setEndPosition((Integer)getProperties().get(SOURCE_REF_END_POSITION));
+ if (getProperties().containsKey(SOURCE_REF_START_POSITION)) {
+ sref.setStartPosition((Integer)getProperties().get(SOURCE_REF_START_POSITION));
+ }
+
+ if (getProperties().containsKey(SOURCE_REF_END_POSITION)) {
+ sref.setEndPosition((Integer)getProperties().get(SOURCE_REF_END_POSITION));
+ }
+
// Recover the properties for model and source ref
java.util.Iterator<String> iter=getProperties().keySet().iterator();
while (iter.hasNext()) {
Added:
branches/1.1.x/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/resolutions/MarkerResolutionGenerator.java
===================================================================
---
branches/1.1.x/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/resolutions/MarkerResolutionGenerator.java
(rev 0)
+++
branches/1.1.x/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/resolutions/MarkerResolutionGenerator.java 2010-09-22
15:04:06 UTC (rev 422)
@@ -0,0 +1,206 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * 1 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.eclipse.resolutions;
+
+import java.util.Comparator;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.internal.UIPlugin;
+import org.scribble.eclipse.model.admin.OSGIModelListener;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.resolutions.Resolution;
+import org.scribble.util.*;
+
+/**
+ * This class represents the implementation of the marker
+ * resolution generator interface, responsible for
+ * providing resolutions related to markers.
+ *
+ */
+public class MarkerResolutionGenerator
+ implements org.eclipse.ui.IMarkerResolutionGenerator2 {
+
+ /**
+ * This method determines whether there are available resolutions
+ * for the supplied marker.
+ *
+ * @param marker The marker
+ * @return Whether resolutions are available
+ */
+ public boolean hasResolutions(org.eclipse.core.resources.IMarker marker) {
+ boolean ret=false;
+
+ try {
+ ret = ModelIssueUtil.hasResolutions(marker.getAttributes());
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns any available resolutions for the supplied
+ * marker.
+ *
+ * @param marker The marker
+ * @return The list of available resolutions
+ */
+ public org.eclipse.ui.IMarkerResolution[]
getResolutions(org.eclipse.core.resources.IMarker marker) {
+ org.eclipse.ui.IMarkerResolution[] ret=null;
+
+ try {
+ java.util.List<Resolution> resolutions=
+ ModelIssueUtil.deserializeResolutions(marker.getAttributes());
+
+ java.util.Collections.sort(resolutions, new ResolutionComparator());
+
+ ret = new org.eclipse.ui.IMarkerResolution[resolutions.size()];
+
+ for (int i=0; i < resolutions.size(); i++) {
+ ret[i] = new MarkerResolutionWrapper(resolutions.get(i));
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+
+ /*
+ String resolutions=marker.getAttribute(org.scribble.model.ModelListener.RESOLUTIONS,
null);
+
+ try {
+ java.util.List<org.eclipse.ui.IMarkerResolution> impls=
+ new java.util.Vector<org.eclipse.ui.IMarkerResolution>();
+
+ java.util.StringTokenizer st=new
java.util.StringTokenizer(resolutions,",");
+
+ while (st.hasMoreTokens()) {
+ String resolution=st.nextToken();
+
+ if (resolution.equals(ModelListener.SHOW_EXTERNAL_ISSUE_RESOLUTION)) {
+ impls.add(new ShowExternalIssue());
+ } else if (resolution.equals(ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION)) {
+ impls.add(new ShowReferencedDescription());
+ } else {
+ try {
+ Class<?> cls=Class.forName(resolution);
+
+ org.eclipse.ui.IMarkerResolution res=
+ (org.eclipse.ui.IMarkerResolution)cls.newInstance();
+
+ impls.add(res);
+ } catch(Exception cnfe) {
+ org.scribble.osgi.eclipse.Activator.logError(
+ "Failed to instantiate resolution '"+resolution+"'",
cnfe);
+ }
+ }
+ }
+
+ ret = new org.eclipse.ui.IMarkerResolution[impls.size()];
+
+ impls.toArray(ret);
+
+ } catch(Exception e) {
+ org.scribble.osgi.eclipse.Activator.logError(
+ "Failed to instantiate resolution '"+resolutions+"'",
e);
+ }
+ */
+
+ return(ret);
+ }
+
+ private static Logger logger =
Logger.getLogger("org.scribble.osgi.resolutions");
+
+ public class ResolutionComparator implements Comparator<Resolution> {
+
+ public int compare(Resolution res1, Resolution res2) {
+ return(res1.getName().compareTo(res2.getName()));
+ }
+ }
+
+ public class MarkerResolutionWrapper implements org.eclipse.ui.IMarkerResolution2 {
+
+ public MarkerResolutionWrapper(Resolution res) {
+ m_resolution = res;
+ }
+
+ public String getLabel() {
+ return(m_resolution.getName());
+ }
+
+ public String getDescription() {
+ return(m_resolution.getDescription());
+ }
+
+ public Image getImage() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void run(IMarker marker) {
+ try {
+ ModelIssue issue=new ModelIssue();
+ issue.setMessage((String)marker.getAttribute(IMarker.MESSAGE));
+ issue.getProperties().putAll(marker.getAttributes());
+
+ SourceRef obj=new SourceRef();
+ obj.setStartPosition(((Integer)marker.getAttribute(IMarker.CHAR_START,
0)).intValue());
+ obj.setEndPosition(((Integer)marker.getAttribute(IMarker.CHAR_END, 0)).intValue());
+ obj.setModelObjectURI((String)marker.getAttribute(OSGIModelListener.SOURCE_MODEL_OBJECT_URI));
+ obj.setComponentURI((String)marker.getAttribute(OSGIModelListener.SOURCE_COMPONENT_URI));
+
+ ModelReference ref=new ModelReference(
+ (String)marker.getAttribute(OSGIModelListener.MODEL_NAMESPACE),
+ (String)marker.getAttribute(OSGIModelListener.MODEL_LOCALPART),
+ (String)marker.getAttribute(OSGIModelListener.MODEL_LOCATED_ROLE),
+ (String)marker.getAttribute(OSGIModelListener.MODEL_NOTATION));
+
+ // Recover the properties for model ref
+ java.util.Iterator<String> iter=
+ marker.getAttributes().keySet().iterator();
+ while (iter.hasNext()) {
+ String name=iter.next();
+
+ if (name.startsWith(OSGIModelListener.MODEL_PROP_PREFIX)) {
+ Object value=marker.getAttributes().get(name);
+
+ name = name.substring(OSGIModelListener.MODEL_PROP_PREFIX.length());
+
+ ref.setProperty(name, value);
+ }
+ }
+
+ m_resolution.resolve(ref, obj, issue);
+ } catch(Exception e) {
+
+ org.eclipse.jface.dialogs.MessageDialog.openError(
+ UIPlugin.getDefault().getWorkbench().getDisplay().getActiveShell(),
+ "Error", e.getLocalizedMessage());
+
+ logger.log(Level.SEVERE, "Failed to resolve", e);
+ }
+ }
+
+ private Resolution m_resolution=null;
+ }
+}
Modified: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/META-INF/MANIFEST.MF
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/META-INF/MANIFEST.MF 2010-09-22
11:07:50 UTC (rev 421)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/META-INF/MANIFEST.MF 2010-09-22
15:04:06 UTC (rev 422)
@@ -23,7 +23,9 @@
Scribble-Extensions: org.jboss.savara.pi4soa.cdm.parser.CDMTokenizer,
org.jboss.savara.pi4soa.cdm.parser.CDMModelParserRule,
org.jboss.savara.pi4soa.cdm.model.CDMNotation,
+ org.jboss.savara.pi4soa.cdm.model.SCNNotation,
org.jboss.savara.pi4soa.cdm.validation.TypeReferenceValidationRule,
- org.jboss.savara.pi4soa.cdm.editor.CDMEditorManager
+ org.jboss.savara.pi4soa.cdm.editor.CDMEditorManager,
+ org.jboss.savara.pi4soa.cdm.editor.SCNEditorManager
Export-Package: org.jboss.savara.pi4soa.cdm.model,
org.jboss.savara.pi4soa.cdm.parser
Added:
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/editor/SCNEditorManager.java
===================================================================
---
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/editor/SCNEditorManager.java
(rev 0)
+++
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/editor/SCNEditorManager.java 2010-09-22
15:04:06 UTC (rev 422)
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * 19 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.editor;
+
+import org.eclipse.emf.ecore.EValidator;
+import org.jboss.savara.pi4soa.cdm.model.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.ModelReference;
+import org.scribble.model.SourceRef;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.editor.*;
+
+/**
+ * This is the CDM designer's implementation of the EditorManager
+ * interface.
+ */
+(a)RegistryInfo(extension=EditorManager.class,notation=SCNNotation.NOTATION_CODE)
//preference=10,
+public class SCNEditorManager extends AbstractEditorManager {
+
+ /**
+ * This method focuses the editor on the specified source,
+ * identified by the model reference and source reference.
+ *
+ * @param mref The model reference
+ * @param sref The component source reference
+ * @param prop Additional properties
+ */
+ public void focus(ModelReference mref, SourceRef sref,
+ java.util.Map<String,Object> props) {
+ String uri=null;
+ org.eclipse.core.resources.IFile file=
+ org.scribble.eclipse.model.admin.OSGIModelRepository.getFile(mref);
+
+ if (file == null || file.exists() == false) {
+ file = org.scribble.eclipse.model.admin.OSGIModelRepository.getGlobalFile(mref);
+ }
+
+ if (file != null && file.exists()) {
+ uri = file.getFullPath().toPortableString();
+ }
+
+ if (uri != null) {
+ org.eclipse.ui.IWorkbenchPage page=
+ org.eclipse.ui.PlatformUI.getWorkbench().
+ getActiveWorkbenchWindow().getActivePage();
+
+ org.eclipse.core.resources.IResource res=
+ org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().findMember(uri);
+
+ if (res instanceof org.eclipse.core.resources.IFile) {
+ org.eclipse.ui.part.FileEditorInput input=
+ new org.eclipse.ui.part.FileEditorInput(
+ (org.eclipse.core.resources.IFile)res);
+
+ try {
+ org.eclipse.ui.IEditorPart part=page.openEditor(input,
+ "org.pi4soa.scenario.designer.Pi4SOAScenarioDesignerID");
+
+ if (part instanceof org.pi4soa.designer.editor.ChoreographyDescriptionEditor) {
+ org.pi4soa.designer.editor.ChoreographyDescriptionEditor editor=
+ (org.pi4soa.designer.editor.ChoreographyDescriptionEditor)part;
+
+ /* Other approach using marker - can be used if editor does not
+ * provide alternative way to focus on component.
+ org.eclipse.core.resources.IMarker marker=res.createMarker(EValidator.MARKER);
+ marker.setAttribute(EValidator.URI_ATTRIBUTE, ref.getComponentURI());
+ editor.gotoMarker(marker);
+ marker.delete();
+ */
+
+ editor.showComponent(sref.getComponentURI());
+ }
+
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ /**
+ * This method enriches the set of properties required
+ * by the editor, using the properties associated with
+ * the model issue.
+ *
+ * @param issue The model issue
+ */
+ @Override
+ public void enrich(ModelIssue issue) {
+
+ if (issue.getModelObject() != null) {
+ // Set the EMF URI attribute
+ issue.getProperties().put(EValidator.URI_ATTRIBUTE,
+ issue.getModelObject().getSource().getComponentURI());
+ }
+ }
+}
Added:
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/model/SCNNotation.java
===================================================================
---
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/model/SCNNotation.java
(rev 0)
+++
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/model/SCNNotation.java 2010-09-22
15:04:06 UTC (rev 422)
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * 17 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.model;
+
+import org.scribble.extensions.*;
+import org.scribble.model.ModelReference;
+import org.scribble.model.Notation;
+
+/**
+ * This class represents the SCN notation implementation.
+ */
+(a)RegistryInfo(extension=org.scribble.model.Notation.class)
+public class SCNNotation extends org.scribble.model.AbstractNotation {
+
+ public static final String NOTATION_CODE="scn";
+
+ /**
+ * This is the constructor for the CDM notation.
+ */
+ public SCNNotation() {
+ super(NOTATION_CODE, "SCN", false);
+ }
+
+ /**
+ * This method returns the initial description associated
+ * with the supplied reference.
+ *
+ * @param ref The reference
+ * @return The initial description, or null if no description
+ */
+ public String getInitialDescription(ModelReference ref) {
+ StringBuffer buf=new StringBuffer();
+
+ return(buf.toString());
+ }
+
+ /**
+ * This method returns the optional 'super' notation.
+ * If defined, then this notation is a derived notation
+ * from the 'super' notation.
+ *
+ * @return The optional 'super' notation
+ */
+ @Override
+ public Notation getSuperNotation() {
+ return(m_superNotation);
+ }
+
+ private Notation m_superNotation=new
org.scribble.conversation.model.ConversationNotation();
+}
Modified:
trunk/tools/plugins/org.jboss.savara.tap.eclipse/src/java/org/jboss/savara/tap/eclipse/actions/ValidateAction.java
===================================================================
---
trunk/tools/plugins/org.jboss.savara.tap.eclipse/src/java/org/jboss/savara/tap/eclipse/actions/ValidateAction.java 2010-09-22
11:07:50 UTC (rev 421)
+++
trunk/tools/plugins/org.jboss.savara.tap.eclipse/src/java/org/jboss/savara/tap/eclipse/actions/ValidateAction.java 2010-09-22
15:04:06 UTC (rev 422)
@@ -100,6 +100,8 @@
}
}
+ e.printStackTrace();
+
error(e.getMessage());
}
Modified:
trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/TAPValidator.java
===================================================================
---
trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/TAPValidator.java 2010-09-22
11:07:50 UTC (rev 421)
+++
trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/TAPValidator.java 2010-09-22
15:04:06 UTC (rev 422)
@@ -43,8 +43,10 @@
import org.jboss.savara.tap.model.Relationship;
import org.jboss.savara.tap.model.Resource;
import org.jboss.savara.tap.model.admin.ResourceLoader;
+import org.scribble.model.ModelReference;
import org.scribble.model.admin.ModelIssue;
import org.scribble.model.admin.ModelListener;
+import org.scribble.model.resolutions.ShowReferencedDescription;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
@@ -168,39 +170,43 @@
Resource toResource=(Resource)rel.getRef();
if (toResource !=null) {
- for (RelationshipValidator rv : m_relationshipValidators) {
+ // Obtain input stream for resource
+ ResourceLoader fromRL=getResourceLoader(resource);
+ ResourceLoader toRL=getResourceLoader(toResource);
+
+ if (fromRL == null) {
+ l.error(new ModelIssue(null,
+ MessageFormat.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.savara.tap.validation.Messages").
+ getString("SAVARATAPV-00001"), resource.getId())));
+ } else if (toRL == null) {
+ l.error(new ModelIssue(null,
+ MessageFormat.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.savara.tap.validation.Messages").
+ getString("SAVARATAPV-00001"), toResource.getId())));
+ } else if (!fromRL.exists(resource)) {
+ l.error(new ModelIssue(null,
+ MessageFormat.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.savara.tap.validation.Messages").
+ getString("SAVARATAPV-00002"), resource.getId())));
+ } else if (!toRL.exists(toResource)) {
+ l.error(new ModelIssue(null,
+ MessageFormat.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.savara.tap.validation.Messages").
+ getString("SAVARATAPV-00002"), toResource.getId())));
+ } else {
+ ModelReference ref=toRL.getModelReference(toResource);
- if (rv.isSupported(rel, resource, toResource)) {
- // Obtain input stream for resource
- ResourceLoader fromRL=getResourceLoader(resource);
- ResourceLoader toRL=getResourceLoader(toResource);
+ ModelListener proxyml=new InnerModelListener(ref, ml);
+
+ for (RelationshipValidator rv : m_relationshipValidators) {
- if (fromRL == null) {
- l.error(new ModelIssue(null,
- MessageFormat.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.savara.tap.validation.Messages").
- getString("SAVARATAPV-00001"), resource.getId())));
- } else if (toRL == null) {
- l.error(new ModelIssue(null,
- MessageFormat.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.savara.tap.validation.Messages").
- getString("SAVARATAPV-00001"), toResource.getId())));
- } else if (!fromRL.exists(resource)) {
- l.error(new ModelIssue(null,
- MessageFormat.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.savara.tap.validation.Messages").
- getString("SAVARATAPV-00002"), resource.getId())));
- } else if (!toRL.exists(toResource)) {
- l.error(new ModelIssue(null,
- MessageFormat.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.savara.tap.validation.Messages").
- getString("SAVARATAPV-00002"), toResource.getId())));
- } else {
- rv.validate(rel, resource, fromRL, toResource, toRL, ml);
+ if (rv.isSupported(rel, resource, toResource)) {
+ rv.validate(rel, resource, fromRL, toResource, toRL, proxyml);
break;
}
@@ -316,4 +322,39 @@
}
}
}
+
+ public class InnerModelListener implements ModelListener {
+
+ private ModelListener m_listener=null;
+ private ModelReference m_reference=null;
+
+ public InnerModelListener(ModelReference ref, ModelListener l) {
+ m_reference = ref;
+ m_listener = l;
+ }
+
+ public void error(ModelIssue issue) {
+
+ ShowReferencedDescription res=new ShowReferencedDescription();
+ res.setModel(m_reference);
+
+ if (issue.getModelObject() != null) {
+ res.setSourceReference(issue.getModelObject().getSource());
+ }
+
+ issue.getResolutions().add(res);
+
+ m_listener.error(issue);
+ }
+
+ public void warning(ModelIssue issue) {
+ ShowReferencedDescription res=new ShowReferencedDescription();
+ res.setModel(m_reference);
+ res.setSourceReference(issue.getModelObject().getSource());
+
+ issue.getResolutions().add(res);
+
+ m_listener.warning(issue);
+ }
+ }
}
Deleted:
trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/action/ValidateAction.java
===================================================================
---
trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/action/ValidateAction.java 2010-09-22
11:07:50 UTC (rev 421)
+++
trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/action/ValidateAction.java 2010-09-22
15:04:06 UTC (rev 422)
@@ -1,214 +0,0 @@
-/*
- * Copyright 2005-8 Pi4 Technologies Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- * Change History:
- * 17 Jan, 2008 : Initial version created by gary
- */
-package org.jboss.savara.tap.validation.action;
-
-import java.io.IOException;
-import java.util.logging.Logger;
-
-import javax.xml.XMLConstants;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.Source;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-import javax.xml.validation.Validator;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.MessageBox;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-import org.jboss.savara.tap.model.Project;
-import org.jboss.savara.tap.model.admin.TAPModelUtil;
-import org.jboss.savara.tap.validation.TAPValidator;
-import org.scribble.eclipse.model.admin.OSGIModelListener;
-import org.scribble.model.admin.ModelIssue;
-import org.scribble.model.admin.ModelListener;
-import org.w3c.dom.Document;
-import org.xml.sax.SAXException;
-
-/**
- * This class invokes the validation action on the selected
- * TAP file.
- *
- */
-public class ValidateAction implements IObjectActionDelegate {
-
- private static Logger logger = Logger.getLogger(ValidateAction.class.getName());
-
- private ISelection m_selection=null;
- private IWorkbenchPart m_targetPart=null;
- //private static TAPValidator m_validator=new TAPValidator();
-
- public ValidateAction() {
- }
-
- /**
- * This method returns the validator.
- *
- * @return The validator
- */
- /*
- public static TAPValidator getValidator() {
- return(m_validator);
- }
- */
-
- /**
- * This method implements the action's run method.
- *
- * @param action The action
- */
- public void run(IAction action) {
- /*
- if (m_selection instanceof StructuredSelection) {
- StructuredSelection sel=(StructuredSelection)m_selection;
-
- IResource res=(IResource)sel.getFirstElement();
-
- // Obtain the TAP model from the resource
- if (res instanceof IFile) {
- Project project=null;
- OSGIModelListener l=new OSGIModelListener(res);
-
- // Check the XML document is valid
- if (isValidTAPDocument((IFile)res, l)) {
-
- try {
- java.io.InputStream is=((IFile)res).getContents();
-
- project = TAPModelUtil.deserialize(is);
-
- is.close();
- } catch(Exception e) {
- error(e.getMessage());
- }
-
- if (project != null) {
- m_validator.validate(project, l);
- }
- }
-
- l.finished();
- }
- }
- */
- }
-
- protected boolean isValidTAPDocument(IFile file, ModelListener l) {
- boolean ret=false;
-
- try {
-
- // Parse an XML document into a DOM tree.
- DocumentBuilderFactory f=DocumentBuilderFactory.newInstance();
- f.setNamespaceAware(true);
-
- DocumentBuilder parser=f.newDocumentBuilder();
-
- java.io.InputStream is=file.getContents();
- Document document = parser.parse(is);
-
- is.close();
-
- // Create a SchemaFactory capable of understanding WXS schemas.
- SchemaFactory factory =
- SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
-
- // Load a WXS schema, represented by a Schema instance.
- java.io.InputStream
schemais=ValidateAction.class.getResourceAsStream("/tap.xsd");
-
- Source schemaFile = new StreamSource(schemais);
- Schema schema = factory.newSchema(schemaFile);
-
- schemais.close();
-
- // Create a Validator object, which can be used to validate
- // an instance document.
- Validator validator = schema.newValidator();
-
- // Validate the DOM tree.
- validator.validate(new DOMSource(document));
-
- ret = true;
-
- } catch (ParserConfigurationException e) {
- l.error(new ModelIssue(null, "Failed to parse TAP document:
"+e.getMessage()));
- } catch (SAXException e) {
- l.error(new ModelIssue(null, "Invalid TAP document: "+e.getMessage()));
- } catch (IOException e) {
- l.error(new ModelIssue(null, "Failed to load TAP document:
"+e.getMessage()));
- } catch (CoreException e) {
- l.error(new ModelIssue(null, "Failed to load TAP document:
"+e.getMessage()));
- }
-
- return(ret);
- }
-
- /**
- * This method is used to report an error.
- *
- * @param mesg The error message
- */
- public void error(String mesg) {
-
- logger.severe("Error occurred: "+mesg);
-
- MessageBox mbox=new MessageBox(m_targetPart.getSite().getShell(),
- SWT.ICON_ERROR|SWT.OK);
-
- if (mesg == null) {
- mesg = "Null pointer exception has occurred";
- }
-
- mbox.setMessage(mesg);
- mbox.open();
- }
-
- /**
- * This method indicates that the selection has changed.
- *
- * @param action The action
- * @param selection The selection
- */
- public void selectionChanged(IAction action,
- ISelection selection) {
- m_selection = selection;
- }
-
- /**
- * This method sets the currently active workbench part.
- *
- * @param action The action
- * @param targetPart The active workbench part
- */
- public void setActivePart(IAction action,
- IWorkbenchPart targetPart) {
- m_targetPart = targetPart;
- }
-}
Modified:
trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/osgi/Activator.java
===================================================================
---
trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/osgi/Activator.java 2010-09-22
11:07:50 UTC (rev 421)
+++
trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/osgi/Activator.java 2010-09-22
15:04:06 UTC (rev 422)
@@ -7,7 +7,6 @@
import org.jboss.savara.tap.validation.RelationshipValidator;
import org.jboss.savara.tap.validation.ResourceValidator;
import org.jboss.savara.tap.validation.TAPValidator;
-import org.jboss.savara.tap.validation.action.ValidateAction;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
Modified:
trunk/tools/plugins/org.scribble.core/src/java/org/scribble/model/resolutions/ShowReferencedDescription.java
===================================================================
---
trunk/tools/plugins/org.scribble.core/src/java/org/scribble/model/resolutions/ShowReferencedDescription.java 2010-09-22
11:07:50 UTC (rev 421)
+++
trunk/tools/plugins/org.scribble.core/src/java/org/scribble/model/resolutions/ShowReferencedDescription.java 2010-09-22
15:04:06 UTC (rev 422)
@@ -127,9 +127,15 @@
SourceRef sref=new SourceRef();
sref.setComponentURI((String)getProperties().get(SOURCE_REF_COMPONENT_URI));
sref.setModelObjectURI((String)getProperties().get(SOURCE_REF_MODEL_OBJECT_URI));
- sref.setStartPosition((Integer)getProperties().get(SOURCE_REF_START_POSITION));
- sref.setEndPosition((Integer)getProperties().get(SOURCE_REF_END_POSITION));
+ if (getProperties().containsKey(SOURCE_REF_START_POSITION)) {
+ sref.setStartPosition((Integer)getProperties().get(SOURCE_REF_START_POSITION));
+ }
+
+ if (getProperties().containsKey(SOURCE_REF_END_POSITION)) {
+ sref.setEndPosition((Integer)getProperties().get(SOURCE_REF_END_POSITION));
+ }
+
// Recover the properties for model and source ref
java.util.Iterator<String> iter=getProperties().keySet().iterator();
while (iter.hasNext()) {
Added:
trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/resolutions/MarkerResolutionGenerator.java
===================================================================
---
trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/resolutions/MarkerResolutionGenerator.java
(rev 0)
+++
trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/resolutions/MarkerResolutionGenerator.java 2010-09-22
15:04:06 UTC (rev 422)
@@ -0,0 +1,206 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * 1 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.eclipse.resolutions;
+
+import java.util.Comparator;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.internal.UIPlugin;
+import org.scribble.eclipse.model.admin.OSGIModelListener;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.resolutions.Resolution;
+import org.scribble.util.*;
+
+/**
+ * This class represents the implementation of the marker
+ * resolution generator interface, responsible for
+ * providing resolutions related to markers.
+ *
+ */
+public class MarkerResolutionGenerator
+ implements org.eclipse.ui.IMarkerResolutionGenerator2 {
+
+ /**
+ * This method determines whether there are available resolutions
+ * for the supplied marker.
+ *
+ * @param marker The marker
+ * @return Whether resolutions are available
+ */
+ public boolean hasResolutions(org.eclipse.core.resources.IMarker marker) {
+ boolean ret=false;
+
+ try {
+ ret = ModelIssueUtil.hasResolutions(marker.getAttributes());
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns any available resolutions for the supplied
+ * marker.
+ *
+ * @param marker The marker
+ * @return The list of available resolutions
+ */
+ public org.eclipse.ui.IMarkerResolution[]
getResolutions(org.eclipse.core.resources.IMarker marker) {
+ org.eclipse.ui.IMarkerResolution[] ret=null;
+
+ try {
+ java.util.List<Resolution> resolutions=
+ ModelIssueUtil.deserializeResolutions(marker.getAttributes());
+
+ java.util.Collections.sort(resolutions, new ResolutionComparator());
+
+ ret = new org.eclipse.ui.IMarkerResolution[resolutions.size()];
+
+ for (int i=0; i < resolutions.size(); i++) {
+ ret[i] = new MarkerResolutionWrapper(resolutions.get(i));
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+
+ /*
+ String resolutions=marker.getAttribute(org.scribble.model.ModelListener.RESOLUTIONS,
null);
+
+ try {
+ java.util.List<org.eclipse.ui.IMarkerResolution> impls=
+ new java.util.Vector<org.eclipse.ui.IMarkerResolution>();
+
+ java.util.StringTokenizer st=new
java.util.StringTokenizer(resolutions,",");
+
+ while (st.hasMoreTokens()) {
+ String resolution=st.nextToken();
+
+ if (resolution.equals(ModelListener.SHOW_EXTERNAL_ISSUE_RESOLUTION)) {
+ impls.add(new ShowExternalIssue());
+ } else if (resolution.equals(ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION)) {
+ impls.add(new ShowReferencedDescription());
+ } else {
+ try {
+ Class<?> cls=Class.forName(resolution);
+
+ org.eclipse.ui.IMarkerResolution res=
+ (org.eclipse.ui.IMarkerResolution)cls.newInstance();
+
+ impls.add(res);
+ } catch(Exception cnfe) {
+ org.scribble.osgi.eclipse.Activator.logError(
+ "Failed to instantiate resolution '"+resolution+"'",
cnfe);
+ }
+ }
+ }
+
+ ret = new org.eclipse.ui.IMarkerResolution[impls.size()];
+
+ impls.toArray(ret);
+
+ } catch(Exception e) {
+ org.scribble.osgi.eclipse.Activator.logError(
+ "Failed to instantiate resolution '"+resolutions+"'",
e);
+ }
+ */
+
+ return(ret);
+ }
+
+ private static Logger logger =
Logger.getLogger("org.scribble.osgi.resolutions");
+
+ public class ResolutionComparator implements Comparator<Resolution> {
+
+ public int compare(Resolution res1, Resolution res2) {
+ return(res1.getName().compareTo(res2.getName()));
+ }
+ }
+
+ public class MarkerResolutionWrapper implements org.eclipse.ui.IMarkerResolution2 {
+
+ public MarkerResolutionWrapper(Resolution res) {
+ m_resolution = res;
+ }
+
+ public String getLabel() {
+ return(m_resolution.getName());
+ }
+
+ public String getDescription() {
+ return(m_resolution.getDescription());
+ }
+
+ public Image getImage() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void run(IMarker marker) {
+ try {
+ ModelIssue issue=new ModelIssue();
+ issue.setMessage((String)marker.getAttribute(IMarker.MESSAGE));
+ issue.getProperties().putAll(marker.getAttributes());
+
+ SourceRef obj=new SourceRef();
+ obj.setStartPosition(((Integer)marker.getAttribute(IMarker.CHAR_START,
0)).intValue());
+ obj.setEndPosition(((Integer)marker.getAttribute(IMarker.CHAR_END, 0)).intValue());
+ obj.setModelObjectURI((String)marker.getAttribute(OSGIModelListener.SOURCE_MODEL_OBJECT_URI));
+ obj.setComponentURI((String)marker.getAttribute(OSGIModelListener.SOURCE_COMPONENT_URI));
+
+ ModelReference ref=new ModelReference(
+ (String)marker.getAttribute(OSGIModelListener.MODEL_NAMESPACE),
+ (String)marker.getAttribute(OSGIModelListener.MODEL_LOCALPART),
+ (String)marker.getAttribute(OSGIModelListener.MODEL_LOCATED_ROLE),
+ (String)marker.getAttribute(OSGIModelListener.MODEL_NOTATION));
+
+ // Recover the properties for model ref
+ java.util.Iterator<String> iter=
+ marker.getAttributes().keySet().iterator();
+ while (iter.hasNext()) {
+ String name=iter.next();
+
+ if (name.startsWith(OSGIModelListener.MODEL_PROP_PREFIX)) {
+ Object value=marker.getAttributes().get(name);
+
+ name = name.substring(OSGIModelListener.MODEL_PROP_PREFIX.length());
+
+ ref.setProperty(name, value);
+ }
+ }
+
+ m_resolution.resolve(ref, obj, issue);
+ } catch(Exception e) {
+
+ org.eclipse.jface.dialogs.MessageDialog.openError(
+ UIPlugin.getDefault().getWorkbench().getDisplay().getActiveShell(),
+ "Error", e.getLocalizedMessage());
+
+ logger.log(Level.SEVERE, "Failed to resolve", e);
+ }
+ }
+
+ private Resolution m_resolution=null;
+ }
+}