Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-07-28 16:56:52 +0000
committerEike Stepper2012-07-28 16:56:52 +0000
commit6d9247b4087c4a03bd8d9b505ed54877f4e27158 (patch)
tree8bddb415b1be76cf1c9b78559db3ba566cce5b03 /plugins
parent6674748a1cc82cfe4440621ef4b77f0f06293d48 (diff)
downloadcdo-6d9247b4087c4a03bd8d9b505ed54877f4e27158.tar.gz
cdo-6d9247b4087c4a03bd8d9b505ed54877f4e27158.tar.xz
cdo-6d9247b4087c4a03bd8d9b505ed54877f4e27158.zip
Add view prototype
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version.ui/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version.ui/icons/sample.gifbin0 -> 983 bytes
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version.ui/plugin.xml19
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/views/VersionsView.java228
4 files changed, 248 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.cdo.releng.version.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.releng.version.ui/META-INF/MANIFEST.MF
index 8714f5e351..7d637a202b 100644
--- a/plugins/org.eclipse.emf.cdo.releng.version.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.releng.version.ui/META-INF/MANIFEST.MF
@@ -19,5 +19,6 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)",
Export-Package: org.eclipse.emf.cdo.releng.version.ui;version="2.0.0";x-internal:=true,
org.eclipse.emf.cdo.releng.version.ui.actions;version="2.0.0";x-internal:=true,
org.eclipse.emf.cdo.releng.version.ui.dialogs;version="2.0.0";x-internal:=true,
- org.eclipse.emf.cdo.releng.version.ui.quickfixes;version="2.0.0";x-internal:=true
+ org.eclipse.emf.cdo.releng.version.ui.quickfixes;version="2.0.0";x-internal:=true,
+ org.eclipse.emf.cdo.releng.version.ui.views;version="2.0.0";x-internal:=true
Eclipse-BuddyPolicy: dependent
diff --git a/plugins/org.eclipse.emf.cdo.releng.version.ui/icons/sample.gif b/plugins/org.eclipse.emf.cdo.releng.version.ui/icons/sample.gif
new file mode 100644
index 0000000000..34fb3c9d8c
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.releng.version.ui/icons/sample.gif
Binary files differ
diff --git a/plugins/org.eclipse.emf.cdo.releng.version.ui/plugin.xml b/plugins/org.eclipse.emf.cdo.releng.version.ui/plugin.xml
index 0e5097f622..b8f4774ecb 100644
--- a/plugins/org.eclipse.emf.cdo.releng.version.ui/plugin.xml
+++ b/plugins/org.eclipse.emf.cdo.releng.version.ui/plugin.xml
@@ -81,7 +81,7 @@
</visibility>
</objectContribution>
</extension>
-
+
<extension
point="org.eclipse.ui.ide.markerResolution">
<markerResolutionGenerator
@@ -90,4 +90,21 @@
</markerResolutionGenerator>
</extension>
+ <!--
+ <extension
+ point="org.eclipse.ui.views">
+ <category
+ id="org.eclipse.emf.cdo.releng.version"
+ name="Extended Version Management">
+ </category>
+ <view
+ category="org.eclipse.emf.cdo.releng.version"
+ class="org.eclipse.emf.cdo.releng.version.ui.views.VersionsView"
+ icon="icons/sample.gif"
+ id="org.eclipse.emf.cdo.releng.version.VersionsView"
+ name="Versions">
+ </view>
+ </extension>
+ -->
+
</plugin>
diff --git a/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/views/VersionsView.java b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/views/VersionsView.java
new file mode 100644
index 0000000000..d57c48d5a5
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/views/VersionsView.java
@@ -0,0 +1,228 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.releng.version.ui.views;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.ViewPart;
+
+/**
+ * @author Eike Stepper
+ */
+public class VersionsView extends ViewPart
+{
+ public static final String ID = "org.eclipse.emf.cdo.releng.version.VersionsView";
+
+ private TableViewer viewer;
+
+ private Action action1;
+
+ private Action action2;
+
+ private Action doubleClickAction;
+
+ public VersionsView()
+ {
+ }
+
+ @Override
+ public void setFocus()
+ {
+ viewer.getControl().setFocus();
+ }
+
+ @Override
+ public void createPartControl(Composite parent)
+ {
+ viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ viewer.setContentProvider(new ViewContentProvider());
+ viewer.setLabelProvider(new ViewLabelProvider());
+ viewer.setSorter(new NameSorter());
+ viewer.setInput(getViewSite());
+
+ getViewSite().setSelectionProvider(viewer);
+
+ makeActions();
+ hookContextMenu();
+ hookDoubleClickAction();
+ contributeToActionBars();
+ }
+
+ private void hookContextMenu()
+ {
+ MenuManager menuMgr = new MenuManager("#PopupMenu");
+ menuMgr.setRemoveAllWhenShown(true);
+ menuMgr.addMenuListener(new IMenuListener()
+ {
+ public void menuAboutToShow(IMenuManager manager)
+ {
+ VersionsView.this.fillContextMenu(manager);
+ }
+ });
+
+ Menu menu = menuMgr.createContextMenu(viewer.getControl());
+ viewer.getControl().setMenu(menu);
+ getSite().registerContextMenu(menuMgr, viewer);
+ }
+
+ private void contributeToActionBars()
+ {
+ IActionBars bars = getViewSite().getActionBars();
+ fillLocalPullDown(bars.getMenuManager());
+ fillLocalToolBar(bars.getToolBarManager());
+ }
+
+ private void fillLocalPullDown(IMenuManager manager)
+ {
+ manager.add(action1);
+ manager.add(new Separator());
+ manager.add(action2);
+ }
+
+ private void fillContextMenu(IMenuManager manager)
+ {
+ manager.add(action1);
+ manager.add(action2);
+ manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ }
+
+ private void fillLocalToolBar(IToolBarManager manager)
+ {
+ manager.add(action1);
+ manager.add(action2);
+ }
+
+ private void makeActions()
+ {
+ action1 = new Action()
+ {
+ @Override
+ public void run()
+ {
+ showMessage("Action 1 executed");
+ }
+ };
+ action1.setText("Action 1");
+ action1.setToolTipText("Action 1 tooltip");
+ action1.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
+ .getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
+
+ action2 = new Action()
+ {
+ @Override
+ public void run()
+ {
+ showMessage("Action 2 executed");
+ }
+ };
+ action2.setText("Action 2");
+ action2.setToolTipText("Action 2 tooltip");
+ action2.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
+ .getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
+ doubleClickAction = new Action()
+ {
+ @Override
+ public void run()
+ {
+ ISelection selection = viewer.getSelection();
+ Object obj = ((IStructuredSelection)selection).getFirstElement();
+ showMessage("Double-click detected on " + obj.toString());
+ }
+ };
+ }
+
+ private void hookDoubleClickAction()
+ {
+ viewer.addDoubleClickListener(new IDoubleClickListener()
+ {
+ public void doubleClick(DoubleClickEvent event)
+ {
+ doubleClickAction.run();
+ }
+ });
+ }
+
+ private void showMessage(String message)
+ {
+ MessageDialog.openInformation(viewer.getControl().getShell(), "Versions", message);
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ class ViewContentProvider implements IStructuredContentProvider
+ {
+ public void inputChanged(Viewer v, Object oldInput, Object newInput)
+ {
+ }
+
+ public void dispose()
+ {
+ }
+
+ public Object[] getElements(Object parent)
+ {
+ return new String[] { "One", "Two", "Three" };
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ class ViewLabelProvider extends LabelProvider implements ITableLabelProvider
+ {
+ public String getColumnText(Object obj, int index)
+ {
+ return getText(obj);
+ }
+
+ public Image getColumnImage(Object obj, int index)
+ {
+ return getImage(obj);
+ }
+
+ @Override
+ public Image getImage(Object obj)
+ {
+ return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT);
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ class NameSorter extends ViewerSorter
+ {
+ }
+}

Back to the top