Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Merks2012-01-14 14:59:11 +0000
committerEd Merks2012-01-14 14:59:11 +0000
commit8401175ad65c95c692b83ade868787d8390eaa9b (patch)
tree44d11e38ee1c6e7d71c72ad11dcc91ab834e4395 /examples
parent7a3513eef65279426b783df93879fcf7259a537e (diff)
downloadorg.eclipse.emf-8401175ad65c95c692b83ade868787d8390eaa9b.tar.gz
org.eclipse.emf-8401175ad65c95c692b83ade868787d8390eaa9b.tar.xz
org.eclipse.emf-8401175ad65c95c692b83ade868787d8390eaa9b.zip
[368320] Eliminate warnings
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.emf.examples.databinding.project.core.model/plugin.properties6
-rw-r--r--examples/org.eclipse.emf.examples.databinding.project.core/META-INF/MANIFEST.MF30
-rw-r--r--examples/org.eclipse.emf.examples.databinding.project.core/build.properties15
-rw-r--r--examples/org.eclipse.emf.examples.databinding.project.core/plugin.properties2
-rw-r--r--examples/org.eclipse.emf.examples.databinding.project.core/src/org/eclipse/emf/examples/databinding/project/core/internal/Activator.java134
-rw-r--r--examples/org.eclipse.emf.examples.databinding.project.ui.rcp/META-INF/MANIFEST.MF42
-rw-r--r--examples/org.eclipse.emf.examples.databinding.project.ui.rcp/build.properties13
-rw-r--r--examples/org.eclipse.emf.examples.databinding.project.ui.rcp/plugin.properties23
-rw-r--r--examples/org.eclipse.emf.examples.databinding.project.ui.rcp/plugin.xml688
-rw-r--r--examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/Activator.java281
-rw-r--r--examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/databinding/Base64ToImageConverter.java145
-rw-r--r--examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/databinding/StringToDateConverter.java162
-rw-r--r--examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/dialogs/CommitterShipDialog.java398
-rw-r--r--examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/handlers/NewXMIHandler.java214
-rw-r--r--examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/handlers/OpenXMIHandler.java138
-rw-r--r--examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/views/ProjectAdminViewPart.java579
-rw-r--r--examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/views/ProjectCommittersPart.java405
-rw-r--r--examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/views/ProjectExplorerPart.java1137
-rw-r--r--examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/views/ProjectFormAreaPart.java840
-rw-r--r--examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/views/RedoAction.java145
-rw-r--r--examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/views/UndoAction.java143
21 files changed, 2802 insertions, 2738 deletions
diff --git a/examples/org.eclipse.emf.examples.databinding.project.core.model/plugin.properties b/examples/org.eclipse.emf.examples.databinding.project.core.model/plugin.properties
index d4fcd5c75..dd60f5076 100644
--- a/examples/org.eclipse.emf.examples.databinding.project.core.model/plugin.properties
+++ b/examples/org.eclipse.emf.examples.databinding.project.core.model/plugin.properties
@@ -1,4 +1,2 @@
-
-
-pluginName = Project Model
-providerName = www.example.org
+pluginName = EMF Data Binding Example Model Project
+providerName = Eclipse Modeling Project
diff --git a/examples/org.eclipse.emf.examples.databinding.project.core/META-INF/MANIFEST.MF b/examples/org.eclipse.emf.examples.databinding.project.core/META-INF/MANIFEST.MF
index 9abd54fbd..339a4bce1 100644
--- a/examples/org.eclipse.emf.examples.databinding.project.core/META-INF/MANIFEST.MF
+++ b/examples/org.eclipse.emf.examples.databinding.project.core/META-INF/MANIFEST.MF
@@ -1,14 +1,16 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: Core
-Bundle-SymbolicName: org.eclipse.emf.examples.databinding.project.core
-Bundle-Version: 1.0.0.qualifier
-Bundle-Activator: org.eclipse.emf.examples.databinding.project.core.internal.Activator
-Require-Bundle: org.eclipse.core.runtime,
- org.eclipse.emf.ecore.xmi,
- org.eclipse.emf.edit
-Bundle-ActivationPolicy: lazy
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Export-Package: org.eclipse.emf.examples.databinding.project.core
-Service-Component: META-INF/component.xml, META-INF/xmiprovider.xml
-Import-Package: org.eclipse.emf.examples.databinding.project.core.model.project
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
+Bundle-SymbolicName: org.eclipse.emf.examples.databinding.project.core
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.emf.examples.databinding.project.core.internal.Activator
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.emf.ecore.xmi,
+ org.eclipse.emf.edit
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.eclipse.emf.examples.databinding.project.core
+Service-Component: META-INF/component.xml, META-INF/xmiprovider.xml
+Import-Package: org.eclipse.emf.examples.databinding.project.core.model.project
diff --git a/examples/org.eclipse.emf.examples.databinding.project.core/build.properties b/examples/org.eclipse.emf.examples.databinding.project.core/build.properties
index c48aba55b..0b3de4340 100644
--- a/examples/org.eclipse.emf.examples.databinding.project.core/build.properties
+++ b/examples/org.eclipse.emf.examples.databinding.project.core/build.properties
@@ -1,7 +1,8 @@
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- META-INF/xmiprovider.xml,\
- META-INF/component.xml
-source.. = src/
-
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ META-INF/xmiprovider.xml,\
+ META-INF/component.xml,\
+ plugin.properties
+source.. = src/
+
diff --git a/examples/org.eclipse.emf.examples.databinding.project.core/plugin.properties b/examples/org.eclipse.emf.examples.databinding.project.core/plugin.properties
new file mode 100644
index 000000000..48d52f10e
--- /dev/null
+++ b/examples/org.eclipse.emf.examples.databinding.project.core/plugin.properties
@@ -0,0 +1,2 @@
+pluginName = EMF Data Binding Example Project
+providerName = Eclipse Modeling Project \ No newline at end of file
diff --git a/examples/org.eclipse.emf.examples.databinding.project.core/src/org/eclipse/emf/examples/databinding/project/core/internal/Activator.java b/examples/org.eclipse.emf.examples.databinding.project.core/src/org/eclipse/emf/examples/databinding/project/core/internal/Activator.java
index 8d29b9d38..911c98fe8 100644
--- a/examples/org.eclipse.emf.examples.databinding.project.core/src/org/eclipse/emf/examples/databinding/project/core/internal/Activator.java
+++ b/examples/org.eclipse.emf.examples.databinding.project.core/src/org/eclipse/emf/examples/databinding/project/core/internal/Activator.java
@@ -1,66 +1,68 @@
-/**
- * Copyright (c) 2009 Bestsolution.at and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Tom Schindl<tom.schindl@bestsolution.at> - Initial API and implementation
- */
-package org.eclipse.emf.examples.databinding.project.core.internal;
-
-import org.eclipse.core.runtime.Plugin;
-import org.osgi.framework.BundleContext;
-
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class Activator extends Plugin
-{
-
- // The plug-in ID
- public static final String PLUGIN_ID = "org.eclipse.emf.examples.databinding.project.core";
-
- // The shared instance
- private static Activator plugin;
-
- /**
- * The constructor
- */
- public Activator()
- {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception
- {
- super.start(context);
- plugin = this;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception
- {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static Activator getDefault()
- {
- return plugin;
- }
-
-}
+/**
+ * Copyright (c) 2009 Bestsolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl<tom.schindl@bestsolution.at> - Initial API and implementation
+ */
+package org.eclipse.emf.examples.databinding.project.core.internal;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends Plugin
+{
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.emf.examples.databinding.project.core";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator()
+ {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception
+ {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception
+ {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault()
+ {
+ return plugin;
+ }
+
+}
diff --git a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/META-INF/MANIFEST.MF b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/META-INF/MANIFEST.MF
index 103e0c877..3df35f017 100644
--- a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/META-INF/MANIFEST.MF
+++ b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/META-INF/MANIFEST.MF
@@ -1,20 +1,22 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: Rcp
-Bundle-SymbolicName: org.eclipse.emf.examples.databinding.project.ui.rcp;singleton:=true
-Bundle-Version: 1.0.0.qualifier
-Bundle-Activator: org.eclipse.emf.example.databinding.project.ui.rcp.Activator
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.core.databinding,
- org.eclipse.core.databinding.property,
- org.eclipse.jface.databinding,
- org.eclipse.ui.forms,
- org.eclipse.emf.databinding,
- org.eclipse.emf.databinding.edit,
- org.eclipse.emf.examples.databinding.project.core;bundle-version="1.0.0",
- org.eclipse.core.expressions,
- org.eclipse.emf.ecore.xmi
-Bundle-ActivationPolicy: lazy
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Import-Package: org.eclipse.emf.examples.databinding.project.core.model.project
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
+Bundle-SymbolicName: org.eclipse.emf.examples.databinding.project.ui.rcp;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.emf.example.databinding.project.ui.rcp.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.databinding,
+ org.eclipse.core.databinding.property,
+ org.eclipse.jface.databinding,
+ org.eclipse.ui.forms,
+ org.eclipse.emf.databinding,
+ org.eclipse.emf.databinding.edit,
+ org.eclipse.emf.examples.databinding.project.core;bundle-version="1.0.0",
+ org.eclipse.core.expressions,
+ org.eclipse.emf.ecore.xmi
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Import-Package: org.eclipse.emf.examples.databinding.project.core.model.project
diff --git a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/build.properties b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/build.properties
index a60159647..9ebd3d7d6 100644
--- a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/build.properties
+++ b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/build.properties
@@ -1,6 +1,7 @@
-output.. = bin/
-bin.includes = plugin.xml,\
- META-INF/,\
- .
-source.. = src/
-
+output.. = bin/
+bin.includes = plugin.xml,\
+ META-INF/,\
+ .,\
+ plugin.properties
+source.. = src/
+
diff --git a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/plugin.properties b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/plugin.properties
new file mode 100644
index 000000000..498622881
--- /dev/null
+++ b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/plugin.properties
@@ -0,0 +1,23 @@
+pluginName = EMF Data Binding Example RCP Project
+providerName = Eclipse Modeling Project
+perspective.name = RCP Perspective
+view.name = Project Administration
+command.name = New Person
+commandParameter.name = Action
+command.name.0 = Edit Person
+commandParameter.name.0 = Action
+command.name.1 = Open XMI
+command.name.2 = New XMI
+command.name.3 = New Toplevel Project
+command.name.4 = New Sublevel Project
+command.name.5 = New Committership
+command.name.6 = Edit Committership
+command.label = Edit Person
+command.label.0 = Add Committership
+command.label.1 = Edit Committership
+command.label.2 = Add Subproject
+command.label.3 = XMI Resource ...
+command.label.4 = XMI Resource ...
+command.label.5 = Sublevel Project
+command.label.6 = Toplevel Project
+command.label.7 = Person ... \ No newline at end of file
diff --git a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/plugin.xml b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/plugin.xml
index 49c6f65af..f690497d8 100644
--- a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/plugin.xml
+++ b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/plugin.xml
@@ -1,344 +1,344 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
-
- <extension
- id="application"
- point="org.eclipse.core.runtime.applications">
- <application>
- <run
- class="org.eclipse.emf.example.databinding.project.ui.rcp.Application">
- </run>
- </application>
- </extension>
- <extension
- point="org.eclipse.ui.perspectives">
- <perspective
- name="RCP Perspective"
- class="org.eclipse.emf.example.databinding.project.ui.rcp.Perspective"
- id="org.eclipse.emf.example.project.ui.rcp.perspective">
- </perspective>
- </extension>
- <extension
- point="org.eclipse.ui.views">
- <view
- allowMultiple="true"
- class="org.eclipse.emf.example.databinding.project.ui.rcp.views.ProjectAdminViewPart"
- id="org.eclipse.emf.example.databinding.project.ui.rcp.views.ProjectAdminViewPart"
- name="Project Administration"
- restorable="true">
- </view>
- </extension>
- <extension
- point="org.eclipse.ui.services">
- <sourceProvider
- provider="org.eclipse.emf.example.databinding.project.ui.rcp.ResourceProvider">
- <variable
- name="modelresource"
- priorityLevel="activePartId">
- </variable>
- <variable
- name="committer"
- priorityLevel="activePartId">
- </variable>
- <variable
- name="project"
- priorityLevel="activePartId">
- </variable>
- </sourceProvider>
- </extension>
- <extension
- point="org.eclipse.ui.commands">
- <command
- id="org.eclipse.emf.examples.databinding.project.ui.rcp.newperson"
- name="New Person">
- <commandParameter
- id="org.eclipse.emf.examples.databinding.project.ui.rcp.person.action"
- name="Action"
- optional="true"
- values="org.eclipse.emf.example.databinding.project.ui.rcp.handlers.PersonParamValues">
- </commandParameter>
- </command>
- <command
- id="org.eclipse.emf.examples.databinding.project.ui.rcp.editperson"
- name="Edit Person">
- <commandParameter
- id="org.eclipse.emf.examples.databinding.project.ui.rcp.person.action"
- name="Action"
- optional="true"
- values="org.eclipse.emf.example.databinding.project.ui.rcp.handlers.PersonParamValues">
- </commandParameter>
- </command>
- <command
- defaultHandler="org.eclipse.emf.example.databinding.project.ui.rcp.handlers.OpenXMIHandler"
- id="org.eclipse.emf.examples.databinding.project.ui.rcp.openxmi"
- name="Open XMI">
- </command>
- <command
- defaultHandler="org.eclipse.emf.example.databinding.project.ui.rcp.handlers.NewXMIHandler"
- id="org.eclipse.emf.examples.databinding.project.ui.rcp.newxmi"
- name="New XMI">
- </command>
- <command
- id="org.eclipse.emf.examples.databinding.project.ui.rcp.createtopproject"
- name="New Toplevel Project">
- </command>
- <command
- id="org.eclipse.emf.examples.databinding.project.ui.rcp.createsubproject"
- name="New Sublevel Project">
- </command>
- <command
- id="org.eclipse.emf.examples.databinding.project.ui.rcp.newcommittership"
- name="New Committership">
- </command>
- <command
- id="org.eclipse.emf.examples.databinding.project.ui.rcp.editcommittership"
- name="Edit Committership">
- </command>
- </extension>
- <extension
- point="org.eclipse.ui.menus">
- <menuContribution
- locationURI="popup:org.eclipse.emf.examples.databinding.project.ui.rcp.projectexp?after=additions">
- <command
- commandId="org.eclipse.emf.examples.databinding.project.ui.rcp.editperson"
- label="Edit Person"
- style="push">
- <parameter
- name="org.eclipse.emf.examples.databinding.project.ui.rcp.person.action"
- value="edit">
- </parameter>
- <visibleWhen
- checkEnabled="true">
- </visibleWhen>
- </command>
- <command
- commandId="org.eclipse.emf.examples.databinding.project.ui.rcp.newcommittership"
- label="Add Committership"
- style="push">
- <visibleWhen
- checkEnabled="true">
- <with
- variable="activeMenuSelection">
- <and>
- <count
- value="1">
- </count>
- <iterate
- ifEmpty="false"
- operator="and">
- <instanceof
- value="org.eclipse.emf.examples.databinding.project.core.model.project.Project">
- </instanceof>
- </iterate>
- </and>
- </with>
- </visibleWhen>
- </command>
- <command
- commandId="org.eclipse.emf.examples.databinding.project.ui.rcp.editcommittership"
- label="Edit Committership"
- style="push">
- <visibleWhen
- checkEnabled="true">
- </visibleWhen>
- </command>
- <command
- commandId="org.eclipse.emf.examples.databinding.project.ui.rcp.createsubproject"
- label="Add Subproject"
- style="push">
- <visibleWhen
- checkEnabled="true">
- <with
- variable="activeMenuSelection">
- <and>
- <count
- value="1">
- </count>
- <iterate
- ifEmpty="false"
- operator="and">
- <instanceof
- value="org.eclipse.emf.examples.databinding.project.core.model.project.Project">
- </instanceof>
- </iterate>
- </and>
- </with>
- </visibleWhen>
- </command>
- </menuContribution>
- <menuContribution
- locationURI="menu:open?after=additions">
- <command
- commandId="org.eclipse.emf.examples.databinding.project.ui.rcp.openxmi"
- label="XMI Resource ..."
- style="push">
- </command>
- </menuContribution>
- <menuContribution
- locationURI="menu:new?before=after_resource">
- <command
- commandId="org.eclipse.emf.examples.databinding.project.ui.rcp.newxmi"
- label="XMI Resource ..."
- style="push">
- </command>
- </menuContribution>
- <menuContribution
- locationURI="menu:new?after=after_resource">
- <command
- commandId="org.eclipse.emf.examples.databinding.project.ui.rcp.createsubproject"
- label="Sublevel Project"
- style="push">
- </command>
- </menuContribution>
- <menuContribution
- locationURI="menu:new?after=after_resource">
- <command
- commandId="org.eclipse.emf.examples.databinding.project.ui.rcp.createtopproject"
- label="Toplevel Project"
- style="push">
- </command>
- </menuContribution>
- <menuContribution
- locationURI="menu:new?after=after_resource">
- <command
- commandId="org.eclipse.emf.examples.databinding.project.ui.rcp.newperson"
- label="Person ..."
- style="push">
- <parameter
- name="org.eclipse.emf.examples.databinding.project.ui.rcp.person.action"
- value="new">
- </parameter>
- </command>
- </menuContribution>
- </extension>
- <extension
- point="org.eclipse.ui.handlers">
- <handler
- class="org.eclipse.emf.example.databinding.project.ui.rcp.handlers.PersonEditingHandler"
- commandId="org.eclipse.emf.examples.databinding.project.ui.rcp.editperson">
- <enabledWhen>
- <and>
- <with
- variable="committer">
- <not>
- <equals
- value="null">
- </equals>
- </not>
- </with>
- <with
- variable="modelresource">
- <not>
- <equals
- value="null">
- </equals>
- </not>
- </with>
- </and>
-
- </enabledWhen>
- </handler>
- <handler
- class="org.eclipse.emf.example.databinding.project.ui.rcp.handlers.CreateToplevelProjectHandler"
- commandId="org.eclipse.emf.examples.databinding.project.ui.rcp.createtopproject">
- <enabledWhen>
- <with
- variable="modelresource">
- <not>
- <equals
- value="null">
- </equals>
- </not>
- </with>
- </enabledWhen>
- </handler>
- <handler
- class="org.eclipse.emf.example.databinding.project.ui.rcp.handlers.CreateSublevelProjectHandler"
- commandId="org.eclipse.emf.examples.databinding.project.ui.rcp.createsubproject">
- <enabledWhen>
- <and>
- <with
- variable="project">
- <not>
- <equals
- value="null">
- </equals>
- </not>
- </with>
- <with
- variable="modelresource">
- <not>
- <equals
- value="null">
- </equals>
- </not>
- </with>
- </and>
- </enabledWhen>
- </handler>
- <handler
- class="org.eclipse.emf.example.databinding.project.ui.rcp.handlers.CreateCommittershipHandler"
- commandId="org.eclipse.emf.examples.databinding.project.ui.rcp.newcommittership">
- <enabledWhen>
- <and>
- <with
- variable="project">
- <not>
- <equals
- value="null">
- </equals>
- </not>
- </with>
- <with
- variable="modelresource">
- <not>
- <equals
- value="null">
- </equals>
- </not>
- </with>
- </and>
- </enabledWhen>
- </handler>
- <handler
- class="org.eclipse.emf.example.databinding.project.ui.rcp.handlers.PersonEditingHandler"
- commandId="org.eclipse.emf.examples.databinding.project.ui.rcp.newperson">
- <enabledWhen>
- <with
- variable="modelresource">
- <not>
- <equals
- value="null">
- </equals>
- </not>
- </with>
- </enabledWhen>
- </handler>
- <handler
- class="org.eclipse.emf.example.databinding.project.ui.rcp.handlers.EditCommittershipHandler"
- commandId="org.eclipse.emf.examples.databinding.project.ui.rcp.editcommittership">
- <enabledWhen>
- <and>
- <with
- variable="committer">
- <not>
- <equals
- value="null">
- </equals>
- </not>
- </with>
- <with
- variable="modelresource">
- <not>
- <equals
- value="null">
- </equals>
- </not>
- </with>
- </and>
- </enabledWhen>
- </handler>
- </extension>
-
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+ <extension
+ id="application"
+ point="org.eclipse.core.runtime.applications">
+ <application>
+ <run
+ class="org.eclipse.emf.example.databinding.project.ui.rcp.Application">
+ </run>
+ </application>
+ </extension>
+ <extension
+ point="org.eclipse.ui.perspectives">
+ <perspective
+ name="%perspective.name"
+ class="org.eclipse.emf.example.databinding.project.ui.rcp.Perspective"
+ id="org.eclipse.emf.example.project.ui.rcp.perspective">
+ </perspective>
+ </extension>
+ <extension
+ point="org.eclipse.ui.views">
+ <view
+ allowMultiple="true"
+ class="org.eclipse.emf.example.databinding.project.ui.rcp.views.ProjectAdminViewPart"
+ id="org.eclipse.emf.example.databinding.project.ui.rcp.views.ProjectAdminViewPart"
+ name="%view.name"
+ restorable="true">
+ </view>
+ </extension>
+ <extension
+ point="org.eclipse.ui.services">
+ <sourceProvider
+ provider="org.eclipse.emf.example.databinding.project.ui.rcp.ResourceProvider">
+ <variable
+ name="modelresource"
+ priorityLevel="activePartId">
+ </variable>
+ <variable
+ name="committer"
+ priorityLevel="activePartId">
+ </variable>
+ <variable
+ name="project"
+ priorityLevel="activePartId">
+ </variable>
+ </sourceProvider>
+ </extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ id="org.eclipse.emf.examples.databinding.project.ui.rcp.newperson"
+ name="%command.name">
+ <commandParameter
+ id="org.eclipse.emf.examples.databinding.project.ui.rcp.person.action"
+ name="%commandParameter.name"
+ optional="true"
+ values="org.eclipse.emf.example.databinding.project.ui.rcp.handlers.PersonParamValues">
+ </commandParameter>
+ </command>
+ <command
+ id="org.eclipse.emf.examples.databinding.project.ui.rcp.editperson"
+ name="%command.name.0">
+ <commandParameter
+ id="org.eclipse.emf.examples.databinding.project.ui.rcp.person.action"
+ name="%commandParameter.name.0"
+ optional="true"
+ values="org.eclipse.emf.example.databinding.project.ui.rcp.handlers.PersonParamValues">
+ </commandParameter>
+ </command>
+ <command
+ defaultHandler="org.eclipse.emf.example.databinding.project.ui.rcp.handlers.OpenXMIHandler"
+ id="org.eclipse.emf.examples.databinding.project.ui.rcp.openxmi"
+ name="%command.name.1">
+ </command>
+ <command
+ defaultHandler="org.eclipse.emf.example.databinding.project.ui.rcp.handlers.NewXMIHandler"
+ id="org.eclipse.emf.examples.databinding.project.ui.rcp.newxmi"
+ name="%command.name.2">
+ </command>
+ <command
+ id="org.eclipse.emf.examples.databinding.project.ui.rcp.createtopproject"
+ name="%command.name.3">
+ </command>
+ <command
+ id="org.eclipse.emf.examples.databinding.project.ui.rcp.createsubproject"
+ name="%command.name.4">
+ </command>
+ <command
+ id="org.eclipse.emf.examples.databinding.project.ui.rcp.newcommittership"
+ name="%command.name.5">
+ </command>
+ <command
+ id="org.eclipse.emf.examples.databinding.project.ui.rcp.editcommittership"
+ name="%command.name.6">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="popup:org.eclipse.emf.examples.databinding.project.ui.rcp.projectexp?after=additions">
+ <command
+ commandId="org.eclipse.emf.examples.databinding.project.ui.rcp.editperson"
+ label="%command.label"
+ style="push">
+ <parameter
+ name="org.eclipse.emf.examples.databinding.project.ui.rcp.person.action"
+ value="edit">
+ </parameter>
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.emf.examples.databinding.project.ui.rcp.newcommittership"
+ label="%command.label.0"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ <with
+ variable="activeMenuSelection">
+ <and>
+ <count
+ value="1">
+ </count>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <instanceof
+ value="org.eclipse.emf.examples.databinding.project.core.model.project.Project">
+ </instanceof>
+ </iterate>
+ </and>
+ </with>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.emf.examples.databinding.project.ui.rcp.editcommittership"
+ label="%command.label.1"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.emf.examples.databinding.project.ui.rcp.createsubproject"
+ label="%command.label.2"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ <with
+ variable="activeMenuSelection">
+ <and>
+ <count
+ value="1">
+ </count>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <instanceof
+ value="org.eclipse.emf.examples.databinding.project.core.model.project.Project">
+ </instanceof>
+ </iterate>
+ </and>
+ </with>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ <menuContribution
+ locationURI="menu:open?after=additions">
+ <command
+ commandId="org.eclipse.emf.examples.databinding.project.ui.rcp.openxmi"
+ label="%command.label.3"
+ style="push">
+ </command>
+ </menuContribution>
+ <menuContribution
+ locationURI="menu:new?before=after_resource">
+ <command
+ commandId="org.eclipse.emf.examples.databinding.project.ui.rcp.newxmi"
+ label="%command.label.4"
+ style="push">
+ </command>
+ </menuContribution>
+ <menuContribution
+ locationURI="menu:new?after=after_resource">
+ <command
+ commandId="org.eclipse.emf.examples.databinding.project.ui.rcp.createsubproject"
+ label="%command.label.5"
+ style="push">
+ </command>
+ </menuContribution>
+ <menuContribution
+ locationURI="menu:new?after=after_resource">
+ <command
+ commandId="org.eclipse.emf.examples.databinding.project.ui.rcp.createtopproject"
+ label="%command.label.6"
+ style="push">
+ </command>
+ </menuContribution>
+ <menuContribution
+ locationURI="menu:new?after=after_resource">
+ <command
+ commandId="org.eclipse.emf.examples.databinding.project.ui.rcp.newperson"
+ label="%command.label.7"
+ style="push">
+ <parameter
+ name="org.eclipse.emf.examples.databinding.project.ui.rcp.person.action"
+ value="new">
+ </parameter>
+ </command>
+ </menuContribution>
+ </extension>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.emf.example.databinding.project.ui.rcp.handlers.PersonEditingHandler"
+ commandId="org.eclipse.emf.examples.databinding.project.ui.rcp.editperson">
+ <enabledWhen>
+ <and>
+ <with
+ variable="committer">
+ <not>
+ <equals
+ value="null">
+ </equals>
+ </not>
+ </with>
+ <with
+ variable="modelresource">
+ <not>
+ <equals
+ value="null">
+ </equals>
+ </not>
+ </with>
+ </and>
+
+ </enabledWhen>
+ </handler>
+ <handler
+ class="org.eclipse.emf.example.databinding.project.ui.rcp.handlers.CreateToplevelProjectHandler"
+ commandId="org.eclipse.emf.examples.databinding.project.ui.rcp.createtopproject">
+ <enabledWhen>
+ <with
+ variable="modelresource">
+ <not>
+ <equals
+ value="null">
+ </equals>
+ </not>
+ </with>
+ </enabledWhen>
+ </handler>
+ <handler
+ class="org.eclipse.emf.example.databinding.project.ui.rcp.handlers.CreateSublevelProjectHandler"
+ commandId="org.eclipse.emf.examples.databinding.project.ui.rcp.createsubproject">
+ <enabledWhen>
+ <and>
+ <with
+ variable="project">
+ <not>
+ <equals
+ value="null">
+ </equals>
+ </not>
+ </with>
+ <with
+ variable="modelresource">
+ <not>
+ <equals
+ value="null">
+ </equals>
+ </not>
+ </with>
+ </and>
+ </enabledWhen>
+ </handler>
+ <handler
+ class="org.eclipse.emf.example.databinding.project.ui.rcp.handlers.CreateCommittershipHandler"
+ commandId="org.eclipse.emf.examples.databinding.project.ui.rcp.newcommittership">
+ <enabledWhen>
+ <and>
+ <with
+ variable="project">
+ <not>
+ <equals
+ value="null">
+ </equals>
+ </not>
+ </with>
+ <with
+ variable="modelresource">
+ <not>
+ <equals
+ value="null">
+ </equals>
+ </not>
+ </with>
+ </and>
+ </enabledWhen>
+ </handler>
+ <handler
+ class="org.eclipse.emf.example.databinding.project.ui.rcp.handlers.PersonEditingHandler"
+ commandId="org.eclipse.emf.examples.databinding.project.ui.rcp.newperson">
+ <enabledWhen>
+ <with
+ variable="modelresource">
+ <not>
+ <equals
+ value="null">
+ </equals>
+ </not>
+ </with>
+ </enabledWhen>
+ </handler>
+ <handler
+ class="org.eclipse.emf.example.databinding.project.ui.rcp.handlers.EditCommittershipHandler"
+ commandId="org.eclipse.emf.examples.databinding.project.ui.rcp.editcommittership">
+ <enabledWhen>
+ <and>
+ <with
+ variable="committer">
+ <not>
+ <equals
+ value="null">
+ </equals>
+ </not>
+ </with>
+ <with
+ variable="modelresource">
+ <not>
+ <equals
+ value="null">
+ </equals>
+ </not>
+ </with>
+ </and>
+ </enabledWhen>
+ </handler>
+ </extension>
+
+</plugin>
diff --git a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/Activator.java b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/Activator.java
index 7eb2bc290..2f4ce4df5 100644
--- a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/Activator.java
+++ b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/Activator.java
@@ -1,135 +1,146 @@
-/**
- * Copyright (c) 2009 Bestsolution.at and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Tom Schindl<tom.schindl@bestsolution.at> - Initial API and implementation
- */
-package org.eclipse.emf.example.databinding.project.ui.rcp;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-
-import org.eclipse.emf.examples.databinding.project.core.IModelLoadingService;
-import org.eclipse.emf.examples.databinding.project.core.IModelResource;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTracker;
-
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class Activator extends AbstractUIPlugin implements ServiceListener
-{
-
- /**
- * The plug-in ID
- */
- public static final String PLUGIN_ID = "org.eclipse.emf.examples.databinding.project.ui.rcp";
-
- // The shared instance
- private static Activator plugin;
-
- private ServiceTracker tracker;
-
- private IModelLoadingService loadingService;
-
- private BundleContext context;
-
- /**
- * The constructor
- */
- public Activator()
- {
- }
-
- @Override
- public void start(BundleContext context) throws Exception
- {
- super.start(context);
- this.context = context;
- plugin = this;
-
- tracker = new ServiceTracker(context, IModelLoadingService.class.getName(), null);
- tracker.open();
-
- loadingService = (IModelLoadingService)tracker.getService();
-
- context.addServiceListener(this, "(objectclass=" + IModelLoadingService.class.getName() + ")");
- }
-
- @Override
- public void stop(BundleContext context) throws Exception
- {
- plugin = null;
- tracker.close();
- tracker = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static Activator getDefault()
- {
- return plugin;
- }
-
- /**
- * Returns an image descriptor for the image file at the given
- * plug-in relative path
- *
- * @param path the path
- * @return the image descriptor
- */
- public static ImageDescriptor getImageDescriptor(String path)
- {
- return imageDescriptorFromPlugin(PLUGIN_ID, path);
- }
-
- /**
- * Load the model resource
- * @param uri the uri
- * @return the resource
- */
- public IModelResource loadResource(String uri)
- {
- if (loadingService != null)
- {
- return loadingService.findAndLoadResource(uri);
- }
- else
- {
- getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Model loading service not available"));
- }
-
- return null;
- }
-
- public void serviceChanged(ServiceEvent event)
- {
- ServiceReference sr = event.getServiceReference();
- switch (event.getType())
- {
- case ServiceEvent.REGISTERED: {
- loadingService = (IModelLoadingService)context.getService(sr);
- }
- break;
- case ServiceEvent.UNREGISTERING: {
- loadingService = null;
- }
- break;
- }
- }
-}
+/**
+ * Copyright (c) 2009 Bestsolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl<tom.schindl@bestsolution.at> - Initial API and implementation
+ */
+package org.eclipse.emf.example.databinding.project.ui.rcp;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+import org.eclipse.emf.examples.databinding.project.core.IModelLoadingService;
+import org.eclipse.emf.examples.databinding.project.core.IModelResource;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
+
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin implements ServiceListener
+{
+
+ /**
+ * The plug-in ID
+ */
+ public static final String PLUGIN_ID = "org.eclipse.emf.examples.databinding.project.ui.rcp";
+
+ // The shared instance
+ private static Activator plugin;
+
+ private ServiceTracker<?, ?> tracker;
+
+ private IModelLoadingService loadingService;
+
+ private BundleContext context;
+
+ /**
+ * The constructor
+ */
+ public Activator()
+ {
+ }
+
+ @Override
+ public void start(BundleContext context) throws Exception
+ {
+ super.start(context);
+ this.context = context;
+ plugin = this;
+
+ tracker = new ServiceTracker<Object, Object>(context, IModelLoadingService.class.getName(), null);
+ tracker.open();
+
+ loadingService = (IModelLoadingService)tracker.getService();
+
+ context.addServiceListener(this, "(objectclass=" + IModelLoadingService.class.getName() + ")");
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception
+ {
+ plugin = null;
+ tracker.close();
+ tracker = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault()
+ {
+ return plugin;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path)
+ {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+
+ /**
+ * Load the model resource
+ * @param uri the uri
+ * @return the resource
+ */
+ public IModelResource loadResource(String uri)
+ {
+ if (loadingService != null)
+ {
+ return loadingService.findAndLoadResource(uri);
+ }
+ else
+ {
+ getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Model loading service not available"));
+ }
+
+ return null;
+ }
+
+ public void serviceChanged(ServiceEvent event)
+ {
+ ServiceReference<?> sr = event.getServiceReference();
+ switch (event.getType())
+ {
+ case ServiceEvent.REGISTERED: {
+ loadingService = (IModelLoadingService)context.getService(sr);
+ }
+ break;
+ case ServiceEvent.UNREGISTERING: {
+ loadingService = null;
+ }
+ break;
+ }
+ }
+
+ public void log(Throwable throwable)
+ {
+ String message = throwable.getLocalizedMessage();
+ if (message == null)
+ {
+ message = "";
+ }
+
+ getLog().log(new Status(IStatus.WARNING, getBundle().getSymbolicName(), 0, message, throwable));
+ }
+}
diff --git a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/databinding/Base64ToImageConverter.java b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/databinding/Base64ToImageConverter.java
index c3da03775..7a180f250 100644
--- a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/databinding/Base64ToImageConverter.java
+++ b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/databinding/Base64ToImageConverter.java
@@ -1,72 +1,73 @@
-/**
- * Copyright (c) 2009 Bestsolution.at and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Tom Schindl<tom.schindl@bestsolution.at> - Initial API and implementation
- */
-package org.eclipse.emf.example.databinding.project.ui.rcp.databinding;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-
-import org.eclipse.core.databinding.conversion.Converter;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.emf.ecore.xml.type.XMLTypeFactory;
-
-
-/**
- * Converter which able to convert base64 encoded values into SWT-images.
- * The convert remembers the last created image and disposes when a new one is allocated but the
- * last image set on the control has to be disposed by the control itself
- */
-public class Base64ToImageConverter extends Converter
-{
- private Image lastImage;
- private Display display;
-
- /**
- * Create a new converter
- * @param display the display the images are created on
- */
- public Base64ToImageConverter(Display display)
- {
- super(String.class, Image.class);
- this.display = display;
- }
-
- public Object convert(Object fromObject)
- {
- if (lastImage != null && !lastImage.isDisposed())
- {
- lastImage.dispose();
- lastImage = null;
- }
-
- if (fromObject != null)
- {
- ByteArrayInputStream in = new ByteArrayInputStream(XMLTypeFactory.eINSTANCE.createBase64Binary(fromObject.toString()));
- Image img = new Image(display, in);
-
- try
- {
- in.close();
- }
- catch (IOException e)
- {
-
- }
-
- lastImage = img;
-
- return img;
- }
-
- return null;
- }
-}
+/**
+ * Copyright (c) 2009 Bestsolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl<tom.schindl@bestsolution.at> - Initial API and implementation
+ */
+package org.eclipse.emf.example.databinding.project.ui.rcp.databinding;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+
+import org.eclipse.core.databinding.conversion.Converter;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+
+import org.eclipse.emf.ecore.xml.type.XMLTypeFactory;
+import org.eclipse.emf.example.databinding.project.ui.rcp.Activator;
+
+
+/**
+ * Converter which able to convert base64 encoded values into SWT-images.
+ * The convert remembers the last created image and disposes when a new one is allocated but the
+ * last image set on the control has to be disposed by the control itself
+ */
+public class Base64ToImageConverter extends Converter
+{
+ private Image lastImage;
+ private Display display;
+
+ /**
+ * Create a new converter
+ * @param display the display the images are created on
+ */
+ public Base64ToImageConverter(Display display)
+ {
+ super(String.class, Image.class);
+ this.display = display;
+ }
+
+ public Object convert(Object fromObject)
+ {
+ if (lastImage != null && !lastImage.isDisposed())
+ {
+ lastImage.dispose();
+ lastImage = null;
+ }
+
+ if (fromObject != null)
+ {
+ ByteArrayInputStream in = new ByteArrayInputStream(XMLTypeFactory.eINSTANCE.createBase64Binary(fromObject.toString()));
+ Image img = new Image(display, in);
+
+ try
+ {
+ in.close();
+ }
+ catch (IOException e)
+ {
+ Activator.getDefault().log(e);
+ }
+
+ lastImage = img;
+
+ return img;
+ }
+
+ return null;
+ }
+}
diff --git a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/databinding/StringToDateConverter.java b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/databinding/StringToDateConverter.java
index 302cbc5f9..99d0d6ccf 100644
--- a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/databinding/StringToDateConverter.java
+++ b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/databinding/StringToDateConverter.java
@@ -1,82 +1,82 @@
-/**
- * Copyright (c) 2009 Bestsolution.at and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Tom Schindl<tom.schindl@bestsolution.at> - Initial API and implementation
- */
-package org.eclipse.emf.example.databinding.project.ui.rcp.databinding;
-
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import org.eclipse.core.databinding.conversion.Converter;
-import org.eclipse.core.databinding.validation.IValidator;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-
-import org.eclipse.emf.example.databinding.project.ui.rcp.Activator;
-
-
-/**
- * Convert a String to a date
- */
-public class StringToDateConverter extends Converter implements IValidator
-{
- private List<DateFormat> formats = new ArrayList<DateFormat>();
- private String message;
-
- /**
- * New converter
- * @param message message when conversion fails
- */
- public StringToDateConverter(String message)
- {
- super(String.class, Date.class);
- this.message = message;
- formats.add(DateFormat.getDateInstance(DateFormat.SHORT));
- formats.add(new SimpleDateFormat("yyyy-MM-dd"));
- }
-
- public Object convert(Object fromObject)
- {
- if (fromObject != null && fromObject.toString().trim().length() == 0)
- {
- return null;
- }
-
- for (DateFormat f : formats)
- {
- try
- {
- return f.parse(fromObject.toString());
- }
- catch (ParseException e)
- {
- // Ignore
- }
- }
-
- throw new RuntimeException(message);
- }
-
- public IStatus validate(Object value)
- {
- try
- {
- convert(value);
- }
- catch (Exception e)
- {
- return new Status(IStatus.ERROR, Activator.PLUGIN_ID, message);
- }
- return Status.OK_STATUS;
- }
+/**
+ * Copyright (c) 2009 Bestsolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl<tom.schindl@bestsolution.at> - Initial API and implementation
+ */
+package org.eclipse.emf.example.databinding.project.ui.rcp.databinding;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.eclipse.core.databinding.conversion.Converter;
+import org.eclipse.core.databinding.validation.IValidator;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+import org.eclipse.emf.example.databinding.project.ui.rcp.Activator;
+
+
+/**
+ * Convert a String to a date
+ */
+public class StringToDateConverter extends Converter implements IValidator
+{
+ private List<DateFormat> formats = new ArrayList<DateFormat>();
+ private String message;
+
+ /**
+ * New converter
+ * @param message message when conversion fails
+ */
+ public StringToDateConverter(String message)
+ {
+ super(String.class, Date.class);
+ this.message = message;
+ formats.add(DateFormat.getDateInstance(DateFormat.SHORT));
+ formats.add(new SimpleDateFormat("yyyy-MM-dd"));
+ }
+
+ public Object convert(Object fromObject)
+ {
+ if (fromObject == null || fromObject.toString().trim().length() == 0)
+ {
+ return null;
+ }
+
+ for (DateFormat f : formats)
+ {
+ try
+ {
+ return f.parse(fromObject.toString());
+ }
+ catch (ParseException e)
+ {
+ // Ignore
+ }
+ }
+
+ throw new RuntimeException(message);
+ }
+
+ public IStatus validate(Object value)
+ {
+ try
+ {
+ convert(value);
+ }
+ catch (Exception e)
+ {
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, message);
+ }
+ return Status.OK_STATUS;
+ }
} \ No newline at end of file
diff --git a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/dialogs/CommitterShipDialog.java b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/dialogs/CommitterShipDialog.java
index 714176ac8..3f76e9952 100644
--- a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/dialogs/CommitterShipDialog.java
+++ b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/dialogs/CommitterShipDialog.java
@@ -1,200 +1,200 @@
-/**
- * Copyright (c) 2009 Bestsolution.at and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Tom Schindl<tom.schindl@bestsolution.at> - Initial API and implementation
- */
-package org.eclipse.emf.example.databinding.project.ui.rcp.dialogs;
-
-import org.eclipse.core.databinding.DataBindingContext;
-import org.eclipse.core.databinding.ObservablesManager;
-import org.eclipse.core.databinding.conversion.Converter;
-import org.eclipse.jface.databinding.dialog.TitleAreaDialogSupport;
-import org.eclipse.jface.databinding.swt.IWidgetValueProperty;
-import org.eclipse.jface.databinding.swt.WidgetProperties;
-import org.eclipse.jface.dialogs.TitleAreaDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.custom.ViewForm;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-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.dialogs.FilteredItemsSelectionDialog;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.databinding.EMFDataBindingContext;
-import org.eclipse.emf.databinding.EMFUpdateValueStrategy;
-import org.eclipse.emf.databinding.edit.EMFEditProperties;
-import org.eclipse.emf.databinding.edit.IEMFEditValueProperty;
-import org.eclipse.emf.edit.command.SetCommand;
-import org.eclipse.emf.example.databinding.project.ui.rcp.databinding.EMFObservablesManager;
-import org.eclipse.emf.example.databinding.project.ui.rcp.databinding.UpdateStrategyFactory;
-import org.eclipse.emf.examples.databinding.project.core.IModelResource;
-import org.eclipse.emf.examples.databinding.project.core.model.project.CommitterShip;
-import org.eclipse.emf.examples.databinding.project.core.model.project.Person;
-import org.eclipse.emf.examples.databinding.project.core.model.project.ProjectPackage;
-
-
-/**
- * Dialog to edit the committer ship
- */
-public class CommitterShipDialog extends TitleAreaDialog
-{
- private final DataBindingContext ctx;
- private final CommitterShip committership;
- final IModelResource resource;
- private final boolean isnew;
-
- /**
- * Create new dialog
- * @param parentShell the parent shell
- * @param resource the resource
- * @param committership the committership instance
- * @param isnew flag to indicate if the committer ship is new
- */
- public CommitterShipDialog(Shell parentShell, IModelResource resource, CommitterShip committership, boolean isnew)
- {
- super(parentShell);
- this.committership = committership;
- this.resource = resource;
- this.isnew = isnew;
- this.ctx = new EMFDataBindingContext();
- }
-
- @Override
- protected Control createDialogArea(Composite parent)
- {
- getShell().setText("Edit Committership");
- setTitle("Edit Committership");
- setMessage("Edit the committership of a person in the project");
-
- final Composite comp = (Composite)super.createDialogArea(parent);
-
- ObservablesManager mgr = new EMFObservablesManager();
- mgr.runAndCollect(new Runnable()
- {
-
- public void run()
- {
- createForm(comp).setLayoutData(new GridData(GridData.FILL_BOTH));
- }
-
- });
-
- return comp;
- }
-
- private Control createForm(final Composite comp)
- {
-
- Composite container = new Composite(comp, SWT.NONE);
- container.setLayout(new GridLayout(3, false));
-
- {
- Label l = new Label(container, SWT.NONE);
- l.setText("Committer");
-
- IEMFEditValueProperty mprop = EMFEditProperties.value(resource.getEditingDomain(), ProjectPackage.Literals.COMMITTER_SHIP__PERSON);
-
- ViewForm form = new ViewForm(container, SWT.BORDER | SWT.FLAT);
- form.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- CLabel label = new CLabel(form, SWT.NONE);
- form.setContent(label);
-
- ctx.bindValue(
- WidgetProperties.text().observe(label),
- mprop.observe(committership),
- null,
- new EMFUpdateValueStrategy().setConverter(new PersonToStringConverter()));
-
- Button b = new Button(container, SWT.PUSH);
- b.setText("...");
- b.setEnabled(isnew);
- b.addSelectionListener(new SelectionAdapter()
- {
- @Override
- public void widgetSelected(SelectionEvent e)
- {
- FilteredItemsSelectionDialog dialog = new PersonFilterDialog(comp.getShell(), resource);
- dialog.open();
- Person p = (Person)dialog.getFirstResult();
-
- if (p != null)
- {
- Command cmd = SetCommand.create(resource.getEditingDomain(), committership, ProjectPackage.Literals.COMMITTER_SHIP__PERSON, p);
- if (cmd.canExecute())
- {
- resource.executeCmd(cmd);
- }
- }
- }
- });
- }
-
- IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify);
-
- {
- Label l = new Label(container, SWT.NONE);
- l.setText("Startdate");
-
- IEMFEditValueProperty mprop = EMFEditProperties.value(resource.getEditingDomain(), ProjectPackage.Literals.COMMITTER_SHIP__START);
-
- Text t = new Text(container, SWT.BORDER);
- t.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 2, 1));
-
- ctx.bindValue(textProp.observe(t), mprop.observe(committership), UpdateStrategyFactory.stringToDateNotNull(
- "Can't convert start date value into a valid date",
- "The start date can not be null"), UpdateStrategyFactory.dateToString());
- }
-
- {
- Label l = new Label(container, SWT.NONE);
- l.setText("Enddate");
-
- IEMFEditValueProperty mprop = EMFEditProperties.value(resource.getEditingDomain(), ProjectPackage.Literals.COMMITTER_SHIP__END);
-
- Text t = new Text(container, SWT.BORDER);
- t.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 2, 1));
-
- ctx.bindValue(
- textProp.observe(t),
- mprop.observe(committership),
- UpdateStrategyFactory.stringToDate("Can't convert end date value into a valid date"),
- UpdateStrategyFactory.dateToString());
- }
-
- TitleAreaDialogSupport.create(this, ctx);
-
- return container;
- }
-
- private class PersonToStringConverter extends Converter
- {
- public PersonToStringConverter()
- {
- super(Person.class, String.class);
- }
-
- public Object convert(Object fromObject)
- {
- if (fromObject != null)
- {
- Person p = (Person)fromObject;
- return p.getLastname() + ", " + p.getFirstname();
- }
-
- return null;
- }
- };
+/**
+ * Copyright (c) 2009 Bestsolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl<tom.schindl@bestsolution.at> - Initial API and implementation
+ */
+package org.eclipse.emf.example.databinding.project.ui.rcp.dialogs;
+
+import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.databinding.ObservablesManager;
+import org.eclipse.core.databinding.conversion.Converter;
+import org.eclipse.jface.databinding.dialog.TitleAreaDialogSupport;
+import org.eclipse.jface.databinding.swt.IWidgetValueProperty;
+import org.eclipse.jface.databinding.swt.WidgetProperties;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.custom.ViewForm;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+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.dialogs.FilteredItemsSelectionDialog;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.databinding.EMFDataBindingContext;
+import org.eclipse.emf.databinding.EMFUpdateValueStrategy;
+import org.eclipse.emf.databinding.edit.EMFEditProperties;
+import org.eclipse.emf.databinding.edit.IEMFEditValueProperty;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.example.databinding.project.ui.rcp.databinding.EMFObservablesManager;
+import org.eclipse.emf.example.databinding.project.ui.rcp.databinding.UpdateStrategyFactory;
+import org.eclipse.emf.examples.databinding.project.core.IModelResource;
+import org.eclipse.emf.examples.databinding.project.core.model.project.CommitterShip;
+import org.eclipse.emf.examples.databinding.project.core.model.project.Person;
+import org.eclipse.emf.examples.databinding.project.core.model.project.ProjectPackage;
+
+
+/**
+ * Dialog to edit the committer ship
+ */
+public class CommitterShipDialog extends TitleAreaDialog
+{
+ private final DataBindingContext ctx;
+ private final CommitterShip committership;
+ final IModelResource resource;
+ private final boolean isnew;
+
+ /**
+ * Create new dialog
+ * @param parentShell the parent shell
+ * @param resource the resource
+ * @param committership the committership instance
+ * @param isnew flag to indicate if the committer ship is new
+ */
+ public CommitterShipDialog(Shell parentShell, IModelResource resource, CommitterShip committership, boolean isnew)
+ {
+ super(parentShell);
+ this.committership = committership;
+ this.resource = resource;
+ this.isnew = isnew;
+ this.ctx = new EMFDataBindingContext();
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent)
+ {
+ getShell().setText("Edit Committership");
+ setTitle("Edit Committership");
+ setMessage("Edit the committership of a person in the project");
+
+ final Composite comp = (Composite)super.createDialogArea(parent);
+
+ ObservablesManager mgr = new EMFObservablesManager();
+ mgr.runAndCollect(new Runnable()
+ {
+
+ public void run()
+ {
+ createForm(comp).setLayoutData(new GridData(GridData.FILL_BOTH));
+ }
+
+ });
+
+ return comp;
+ }
+
+ private Control createForm(final Composite comp)
+ {
+
+ Composite container = new Composite(comp, SWT.NONE);
+ container.setLayout(new GridLayout(3, false));
+
+ {
+ Label l = new Label(container, SWT.NONE);
+ l.setText("Committer");
+
+ IEMFEditValueProperty mprop = EMFEditProperties.value(resource.getEditingDomain(), ProjectPackage.Literals.COMMITTER_SHIP__PERSON);
+
+ ViewForm form = new ViewForm(container, SWT.BORDER | SWT.FLAT);
+ form.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ CLabel label = new CLabel(form, SWT.NONE);
+ form.setContent(label);
+
+ ctx.bindValue(
+ WidgetProperties.text().observe(label),
+ mprop.observe(committership),
+ null,
+ new EMFUpdateValueStrategy().setConverter(new PersonToStringConverter()));
+
+ Button b = new Button(container, SWT.PUSH);
+ b.setText("...");
+ b.setEnabled(isnew);
+ b.addSelectionListener(new SelectionAdapter()
+ {
+ @Override
+ public void widgetSelected(SelectionEvent e)
+ {
+ FilteredItemsSelectionDialog dialog = new PersonFilterDialog(comp.getShell(), resource);
+ dialog.open();
+ Person p = (Person)dialog.getFirstResult();
+
+ if (p != null)
+ {
+ Command cmd = SetCommand.create(resource.getEditingDomain(), committership, ProjectPackage.Literals.COMMITTER_SHIP__PERSON, p);
+ if (cmd.canExecute())
+ {
+ resource.executeCmd(cmd);
+ }
+ }
+ }
+ });
+ }
+
+ IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify);
+
+ {
+ Label l = new Label(container, SWT.NONE);
+ l.setText("Startdate");
+
+ IEMFEditValueProperty mprop = EMFEditProperties.value(resource.getEditingDomain(), ProjectPackage.Literals.COMMITTER_SHIP__START);
+
+ Text t = new Text(container, SWT.BORDER);
+ t.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 2, 1));
+
+ ctx.bindValue(textProp.observe(t), mprop.observe(committership), UpdateStrategyFactory.stringToDateNotNull(
+ "Can't convert start date value into a valid date",
+ "The start date can not be null"), UpdateStrategyFactory.dateToString());
+ }
+
+ {
+ Label l = new Label(container, SWT.NONE);
+ l.setText("Enddate");
+
+ IEMFEditValueProperty mprop = EMFEditProperties.value(resource.getEditingDomain(), ProjectPackage.Literals.COMMITTER_SHIP__END);
+
+ Text t = new Text(container, SWT.BORDER);
+ t.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 2, 1));
+
+ ctx.bindValue(
+ textProp.observe(t),
+ mprop.observe(committership),
+ UpdateStrategyFactory.stringToDate("Can't convert end date value into a valid date"),
+ UpdateStrategyFactory.dateToString());
+ }
+
+ TitleAreaDialogSupport.create(this, ctx);
+
+ return container;
+ }
+
+ private class PersonToStringConverter extends Converter
+ {
+ public PersonToStringConverter()
+ {
+ super(Person.class, String.class);
+ }
+
+ public Object convert(Object fromObject)
+ {
+ if (fromObject != null)
+ {
+ Person p = (Person)fromObject;
+ return p.getLastname() + ", " + p.getFirstname();
+ }
+
+ return null;
+ }
+ }
} \ No newline at end of file
diff --git a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/handlers/NewXMIHandler.java b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/handlers/NewXMIHandler.java
index 5306c9370..4fe6ae054 100644
--- a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/handlers/NewXMIHandler.java
+++ b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/handlers/NewXMIHandler.java
@@ -1,107 +1,107 @@
-/**
- * Copyright (c) 2009 Bestsolution.at and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Tom Schindl<tom.schindl@bestsolution.at> - Initial API and implementation
- */
-package org.eclipse.emf.example.databinding.project.ui.rcp.handlers;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.net.MalformedURLException;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.expressions.IEvaluationContext;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.ISources;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
-import org.eclipse.emf.example.databinding.project.ui.rcp.views.ProjectAdminViewPart;
-import org.eclipse.emf.examples.databinding.project.core.model.project.Foundation;
-import org.eclipse.emf.examples.databinding.project.core.model.project.ProjectFactory;
-import org.eclipse.emf.examples.databinding.project.core.model.project.ProjectPackage;
-
-
-/**
- * Handles the creation of a new XMI-Resource
- */
-public class NewXMIHandler extends AbstractHandler
-{
-
- public Object execute(ExecutionEvent event) throws ExecutionException
- {
- IEvaluationContext ctx = (IEvaluationContext)event.getApplicationContext();
- Shell shell = (Shell)ctx.getVariable(ISources.ACTIVE_WORKBENCH_WINDOW_SHELL_NAME);
-
- FileDialog dialog = new FileDialog(shell, SWT.SAVE);
- String name = dialog.open();
-
- if (name != null)
- {
- File f = new File(name);
-
- if (!f.exists())
- {
- ResourceSet resourceSet = new ResourceSetImpl();
- resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
- Resource.Factory.Registry.DEFAULT_EXTENSION,
- new XMIResourceFactoryImpl());
- resourceSet.getPackageRegistry().put(ProjectPackage.eNS_URI, ProjectPackage.eINSTANCE);
-
- Resource resource = resourceSet.createResource(URI.createURI("http:///My.project"));
- Foundation root = ProjectFactory.eINSTANCE.createFoundation();
- resource.getContents().add(root);
- try
- {
- FileOutputStream out = new FileOutputStream(f);
- resource.save(out, null);
- out.close();
- }
- catch (FileNotFoundException e)
- {
- e.printStackTrace();
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- }
-
- try
- {
- IWorkbenchWindow w = (IWorkbenchWindow)ctx.getVariable(ISources.ACTIVE_WORKBENCH_WINDOW_NAME);
- String path = f.toURL().toString();
- path = path.replaceAll(":", "#_#");
-
- w.getActivePage().showView(ProjectAdminViewPart.ID, path, IWorkbenchPage.VIEW_ACTIVATE);
- }
- catch (PartInitException e)
- {
- e.printStackTrace();
- }
- catch (MalformedURLException e)
- {
- e.printStackTrace();
- }
- }
-
- return null;
- }
-}
+/**
+ * Copyright (c) 2009 Bestsolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl<tom.schindl@bestsolution.at> - Initial API and implementation
+ */
+package org.eclipse.emf.example.databinding.project.ui.rcp.handlers;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.expressions.IEvaluationContext;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.ISources;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
+import org.eclipse.emf.example.databinding.project.ui.rcp.views.ProjectAdminViewPart;
+import org.eclipse.emf.examples.databinding.project.core.model.project.Foundation;
+import org.eclipse.emf.examples.databinding.project.core.model.project.ProjectFactory;
+import org.eclipse.emf.examples.databinding.project.core.model.project.ProjectPackage;
+
+
+/**
+ * Handles the creation of a new XMI-Resource
+ */
+public class NewXMIHandler extends AbstractHandler
+{
+
+ public Object execute(ExecutionEvent event) throws ExecutionException
+ {
+ IEvaluationContext ctx = (IEvaluationContext)event.getApplicationContext();
+ Shell shell = (Shell)ctx.getVariable(ISources.ACTIVE_WORKBENCH_WINDOW_SHELL_NAME);
+
+ FileDialog dialog = new FileDialog(shell, SWT.SAVE);
+ String name = dialog.open();
+
+ if (name != null)
+ {
+ File f = new File(name);
+
+ if (!f.exists())
+ {
+ ResourceSet resourceSet = new ResourceSetImpl();
+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
+ Resource.Factory.Registry.DEFAULT_EXTENSION,
+ new XMIResourceFactoryImpl());
+ resourceSet.getPackageRegistry().put(ProjectPackage.eNS_URI, ProjectPackage.eINSTANCE);
+
+ Resource resource = resourceSet.createResource(URI.createURI("http:///My.project"));
+ Foundation root = ProjectFactory.eINSTANCE.createFoundation();
+ resource.getContents().add(root);
+ try
+ {
+ FileOutputStream out = new FileOutputStream(f);
+ resource.save(out, null);
+ out.close();
+ }
+ catch (FileNotFoundException e)
+ {
+ e.printStackTrace();
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ try
+ {
+ IWorkbenchWindow w = (IWorkbenchWindow)ctx.getVariable(ISources.ACTIVE_WORKBENCH_WINDOW_NAME);
+ String path = f.toURI().toURL().toString();
+ path = path.replaceAll(":", "#_#");
+
+ w.getActivePage().showView(ProjectAdminViewPart.ID, path, IWorkbenchPage.VIEW_ACTIVATE);
+ }
+ catch (PartInitException e)
+ {
+ e.printStackTrace();
+ }
+ catch (MalformedURLException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/handlers/OpenXMIHandler.java b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/handlers/OpenXMIHandler.java
index 89b0e3d4f..e4c58357a 100644
--- a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/handlers/OpenXMIHandler.java
+++ b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/handlers/OpenXMIHandler.java
@@ -1,69 +1,69 @@
-/**
- * Copyright (c) 2009 Bestsolution.at and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Tom Schindl<tom.schindl@bestsolution.at> - Initial API and implementation
- */
-package org.eclipse.emf.example.databinding.project.ui.rcp.handlers;
-
-import java.io.File;
-import java.net.MalformedURLException;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.expressions.IEvaluationContext;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.ISources;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-
-import org.eclipse.emf.example.databinding.project.ui.rcp.views.ProjectAdminViewPart;
-
-
-/**
- * Handles the opening of a XMI-Resource
- */
-public class OpenXMIHandler extends AbstractHandler
-{
-
- public Object execute(ExecutionEvent event) throws ExecutionException
- {
- IEvaluationContext ctx = (IEvaluationContext)event.getApplicationContext();
- Shell shell = (Shell)ctx.getVariable(ISources.ACTIVE_WORKBENCH_WINDOW_SHELL_NAME);
-
- FileDialog dialog = new FileDialog(shell, SWT.OPEN);
- String name = dialog.open();
-
- if (name != null)
- {
- File f = new File(name);
- try
- {
- IWorkbenchWindow w = (IWorkbenchWindow)ctx.getVariable(ISources.ACTIVE_WORKBENCH_WINDOW_NAME);
- String path = f.toURL().toString();
- path = path.replaceAll(":", "#_#");
-
- w.getActivePage().showView(ProjectAdminViewPart.ID, path, IWorkbenchPage.VIEW_ACTIVATE);
- }
- catch (PartInitException e)
- {
- e.printStackTrace();
- }
- catch (MalformedURLException e)
- {
- e.printStackTrace();
- }
- }
-
- return null;
- }
-
-}
+/**
+ * Copyright (c) 2009 Bestsolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl<tom.schindl@bestsolution.at> - Initial API and implementation
+ */
+package org.eclipse.emf.example.databinding.project.ui.rcp.handlers;
+
+import java.io.File;
+import java.net.MalformedURLException;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.expressions.IEvaluationContext;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.ISources;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+
+import org.eclipse.emf.example.databinding.project.ui.rcp.views.ProjectAdminViewPart;
+
+
+/**
+ * Handles the opening of a XMI-Resource
+ */
+public class OpenXMIHandler extends AbstractHandler
+{
+
+ public Object execute(ExecutionEvent event) throws ExecutionException
+ {
+ IEvaluationContext ctx = (IEvaluationContext)event.getApplicationContext();
+ Shell shell = (Shell)ctx.getVariable(ISources.ACTIVE_WORKBENCH_WINDOW_SHELL_NAME);
+
+ FileDialog dialog = new FileDialog(shell, SWT.OPEN);
+ String name = dialog.open();
+
+ if (name != null)
+ {
+ File f = new File(name);
+ try
+ {
+ IWorkbenchWindow w = (IWorkbenchWindow)ctx.getVariable(ISources.ACTIVE_WORKBENCH_WINDOW_NAME);
+ String path = f.toURI().toURL().toString();
+ path = path.replaceAll(":", "#_#");
+
+ w.getActivePage().showView(ProjectAdminViewPart.ID, path, IWorkbenchPage.VIEW_ACTIVATE);
+ }
+ catch (PartInitException e)
+ {
+ e.printStackTrace();
+ }
+ catch (MalformedURLException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ return null;
+ }
+
+}
diff --git a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/views/ProjectAdminViewPart.java b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/views/ProjectAdminViewPart.java
index df6437d9d..f9d3b3891 100644
--- a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/views/ProjectAdminViewPart.java
+++ b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/views/ProjectAdminViewPart.java
@@ -1,285 +1,294 @@
-/**
- * Copyright (c) 2009 Bestsolution.at and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Tom Schindl<tom.schindl@bestsolution.at> - Initial API and implementation
- */
-package org.eclipse.emf.example.databinding.project.ui.rcp.views;
-
-import org.eclipse.core.databinding.ObservablesManager;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IPartListener2;
-import org.eclipse.ui.ISaveablePart2;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.part.ViewPart;
-import org.eclipse.ui.services.ISourceProviderService;
-
-import org.eclipse.emf.examples.databinding.project.core.IModelResource;
-import org.eclipse.emf.examples.databinding.project.core.model.project.Project;
-import org.eclipse.emf.example.databinding.project.ui.rcp.Activator;
-import org.eclipse.emf.example.databinding.project.ui.rcp.ResourceProvider;
-import org.eclipse.emf.example.databinding.project.ui.rcp.databinding.EMFObservablesManager;
-
-
-/**
- * The workbench part displayed to the user
- */
-public class ProjectAdminViewPart extends ViewPart implements ISaveablePart2
-{
- /**
- * Id of the view
- */
- public static final String ID = "org.eclipse.emf.example.databinding.project.ui.rcp.views.ProjectAdminViewPart";
-
- private SashForm sashForm;
-
- private FormToolkit toolkit;
-
- private float divider = 0.2f;
- private static final String DIVIDER_KEY = Activator.PLUGIN_ID + ".divider";
-
- private ObservablesManager mgr;
- private ObservablesManager defaultMgr;
- private IModelResource resource;
-
- private ProjectExplorerPart projectExplorer;
- private ProjectFormAreaPart projectDataForm;
- private IPartListener2 listener;
- private UndoAction undoAction;
- private RedoAction redoAction;
- private IModelResource.Listener modelListener;
-
- @Override
- public void init(final IViewSite site, IMemento memento) throws PartInitException
- {
- super.init(site, memento);
- if (memento != null && memento.getFloat(DIVIDER_KEY) != null)
- {
- divider = memento.getFloat(DIVIDER_KEY);
- }
-
- listener = new PartListenerImpl(site);
- site.getPage().addPartListener(listener);
- }
-
- @Override
- public void saveState(IMemento memento)
- {
- super.saveState(memento);
- int total = sashForm.getWeights()[0] + sashForm.getWeights()[1];
- memento.putFloat(DIVIDER_KEY, sashForm.getWeights()[0] * 1.f / total);
- }
-
- @Override
- public void createPartControl(Composite parent)
- {
- String path = getViewSite().getSecondaryId().replaceAll("#_#", ":");
-
- resource = Activator.getDefault().loadResource(path); //FIXME This needs to be a real URI
- modelListener = new IModelResource.Listener()
- {
-
- public void dirtyStateChanged()
- {
- firePropertyChange(PROP_DIRTY);
- }
-
- public void commandStackChanged()
- {
- }
-
- };
-
- resource.addListener(modelListener);
-
- if (resource == null)
- {
- throw new RuntimeException("Could not load resource!");
- }
-
- toolkit = new FormToolkit(parent.getDisplay());
- sashForm = new SashForm(parent, SWT.HORIZONTAL);
-
- /*
- * Track the creation of observables so that we don't leak listeners
- * when the view part is closed
- */
- mgr = new EMFObservablesManager();
- defaultMgr = new ObservablesManager();
- mgr.runAndCollect(new Runnable()
- {
-
- public void run()
- {
- projectExplorer = new ProjectExplorerPart(getViewSite(), sashForm, toolkit, resource.getFoundation(), defaultMgr);
- projectDataForm = new ProjectFormAreaPart(
- getViewSite(),
- sashForm,
- toolkit,
- resource,
- defaultMgr,
- projectExplorer.getProjectObservable());
- }
- });
-
- int left = (int)(100 * divider);
- sashForm.setWeights(new int []{ left, 100 - left });
-
- makeActions();
-
- }
-
- private void makeActions()
- {
- undoAction = new UndoAction(resource);
- redoAction = new RedoAction(resource);
-
- getViewSite().getActionBars().setGlobalActionHandler(ActionFactory.UNDO.getId(), undoAction);
- getViewSite().getActionBars().setGlobalActionHandler(ActionFactory.REDO.getId(), redoAction);
- }
-
- @Override
- public void setFocus()
- {
- projectExplorer.setFocus();
- }
-
- @Override
- public void dispose()
- {
- if (undoAction != null)
- undoAction.dispose();
-
- if (redoAction != null)
- redoAction.dispose();
-
- if (modelListener != null && resource != null)
- resource.removeListener(modelListener);
-
- ISourceProviderService s = (ISourceProviderService)getSite().getService(ISourceProviderService.class);
- ResourceProvider p = (ResourceProvider)s.getSourceProvider(ResourceProvider.MODEL_RESOURCE_NAME);
- p.setModelResource(null);
- getSite().getPage().removePartListener(listener);
-
- projectDataForm.dispose();
- projectExplorer.dispose();
-
- if (toolkit != null)
- {
- toolkit.dispose();
- }
-
- if (defaultMgr != null)
- {
- defaultMgr.dispose();
- }
-
- if (mgr != null)
- {
- mgr.dispose();
- }
-
- super.dispose();
- }
-
- private class PartListenerImpl implements IPartListener2
- {
- private IViewSite site;
-
- public PartListenerImpl(IViewSite site)
- {
- this.site = site;
- }
-
- public void partVisible(IWorkbenchPartReference partRef)
- {
- }
-
- public void partOpened(IWorkbenchPartReference partRef)
- {
- }
-
- public void partInputChanged(IWorkbenchPartReference partRef)
- {
- }
-
- public void partHidden(IWorkbenchPartReference partRef)
- {
- }
-
- public void partDeactivated(IWorkbenchPartReference partRef)
- {
- }
-
- public void partClosed(IWorkbenchPartReference partRef)
- {
- }
-
- public void partBroughtToTop(IWorkbenchPartReference partRef)
- {
- }
-
- public void partActivated(IWorkbenchPartReference partRef)
- {
- ISourceProviderService s = (ISourceProviderService)site.getService(ISourceProviderService.class);
- ResourceProvider p = (ResourceProvider)s.getSourceProvider(ResourceProvider.MODEL_RESOURCE_NAME);
- p.setModelResource(resource);
- p.setCommitter(projectExplorer.getCommitter());
- p.setProject((Project)projectExplorer.getProjectObservable().getValue());
- }
- }
-
- public int promptToSaveOnClose()
- {
- return ISaveablePart2.DEFAULT;
- }
-
- public void doSave(IProgressMonitor monitor)
- {
- if (resource != null)
- {
- IStatus s = resource.save();
- if (!s.isOK())
- {
- Activator.getDefault().getLog().log(s);
- throw new RuntimeException();
- }
- else
- {
- firePropertyChange(PROP_DIRTY);
- }
- }
- }
-
- public void doSaveAs()
- {
- }
-
- public boolean isDirty()
- {
- return resource.isDirty();
- }
-
- public boolean isSaveAsAllowed()
- {
- return false;
- }
-
- public boolean isSaveOnCloseNeeded()
- {
- return true;
- }
-}
+/**
+ * Copyright (c) 2009 Bestsolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl<tom.schindl@bestsolution.at> - Initial API and implementation
+ */
+package org.eclipse.emf.example.databinding.project.ui.rcp.views;
+
+import org.eclipse.core.databinding.ObservablesManager;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IPartListener2;
+import org.eclipse.ui.ISaveablePart2;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchPartReference;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.part.ViewPart;
+import org.eclipse.ui.services.ISourceProviderService;
+
+import org.eclipse.emf.examples.databinding.project.core.IModelResource;
+import org.eclipse.emf.examples.databinding.project.core.model.project.Project;
+import org.eclipse.emf.example.databinding.project.ui.rcp.Activator;
+import org.eclipse.emf.example.databinding.project.ui.rcp.ResourceProvider;
+import org.eclipse.emf.example.databinding.project.ui.rcp.databinding.EMFObservablesManager;
+
+
+/**
+ * The workbench part displayed to the user
+ */
+public class ProjectAdminViewPart extends ViewPart implements ISaveablePart2
+{
+ /**
+ * Id of the view
+ */
+ public static final String ID = "org.eclipse.emf.example.databinding.project.ui.rcp.views.ProjectAdminViewPart";
+
+ private SashForm sashForm;
+
+ private FormToolkit toolkit;
+
+ private float divider = 0.2f;
+ private static final String DIVIDER_KEY = Activator.PLUGIN_ID + ".divider";
+
+ private ObservablesManager mgr;
+ private ObservablesManager defaultMgr;
+ private IModelResource resource;
+
+ private ProjectExplorerPart projectExplorer;
+ private ProjectFormAreaPart projectDataForm;
+ private IPartListener2 listener;
+ private UndoAction undoAction;
+ private RedoAction redoAction;
+ private IModelResource.Listener modelListener;
+
+ @Override
+ public void init(final IViewSite site, IMemento memento) throws PartInitException
+ {
+ super.init(site, memento);
+ if (memento != null && memento.getFloat(DIVIDER_KEY) != null)
+ {
+ divider = memento.getFloat(DIVIDER_KEY);
+ }
+
+ listener = new PartListenerImpl(site);
+ site.getPage().addPartListener(listener);
+ }
+
+ @Override
+ public void saveState(IMemento memento)
+ {
+ super.saveState(memento);
+ int total = sashForm.getWeights()[0] + sashForm.getWeights()[1];
+ memento.putFloat(DIVIDER_KEY, sashForm.getWeights()[0] * 1.f / total);
+ }
+
+ @Override
+ public void createPartControl(Composite parent)
+ {
+ String path = getViewSite().getSecondaryId().replaceAll("#_#", ":");
+
+ resource = Activator.getDefault().loadResource(path); //FIXME This needs to be a real URI
+ modelListener = new IModelResource.Listener()
+ {
+
+ public void dirtyStateChanged()
+ {
+ firePropertyChange(PROP_DIRTY);
+ }
+
+ public void commandStackChanged()
+ {
+ // Ignore
+ }
+
+ };
+
+ resource.addListener(modelListener);
+
+ if (resource == null)
+ {
+ throw new RuntimeException("Could not load resource!");
+ }
+
+ toolkit = new FormToolkit(parent.getDisplay());
+ sashForm = new SashForm(parent, SWT.HORIZONTAL);
+
+ /*
+ * Track the creation of observables so that we don't leak listeners
+ * when the view part is closed
+ */
+ mgr = new EMFObservablesManager();
+ defaultMgr = new ObservablesManager();
+ mgr.runAndCollect(new Runnable()
+ {
+
+ public void run()
+ {
+ projectExplorer = new ProjectExplorerPart(getViewSite(), sashForm, toolkit, resource.getFoundation(), defaultMgr);
+ projectDataForm = new ProjectFormAreaPart(
+ getViewSite(),
+ sashForm,
+ toolkit,
+ resource,
+ defaultMgr,
+ projectExplorer.getProjectObservable());
+ }
+ });
+
+ int left = (int)(100 * divider);
+ sashForm.setWeights(new int []{ left, 100 - left });
+
+ makeActions();
+
+ }
+
+ private void makeActions()
+ {
+ undoAction = new UndoAction(resource);
+ redoAction = new RedoAction(resource);
+
+ getViewSite().getActionBars().setGlobalActionHandler(ActionFactory.UNDO.getId(), undoAction);
+ getViewSite().getActionBars().setGlobalActionHandler(ActionFactory.REDO.getId(), redoAction);
+ }
+
+ @Override
+ public void setFocus()
+ {
+ projectExplorer.setFocus();
+ }
+
+ @Override
+ public void dispose()
+ {
+ if (undoAction != null)
+ undoAction.dispose();
+
+ if (redoAction != null)
+ redoAction.dispose();
+
+ if (modelListener != null && resource != null)
+ resource.removeListener(modelListener);
+
+ ISourceProviderService s = (ISourceProviderService)getSite().getService(ISourceProviderService.class);
+ ResourceProvider p = (ResourceProvider)s.getSourceProvider(ResourceProvider.MODEL_RESOURCE_NAME);
+ p.setModelResource(null);
+ getSite().getPage().removePartListener(listener);
+
+ projectDataForm.dispose();
+ projectExplorer.dispose();
+
+ if (toolkit != null)
+ {
+ toolkit.dispose();
+ }
+
+ if (defaultMgr != null)
+ {
+ defaultMgr.dispose();
+ }
+
+ if (mgr != null)
+ {
+ mgr.dispose();
+ }
+
+ super.dispose();
+ }
+
+ private class PartListenerImpl implements IPartListener2
+ {
+ private IViewSite site;
+
+ public PartListenerImpl(IViewSite site)
+ {
+ this.site = site;
+ }
+
+ public void partVisible(IWorkbenchPartReference partRef)
+ {
+ // Ignore
+ }
+
+ public void partOpened(IWorkbenchPartReference partRef)
+ {
+ // Ignore
+ }
+
+ public void partInputChanged(IWorkbenchPartReference partRef)
+ {
+ // Ignore
+ }
+
+ public void partHidden(IWorkbenchPartReference partRef)
+ {
+ // Ignore
+ }
+
+ public void partDeactivated(IWorkbenchPartReference partRef)
+ {
+ // Ignore
+ }
+
+ public void partClosed(IWorkbenchPartReference partRef)
+ {
+ // Ignore
+ }
+
+ public void partBroughtToTop(IWorkbenchPartReference partRef)
+ {
+ // Ignore
+ }
+
+ public void partActivated(IWorkbenchPartReference partRef)
+ {
+ ISourceProviderService s = (ISourceProviderService)site.getService(ISourceProviderService.class);
+ ResourceProvider p = (ResourceProvider)s.getSourceProvider(ResourceProvider.MODEL_RESOURCE_NAME);
+ p.setModelResource(resource);
+ p.setCommitter(projectExplorer.getCommitter());
+ p.setProject((Project)projectExplorer.getProjectObservable().getValue());
+ }
+ }
+
+ public int promptToSaveOnClose()
+ {
+ return ISaveablePart2.DEFAULT;
+ }
+
+ public void doSave(IProgressMonitor monitor)
+ {
+ if (resource != null)
+ {
+ IStatus s = resource.save();
+ if (!s.isOK())
+ {
+ Activator.getDefault().getLog().log(s);
+ throw new RuntimeException();
+ }
+ else
+ {
+ firePropertyChange(PROP_DIRTY);
+ }
+ }
+ }
+
+ public void doSaveAs()
+ {
+ // Ignore
+ }
+
+ public boolean isDirty()
+ {
+ return resource.isDirty();
+ }
+
+ public boolean isSaveAsAllowed()
+ {
+ return false;
+ }
+
+ public boolean isSaveOnCloseNeeded()
+ {
+ return true;
+ }
+}
diff --git a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/views/ProjectCommittersPart.java b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/views/ProjectCommittersPart.java
index c94e76099..beeed8921 100644
--- a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/views/ProjectCommittersPart.java
+++ b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/views/ProjectCommittersPart.java
@@ -1,202 +1,203 @@
-/**
- * Copyright (c) 2009 Bestsolution.at and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Tom Schindl<tom.schindl@bestsolution.at> - Initial API and implementation
- */
-package org.eclipse.emf.example.databinding.project.ui.rcp.views;
-
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-
-import org.eclipse.core.databinding.DataBindingContext;
-import org.eclipse.core.databinding.ObservablesManager;
-import org.eclipse.core.databinding.conversion.Converter;
-import org.eclipse.core.databinding.observable.map.IObservableMap;
-import org.eclipse.core.databinding.observable.value.IObservableValue;
-import org.eclipse.core.databinding.property.list.IListProperty;
-import org.eclipse.core.databinding.property.value.IValueProperty;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.databinding.swt.WidgetProperties;
-import org.eclipse.jface.databinding.viewers.ObservableListContentProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CTabFolder;
-import org.eclipse.swt.custom.CTabItem;
-import org.eclipse.ui.IViewSite;
-
-import org.eclipse.emf.databinding.EMFUpdateValueStrategy;
-import org.eclipse.emf.databinding.FeaturePath;
-import org.eclipse.emf.databinding.edit.EMFEditProperties;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.example.databinding.project.ui.rcp.Activator;
-import org.eclipse.emf.example.databinding.project.ui.rcp.databinding.GenericMapCellLabelProvider;
-import org.eclipse.emf.examples.databinding.project.core.model.project.CommitterShip;
-import org.eclipse.emf.examples.databinding.project.core.model.project.ProjectPackage;
-
-
-/**
- * Part showing the current committers
- */
-public class ProjectCommittersPart
-{
- private static final String END_DATE_PROPERTY = "enddate";
-
- /**
- * Create a new part
- * @param site the site
- * @param folder the folder where shown
- * @param ctx the databinding context
- * @param editingDomain the editing domain to make changes
- * @param manager manager for observables to avoid leaks
- * @param master the master observable
- */
- public ProjectCommittersPart(
- IViewSite site,
- CTabFolder folder,
- DataBindingContext ctx,
- EditingDomain editingDomain,
- ObservablesManager manager,
- IObservableValue master)
- {
- init(site, folder, ctx, editingDomain, master);
- }
-
- private void init(IViewSite site, CTabFolder folder, DataBindingContext ctx, EditingDomain editingDomain, IObservableValue master)
- {
- final TableViewer viewer = new TableViewer(folder, SWT.FULL_SELECTION);
-
- {
- IValueProperty prop = EMFEditProperties.value(editingDomain, ProjectPackage.Literals.PROJECT__COMMITTERS);
- CTabItem item = new CTabItem(folder, SWT.NONE);
- item.setControl(viewer.getControl());
-
- ctx.bindValue(
- WidgetProperties.text().observe(item),
- prop.observeDetail(master),
- new EMFUpdateValueStrategy(),
- new EMFUpdateValueStrategy().setConverter(new LengthConverter()));
- }
-
- folder.setSelection(0);
-
- viewer.getTable().setHeaderVisible(true);
- ObservableListContentProvider cp = new ObservableListContentProvider();
-
- {
- IObservableMap[] attributeMap = new IObservableMap [2];
- attributeMap[0] = EMFEditProperties.value(
- editingDomain,
- FeaturePath.fromList(ProjectPackage.Literals.COMMITTER_SHIP__PERSON, ProjectPackage.Literals.PERSON__LASTNAME)).observeDetail(
- cp.getKnownElements());
- attributeMap[1] = EMFEditProperties.value(
- editingDomain,
- FeaturePath.fromList(ProjectPackage.Literals.COMMITTER_SHIP__PERSON, ProjectPackage.Literals.PERSON__FIRSTNAME)).observeDetail(
- cp.getKnownElements());
-
- TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
- column.getColumn().setText("Name");
- column.getColumn().setWidth(150);
- column.setLabelProvider(new GenericMapCellLabelProvider("{0}, {1}", attributeMap));
- }
-
- {
- IObservableMap attributeMap = EMFEditProperties.value(editingDomain, ProjectPackage.Literals.COMMITTER_SHIP__START).observeDetail(
- cp.getKnownElements());
- TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
- column.getColumn().setText("Start");
- column.getColumn().setWidth(100);
- column.setLabelProvider(new GenericMapCellLabelProvider("{0,date,short}", attributeMap));
- }
-
- {
- IObservableMap attributeMap = EMFEditProperties.value(editingDomain, ProjectPackage.Literals.COMMITTER_SHIP__END).observeDetail(
- cp.getKnownElements());
- TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
- column.getColumn().setText("End");
- column.getColumn().setWidth(100);
- column.setLabelProvider(new GenericMapCellLabelProvider("{0,date,short}", attributeMap));
- }
-
- IListProperty prop = EMFEditProperties.list(editingDomain, ProjectPackage.Literals.PROJECT__COMMITTERS);
- viewer.setContentProvider(cp);
- viewer.setInput(prop.observeDetail(master));
-
- MenuManager mgr = new MenuManager();
- mgr.add(new Action("Hide historic committers", IAction.AS_CHECK_BOX)
- {
- @Override
- public void run()
- {
- if (isChecked())
- {
- viewer.addFilter(new ViewerFilterImpl());
- }
- else
- {
- viewer.setFilters(new ViewerFilter [0]);
- }
- }
- });
-
- viewer.getControl().setMenu(mgr.createContextMenu(viewer.getControl()));
-
- site.registerContextMenu(Activator.PLUGIN_ID + ".committers", mgr, viewer);
- }
-
- private class LengthConverter extends Converter
- {
-
- public LengthConverter()
- {
- super(Collection.class, String.class);
- }
-
- public Object convert(Object fromObject)
- {
- return "Committers (" + (fromObject != null ? ((Collection< ? >)fromObject).size() : "0") + ")";
- }
- }
-
- private class ViewerFilterImpl extends ViewerFilter
- {
- @Override
- public boolean isFilterProperty(Object element, String property)
- {
- if (property != null && property == END_DATE_PROPERTY)
- {
- return true;
- }
- return super.isFilterProperty(element, property);
- }
-
- @Override
- public boolean select(Viewer viewer, Object parentElement, Object element)
- {
- Date enddate = ((CommitterShip)element).getEnd();
- if (enddate == null || enddate.getTime() > Calendar.getInstance().getTimeInMillis())
- {
- return true;
- }
- return false;
- }
-
- }
-
- /**
- * Release all allocated resources
- */
- public void dispose()
- {
- }
-}
+/**
+ * Copyright (c) 2009 Bestsolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl<tom.schindl@bestsolution.at> - Initial API and implementation
+ */
+package org.eclipse.emf.example.databinding.project.ui.rcp.views;
+
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+
+import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.databinding.ObservablesManager;
+import org.eclipse.core.databinding.conversion.Converter;
+import org.eclipse.core.databinding.observable.map.IObservableMap;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.core.databinding.property.list.IListProperty;
+import org.eclipse.core.databinding.property.value.IValueProperty;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.databinding.swt.WidgetProperties;
+import org.eclipse.jface.databinding.viewers.ObservableListContentProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CTabFolder;
+import org.eclipse.swt.custom.CTabItem;
+import org.eclipse.ui.IViewSite;
+
+import org.eclipse.emf.databinding.EMFUpdateValueStrategy;
+import org.eclipse.emf.databinding.FeaturePath;
+import org.eclipse.emf.databinding.edit.EMFEditProperties;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.example.databinding.project.ui.rcp.Activator;
+import org.eclipse.emf.example.databinding.project.ui.rcp.databinding.GenericMapCellLabelProvider;
+import org.eclipse.emf.examples.databinding.project.core.model.project.CommitterShip;
+import org.eclipse.emf.examples.databinding.project.core.model.project.ProjectPackage;
+
+
+/**
+ * Part showing the current committers
+ */
+public class ProjectCommittersPart
+{
+ private static final String END_DATE_PROPERTY = "enddate";
+
+ /**
+ * Create a new part
+ * @param site the site
+ * @param folder the folder where shown
+ * @param ctx the databinding context
+ * @param editingDomain the editing domain to make changes
+ * @param manager manager for observables to avoid leaks
+ * @param master the master observable
+ */
+ public ProjectCommittersPart(
+ IViewSite site,
+ CTabFolder folder,
+ DataBindingContext ctx,
+ EditingDomain editingDomain,
+ ObservablesManager manager,
+ IObservableValue master)
+ {
+ init(site, folder, ctx, editingDomain, master);
+ }
+
+ private void init(IViewSite site, CTabFolder folder, DataBindingContext ctx, EditingDomain editingDomain, IObservableValue master)
+ {
+ final TableViewer viewer = new TableViewer(folder, SWT.FULL_SELECTION);
+
+ {
+ IValueProperty prop = EMFEditProperties.value(editingDomain, ProjectPackage.Literals.PROJECT__COMMITTERS);
+ CTabItem item = new CTabItem(folder, SWT.NONE);
+ item.setControl(viewer.getControl());
+
+ ctx.bindValue(
+ WidgetProperties.text().observe(item),
+ prop.observeDetail(master),
+ new EMFUpdateValueStrategy(),
+ new EMFUpdateValueStrategy().setConverter(new LengthConverter()));
+ }
+
+ folder.setSelection(0);
+
+ viewer.getTable().setHeaderVisible(true);
+ ObservableListContentProvider cp = new ObservableListContentProvider();
+
+ {
+ IObservableMap[] attributeMap = new IObservableMap [2];
+ attributeMap[0] = EMFEditProperties.value(
+ editingDomain,
+ FeaturePath.fromList(ProjectPackage.Literals.COMMITTER_SHIP__PERSON, ProjectPackage.Literals.PERSON__LASTNAME)).observeDetail(
+ cp.getKnownElements());
+ attributeMap[1] = EMFEditProperties.value(
+ editingDomain,
+ FeaturePath.fromList(ProjectPackage.Literals.COMMITTER_SHIP__PERSON, ProjectPackage.Literals.PERSON__FIRSTNAME)).observeDetail(
+ cp.getKnownElements());
+
+ TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
+ column.getColumn().setText("Name");
+ column.getColumn().setWidth(150);
+ column.setLabelProvider(new GenericMapCellLabelProvider("{0}, {1}", attributeMap));
+ }
+
+ {
+ IObservableMap attributeMap = EMFEditProperties.value(editingDomain, ProjectPackage.Literals.COMMITTER_SHIP__START).observeDetail(
+ cp.getKnownElements());
+ TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
+ column.getColumn().setText("Start");
+ column.getColumn().setWidth(100);
+ column.setLabelProvider(new GenericMapCellLabelProvider("{0,date,short}", attributeMap));
+ }
+
+ {
+ IObservableMap attributeMap = EMFEditProperties.value(editingDomain, ProjectPackage.Literals.COMMITTER_SHIP__END).observeDetail(
+ cp.getKnownElements());
+ TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
+ column.getColumn().setText("End");
+ column.getColumn().setWidth(100);
+ column.setLabelProvider(new GenericMapCellLabelProvider("{0,date,short}", attributeMap));
+ }
+
+ IListProperty prop = EMFEditProperties.list(editingDomain, ProjectPackage.Literals.PROJECT__COMMITTERS);
+ viewer.setContentProvider(cp);
+ viewer.setInput(prop.observeDetail(master));
+
+ MenuManager mgr = new MenuManager();
+ mgr.add(new Action("Hide historic committers", IAction.AS_CHECK_BOX)
+ {
+ @Override
+ public void run()
+ {
+ if (isChecked())
+ {
+ viewer.addFilter(new ViewerFilterImpl());
+ }
+ else
+ {
+ viewer.setFilters(new ViewerFilter [0]);
+ }
+ }
+ });
+
+ viewer.getControl().setMenu(mgr.createContextMenu(viewer.getControl()));
+
+ site.registerContextMenu(Activator.PLUGIN_ID + ".committers", mgr, viewer);
+ }
+
+ private class LengthConverter extends Converter
+ {
+
+ public LengthConverter()
+ {
+ super(Collection.class, String.class);
+ }
+
+ public Object convert(Object fromObject)
+ {
+ return "Committers (" + (fromObject != null ? ((Collection< ? >)fromObject).size() : "0") + ")";
+ }
+ }
+
+ private class ViewerFilterImpl extends ViewerFilter
+ {
+ @Override
+ public boolean isFilterProperty(Object element, String property)
+ {
+ if (property != null && property == END_DATE_PROPERTY)
+ {
+ return true;
+ }
+ return super.isFilterProperty(element, property);
+ }
+
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element)
+ {
+ Date enddate = ((CommitterShip)element).getEnd();
+ if (enddate == null || enddate.getTime() > Calendar.getInstance().getTimeInMillis())
+ {
+ return true;
+ }
+ return false;
+ }
+
+ }
+
+ /**
+ * Release all allocated resources
+ */
+ public void dispose()
+ {
+ // Ignore
+ }
+}
diff --git a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/views/ProjectExplorerPart.java b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/views/ProjectExplorerPart.java
index c1e75b0f5..71ac359a1 100644
--- a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/views/ProjectExplorerPart.java
+++ b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/views/ProjectExplorerPart.java
@@ -1,564 +1,573 @@
-/**
- * Copyright (c) 2009 Bestsolution.at and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Tom Schindl<tom.schindl@bestsolution.at> - Initial API and implementation
- */
-package org.eclipse.emf.example.databinding.project.ui.rcp.views;
-
-import java.text.DateFormat;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IExecutionListener;
-import org.eclipse.core.commands.NotHandledException;
-import org.eclipse.core.databinding.ObservablesManager;
-import org.eclipse.core.databinding.observable.IObservable;
-import org.eclipse.core.databinding.observable.list.IObservableList;
-import org.eclipse.core.databinding.observable.map.IMapChangeListener;
-import org.eclipse.core.databinding.observable.map.IObservableMap;
-import org.eclipse.core.databinding.observable.map.MapChangeEvent;
-import org.eclipse.core.databinding.observable.masterdetail.IObservableFactory;
-import org.eclipse.core.databinding.observable.set.IObservableSet;
-import org.eclipse.core.databinding.observable.value.IObservableValue;
-import org.eclipse.core.databinding.observable.value.IValueChangeListener;
-import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
-import org.eclipse.core.databinding.observable.value.WritableValue;
-import org.eclipse.jface.action.GroupMarker;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.databinding.viewers.ObservableListTreeContentProvider;
-import org.eclipse.jface.databinding.viewers.TreeStructureAdvisor;
-import org.eclipse.jface.databinding.viewers.ViewerProperties;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ColumnViewer;
-import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProviderChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.StyledCellLabelProvider;
-import org.eclipse.jface.viewers.StyledString;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.ViewerCell;
-import org.eclipse.jface.window.ToolTip;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.program.Program;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.forms.IFormColors;
-import org.eclipse.ui.forms.events.HyperlinkEvent;
-import org.eclipse.ui.forms.events.IHyperlinkListener;
-import org.eclipse.ui.forms.widgets.Form;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.services.ISourceProviderService;
-
-import org.eclipse.emf.databinding.EMFProperties;
-import org.eclipse.emf.databinding.FeaturePath;
-import org.eclipse.emf.databinding.IEMFListProperty;
-import org.eclipse.emf.example.databinding.project.ui.rcp.Activator;
-import org.eclipse.emf.example.databinding.project.ui.rcp.ResourceProvider;
-import org.eclipse.emf.example.databinding.project.ui.rcp.databinding.Base64ToImageConverter;
-import org.eclipse.emf.example.databinding.project.ui.rcp.handlers.CreateSublevelProjectHandler;
-import org.eclipse.emf.example.databinding.project.ui.rcp.handlers.CreateToplevelProjectHandler;
-import org.eclipse.emf.examples.databinding.project.core.model.project.CommitterShip;
-import org.eclipse.emf.examples.databinding.project.core.model.project.Foundation;
-import org.eclipse.emf.examples.databinding.project.core.model.project.Person;
-import org.eclipse.emf.examples.databinding.project.core.model.project.Project;
-import org.eclipse.emf.examples.databinding.project.core.model.project.ProjectPackage;
-
-
-/**
- * Part responsible for rendering the project tree
- */
-public class ProjectExplorerPart
-{
- private final TreeViewer viewer;
- private FormToolkit toolkit;
-
- private final Image projectImage;
- private final Image committerImage;
- private final IObservableValue master = new WritableValue();
- private final IExecutionListener paramListener;
- private final IViewSite site;
-
- /**
- * Create a new project explorer
- * @param site the view site
- * @param parent the parent control to renderer on
- * @param toolkit the toolkit
- * @param foundation the foundation instance
- * @param manager manager for observables to avoid leaks
- */
- public ProjectExplorerPart(IViewSite site, Composite parent, FormToolkit toolkit, Foundation foundation, ObservablesManager manager)
- {
- this.toolkit = toolkit;
- this.site = site;
-
- ImageDescriptor desc = Activator.imageDescriptorFromPlugin("org.eclipse.ui", "icons/full/obj16/generic_elements.gif");
- if (desc != null)
- {
- projectImage = desc.createImage();
- }
- else
- {
- projectImage = null;
- }
-
- desc = Activator.imageDescriptorFromPlugin("org.eclipse.ui", "icons/full/obj16/signed_yes_tbl.gif");
- if (desc != null)
- {
- committerImage = desc.createImage();
- }
- else
- {
- committerImage = null;
- }
-
- viewer = init(parent, foundation);
-
- paramListener = new CommandListener();
- ICommandService service = (ICommandService)site.getService(ICommandService.class);
- service.addExecutionListener(paramListener);
- }
-
- private TreeViewer init(Composite parent, Foundation foundation)
- {
- TreeViewer viewer = new TreeViewer(parent);
-
- ObservableListTreeContentProvider cp = new ObservableListTreeContentProvider(new TreeFactoryImpl(), new TreeStructureAdvisorImpl());
- viewer.setContentProvider(cp);
-
- IObservableSet set = cp.getKnownElements();
-
- IObservableMap[] map = new IObservableMap [4];
- map[0] = EMFProperties.value(ProjectPackage.Literals.PROJECT__SHORTNAME).observeDetail(set);
- map[1] = EMFProperties.value(ProjectPackage.Literals.PROJECT__COMMITTERS).observeDetail(set);
- map[2] = EMFProperties.value(
- FeaturePath.fromList(ProjectPackage.Literals.COMMITTER_SHIP__PERSON, ProjectPackage.Literals.PERSON__FIRSTNAME)).observeDetail(set);
- map[3] = EMFProperties.value(
- FeaturePath.fromList(ProjectPackage.Literals.COMMITTER_SHIP__PERSON, ProjectPackage.Literals.PERSON__LASTNAME)).observeDetail(set);
-
- viewer.setLabelProvider(new TreeLabelProviderImpl(map));
-
- IEMFListProperty projects = EMFProperties.list(ProjectPackage.Literals.FOUNDATION__PROJECTS);
- viewer.setInput(projects.observe(foundation));
-
- MenuManager mgr = new MenuManager();
- mgr.add(new GroupMarker("additions"));
- viewer.getControl().setMenu(mgr.createContextMenu(viewer.getControl()));
-
- site.registerContextMenu(Activator.PLUGIN_ID + ".projectexp", mgr, viewer);
- site.setSelectionProvider(viewer);
-
- ColumnViewerToolTipSupportImpl.enableFor(viewer, toolkit);
-
- IObservableValue treeObs = ViewerProperties.singleSelection().observe(viewer);
- treeObs.addValueChangeListener(new IValueChangeListener()
- {
-
- public void handleValueChange(ValueChangeEvent event)
- {
- ISourceProviderService s = (ISourceProviderService)site.getService(ISourceProviderService.class);
- ResourceProvider p = (ResourceProvider)s.getSourceProvider(ResourceProvider.MODEL_RESOURCE_NAME);
-
- if (event.diff.getNewValue() instanceof Project)
- {
- Project pr = (Project)event.diff.getNewValue();
- master.setValue(pr);
- p.setCommitter(null);
- p.setProject(pr);
- }
- else if (event.diff.getNewValue() != null)
- {
- CommitterShip cm = (CommitterShip)event.diff.getNewValue();
- master.setValue(cm.getProject());
- p.setCommitter(cm);
- p.setProject(cm.getProject());
- }
- else
- {
- p.setCommitter(null);
- p.setProject(null);
- }
- }
- });
-
- return viewer;
- }
-
- /**
- * @return observable of the current active project in the tree
- */
- public IObservableValue getProjectObservable()
- {
- return master;
- }
-
- private static class TreeFactoryImpl implements IObservableFactory
- {
- private IEMFListProperty multi = EMFProperties.multiList(
- ProjectPackage.Literals.PROJECT__SUBPROJECTS,
- ProjectPackage.Literals.PROJECT__COMMITTERS);
-
- public IObservable createObservable(final Object target)
- {
- if (target instanceof IObservableList)
- {
- return (IObservable)target;
- }
- else if (target instanceof Project)
- {
- return multi.observe(target);
- }
-
- return null;
- }
- }
-
- private static class TreeStructureAdvisorImpl extends TreeStructureAdvisor
- {
- @Override
- public Object getParent(Object element)
- {
- if (element instanceof Project)
- {
- return ((Project)element).getParent();
- }
-
- return null;
- }
-
- @Override
- public Boolean hasChildren(Object element)
- {
- if (element instanceof Project && (((Project)element).getCommitters().size() > 0 || ((Project)element).getSubprojects().size() > 0))
- {
- return Boolean.TRUE;
- }
- return super.hasChildren(element);
- }
- }
-
- private class TreeLabelProviderImpl extends StyledCellLabelProvider
- {
-
- private IMapChangeListener mapChangeListener = new IMapChangeListener()
- {
- public void handleMapChange(MapChangeEvent event)
- {
- Set< ? > affectedElements = event.diff.getChangedKeys();
- if (!affectedElements.isEmpty())
- {
- LabelProviderChangedEvent newEvent = new LabelProviderChangedEvent(TreeLabelProviderImpl.this, affectedElements.toArray());
- fireLabelProviderChanged(newEvent);
- }
- }
- };
-
- public TreeLabelProviderImpl(IObservableMap... attributeMaps)
- {
- for (int i = 0; i < attributeMaps.length; i++)
- {
- attributeMaps[i].addMapChangeListener(mapChangeListener);
- }
- }
-
- @Override
- public String getToolTipText(Object element)
- {
- return "#dummy#";
- }
-
- @Override
- public void update(ViewerCell cell)
- {
- if (cell.getElement() instanceof Project)
- {
- Project p = (Project)cell.getElement();
-
- StyledString styledString = new StyledString(p.getShortname() != null ? p.getShortname() : "*noname*", null);
- String decoration = " (" + p.getCommitters().size() + " Committers)";
- styledString.append(decoration, StyledString.COUNTER_STYLER);
- cell.setText(styledString.getString());
- cell.setImage(projectImage);
- cell.setStyleRanges(styledString.getStyleRanges());
- }
- else if (cell.getElement() instanceof CommitterShip)
- {
- Person p = ((CommitterShip)cell.getElement()).getPerson();
- String value = "*noname*";
- if (p != null)
- {
- value = p.getLastname() + ", " + p.getFirstname();
- }
- StyledString styledString = new StyledString(value, null);
- cell.setText(styledString.getString());
- cell.setForeground(cell.getControl().getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
- cell.setImage(committerImage);
- cell.setStyleRanges(styledString.getStyleRanges());
- }
- }
- }
-
- private static class ColumnViewerToolTipSupportImpl extends ColumnViewerToolTipSupport
- {
- private FormToolkit toolkit;
-
- protected ColumnViewerToolTipSupportImpl(FormToolkit toolkit, ColumnViewer viewer, int style)
- {
- super(viewer, style, false);
- setHideOnMouseDown(false);
- this.toolkit = toolkit;
- }
-
- @Override
- protected Composite createViewerToolTipContentArea(Event event, ViewerCell cell, Composite parent)
- {
- if (cell.getElement() instanceof Project)
- {
- final Project p = (Project)cell.getElement();
-
- StringBuilder b = new StringBuilder();
- for (Person lead : p.getProjectleads())
- {
- if (b.length() > 0)
- {
- b.append(", ");
- }
- b.append(lead.getFirstname() + " " + lead.getLastname());
- }
-
- Form form = toolkit.createForm(parent);
- toolkit.decorateFormHeading(form);
- form.setText(p.getShortname() + " - " + p.getLongname());
- Composite body = form.getBody();
- body.setLayout(new GridLayout(2, false));
-
- toolkit.createLabel(body, "Project creation:").setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
- toolkit.createLabel(body, p.getStart() != null ? DateFormat.getDateInstance().format(p.getStart()) : "");
-
- toolkit.createLabel(body, "Project lead:").setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
- toolkit.createLabel(body, b.toString());
-
- toolkit.createLabel(body, "Committers:").setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
- toolkit.createLabel(body, p.getCommitters().size() + "");
-
- toolkit.createLabel(body, "Mailing-List:").setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
- if (p.getDevmail() != null)
- {
- toolkit.createHyperlink(body, p.getDevmail(), SWT.NONE).addHyperlinkListener(new IHyperlinkListener()
- {
-
- public void linkExited(HyperlinkEvent e)
- {
- }
-
- public void linkEntered(HyperlinkEvent e)
- {
- }
-
- public void linkActivated(HyperlinkEvent e)
- {
- Program.launch(p.getDevmail());
- }
- });
- }
- else
- {
- toolkit.createLabel(body, "-");
- }
-
- toolkit.createLabel(body, "Homepage:").setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
- if (p.getHomepage() != null)
- {
- toolkit.createHyperlink(body, p.getHomepage(), SWT.NONE).addHyperlinkListener(new IHyperlinkListener()
- {
-
- public void linkExited(HyperlinkEvent e)
- {
- }
-
- public void linkEntered(HyperlinkEvent e)
- {
- }
-
- public void linkActivated(HyperlinkEvent e)
- {
- Program.launch(p.getHomepage());
- }
- });
- }
- else
- {
- toolkit.createLabel(body, "-");
- }
-
- return form;
- }
- else
- {
- final CommitterShip committership = (CommitterShip)cell.getElement();
- Form form = toolkit.createForm(parent);
- toolkit.decorateFormHeading(form);
- form.setText(committership.getPerson().getFirstname() + ", " + committership.getPerson().getLastname());
-
- Composite formBody = form.getBody();
- formBody.setLayout(new GridLayout(2, false));
-
- GridData gd = new GridData();
-
- final Label l = toolkit.createLabel(formBody, "");
- l.setLayoutData(gd);
-
- Base64ToImageConverter c = new Base64ToImageConverter(form.getDisplay());
- l.setImage((Image)c.convert(committership.getPerson().getImage()));
- l.addDisposeListener(new DisposeListener()
- {
-
- public void widgetDisposed(DisposeEvent e)
- {
- if (l.getImage() != null)
- l.getImage().dispose();
- }
- });
-
- Composite body = toolkit.createComposite(formBody);
- body.setLayout(new GridLayout(2, false));
-
- toolkit.createLabel(body, "Start:").setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
- toolkit.createLabel(body, committership.getStart() != null ? DateFormat.getDateInstance().format(committership.getStart()) : "");
-
- toolkit.createLabel(body, "End:").setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
- toolkit.createLabel(body, committership.getEnd() != null ? DateFormat.getDateInstance().format(committership.getEnd()) : "");
-
- toolkit.createLabel(body, "E-Mail:").setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
- if (committership.getPerson().getEmail() != null)
- {
- toolkit.createHyperlink(body, committership.getPerson().getEmail(), SWT.NONE).addHyperlinkListener(new IHyperlinkListener()
- {
-
- public void linkExited(HyperlinkEvent e)
- {
- }
-
- public void linkEntered(HyperlinkEvent e)
- {
- }
-
- public void linkActivated(HyperlinkEvent e)
- {
- Program.launch(committership.getPerson().getEmail());
- }
- });
- }
- else
- {
- toolkit.createLabel(body, "");
- }
-
- return form;
- }
- }
-
- static void enableFor(ColumnViewer viewer, FormToolkit toolkit)
- {
- new ColumnViewerToolTipSupportImpl(toolkit, viewer, ToolTip.NO_RECREATE);
- }
- }
-
- /**
- * Set the focus
- */
- public void setFocus()
- {
- viewer.getControl().setFocus();
- if (viewer.getTree().getItemCount() > 0)
- {
- viewer.setSelection(new StructuredSelection(viewer.getTree().getItem(0).getData()));
- }
- }
-
- /**
- * Dispose all resources and remove all listeners
- */
- public void dispose()
- {
- ICommandService service = (ICommandService)site.getService(ICommandService.class);
- service.removeExecutionListener(paramListener);
-
- if (projectImage != null)
- {
- projectImage.dispose();
- }
-
- if (committerImage != null)
- {
- committerImage.dispose();
- }
- }
-
- /**
- * @return the current selected committer
- */
- public CommitterShip getCommitter()
- {
- Object obj = ((IStructuredSelection)viewer.getSelection()).getFirstElement();
- return (CommitterShip)((obj instanceof CommitterShip) ? obj : null);
- }
-
- private class CommandListener implements IExecutionListener
- {
-
- public void preExecute(String commandId, ExecutionEvent event)
- {
- }
-
- public void postExecuteSuccess(String commandId, Object returnValue)
- {
- if (site.getPage() != null && site.getPage().getActivePart() != null && site.getPage().getActivePart().getSite() == site)
- {
- if (commandId.equals(CreateToplevelProjectHandler.ID) && returnValue != null)
- {
- viewer.setSelection(new StructuredSelection(returnValue));
- }
- else if (commandId.equals(CreateSublevelProjectHandler.ID) && returnValue != null)
- {
- Project project = (Project)returnValue;
- List<Project> path = new ArrayList<Project>();
- path.add(project);
- while ((project = project.getParent()) != null)
- {
- path.add(0, project);
- }
-
- viewer.expandToLevel(new TreePath(path.toArray()), 0);
- viewer.setSelection(new TreeSelection(new TreePath(path.toArray())));
- }
- }
- }
-
- public void postExecuteFailure(String commandId, ExecutionException exception)
- {
- }
-
- public void notHandled(String commandId, NotHandledException exception)
- {
- }
- }
-}
+/**
+ * Copyright (c) 2009 Bestsolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl<tom.schindl@bestsolution.at> - Initial API and implementation
+ */
+package org.eclipse.emf.example.databinding.project.ui.rcp.views;
+
+import java.text.DateFormat;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IExecutionListener;
+import org.eclipse.core.commands.NotHandledException;
+import org.eclipse.core.databinding.ObservablesManager;
+import org.eclipse.core.databinding.observable.IObservable;
+import org.eclipse.core.databinding.observable.list.IObservableList;
+import org.eclipse.core.databinding.observable.map.IMapChangeListener;
+import org.eclipse.core.databinding.observable.map.IObservableMap;
+import org.eclipse.core.databinding.observable.map.MapChangeEvent;
+import org.eclipse.core.databinding.observable.masterdetail.IObservableFactory;
+import org.eclipse.core.databinding.observable.set.IObservableSet;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.core.databinding.observable.value.IValueChangeListener;
+import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
+import org.eclipse.core.databinding.observable.value.WritableValue;
+import org.eclipse.jface.action.GroupMarker;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.databinding.viewers.ObservableListTreeContentProvider;
+import org.eclipse.jface.databinding.viewers.TreeStructureAdvisor;
+import org.eclipse.jface.databinding.viewers.ViewerProperties;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProviderChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.StyledCellLabelProvider;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.jface.window.ToolTip;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.program.Program;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.forms.IFormColors;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.events.IHyperlinkListener;
+import org.eclipse.ui.forms.widgets.Form;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.services.ISourceProviderService;
+
+import org.eclipse.emf.databinding.EMFProperties;
+import org.eclipse.emf.databinding.FeaturePath;
+import org.eclipse.emf.databinding.IEMFListProperty;
+import org.eclipse.emf.example.databinding.project.ui.rcp.Activator;
+import org.eclipse.emf.example.databinding.project.ui.rcp.ResourceProvider;
+import org.eclipse.emf.example.databinding.project.ui.rcp.databinding.Base64ToImageConverter;
+import org.eclipse.emf.example.databinding.project.ui.rcp.handlers.CreateSublevelProjectHandler;
+import org.eclipse.emf.example.databinding.project.ui.rcp.handlers.CreateToplevelProjectHandler;
+import org.eclipse.emf.examples.databinding.project.core.model.project.CommitterShip;
+import org.eclipse.emf.examples.databinding.project.core.model.project.Foundation;
+import org.eclipse.emf.examples.databinding.project.core.model.project.Person;
+import org.eclipse.emf.examples.databinding.project.core.model.project.Project;
+import org.eclipse.emf.examples.databinding.project.core.model.project.ProjectPackage;
+
+
+/**
+ * Part responsible for rendering the project tree
+ */
+public class ProjectExplorerPart
+{
+ private final TreeViewer viewer;
+ private FormToolkit toolkit;
+
+ private final Image projectImage;
+ private final Image committerImage;
+ private final IObservableValue master = new WritableValue();
+ private final IExecutionListener paramListener;
+ private final IViewSite site;
+
+ /**
+ * Create a new project explorer
+ * @param site the view site
+ * @param parent the parent control to renderer on
+ * @param toolkit the toolkit
+ * @param foundation the foundation instance
+ * @param manager manager for observables to avoid leaks
+ */
+ public ProjectExplorerPart(IViewSite site, Composite parent, FormToolkit toolkit, Foundation foundation, ObservablesManager manager)
+ {
+ this.toolkit = toolkit;
+ this.site = site;
+
+ ImageDescriptor desc = Activator.imageDescriptorFromPlugin("org.eclipse.ui", "icons/full/obj16/generic_elements.gif");
+ if (desc != null)
+ {
+ projectImage = desc.createImage();
+ }
+ else
+ {
+ projectImage = null;
+ }
+
+ desc = Activator.imageDescriptorFromPlugin("org.eclipse.ui", "icons/full/obj16/signed_yes_tbl.gif");
+ if (desc != null)
+ {
+ committerImage = desc.createImage();
+ }
+ else
+ {
+ committerImage = null;
+ }
+
+ viewer = init(parent, foundation);
+
+ paramListener = new CommandListener();
+ ICommandService service = (ICommandService)site.getService(ICommandService.class);
+ service.addExecutionListener(paramListener);
+ }
+
+ private TreeViewer init(Composite parent, Foundation foundation)
+ {
+ TreeViewer viewer = new TreeViewer(parent);
+
+ ObservableListTreeContentProvider cp = new ObservableListTreeContentProvider(new TreeFactoryImpl(), new TreeStructureAdvisorImpl());
+ viewer.setContentProvider(cp);
+
+ IObservableSet set = cp.getKnownElements();
+
+ IObservableMap[] map = new IObservableMap [4];
+ map[0] = EMFProperties.value(ProjectPackage.Literals.PROJECT__SHORTNAME).observeDetail(set);
+ map[1] = EMFProperties.value(ProjectPackage.Literals.PROJECT__COMMITTERS).observeDetail(set);
+ map[2] = EMFProperties.value(
+ FeaturePath.fromList(ProjectPackage.Literals.COMMITTER_SHIP__PERSON, ProjectPackage.Literals.PERSON__FIRSTNAME)).observeDetail(set);
+ map[3] = EMFProperties.value(
+ FeaturePath.fromList(ProjectPackage.Literals.COMMITTER_SHIP__PERSON, ProjectPackage.Literals.PERSON__LASTNAME)).observeDetail(set);
+
+ viewer.setLabelProvider(new TreeLabelProviderImpl(map));
+
+ IEMFListProperty projects = EMFProperties.list(ProjectPackage.Literals.FOUNDATION__PROJECTS);
+ viewer.setInput(projects.observe(foundation));
+
+ MenuManager mgr = new MenuManager();
+ mgr.add(new GroupMarker("additions"));
+ viewer.getControl().setMenu(mgr.createContextMenu(viewer.getControl()));
+
+ site.registerContextMenu(Activator.PLUGIN_ID + ".projectexp", mgr, viewer);
+ site.setSelectionProvider(viewer);
+
+ ColumnViewerToolTipSupportImpl.enableFor(viewer, toolkit);
+
+ IObservableValue treeObs = ViewerProperties.singleSelection().observe(viewer);
+ treeObs.addValueChangeListener(new IValueChangeListener()
+ {
+
+ public void handleValueChange(ValueChangeEvent event)
+ {
+ ISourceProviderService s = (ISourceProviderService)site.getService(ISourceProviderService.class);
+ ResourceProvider p = (ResourceProvider)s.getSourceProvider(ResourceProvider.MODEL_RESOURCE_NAME);
+
+ if (event.diff.getNewValue() instanceof Project)
+ {
+ Project pr = (Project)event.diff.getNewValue();
+ master.setValue(pr);
+ p.setCommitter(null);
+ p.setProject(pr);
+ }
+ else if (event.diff.getNewValue() != null)
+ {
+ CommitterShip cm = (CommitterShip)event.diff.getNewValue();
+ master.setValue(cm.getProject());
+ p.setCommitter(cm);
+ p.setProject(cm.getProject());
+ }
+ else
+ {
+ p.setCommitter(null);
+ p.setProject(null);
+ }
+ }
+ });
+
+ return viewer;
+ }
+
+ /**
+ * @return observable of the current active project in the tree
+ */
+ public IObservableValue getProjectObservable()
+ {
+ return master;
+ }
+
+ private static class TreeFactoryImpl implements IObservableFactory
+ {
+ private IEMFListProperty multi = EMFProperties.multiList(
+ ProjectPackage.Literals.PROJECT__SUBPROJECTS,
+ ProjectPackage.Literals.PROJECT__COMMITTERS);
+
+ public IObservable createObservable(final Object target)
+ {
+ if (target instanceof IObservableList)
+ {
+ return (IObservable)target;
+ }
+ else if (target instanceof Project)
+ {
+ return multi.observe(target);
+ }
+
+ return null;
+ }
+ }
+
+ private static class TreeStructureAdvisorImpl extends TreeStructureAdvisor
+ {
+ @Override
+ public Object getParent(Object element)
+ {
+ if (element instanceof Project)
+ {
+ return ((Project)element).getParent();
+ }
+
+ return null;
+ }
+
+ @Override
+ public Boolean hasChildren(Object element)
+ {
+ if (element instanceof Project && (((Project)element).getCommitters().size() > 0 || ((Project)element).getSubprojects().size() > 0))
+ {
+ return Boolean.TRUE;
+ }
+ return super.hasChildren(element);
+ }
+ }
+
+ private class TreeLabelProviderImpl extends StyledCellLabelProvider
+ {
+
+ private IMapChangeListener mapChangeListener = new IMapChangeListener()
+ {
+ public void handleMapChange(MapChangeEvent event)
+ {
+ Set< ? > affectedElements = event.diff.getChangedKeys();
+ if (!affectedElements.isEmpty())
+ {
+ LabelProviderChangedEvent newEvent = new LabelProviderChangedEvent(TreeLabelProviderImpl.this, affectedElements.toArray());
+ fireLabelProviderChanged(newEvent);
+ }
+ }
+ };
+
+ public TreeLabelProviderImpl(IObservableMap... attributeMaps)
+ {
+ for (int i = 0; i < attributeMaps.length; i++)
+ {
+ attributeMaps[i].addMapChangeListener(mapChangeListener);
+ }
+ }
+
+ @Override
+ public String getToolTipText(Object element)
+ {
+ return "#dummy#";
+ }
+
+ @Override
+ public void update(ViewerCell cell)
+ {
+ if (cell.getElement() instanceof Project)
+ {
+ Project p = (Project)cell.getElement();
+
+ StyledString styledString = new StyledString(p.getShortname() != null ? p.getShortname() : "*noname*", null);
+ String decoration = " (" + p.getCommitters().size() + " Committers)";
+ styledString.append(decoration, StyledString.COUNTER_STYLER);
+ cell.setText(styledString.getString());
+ cell.setImage(projectImage);
+ cell.setStyleRanges(styledString.getStyleRanges());
+ }
+ else if (cell.getElement() instanceof CommitterShip)
+ {
+ Person p = ((CommitterShip)cell.getElement()).getPerson();
+ String value = "*noname*";
+ if (p != null)
+ {
+ value = p.getLastname() + ", " + p.getFirstname();
+ }
+ StyledString styledString = new StyledString(value, null);
+ cell.setText(styledString.getString());
+ cell.setForeground(cell.getControl().getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
+ cell.setImage(committerImage);
+ cell.setStyleRanges(styledString.getStyleRanges());
+ }
+ }
+ }
+
+ private static class ColumnViewerToolTipSupportImpl extends ColumnViewerToolTipSupport
+ {
+ private FormToolkit toolkit;
+
+ protected ColumnViewerToolTipSupportImpl(FormToolkit toolkit, ColumnViewer viewer, int style)
+ {
+ super(viewer, style, false);
+ setHideOnMouseDown(false);
+ this.toolkit = toolkit;
+ }
+
+ @Override
+ protected Composite createViewerToolTipContentArea(Event event, ViewerCell cell, Composite parent)
+ {
+ if (cell.getElement() instanceof Project)
+ {
+ final Project p = (Project)cell.getElement();
+
+ StringBuilder b = new StringBuilder();
+ for (Person lead : p.getProjectleads())
+ {
+ if (b.length() > 0)
+ {
+ b.append(", ");
+ }
+ b.append(lead.getFirstname() + " " + lead.getLastname());
+ }
+
+ Form form = toolkit.createForm(parent);
+ toolkit.decorateFormHeading(form);
+ form.setText(p.getShortname() + " - " + p.getLongname());
+ Composite body = form.getBody();
+ body.setLayout(new GridLayout(2, false));
+
+ toolkit.createLabel(body, "Project creation:").setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
+ toolkit.createLabel(body, p.getStart() != null ? DateFormat.getDateInstance().format(p.getStart()) : "");
+
+ toolkit.createLabel(body, "Project lead:").setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
+ toolkit.createLabel(body, b.toString());
+
+ toolkit.createLabel(body, "Committers:").setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
+ toolkit.createLabel(body, p.getCommitters().size() + "");
+
+ toolkit.createLabel(body, "Mailing-List:").setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
+ if (p.getDevmail() != null)
+ {
+ toolkit.createHyperlink(body, p.getDevmail(), SWT.NONE).addHyperlinkListener(new IHyperlinkListener()
+ {
+
+ public void linkExited(HyperlinkEvent e)
+ {
+ // Ignore
+ }
+
+ public void linkEntered(HyperlinkEvent e)
+ {
+ // Ignore
+ }
+
+ public void linkActivated(HyperlinkEvent e)
+ {
+ Program.launch(p.getDevmail());
+ }
+ });
+ }
+ else
+ {
+ toolkit.createLabel(body, "-");
+ }
+
+ toolkit.createLabel(body, "Homepage:").setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
+ if (p.getHomepage() != null)
+ {
+ toolkit.createHyperlink(body, p.getHomepage(), SWT.NONE).addHyperlinkListener(new IHyperlinkListener()
+ {
+
+ public void linkExited(HyperlinkEvent e)
+ {
+ // Ignore
+ }
+
+ public void linkEntered(HyperlinkEvent e)
+ {
+ // Ignore
+ }
+
+ public void linkActivated(HyperlinkEvent e)
+ {
+ Program.launch(p.getHomepage());
+ }
+ });
+ }
+ else
+ {
+ toolkit.createLabel(body, "-");
+ }
+
+ return form;
+ }
+ else
+ {
+ final CommitterShip committership = (CommitterShip)cell.getElement();
+ Form form = toolkit.createForm(parent);
+ toolkit.decorateFormHeading(form);
+ form.setText(committership.getPerson().getFirstname() + ", " + committership.getPerson().getLastname());
+
+ Composite formBody = form.getBody();
+ formBody.setLayout(new GridLayout(2, false));
+
+ GridData gd = new GridData();
+
+ final Label l = toolkit.createLabel(formBody, "");
+ l.setLayoutData(gd);
+
+ Base64ToImageConverter c = new Base64ToImageConverter(form.getDisplay());
+ l.setImage((Image)c.convert(committership.getPerson().getImage()));
+ l.addDisposeListener(new DisposeListener()
+ {
+
+ public void widgetDisposed(DisposeEvent e)
+ {
+ if (l.getImage() != null)
+ l.getImage().dispose();
+ }
+ });
+
+ Composite body = toolkit.createComposite(formBody);
+ body.setLayout(new GridLayout(2, false));
+
+ toolkit.createLabel(body, "Start:").setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
+ toolkit.createLabel(body, committership.getStart() != null ? DateFormat.getDateInstance().format(committership.getStart()) : "");
+
+ toolkit.createLabel(body, "End:").setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
+ toolkit.createLabel(body, committership.getEnd() != null ? DateFormat.getDateInstance().format(committership.getEnd()) : "");
+
+ toolkit.createLabel(body, "E-Mail:").setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
+ if (committership.getPerson().getEmail() != null)
+ {
+ toolkit.createHyperlink(body, committership.getPerson().getEmail(), SWT.NONE).addHyperlinkListener(new IHyperlinkListener()
+ {
+
+ public void linkExited(HyperlinkEvent e)
+ {
+ // Ignore
+ }
+
+ public void linkEntered(HyperlinkEvent e)
+ {
+ // Ignore
+ }
+
+ public void linkActivated(HyperlinkEvent e)
+ {
+ Program.launch(committership.getPerson().getEmail());
+ }
+ });
+ }
+ else
+ {
+ toolkit.createLabel(body, "");
+ }
+
+ return form;
+ }
+ }
+
+ static void enableFor(ColumnViewer viewer, FormToolkit toolkit)
+ {
+ new ColumnViewerToolTipSupportImpl(toolkit, viewer, ToolTip.NO_RECREATE);
+ }
+ }
+
+ /**
+ * Set the focus
+ */
+ public void setFocus()
+ {
+ viewer.getControl().setFocus();
+ if (viewer.getTree().getItemCount() > 0)
+ {
+ viewer.setSelection(new StructuredSelection(viewer.getTree().getItem(0).getData()));
+ }
+ }
+
+ /**
+ * Dispose all resources and remove all listeners
+ */
+ public void dispose()
+ {
+ ICommandService service = (ICommandService)site.getService(ICommandService.class);
+ service.removeExecutionListener(paramListener);
+
+ if (projectImage != null)
+ {
+ projectImage.dispose();
+ }
+
+ if (committerImage != null)
+ {
+ committerImage.dispose();
+ }
+ }
+
+ /**
+ * @return the current selected committer
+ */
+ public CommitterShip getCommitter()
+ {
+ Object obj = ((IStructuredSelection)viewer.getSelection()).getFirstElement();
+ return (CommitterShip)((obj instanceof CommitterShip) ? obj : null);
+ }
+
+ private class CommandListener implements IExecutionListener
+ {
+
+ public void preExecute(String commandId, ExecutionEvent event)
+ {
+ // Ignore
+ }
+
+ public void postExecuteSuccess(String commandId, Object returnValue)
+ {
+ if (site.getPage() != null && site.getPage().getActivePart() != null && site.getPage().getActivePart().getSite() == site)
+ {
+ if (commandId.equals(CreateToplevelProjectHandler.ID) && returnValue != null)
+ {
+ viewer.setSelection(new StructuredSelection(returnValue));
+ }
+ else if (commandId.equals(CreateSublevelProjectHandler.ID) && returnValue != null)
+ {
+ Project project = (Project)returnValue;
+ List<Project> path = new ArrayList<Project>();
+ path.add(project);
+ while ((project = project.getParent()) != null)
+ {
+ path.add(0, project);
+ }
+
+ viewer.expandToLevel(new TreePath(path.toArray()), 0);
+ viewer.setSelection(new TreeSelection(new TreePath(path.toArray())));
+ }
+ }
+ }
+
+ public void postExecuteFailure(String commandId, ExecutionException exception)
+ {
+ // Ignore
+ }
+
+ public void notHandled(String commandId, NotHandledException exception)
+ {
+ // Ignore
+ }
+ }
+}
diff --git a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/views/ProjectFormAreaPart.java b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/views/ProjectFormAreaPart.java
index 13b1979f0..005cfc2d6 100644
--- a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/views/ProjectFormAreaPart.java
+++ b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/views/ProjectFormAreaPart.java
@@ -1,420 +1,420 @@
-/**
- * Copyright (c) 2009 Bestsolution.at and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Tom Schindl<tom.schindl@bestsolution.at> - Initial API and implementation
- */
-package org.eclipse.emf.example.databinding.project.ui.rcp.views;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.databinding.AggregateValidationStatus;
-import org.eclipse.core.databinding.DataBindingContext;
-import org.eclipse.core.databinding.ObservablesManager;
-import org.eclipse.core.databinding.ValidationStatusProvider;
-import org.eclipse.core.databinding.observable.value.ComputedValue;
-import org.eclipse.core.databinding.observable.value.IObservableValue;
-import org.eclipse.core.databinding.observable.value.IValueChangeListener;
-import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.databinding.swt.IWidgetValueProperty;
-import org.eclipse.jface.databinding.swt.WidgetProperties;
-import org.eclipse.jface.databinding.viewers.ObservableListContentProvider;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CTabFolder;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Image;
-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.Table;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.forms.IFormColors;
-import org.eclipse.ui.forms.IMessage;
-import org.eclipse.ui.forms.widgets.Form;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.databinding.EMFDataBindingContext;
-import org.eclipse.emf.databinding.IEMFListProperty;
-import org.eclipse.emf.databinding.IEMFValueProperty;
-import org.eclipse.emf.databinding.edit.EMFEditProperties;
-import org.eclipse.emf.edit.command.AddCommand;
-import org.eclipse.emf.edit.command.RemoveCommand;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.example.databinding.project.ui.rcp.Activator;
-import org.eclipse.emf.example.databinding.project.ui.rcp.NLSMessages;
-import org.eclipse.emf.example.databinding.project.ui.rcp.databinding.FormTextProperty;
-import org.eclipse.emf.example.databinding.project.ui.rcp.databinding.UpdateStrategyFactory;
-import org.eclipse.emf.example.databinding.project.ui.rcp.databinding.Util;
-import org.eclipse.emf.example.databinding.project.ui.rcp.dialogs.PersonFilterDialog;
-import org.eclipse.emf.examples.databinding.project.core.IModelResource;
-import org.eclipse.emf.examples.databinding.project.core.model.project.Person;
-import org.eclipse.emf.examples.databinding.project.core.model.project.ProjectPackage;
-
-
-/**
- * Part creating the form area
- */
-public class ProjectFormAreaPart
-{
- private DataBindingContext ctx;
- private Form form;
- private ProjectCommittersPart committerPart;
- private Image projectImage;
-
- /**
- * Create a new part instance
- * @param site the site
- * @param parent the parent composite
- * @param toolkit the form toolkit to use
- * @param resource the resource
- * @param manager manager for observables to avoid leaks
- * @param master the master observable
- */
- public ProjectFormAreaPart(
- IViewSite site,
- Composite parent,
- FormToolkit toolkit,
- IModelResource resource,
- ObservablesManager manager,
- IObservableValue master)
- {
- ImageDescriptor desc = Activator.imageDescriptorFromPlugin("org.eclipse.ui", "icons/full/obj16/generic_elements.gif");
- if (desc != null)
- {
- projectImage = desc.createImage();
- }
- else
- {
- projectImage = null;
- }
- createFormArea(site, parent, toolkit, resource, manager, master);
- }
-
- private void createFormArea(
- IViewSite site,
- final Composite parent,
- FormToolkit toolkit,
- final IModelResource resource,
- ObservablesManager manager,
- final IObservableValue master)
- {
-
- final EditingDomain editingDomain = resource.getEditingDomain();
-
- ctx = new EMFDataBindingContext();
- // Fix for bug 278301
- Util.masterDetailFixup(ctx, master);
-
- addStatusSupport(manager, ctx);
-
- form = toolkit.createForm(parent);
- toolkit.decorateFormHeading(form);
- form.setText(" ");
- form.setImage(projectImage);
-
- Composite body = form.getBody();
- body.setLayout(new GridLayout(3, false));
-
- IWidgetValueProperty prop = WidgetProperties.text(SWT.Modify);
-
- {
- final IEMFValueProperty shortProp = EMFEditProperties.value(editingDomain, ProjectPackage.Literals.PROJECT__SHORTNAME);;
- toolkit.createLabel(body, "&Short name");
- Text t = toolkit.createText(body, "");
- t.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 2, 1));
- ctx.bindValue(prop.observeDelayed(400, t), shortProp.observeDetail(master));
-
- final IEMFValueProperty longProp = EMFEditProperties.value(editingDomain, ProjectPackage.Literals.PROJECT__LONGNAME);
- toolkit.createLabel(body, "&Long name");
- t = toolkit.createText(body, "");
- t.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 2, 1));
- ctx.bindValue(prop.observeDelayed(400, t), longProp.observeDetail(master));
-
- ComputedValue cVal = new ComputedValue()
- {
- private IObservableValue shortname = shortProp.observeDetail(master);
- private IObservableValue longname = longProp.observeDetail(master);
-
- @Override
- protected Object calculate()
- {
- return shortname.getValue() + " - " + longname.getValue();
- }
- };
- manager.addObservable(cVal);
- ctx.bindValue(FormTextProperty.create().observe(form), cVal);
- }
-
- {
- IEMFValueProperty mProp = EMFEditProperties.value(editingDomain, ProjectPackage.Literals.PROJECT__START);
- toolkit.createLabel(body, "Start Date");
- Text t = toolkit.createText(body, "");
- t.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 2, 1));
- ctx.bindValue(prop.observeDelayed(400, t), mProp.observeDetail(master), UpdateStrategyFactory.stringToDateNotNull(
- NLSMessages.ProjectAdminViewPart_StartDateNotParseable,
- "Start date must not be null"), UpdateStrategyFactory.dateToString());
- }
-
- {
- IEMFValueProperty mProp = EMFEditProperties.value(editingDomain, ProjectPackage.Literals.PROJECT__END);
- toolkit.createLabel(body, "End Date");
- Text t = toolkit.createText(body, "");
- t.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 2, 1));
- ctx.bindValue(
- prop.observeDelayed(400, t),
- mProp.observeDetail(master),
- UpdateStrategyFactory.stringToDate(NLSMessages.ProjectAdminViewPart_EndDateNotParseable),
- UpdateStrategyFactory.dateToString());
- }
-
- {
- IEMFValueProperty mProp = EMFEditProperties.value(editingDomain, ProjectPackage.Literals.PROJECT__HOMEPAGE);
- toolkit.createLabel(body, "Homepage");
- Text t = toolkit.createText(body, "");
- t.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 2, 1));
- ctx.bindValue(prop.observeDelayed(400, t), mProp.observeDetail(master));
- }
-
- {
- IEMFValueProperty mProp = EMFEditProperties.value(editingDomain, ProjectPackage.Literals.PROJECT__DEVMAIL);
- toolkit.createLabel(body, "Dev-Mail");
- Text t = toolkit.createText(body, "");
- t.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 2, 1));
- ctx.bindValue(prop.observeDelayed(400, t), mProp.observeDetail(master));
- }
-
- {
- IEMFListProperty mProp = EMFEditProperties.list(editingDomain, ProjectPackage.Literals.PROJECT__PROJECTLEADS);
- toolkit.createLabel(body, "Project Leads").setLayoutData(new GridData(SWT.TOP, SWT.DEFAULT, false, false));
-
- Table c = toolkit.createTable(body, SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
- final TableViewer tv = new TableViewer(c);
- tv.setLabelProvider(new ColumnLabelProvider()
- {
- @Override
- public String getText(Object element)
- {
- Person p = (Person)element;
- return p.getLastname() + ", " + p.getFirstname();
- }
- });
- tv.setContentProvider(new ObservableListContentProvider());
- tv.setInput(mProp.observeDetail(master));
-
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.heightHint = 100;
- c.setLayoutData(gd);
-
- Composite buttonContainer = toolkit.createComposite(body);
- buttonContainer.setLayoutData(new GridData(SWT.DEFAULT, SWT.BOTTOM, false, false));
- buttonContainer.setLayout(new GridLayout());
-
- Button b = toolkit.createButton(buttonContainer, "Add ...", SWT.FLAT);
- gd = new GridData(SWT.DEFAULT, SWT.DEFAULT);
- gd.horizontalAlignment = SWT.FILL;
- b.setLayoutData(gd);
- b.addSelectionListener(new SelectionAdapter()
- {
- @Override
- public void widgetSelected(SelectionEvent e)
- {
- PersonFilterDialog dialog = new PersonFilterDialog(parent.getShell(), resource);
- if (dialog.open() == IDialogConstants.OK_ID)
- {
- Command cmd = AddCommand.create(
- editingDomain,
- master.getValue(),
- ProjectPackage.Literals.PROJECT__PROJECTLEADS,
- dialog.getFirstResult());
- if (cmd.canExecute())
- {
- resource.executeCmd(cmd);
- }
- }
- }
- });
- b = toolkit.createButton(buttonContainer, "Remove", SWT.FLAT);
- gd = new GridData(SWT.DEFAULT, SWT.DEFAULT);
- gd.horizontalAlignment = SWT.FILL;
- b.setLayoutData(gd);
- b.addSelectionListener(new SelectionAdapter()
- {
- @Override
- public void widgetSelected(SelectionEvent e)
- {
- IStructuredSelection s = (IStructuredSelection)tv.getSelection();
- if (!s.isEmpty())
- {
- Command cmd = RemoveCommand.create(
- editingDomain,
- master.getValue(),
- ProjectPackage.Literals.PROJECT__PROJECTLEADS,
- s.toList());
- if (cmd.canExecute())
- {
- resource.executeCmd(cmd);
- }
- }
- }
- });
- }
-
- addTabArea(site, body, toolkit, ctx, editingDomain, manager, master);
- body.setBackgroundMode(SWT.INHERIT_DEFAULT);
- }
-
- private void addTabArea(
- IViewSite site,
- Composite parent,
- FormToolkit toolkit,
- DataBindingContext ctx,
- EditingDomain editingDomain,
- ObservablesManager manager,
- IObservableValue master)
- {
- CTabFolder folder = new CTabFolder(parent, SWT.BORDER);
- folder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
- folder.setSelectionBackground(new Color []{
- toolkit.getColors().getColor(IFormColors.H_GRADIENT_END),
- toolkit.getColors().getColor(IFormColors.H_GRADIENT_START) }, new int []{ 25 }, true);
- folder.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
- folder.setSelectionForeground(toolkit.getColors().getColor(IFormColors.TITLE));
- folder.setSimple(false);
-
- committerPart = new ProjectCommittersPart(site, folder, ctx, editingDomain, manager, master);
- }
-
- private void addStatusSupport(ObservablesManager mgr, final DataBindingContext ctx)
- {
- AggregateValidationStatus aggregateStatus = new AggregateValidationStatus(
- ctx.getValidationStatusProviders(),
- AggregateValidationStatus.MAX_SEVERITY);
-
- aggregateStatus.addValueChangeListener(new IValueChangeListener()
- {
- public void handleValueChange(ValueChangeEvent event)
- {
- handleStateChange((IStatus)event.diff.getNewValue(), ctx);
- }
- });
- }
-
- private void handleStateChange(IStatus currentStatus, DataBindingContext ctx)
- {
- if (form.isDisposed() || form.getHead().isDisposed())
- {
- return;
- }
-
- if (currentStatus != null && currentStatus.getSeverity() != IStatus.OK)
- {
- int type = convertType(currentStatus.getSeverity());
-
- List<IMessage> list = new ArrayList<IMessage>();
- for (Iterator< ? > it = ctx.getValidationStatusProviders().iterator(); it.hasNext();)
- {
- ValidationStatusProvider validationStatusProvider = (ValidationStatusProvider)it.next();
- final IStatus status = (IStatus)validationStatusProvider.getValidationStatus().getValue();
- if (!status.isOK())
- {
- list.add(new IMessage()
- {
-
- public Control getControl()
- {
- return null;
- }
-
- public Object getData()
- {
- return null;
- }
-
- public Object getKey()
- {
- return null;
- }
-
- public String getPrefix()
- {
- return null;
- }
-
- public String getMessage()
- {
- return status.getMessage();
- }
-
- public int getMessageType()
- {
- return convertType(status.getSeverity());
- }
-
- });
- }
- }
-
- form.setMessage("Data invalid", type, list.toArray(new IMessage [0]));
- }
- else
- {
- form.setMessage(null);
- }
- }
-
- private int convertType(int severity)
- {
- switch (severity)
- {
- case IStatus.OK:
- return IMessageProvider.NONE;
- case IStatus.CANCEL:
- return IMessageProvider.NONE;
- case IStatus.INFO:
- return IMessageProvider.INFORMATION;
- case IStatus.WARNING:
- return IMessageProvider.WARNING;
- case IStatus.ERROR:
- return IMessageProvider.ERROR;
- default:
- return IMessageProvider.NONE;
- }
- }
-
- /**
- * release all sources allocated
- */
- public void dispose()
- {
- if (projectImage != null)
- {
- projectImage.dispose();
- }
-
- committerPart.dispose();
-
- if (ctx != null)
- {
- ctx.dispose();
- }
- }
-}
+/**
+ * Copyright (c) 2009 Bestsolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl<tom.schindl@bestsolution.at> - Initial API and implementation
+ */
+package org.eclipse.emf.example.databinding.project.ui.rcp.views;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.databinding.AggregateValidationStatus;
+import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.databinding.ObservablesManager;
+import org.eclipse.core.databinding.ValidationStatusProvider;
+import org.eclipse.core.databinding.observable.value.ComputedValue;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.core.databinding.observable.value.IValueChangeListener;
+import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.databinding.swt.IWidgetValueProperty;
+import org.eclipse.jface.databinding.swt.WidgetProperties;
+import org.eclipse.jface.databinding.viewers.ObservableListContentProvider;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CTabFolder;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+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.Table;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.forms.IFormColors;
+import org.eclipse.ui.forms.IMessage;
+import org.eclipse.ui.forms.widgets.Form;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.databinding.EMFDataBindingContext;
+import org.eclipse.emf.databinding.IEMFListProperty;
+import org.eclipse.emf.databinding.IEMFValueProperty;
+import org.eclipse.emf.databinding.edit.EMFEditProperties;
+import org.eclipse.emf.edit.command.AddCommand;
+import org.eclipse.emf.edit.command.RemoveCommand;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.example.databinding.project.ui.rcp.Activator;
+import org.eclipse.emf.example.databinding.project.ui.rcp.NLSMessages;
+import org.eclipse.emf.example.databinding.project.ui.rcp.databinding.FormTextProperty;
+import org.eclipse.emf.example.databinding.project.ui.rcp.databinding.UpdateStrategyFactory;
+import org.eclipse.emf.example.databinding.project.ui.rcp.databinding.Util;
+import org.eclipse.emf.example.databinding.project.ui.rcp.dialogs.PersonFilterDialog;
+import org.eclipse.emf.examples.databinding.project.core.IModelResource;
+import org.eclipse.emf.examples.databinding.project.core.model.project.Person;
+import org.eclipse.emf.examples.databinding.project.core.model.project.ProjectPackage;
+
+
+/**
+ * Part creating the form area
+ */
+public class ProjectFormAreaPart
+{
+ private DataBindingContext ctx;
+ private Form form;
+ private ProjectCommittersPart committerPart;
+ private Image projectImage;
+
+ /**
+ * Create a new part instance
+ * @param site the site
+ * @param parent the parent composite
+ * @param toolkit the form toolkit to use
+ * @param resource the resource
+ * @param manager manager for observables to avoid leaks
+ * @param master the master observable
+ */
+ public ProjectFormAreaPart(
+ IViewSite site,
+ Composite parent,
+ FormToolkit toolkit,
+ IModelResource resource,
+ ObservablesManager manager,
+ IObservableValue master)
+ {
+ ImageDescriptor desc = Activator.imageDescriptorFromPlugin("org.eclipse.ui", "icons/full/obj16/generic_elements.gif");
+ if (desc != null)
+ {
+ projectImage = desc.createImage();
+ }
+ else
+ {
+ projectImage = null;
+ }
+ createFormArea(site, parent, toolkit, resource, manager, master);
+ }
+
+ private void createFormArea(
+ IViewSite site,
+ final Composite parent,
+ FormToolkit toolkit,
+ final IModelResource resource,
+ ObservablesManager manager,
+ final IObservableValue master)
+ {
+
+ final EditingDomain editingDomain = resource.getEditingDomain();
+
+ ctx = new EMFDataBindingContext();
+ // Fix for bug 278301
+ Util.masterDetailFixup(ctx, master);
+
+ addStatusSupport(manager, ctx);
+
+ form = toolkit.createForm(parent);
+ toolkit.decorateFormHeading(form);
+ form.setText(" ");
+ form.setImage(projectImage);
+
+ Composite body = form.getBody();
+ body.setLayout(new GridLayout(3, false));
+
+ IWidgetValueProperty prop = WidgetProperties.text(SWT.Modify);
+
+ {
+ final IEMFValueProperty shortProp = EMFEditProperties.value(editingDomain, ProjectPackage.Literals.PROJECT__SHORTNAME);
+ toolkit.createLabel(body, "&Short name");
+ Text t = toolkit.createText(body, "");
+ t.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 2, 1));
+ ctx.bindValue(prop.observeDelayed(400, t), shortProp.observeDetail(master));
+
+ final IEMFValueProperty longProp = EMFEditProperties.value(editingDomain, ProjectPackage.Literals.PROJECT__LONGNAME);
+ toolkit.createLabel(body, "&Long name");
+ t = toolkit.createText(body, "");
+ t.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 2, 1));
+ ctx.bindValue(prop.observeDelayed(400, t), longProp.observeDetail(master));
+
+ ComputedValue cVal = new ComputedValue()
+ {
+ private IObservableValue shortname = shortProp.observeDetail(master);
+ private IObservableValue longname = longProp.observeDetail(master);
+
+ @Override
+ protected Object calculate()
+ {
+ return shortname.getValue() + " - " + longname.getValue();
+ }
+ };
+ manager.addObservable(cVal);
+ ctx.bindValue(FormTextProperty.create().observe(form), cVal);
+ }
+
+ {
+ IEMFValueProperty mProp = EMFEditProperties.value(editingDomain, ProjectPackage.Literals.PROJECT__START);
+ toolkit.createLabel(body, "Start Date");
+ Text t = toolkit.createText(body, "");
+ t.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 2, 1));
+ ctx.bindValue(prop.observeDelayed(400, t), mProp.observeDetail(master), UpdateStrategyFactory.stringToDateNotNull(
+ NLSMessages.ProjectAdminViewPart_StartDateNotParseable,
+ "Start date must not be null"), UpdateStrategyFactory.dateToString());
+ }
+
+ {
+ IEMFValueProperty mProp = EMFEditProperties.value(editingDomain, ProjectPackage.Literals.PROJECT__END);
+ toolkit.createLabel(body, "End Date");
+ Text t = toolkit.createText(body, "");
+ t.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 2, 1));
+ ctx.bindValue(
+ prop.observeDelayed(400, t),
+ mProp.observeDetail(master),
+ UpdateStrategyFactory.stringToDate(NLSMessages.ProjectAdminViewPart_EndDateNotParseable),
+ UpdateStrategyFactory.dateToString());
+ }
+
+ {
+ IEMFValueProperty mProp = EMFEditProperties.value(editingDomain, ProjectPackage.Literals.PROJECT__HOMEPAGE);
+ toolkit.createLabel(body, "Homepage");
+ Text t = toolkit.createText(body, "");
+ t.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 2, 1));
+ ctx.bindValue(prop.observeDelayed(400, t), mProp.observeDetail(master));
+ }
+
+ {
+ IEMFValueProperty mProp = EMFEditProperties.value(editingDomain, ProjectPackage.Literals.PROJECT__DEVMAIL);
+ toolkit.createLabel(body, "Dev-Mail");
+ Text t = toolkit.createText(body, "");
+ t.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 2, 1));
+ ctx.bindValue(prop.observeDelayed(400, t), mProp.observeDetail(master));
+ }
+
+ {
+ IEMFListProperty mProp = EMFEditProperties.list(editingDomain, ProjectPackage.Literals.PROJECT__PROJECTLEADS);
+ toolkit.createLabel(body, "Project Leads").setLayoutData(new GridData(SWT.TOP, SWT.DEFAULT, false, false));
+
+ Table c = toolkit.createTable(body, SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ final TableViewer tv = new TableViewer(c);
+ tv.setLabelProvider(new ColumnLabelProvider()
+ {
+ @Override
+ public String getText(Object element)
+ {
+ Person p = (Person)element;
+ return p.getLastname() + ", " + p.getFirstname();
+ }
+ });
+ tv.setContentProvider(new ObservableListContentProvider());
+ tv.setInput(mProp.observeDetail(master));
+
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.heightHint = 100;
+ c.setLayoutData(gd);
+
+ Composite buttonContainer = toolkit.createComposite(body);
+ buttonContainer.setLayoutData(new GridData(SWT.DEFAULT, SWT.BOTTOM, false, false));
+ buttonContainer.setLayout(new GridLayout());
+
+ Button b = toolkit.createButton(buttonContainer, "Add ...", SWT.FLAT);
+ gd = new GridData(SWT.DEFAULT, SWT.DEFAULT);
+ gd.horizontalAlignment = SWT.FILL;
+ b.setLayoutData(gd);
+ b.addSelectionListener(new SelectionAdapter()
+ {
+ @Override
+ public void widgetSelected(SelectionEvent e)
+ {
+ PersonFilterDialog dialog = new PersonFilterDialog(parent.getShell(), resource);
+ if (dialog.open() == IDialogConstants.OK_ID)
+ {
+ Command cmd = AddCommand.create(
+ editingDomain,
+ master.getValue(),
+ ProjectPackage.Literals.PROJECT__PROJECTLEADS,
+ dialog.getFirstResult());
+ if (cmd.canExecute())
+ {
+ resource.executeCmd(cmd);
+ }
+ }
+ }
+ });
+ b = toolkit.createButton(buttonContainer, "Remove", SWT.FLAT);
+ gd = new GridData(SWT.DEFAULT, SWT.DEFAULT);
+ gd.horizontalAlignment = SWT.FILL;
+ b.setLayoutData(gd);
+ b.addSelectionListener(new SelectionAdapter()
+ {
+ @Override
+ public void widgetSelected(SelectionEvent e)
+ {
+ IStructuredSelection s = (IStructuredSelection)tv.getSelection();
+ if (!s.isEmpty())
+ {
+ Command cmd = RemoveCommand.create(
+ editingDomain,
+ master.getValue(),
+ ProjectPackage.Literals.PROJECT__PROJECTLEADS,
+ s.toList());
+ if (cmd.canExecute())
+ {
+ resource.executeCmd(cmd);
+ }
+ }
+ }
+ });
+ }
+
+ addTabArea(site, body, toolkit, ctx, editingDomain, manager, master);
+ body.setBackgroundMode(SWT.INHERIT_DEFAULT);
+ }
+
+ private void addTabArea(
+ IViewSite site,
+ Composite parent,
+ FormToolkit toolkit,
+ DataBindingContext ctx,
+ EditingDomain editingDomain,
+ ObservablesManager manager,
+ IObservableValue master)
+ {
+ CTabFolder folder = new CTabFolder(parent, SWT.BORDER);
+ folder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
+ folder.setSelectionBackground(new Color []{
+ toolkit.getColors().getColor(IFormColors.H_GRADIENT_END),
+ toolkit.getColors().getColor(IFormColors.H_GRADIENT_START) }, new int []{ 25 }, true);
+ folder.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
+ folder.setSelectionForeground(toolkit.getColors().getColor(IFormColors.TITLE));
+ folder.setSimple(false);
+
+ committerPart = new ProjectCommittersPart(site, folder, ctx, editingDomain, manager, master);
+ }
+
+ private void addStatusSupport(ObservablesManager mgr, final DataBindingContext ctx)
+ {
+ AggregateValidationStatus aggregateStatus = new AggregateValidationStatus(
+ ctx.getValidationStatusProviders(),
+ AggregateValidationStatus.MAX_SEVERITY);
+
+ aggregateStatus.addValueChangeListener(new IValueChangeListener()
+ {
+ public void handleValueChange(ValueChangeEvent event)
+ {
+ handleStateChange((IStatus)event.diff.getNewValue(), ctx);
+ }
+ });
+ }
+
+ private void handleStateChange(IStatus currentStatus, DataBindingContext ctx)
+ {
+ if (form.isDisposed() || form.getHead().isDisposed())
+ {
+ return;
+ }
+
+ if (currentStatus != null && currentStatus.getSeverity() != IStatus.OK)
+ {
+ int type = convertType(currentStatus.getSeverity());
+
+ List<IMessage> list = new ArrayList<IMessage>();
+ for (Iterator< ? > it = ctx.getValidationStatusProviders().iterator(); it.hasNext();)
+ {
+ ValidationStatusProvider validationStatusProvider = (ValidationStatusProvider)it.next();
+ final IStatus status = (IStatus)validationStatusProvider.getValidationStatus().getValue();
+ if (!status.isOK())
+ {
+ list.add(new IMessage()
+ {
+
+ public Control getControl()
+ {
+ return null;
+ }
+
+ public Object getData()
+ {
+ return null;
+ }
+
+ public Object getKey()
+ {
+ return null;
+ }
+
+ public String getPrefix()
+ {
+ return null;
+ }
+
+ public String getMessage()
+ {
+ return status.getMessage();
+ }
+
+ public int getMessageType()
+ {
+ return convertType(status.getSeverity());
+ }
+
+ });
+ }
+ }
+
+ form.setMessage("Data invalid", type, list.toArray(new IMessage [0]));
+ }
+ else
+ {
+ form.setMessage(null);
+ }
+ }
+
+ private int convertType(int severity)
+ {
+ switch (severity)
+ {
+ case IStatus.OK:
+ return IMessageProvider.NONE;
+ case IStatus.CANCEL:
+ return IMessageProvider.NONE;
+ case IStatus.INFO:
+ return IMessageProvider.INFORMATION;
+ case IStatus.WARNING:
+ return IMessageProvider.WARNING;
+ case IStatus.ERROR:
+ return IMessageProvider.ERROR;
+ default:
+ return IMessageProvider.NONE;
+ }
+ }
+
+ /**
+ * release all sources allocated
+ */
+ public void dispose()
+ {
+ if (projectImage != null)
+ {
+ projectImage.dispose();
+ }
+
+ committerPart.dispose();
+
+ if (ctx != null)
+ {
+ ctx.dispose();
+ }
+ }
+}
diff --git a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/views/RedoAction.java b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/views/RedoAction.java
index 5d11989b8..949852d75 100644
--- a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/views/RedoAction.java
+++ b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/views/RedoAction.java
@@ -1,72 +1,73 @@
-/**
- * Copyright (c) 2009 Bestsolution.at and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Tom Schindl<tom.schindl@bestsolution.at> - Initial API and implementation
- */
-package org.eclipse.emf.example.databinding.project.ui.rcp.views;
-
-import org.eclipse.jface.action.Action;
-
-import org.eclipse.emf.examples.databinding.project.core.IModelResource;
-
-
-public class RedoAction extends Action
-{
- private final IModelResource resource;
- private final IModelResource.Listener listener;
-
- public RedoAction(IModelResource resource)
- {
- this.resource = resource;
- this.listener = new IModelResource.Listener()
- {
-
- public void dirtyStateChanged()
- {
- }
-
- public void commandStackChanged()
- {
- update();
- }
- };
- resource.addListener(listener);
- update();
- }
-
- @Override
- public void run()
- {
- if (resource.canRedo().isOK())
- {
- resource.redo();
- }
- }
-
- private void update()
- {
- if (resource.canRedo().isOK())
- {
- setText("Redo " + resource.getEditingDomain().getCommandStack().getRedoCommand().getLabel());
- setEnabled(true);
- }
- else
- {
- setText("Redo");
- setEnabled(false);
- }
- }
-
- /**
- * Clean up
- */
- public void dispose()
- {
- resource.removeListener(listener);
- }
-}
+/**
+ * Copyright (c) 2009 Bestsolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl<tom.schindl@bestsolution.at> - Initial API and implementation
+ */
+package org.eclipse.emf.example.databinding.project.ui.rcp.views;
+
+import org.eclipse.jface.action.Action;
+
+import org.eclipse.emf.examples.databinding.project.core.IModelResource;
+
+
+public class RedoAction extends Action
+{
+ private final IModelResource resource;
+ private final IModelResource.Listener listener;
+
+ public RedoAction(IModelResource resource)
+ {
+ this.resource = resource;
+ this.listener = new IModelResource.Listener()
+ {
+
+ public void dirtyStateChanged()
+ {
+ // Ignore
+ }
+
+ public void commandStackChanged()
+ {
+ update();
+ }
+ };
+ resource.addListener(listener);
+ update();
+ }
+
+ @Override
+ public void run()
+ {
+ if (resource.canRedo().isOK())
+ {
+ resource.redo();
+ }
+ }
+
+ private void update()
+ {
+ if (resource.canRedo().isOK())
+ {
+ setText("Redo " + resource.getEditingDomain().getCommandStack().getRedoCommand().getLabel());
+ setEnabled(true);
+ }
+ else
+ {
+ setText("Redo");
+ setEnabled(false);
+ }
+ }
+
+ /**
+ * Clean up
+ */
+ public void dispose()
+ {
+ resource.removeListener(listener);
+ }
+}
diff --git a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/views/UndoAction.java b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/views/UndoAction.java
index 989c8d30b..1af4328ef 100644
--- a/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/views/UndoAction.java
+++ b/examples/org.eclipse.emf.examples.databinding.project.ui.rcp/src/org/eclipse/emf/example/databinding/project/ui/rcp/views/UndoAction.java
@@ -1,72 +1,73 @@
-/**
- * Copyright (c) 2009 Bestsolution.at and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Tom Schindl<tom.schindl@bestsolution.at> - Initial API and implementation
- */
-package org.eclipse.emf.example.databinding.project.ui.rcp.views;
-
-import org.eclipse.jface.action.Action;
-
-import org.eclipse.emf.examples.databinding.project.core.IModelResource;
-
-
-public class UndoAction extends Action
-{
- private final IModelResource resource;
- private final IModelResource.Listener listener;
-
- public UndoAction(IModelResource resource)
- {
- this.resource = resource;
- this.listener = new IModelResource.Listener()
- {
-
- public void dirtyStateChanged()
- {
- }
-
- public void commandStackChanged()
- {
- update();
- }
- };
- resource.addListener(listener);
- update();
- }
-
- @Override
- public void run()
- {
- if (resource.canUndo().isOK())
- {
- resource.undo();
- }
- }
-
- private void update()
- {
- if (resource.canUndo().isOK())
- {
- setText("Undo " + resource.getEditingDomain().getCommandStack().getUndoCommand().getLabel());
- setEnabled(true);
- }
- else
- {
- setText("Undo");
- setEnabled(false);
- }
- }
-
- /**
- * Clean up
- */
- public void dispose()
- {
- resource.removeListener(listener);
- }
+/**
+ * Copyright (c) 2009 Bestsolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl<tom.schindl@bestsolution.at> - Initial API and implementation
+ */
+package org.eclipse.emf.example.databinding.project.ui.rcp.views;
+
+import org.eclipse.jface.action.Action;
+
+import org.eclipse.emf.examples.databinding.project.core.IModelResource;
+
+
+public class UndoAction extends Action
+{
+ private final IModelResource resource;
+ private final IModelResource.Listener listener;
+
+ public UndoAction(IModelResource resource)
+ {
+ this.resource = resource;
+ this.listener = new IModelResource.Listener()
+ {
+
+ public void dirtyStateChanged()
+ {
+ // Ignore
+ }
+
+ public void commandStackChanged()
+ {
+ update();
+ }
+ };
+ resource.addListener(listener);
+ update();
+ }
+
+ @Override
+ public void run()
+ {
+ if (resource.canUndo().isOK())
+ {
+ resource.undo();
+ }
+ }
+
+ private void update()
+ {
+ if (resource.canUndo().isOK())
+ {
+ setText("Undo " + resource.getEditingDomain().getCommandStack().getUndoCommand().getLabel());
+ setEnabled(true);
+ }
+ else
+ {
+ setText("Undo");
+ setEnabled(false);
+ }
+ }
+
+ /**
+ * Clean up
+ */
+ public void dispose()
+ {
+ resource.removeListener(listener);
+ }
} \ No newline at end of file

Back to the top