Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples')
-rw-r--r--examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/Activator.java61
-rw-r--r--examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/Application.java24
-rw-r--r--examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/ApplicationActionBarAdvisor.java46
-rw-r--r--examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/ApplicationWorkbenchAdvisor.java22
-rw-r--r--examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/ApplicationWorkbenchWindowAdvisor.java31
-rw-r--r--examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/ExecutableExtensionFactory.java21
-rw-r--r--examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/GuiceModule.java101
-rw-r--r--examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/Perspective.java26
-rw-r--r--examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/SaveableView.java15
-rw-r--r--examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/View.java44
10 files changed, 391 insertions, 0 deletions
diff --git a/examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/Activator.java b/examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/Activator.java
new file mode 100644
index 000000000..d83c1a2d2
--- /dev/null
+++ b/examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/Activator.java
@@ -0,0 +1,61 @@
+package org.eclipse.emf.parsley.examples.rap.ui;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.emf.parsley.examples.rap.ui"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#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;
+ }
+
+ /**
+ * 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);
+ }
+}
diff --git a/examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/Application.java b/examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/Application.java
new file mode 100644
index 000000000..6fc42b316
--- /dev/null
+++ b/examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/Application.java
@@ -0,0 +1,24 @@
+package org.eclipse.emf.parsley.examples.rap.ui;
+
+import org.eclipse.equinox.app.IApplication;
+import org.eclipse.equinox.app.IApplicationContext;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.application.WorkbenchAdvisor;
+
+/**
+ * This class controls all aspects of the application's execution
+ * and is contributed through the plugin.xml.
+ */
+public class Application implements IApplication {
+
+ public Object start(IApplicationContext context) throws Exception {
+ Display display = PlatformUI.createDisplay();
+ WorkbenchAdvisor advisor = new ApplicationWorkbenchAdvisor();
+ return PlatformUI.createAndRunWorkbench(display, advisor);
+ }
+
+ public void stop() {
+ // Do nothing
+ }
+}
diff --git a/examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/ApplicationActionBarAdvisor.java b/examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/ApplicationActionBarAdvisor.java
new file mode 100644
index 000000000..c7c595bf6
--- /dev/null
+++ b/examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/ApplicationActionBarAdvisor.java
@@ -0,0 +1,46 @@
+package org.eclipse.emf.parsley.examples.rap.ui;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
+import org.eclipse.ui.application.ActionBarAdvisor;
+import org.eclipse.ui.application.IActionBarConfigurer;
+
+/**
+ * Creates, adds and disposes actions for the menus and action bars of each
+ * workbench window.
+ */
+public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
+
+ public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
+ super(configurer);
+ }
+
+ // Actions - important to allocate these only in makeActions, and then use
+ // them in the fill methods. This ensures that the actions aren't recreated
+ // in the fill methods.
+ private IWorkbenchAction exitAction;
+
+ private IWorkbenchAction saveAction;
+
+ protected void makeActions(IWorkbenchWindow window) {
+ // Creates the actions and registers them. Registering also
+ // provides automatic disposal of the actions when the window is closed.
+ exitAction = ActionFactory.QUIT.create(window);
+ register(exitAction);
+ saveAction = ActionFactory.SAVE.create(window);
+ register(saveAction);
+ }
+
+ protected void fillMenuBar(IMenuManager menuBar) {
+ MenuManager fileMenu = new MenuManager("&File",
+ IWorkbenchActionConstants.M_FILE);
+ menuBar.add(fileMenu);
+ fileMenu.add(exitAction);
+ fileMenu.add(saveAction);
+ }
+
+}
diff --git a/examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/ApplicationWorkbenchAdvisor.java b/examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/ApplicationWorkbenchAdvisor.java
new file mode 100644
index 000000000..466d94abc
--- /dev/null
+++ b/examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/ApplicationWorkbenchAdvisor.java
@@ -0,0 +1,22 @@
+package org.eclipse.emf.parsley.examples.rap.ui;
+
+import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
+import org.eclipse.ui.application.WorkbenchAdvisor;
+import org.eclipse.ui.application.WorkbenchWindowAdvisor;
+
+/**
+ * This workbench advisor creates the window advisor, and specifies
+ * the perspective id for the initial window.
+ */
+public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {
+
+ private static final String PERSPECTIVE_ID = "org.eclipse.emf.parsley.examples.rap.ui.perspective";
+
+ public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
+ return new ApplicationWorkbenchWindowAdvisor(configurer);
+ }
+
+ public String getInitialWindowPerspectiveId() {
+ return PERSPECTIVE_ID;
+ }
+}
diff --git a/examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/ApplicationWorkbenchWindowAdvisor.java b/examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/ApplicationWorkbenchWindowAdvisor.java
new file mode 100644
index 000000000..44c232aa9
--- /dev/null
+++ b/examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/ApplicationWorkbenchWindowAdvisor.java
@@ -0,0 +1,31 @@
+package org.eclipse.emf.parsley.examples.rap.ui;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.ui.application.ActionBarAdvisor;
+import org.eclipse.ui.application.IActionBarConfigurer;
+import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
+import org.eclipse.ui.application.WorkbenchWindowAdvisor;
+
+/**
+ * Configures the initial size and appearance of a workbench window.
+ */
+public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
+
+ public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
+ super(configurer);
+ }
+
+ public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) {
+ return new ApplicationActionBarAdvisor(configurer);
+ }
+
+ public void preWindowOpen() {
+ IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
+ configurer.setInitialSize(new Point(700, 500));
+ configurer.setShowCoolBar(false);
+ configurer.setShowStatusLine(false);
+ configurer.setTitle("RAP with a View");
+ configurer.setShellStyle(SWT.TITLE | SWT.RESIZE);
+ }
+}
diff --git a/examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/ExecutableExtensionFactory.java b/examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/ExecutableExtensionFactory.java
new file mode 100644
index 000000000..e1786396f
--- /dev/null
+++ b/examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/ExecutableExtensionFactory.java
@@ -0,0 +1,21 @@
+package org.eclipse.emf.parsley.examples.rap.ui;
+
+
+import org.eclipse.emf.parsley.EmfComponentsExtensionFactory;
+import org.eclipse.emf.parsley.EmfComponentsGuiceModule;
+import org.osgi.framework.Bundle;
+
+public class ExecutableExtensionFactory extends
+ EmfComponentsExtensionFactory {
+
+ @Override
+ protected Bundle getBundle() {
+ return Activator.getDefault().getBundle();
+ }
+
+ @Override
+ protected EmfComponentsGuiceModule getModule() {
+ return new GuiceModule(Activator.getDefault());
+ }
+
+}
diff --git a/examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/GuiceModule.java b/examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/GuiceModule.java
new file mode 100644
index 000000000..f8b22664a
--- /dev/null
+++ b/examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/GuiceModule.java
@@ -0,0 +1,101 @@
+package org.eclipse.emf.parsley.examples.rap.ui;
+
+
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.emf.parsley.EmfComponentsGuiceModule;
+import org.eclipse.emf.parsley.examples.rap.model.Element;
+import org.eclipse.emf.parsley.examples.rap.model.Item;
+import org.eclipse.emf.parsley.examples.rap.model.Model;
+import org.eclipse.emf.parsley.examples.rap.model.ModelFactory;
+import org.eclipse.emf.parsley.resource.EmptyResourceInitializer;
+import org.eclipse.emf.parsley.ui.provider.ViewerLabelProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+import com.google.inject.Inject;
+
+public class GuiceModule extends EmfComponentsGuiceModule {
+
+ public static class CustomEmptyResourceInitializer extends
+ EmptyResourceInitializer {
+ public void initialize(org.eclipse.emf.ecore.resource.Resource resource) {
+ Model model = ModelFactory.eINSTANCE.createModel();
+ model.setName("My Model");
+
+ Element firstElement = addElement(model, "First Element", 1);
+ Element secondElement = addElement(model, "Second Element", 2);
+ addElement(model, "Third Element", 3);
+
+ Item firstItem = addItem(model, "First Item");
+ Item secondItem = addItem(model, "Second Item");
+ addItem(model, "Third Item");
+ addItem(model, "Fourth Item");
+
+ firstElement.getItems().add(firstItem);
+ firstElement.getItems().add(secondItem);
+
+ secondElement.getItems().add(firstItem);
+
+ resource.getContents().add(model);
+ }
+
+ private Element addElement(Model model, String name, int age) {
+ Element element = ModelFactory.eINSTANCE.createElement();
+ element.setName(name);
+ element.setAge(age);
+ model.getElements().add(element);
+ return element;
+ }
+
+ private Item addItem(Model model, String name) {
+ Item item = ModelFactory.eINSTANCE.createItem();
+ item.setName(name);
+ model.getItems().add(item);
+ return item;
+ }
+ }
+
+ public static class CustomLabelProvider extends ViewerLabelProvider {
+
+ @Inject
+ public CustomLabelProvider(AdapterFactoryLabelProvider delegate) {
+ super(delegate);
+ }
+
+ public String text(Model o) {
+ return "Model: " + (o.getName() != null ? o.getName() : "NO NAME");
+ }
+
+ public Object image(Model o) {
+ return "component.jpg";
+ }
+
+ public String text(Element o) {
+ return "Element: "
+ + (o.getName() != null ? o.getName() : "NO NAME")
+ + " (" + o.getAge() + ")";
+ }
+
+ public Object image(Element o) {
+ return "detail.jpg";
+ }
+
+ public Object image(Item o) {
+ return "table.jpg";
+ }
+ }
+
+ public GuiceModule(AbstractUIPlugin plugin) {
+ super(plugin);
+ }
+
+ @Override
+ public Class<? extends ILabelProvider> bindILabelProvider() {
+ return CustomLabelProvider.class;
+ }
+
+ @Override
+ public Class<? extends EmptyResourceInitializer> bindEmptyResourceInitializer() {
+ return CustomEmptyResourceInitializer.class;
+ }
+}
diff --git a/examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/Perspective.java b/examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/Perspective.java
new file mode 100644
index 000000000..45156ef32
--- /dev/null
+++ b/examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/Perspective.java
@@ -0,0 +1,26 @@
+package org.eclipse.emf.parsley.examples.rap.ui;
+
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+
+/**
+ * Configures the perspective layout. This class is contributed through the
+ * plugin.xml.
+ */
+public class Perspective implements IPerspectiveFactory {
+
+ public void createInitialLayout(IPageLayout layout) {
+ String editorArea = layout.getEditorArea();
+ layout.setEditorAreaVisible(false);
+ layout.setFixed(true);
+
+ layout.addStandaloneView(View.ID, true, IPageLayout.LEFT, .5f,
+ editorArea);
+ layout.addStandaloneView(SaveableView.ID, true, IPageLayout.LEFT, .5f,
+ editorArea);
+
+// IFolderLayout left =
+// layout.createFolder("bottom", IPageLayout.BOTTOM, (float) 0.26, editorArea);
+// left.addView(IPageLayout.ID_PROP_SHEET);
+ }
+}
diff --git a/examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/SaveableView.java b/examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/SaveableView.java
new file mode 100644
index 000000000..fe2f5879f
--- /dev/null
+++ b/examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/SaveableView.java
@@ -0,0 +1,15 @@
+package org.eclipse.emf.parsley.examples.rap.ui;
+
+import org.eclipse.emf.parsley.views.AbstractSaveableTreeFormView;
+
+import org.eclipse.emf.common.util.URI;
+
+public class SaveableView extends AbstractSaveableTreeFormView {
+ public static final String ID = "org.eclipse.emf.parsley.examples.rap.ui.saveableview";
+
+ @Override
+ protected URI createResourceURI() {
+ return URI.createFileURI(System.getProperty("java.io.tmpdir")
+ + "/My.model");
+ }
+} \ No newline at end of file
diff --git a/examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/View.java b/examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/View.java
new file mode 100644
index 000000000..54f94d448
--- /dev/null
+++ b/examples/org.eclipse.emf.parsley.examples.rap.ui/src/org/eclipse/emf/parsley/examples/rap/ui/View.java
@@ -0,0 +1,44 @@
+package org.eclipse.emf.parsley.examples.rap.ui;
+
+
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.impl.ResourceImpl;
+import org.eclipse.emf.parsley.factories.TreeFormFactory;
+import org.eclipse.emf.parsley.resource.EmptyResourceInitializer;
+import org.eclipse.emf.parsley.widgets.TreeFormComposite;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.part.ViewPart;
+
+import com.google.inject.Inject;
+
+public class View extends ViewPart {
+ public static final String ID = "org.eclipse.emf.parsley.examples.rap.ui.view";
+
+ @Inject private EmptyResourceInitializer emptyResourceInitializer;
+
+ @Inject private TreeFormFactory treeFormFactory;
+
+ protected TreeFormComposite treeFormComposite;
+
+ /**
+ * This is a callback that will allow us to create the viewer and initialize
+ * it.
+ */
+ public void createPartControl(Composite parent) {
+ treeFormComposite = treeFormFactory.createTreeFormMasterDetailComposite(parent,
+ SWT.BORDER);
+
+ Resource resource = new ResourceImpl();
+ emptyResourceInitializer.initialize(resource);
+
+ treeFormComposite.update(resource);
+ }
+
+ /**
+ * Passing the focus request to the viewer's control.
+ */
+ public void setFocus() {
+ treeFormComposite.setFocus();
+ }
+} \ No newline at end of file

Back to the top