Author: koen.aers(a)jboss.com
Date: 2009-01-28 23:00:14 -0500 (Wed, 28 Jan 2009)
New Revision: 13315
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/AdvancedSection.java
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/NameSection.java
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/TypeMapper.java
Removed:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/AdvancedPropertySection.java
Modified:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/plugin.xml
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/model/SequenceFlow.java
Log:
add name property support for sequence flow
Modified: trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/plugin.xml
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/plugin.xml 2009-01-29 03:59:43 UTC (rev
13314)
+++ trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/plugin.xml 2009-01-29 04:00:14 UTC (rev
13315)
@@ -227,7 +227,12 @@
</extension>
<extension
point="org.eclipse.ui.views.properties.tabbed.propertyContributor">
- <propertyContributor
contributorId="org.jboss.tools.flow.jpdl4.editor">
+ <propertyContributor
+ contributorId="org.jboss.tools.flow.jpdl4.editor"
+ typeMapper="org.jboss.tools.flow.jpdl4.properties.TypeMapper">
+ <propertyCategory category="general"/>
+ <propertyCategory category="details"/>
+ <propertyCategory category="graphics"/>
<propertyCategory category="advanced"/>
</propertyContributor>
</extension>
@@ -235,6 +240,21 @@
<extension
point="org.eclipse.ui.views.properties.tabbed.propertyTabs">
<propertyTabs contributorId="org.jboss.tools.flow.jpdl4.editor">
<propertyTab
+ category="general"
+ id="org.jboss.tools.jpdl4.general"
+ label="General"/>
+ <propertyTab
+ afterTab="org.jboss.tools.jpdl4.general"
+ category="details"
+ id="org.jboss.tools.jpdl4.details"
+ label="Details"/>
+ <propertyTab
+ afterTab="org.jboss.tools.jpdl4.details"
+ category="graphics"
+ id="org.jboss.tools.jpdl4.graphics"
+ label="Graphics"/>
+ <propertyTab
+ afterTab="org.jboss.tools.jpdl4.graphics"
category="advanced"
id="org.jboss.tools.jpdl4.advanced"
label="Advanced"/>
@@ -244,10 +264,18 @@
<extension
point="org.eclipse.ui.views.properties.tabbed.propertySections">
<propertySections
contributorId="org.jboss.tools.flow.jpdl4.editor">
<propertySection
-
class="org.jboss.tools.flow.jpdl4.properties.AdvancedPropertySection"
+ class="org.jboss.tools.flow.jpdl4.properties.AdvancedSection"
id="org.jboss.tools.jpdl4.advanced"
tab="org.jboss.tools.jpdl4.advanced">
- <input type="java.lang.Object"/>
+ <input type="java.lang.Object"/>
+ </propertySection>
+ <propertySection
+ class="org.jboss.tools.flow.jpdl4.properties.NameSection"
+ id="org.jboss.tools.jpdl4.name"
+ tab="org.jboss.tools.jpdl4.general">
+ <input
type="org.jboss.tools.flow.jpdl4.model.SequenceFlow"/>
+ <input type="org.jboss.tools.flow.jpdl4.model.ProcessNode"/>
+ <input type="org.jboss.tools.flow.jpdl4.model.Process"/>
</propertySection>
</propertySections>
</extension>
Modified:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/model/SequenceFlow.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/model/SequenceFlow.java 2009-01-29
03:59:43 UTC (rev 13314)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/model/SequenceFlow.java 2009-01-29
04:00:14 UTC (rev 13315)
@@ -1,9 +1,15 @@
package org.jboss.tools.flow.jpdl4.model;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
import org.jboss.tools.flow.common.model.DefaultConnection;
import org.jboss.tools.flow.common.model.Node;
+import org.jboss.tools.flow.common.properties.IPropertyId;
public class SequenceFlow extends DefaultConnection {
+
+ private String name;
public SequenceFlow() {
this(null, null);
@@ -11,6 +17,56 @@
public SequenceFlow(Node from, Node to) {
super(from, to);
+ setMetaData("propertySource", new PropertySource());
}
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ private class PropertySource implements IPropertySource, IPropertyId {
+ private IPropertyDescriptor[] propertyDescriptors = new IPropertyDescriptor[] {
+ new TextPropertyDescriptor(NAME, "Name") {}
+ };
+
+ public Object getEditableValue() {
+ return null;
+ }
+
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ return propertyDescriptors;
+ }
+
+ public Object getPropertyValue(Object id) {
+ if (NAME.equals(id)) {
+ return getName() != null ? getName() : "";
+ }
+ return null;
+ }
+
+ public boolean isPropertySet(Object id) {
+ if (NAME.equals(id)) {
+ return getName() != null;
+ }
+ return false;
+ }
+
+ public void resetPropertyValue(Object id) {
+ }
+
+ public void setPropertyValue(Object id, Object value) {
+ if (NAME.equals(id)) {
+ if (value instanceof String) {
+ setName((String)value);
+ }
+ }
+ }
+
+ }
+
}
Deleted:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/AdvancedPropertySection.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/AdvancedPropertySection.java 2009-01-29
03:59:43 UTC (rev 13314)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/AdvancedPropertySection.java 2009-01-29
04:00:14 UTC (rev 13315)
@@ -1,20 +0,0 @@
-package org.jboss.tools.flow.jpdl4.properties;
-
-import org.eclipse.gef.commands.CommandStack;
-import org.eclipse.gef.ui.properties.UndoablePropertySheetEntry;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
-
-public class AdvancedPropertySection
- extends org.eclipse.ui.views.properties.tabbed.AdvancedPropertySection {
-
- public void createControls(Composite parent,
- final TabbedPropertySheetPage atabbedPropertySheetPage) {
- super.createControls(parent, atabbedPropertySheetPage);
- if (atabbedPropertySheetPage instanceof JpdlPropertySheetPage) {
- CommandStack commandStack =
((JpdlPropertySheetPage)atabbedPropertySheetPage).getCommandStack();
- page.setRootEntry(new UndoablePropertySheetEntry(commandStack));
- }
- }
-
-}
Copied:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/AdvancedSection.java
(from rev 13282,
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/AdvancedPropertySection.java)
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/AdvancedSection.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/AdvancedSection.java 2009-01-29
04:00:14 UTC (rev 13315)
@@ -0,0 +1,20 @@
+package org.jboss.tools.flow.jpdl4.properties;
+
+import org.eclipse.gef.commands.CommandStack;
+import org.eclipse.gef.ui.properties.UndoablePropertySheetEntry;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.tabbed.AdvancedPropertySection;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
+
+public class AdvancedSection extends AdvancedPropertySection {
+
+ public void createControls(Composite parent,
+ final TabbedPropertySheetPage atabbedPropertySheetPage) {
+ super.createControls(parent, atabbedPropertySheetPage);
+ if (atabbedPropertySheetPage instanceof JpdlPropertySheetPage) {
+ CommandStack commandStack =
((JpdlPropertySheetPage)atabbedPropertySheetPage).getCommandStack();
+ page.setRootEntry(new UndoablePropertySheetEntry(commandStack));
+ }
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/AdvancedSection.java
___________________________________________________________________
Name: svn:mergeinfo
+
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/NameSection.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/NameSection.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/NameSection.java 2009-01-29
04:00:14 UTC (rev 13315)
@@ -0,0 +1,108 @@
+package org.jboss.tools.flow.jpdl4.properties;
+
+import java.util.EventObject;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.gef.commands.CommandStack;
+import org.eclipse.gef.commands.CommandStackListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
+import org.jboss.tools.flow.common.properties.IPropertyId;
+
+public class NameSection extends AbstractPropertySection implements IPropertyId {
+
+ private Text nameText;
+ private CLabel nameLabel;
+
+ private IPropertySource input;
+ private CommandStack commandStack;
+
+ private ModifyListener nameTextModifyListener = new ModifyListener() {
+ public void modifyText(ModifyEvent arg0) {
+ if (input != null) {
+ input.setPropertyValue(NAME, nameText.getText());
+ }
+ }
+ };
+
+ private CommandStackListener commandStackListener = new CommandStackListener() {
+ public void commandStackChanged(EventObject event) {
+ refresh();
+ }
+ };
+
+ public void dispose() {
+ commandStack.removeCommandStackListener(commandStackListener);
+ super.dispose();
+ }
+
+ public void createControls(Composite parent,
+ TabbedPropertySheetPage aTabbedPropertySheetPage) {
+ super.createControls(parent, aTabbedPropertySheetPage);
+ if (aTabbedPropertySheetPage instanceof JpdlPropertySheetPage) {
+ commandStack = ((JpdlPropertySheetPage)aTabbedPropertySheetPage).getCommandStack();
+ commandStack.addCommandStackListener(commandStackListener);
+ }
+ Composite composite = getWidgetFactory()
+ .createFlatFormComposite(parent);
+ createNameLabel(composite);
+ createNameText(composite);
+ }
+
+
+ private void createNameLabel(Composite parent) {
+ nameLabel = getWidgetFactory().createCLabel(parent, "Name");
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.top = new FormAttachment(0, 5);
+ nameLabel.setLayoutData(data);
+ }
+
+ private void createNameText(Composite parent) {
+ nameText = getWidgetFactory().createText(parent, "");
+ FormData data = new FormData();
+ data.top = new FormAttachment(0, 0);
+ data.left = new FormAttachment(nameLabel, 0, SWT.RIGHT);
+ data.right = new FormAttachment(100, 0);
+ nameText.setLayoutData(data);
+ }
+
+ public void setInput(IWorkbenchPart part, ISelection selection) {
+ super.setInput(part, selection);
+ if (selection instanceof IStructuredSelection) {
+ Object object = ((IStructuredSelection)selection).getFirstElement();
+ if (object instanceof IAdaptable) {
+ object = ((IAdaptable)object).getAdapter(IPropertySource.class);
+ if (object instanceof IPropertySource) {
+ input = (IPropertySource)object;
+ return;
+ }
+ }
+ }
+ input = null;
+ }
+
+ public void refresh() {
+ if (input != null) {
+ String value = (String)input.getPropertyValue(NAME);
+ nameText.removeModifyListener(nameTextModifyListener);
+ nameText.setText(value == null ? "" : value);
+ nameText.addModifyListener(nameTextModifyListener);
+ } else {
+ nameText.setText("");
+ }
+ }
+
+}
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/TypeMapper.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/TypeMapper.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/TypeMapper.java 2009-01-29
04:00:14 UTC (rev 13315)
@@ -0,0 +1,23 @@
+package org.jboss.tools.flow.jpdl4.properties;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.ui.views.properties.tabbed.AbstractTypeMapper;
+import org.jboss.tools.flow.common.wrapper.Wrapper;
+
+public class TypeMapper extends AbstractTypeMapper {
+
+ @SuppressWarnings("unchecked")
+ public Class mapType(Object object) {
+ if (object instanceof EditPart) {
+ Object wrapper = ((EditPart)object).getModel();
+ if (wrapper instanceof Wrapper) {
+ Object element = ((Wrapper)wrapper).getElement();
+ if (element != null) {
+ return element.getClass();
+ }
+ }
+ }
+ return super.mapType(object);
+ }
+
+}
Show replies by date