Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Spungin2014-06-07 00:45:02 +0000
committerSteven Spungin2014-06-11 16:10:22 +0000
commit40f1fb02fbd578e6d50c14630a569984e6bd481e (patch)
treefec6e2b552651dcbef0b86f05c45fcc4dd932670
parent6b0221ba440d61fd94df2cb038f803371e12450c (diff)
downloadorg.eclipse.e4.tools-40f1fb02fbd578e6d50c14630a569984e6bd481e.tar.gz
org.eclipse.e4.tools-40f1fb02fbd578e6d50c14630a569984e6bd481e.tar.xz
org.eclipse.e4.tools-40f1fb02fbd578e6d50c14630a569984e6bd481e.zip
Bug 436889 - [model editor] Save/restore the list tab columns upon
editor activation Bug 436908 - [compatibility] Forward DIEditorPart @Persist and @PersistState to wrapped component Other Changes: removed autosizing and updated pack logic added autosize columns toolbar menu item added reset to default toolbar menu item all columns are now movable all columns now persist state refactored code into TableViewerUtil Change-Id: I1ec44d962063e0f08d4342db0c43b2cc8a1aeec7 Signed-off-by: Steven Spungin <steven@spungin.tv>
-rw-r--r--bundles/org.eclipse.e4.tools.compat/src/org/eclipse/e4/tools/compat/parts/DIEditorPart.java7
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/fragment.e4xmi4
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java8
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/DocUtil.java39
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/EAttributeTableViewerColumn.java18
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/IViewEObjects.java13
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/ListTab.java462
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/TableViewerUtil.java39
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/handlers/AutosizeColumnsHandler.java25
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/handlers/ResetToDefaultHandler.java25
10 files changed, 518 insertions, 122 deletions
diff --git a/bundles/org.eclipse.e4.tools.compat/src/org/eclipse/e4/tools/compat/parts/DIEditorPart.java b/bundles/org.eclipse.e4.tools.compat/src/org/eclipse/e4/tools/compat/parts/DIEditorPart.java
index ca4a7b3b..f247c89e 100644
--- a/bundles/org.eclipse.e4.tools.compat/src/org/eclipse/e4/tools/compat/parts/DIEditorPart.java
+++ b/bundles/org.eclipse.e4.tools.compat/src/org/eclipse/e4/tools/compat/parts/DIEditorPart.java
@@ -9,6 +9,7 @@
* Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
* Jonas Helming <jhelming@eclipsesource.com>
* Lars Vogel <Lars.Vogel@gmail.com> - Bug 421453
+ * Steven Spungin <steven@spungin.tv> - Bug 436889
******************************************************************************/
package org.eclipse.e4.tools.compat.parts;
@@ -23,6 +24,7 @@ import org.eclipse.e4.tools.services.IClipboardService;
import org.eclipse.e4.tools.services.IDirtyProviderService;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.di.Persist;
+import org.eclipse.e4.ui.di.PersistState;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IEditorInput;
@@ -102,6 +104,11 @@ public abstract class DIEditorPart<C> extends EditorPart implements
makeActions();
}
+ @PersistState
+ public void persistState() {
+ ContextInjectionFactory.invoke(component, PersistState.class, context);
+ }
+
protected IEclipseContext getContext() {
return context;
}
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/fragment.e4xmi b/bundles/org.eclipse.e4.tools.emf.ui/fragment.e4xmi
index cadc6334..0762936b 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/fragment.e4xmi
+++ b/bundles/org.eclipse.e4.tools.emf.ui/fragment.e4xmi
@@ -6,6 +6,8 @@
<elements xsi:type="commands:Command" xmi:id="_RObi4L2MEeOqSr2XZwfnmA" elementId="org.eclipse.e4.tools.emf.ui.command.mark_duplicate_attributes" commandName="Mark Duplicate Model Attributes..." description="Marks Duplicate Model Attributes"/>
<elements xsi:type="commands:Command" xmi:id="_dySeYLzDEeO8eO1Rpb-rFA" elementId="org.eclipse.e4.tools.emf.ui.command.repair_duplicate_ids" commandName="Repair Duplicate Model Element IDs" description="Repairs Duplicate Model Element IDs"/>
<elements xsi:type="commands:Command" xmi:id="_CFlw8L2LEeOqSr2XZwfnmA" elementId="org.eclipse.e4.tools.emf.ui.command.unmark" commandName="Unmark Model Items" description="Unmarks All Model Items"/>
+ <elements xsi:type="commands:Command" xmi:id="_jd7xgO5mEeOQXaYP-M2JBA" elementId="org.eclipse.e4.tools.emf.ui.command.autosizeColumns" commandName="Autosize Columns" description="Autosizes all columns to their content"/>
+ <elements xsi:type="commands:Command" xmi:id="_vsQXAPFwEeOSJuCPb-hb7A" elementId="org.eclipse.e4.tools.emf.ui.command.resetToDefault" commandName="Reset To Default" description="Resets the table to default values"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_jtmcsLy3EeOxWJvPH-7sUQ" featurename="handlers" parentElementId="org.eclipse.e4.legacy.ide.application">
<elements xsi:type="commands:Handler" xmi:id="_p45hULy3EeOxWJvPH-7sUQ" elementId="org.eclipse.e4.tools.emf.ui.handler.mark_duplicate_ids" contributionURI="bundleclass://org.eclipse.e4.tools.emf.ui/org.eclipse.e4.tools.emf.ui.internal.handlers.MarkDuplicateElementIdsHandler" command="_RRp7QLy2EeOxWJvPH-7sUQ"/>
@@ -13,5 +15,7 @@
<elements xsi:type="commands:Handler" xmi:id="_TgJt4L2MEeOqSr2XZwfnmA" elementId="org.eclipse.e4.tools.emf.ui.handler.mark_duplicate_attributes" contributionURI="bundleclass://org.eclipse.e4.tools.emf.ui/org.eclipse.e4.tools.emf.ui.internal.handlers.MarkDuplicateAttributesHandler" command="_RObi4L2MEeOqSr2XZwfnmA"/>
<elements xsi:type="commands:Handler" xmi:id="_smaaALzDEeO8eO1Rpb-rFA" elementId="org.eclipse.e4.tools.emf.ui.handler.repair_duplicate_ids" contributionURI="bundleclass://org.eclipse.e4.tools.emf.ui/org.eclipse.e4.tools.emf.ui.internal.handlers.RepairDuplicateItemsHandler" command="_dySeYLzDEeO8eO1Rpb-rFA"/>
<elements xsi:type="commands:Handler" xmi:id="_Fin4gL2LEeOqSr2XZwfnmA" elementId="org.eclipse.e4.tools.emf.ui.handler.unmark" contributionURI="bundleclass://org.eclipse.e4.tools.emf.ui/org.eclipse.e4.tools.emf.ui.internal.handlers.UnmarkItemsHandler" command="_CFlw8L2LEeOqSr2XZwfnmA"/>
+ <elements xsi:type="commands:Handler" xmi:id="_hZcKMO5mEeOQXaYP-M2JBA" elementId="org.eclipse.e4.tools.emf.ui.handler.autosizeColumns" contributionURI="bundleclass://org.eclipse.e4.tools.emf.ui/org.eclipse.e4.tools.emf.ui.internal.handlers.AutosizeColumnsHandler" command="_jd7xgO5mEeOQXaYP-M2JBA"/>
+ <elements xsi:type="commands:Handler" xmi:id="_8AHVUPFwEeOSJuCPb-hb7A" elementId="org.eclipse.e4.tools.emf.ui.handler.resetToDefault" contributionURI="bundleclass://org.eclipse.e4.tools.emf.ui/org.eclipse.e4.tools.emf.ui.internal.handlers.ResetToDefaultHandler" command="_vsQXAPFwEeOSJuCPb-hb7A"/>
</fragments>
</fragment:ModelFragments>
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java
index 5538517f..121cbac8 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java
@@ -144,6 +144,7 @@ import org.eclipse.e4.tools.services.IResourcePool;
import org.eclipse.e4.tools.services.Translation;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.di.Persist;
+import org.eclipse.e4.ui.di.PersistState;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.MApplicationElement;
import org.eclipse.e4.ui.model.application.commands.impl.CommandsPackageImpl;
@@ -381,6 +382,13 @@ public class ModelEditor implements IGotoObject {
labelFeaturePaths.add(FeaturePath.fromList(UiPackageImpl.Literals.UI_ELEMENT__VISIBLE));
}
+ @PersistState
+ protected void persistState() {
+ if (listTab != null) {
+ listTab.saveSettings();
+ }
+ }
+
@PostConstruct
void postCreate(Composite composite) {
if (project == null) {
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/DocUtil.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/DocUtil.java
new file mode 100644
index 00000000..12800b29
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/DocUtil.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2014 TwelveTone LLC 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:
+ * Steven Spungin <steven@spungin.tv> - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.e4.tools.emf.ui.internal.common.component.tabs;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Helper functions for working with documents.
+ *
+ * @author Steven Spungin
+ *
+ */
+public class DocUtil {
+
+ public static Element createChild(Element parent, String name) {
+ Element element = parent.getOwnerDocument().createElement(name);
+ parent.appendChild(element);
+ return element;
+ }
+
+ public static Document createDocument(String name) throws ParserConfigurationException {
+ Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+ doc.appendChild(doc.createElement(name));
+ return doc;
+ }
+
+}
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/EAttributeTableViewerColumn.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/EAttributeTableViewerColumn.java
index e003e3d4..ef145a1f 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/EAttributeTableViewerColumn.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/EAttributeTableViewerColumn.java
@@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Steven Spungin <steven@spungin.tv> - initial API and implementation, Bug 432555
+ * Steven Spungin <steven@spungin.tv> - initial API and implementation, Bug 432555, Bug 436889
*******************************************************************************/
package org.eclipse.e4.tools.emf.ui.internal.common.component.tabs;
@@ -32,7 +32,7 @@ import org.eclipse.swt.graphics.Image;
*/
public class EAttributeTableViewerColumn {
- private TableViewerColumn tlc;
+ private TableViewerColumn tableViewerColumn;
private IResourcePool resourcePool;
private String attName;
private TableViewer tvResults;
@@ -40,13 +40,13 @@ public class EAttributeTableViewerColumn {
public EAttributeTableViewerColumn(final TableViewer tvResults, String label, final String attName, final IEclipseContext context) {
this.tvResults = tvResults;
this.attName = attName;
- tlc = new TableViewerColumn(tvResults, SWT.NONE);
+ tableViewerColumn = new TableViewerColumn(tvResults, SWT.NONE);
// CAN be null. Used for checkbox icon.
resourcePool = context.get(IResourcePool.class);
- tlc.getColumn().setText(label);
- tlc.setLabelProvider(new ColumnLabelProvider() {
+ tableViewerColumn.getColumn().setText(label);
+ tableViewerColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
EObject eObject = (EObject) element;
@@ -93,7 +93,7 @@ public class EAttributeTableViewerColumn {
return EAttributeTableViewerColumn.this.getBackground(element);
}
});
- tlc.setEditingSupport(new EAttributeEditingSupport(tvResults, attName, context));
+ tableViewerColumn.setEditingSupport(new EAttributeEditingSupport(tvResults, attName, context));
}
public Color getBackground(Object element) {
@@ -107,7 +107,11 @@ public class EAttributeTableViewerColumn {
}
public void dispose() {
- tlc.getColumn().dispose();
+ tableViewerColumn.getColumn().dispose();
+ }
+
+ public TableViewerColumn getTableViewerColumn() {
+ return tableViewerColumn;
}
}
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/IViewEObjects.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/IViewEObjects.java
index a7ec21d8..98730b7f 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/IViewEObjects.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/IViewEObjects.java
@@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Steven Spungin <steven@spungin.tv> - initial API and implementation, Bug 432555
+ * Steven Spungin <steven@spungin.tv> - initial API and implementation, Bug 432555, Bug 436889
*******************************************************************************/
package org.eclipse.e4.tools.emf.ui.internal.common.component.tabs;
@@ -61,4 +61,15 @@ public interface IViewEObjects {
* @return The editing domain for the implementor's model.
*/
EditingDomain getEditingDomain();
+
+ /**
+ * Sizes widgets to fit their content. For example, columns will adjust
+ * their width.
+ */
+ void autosizeContent();
+
+ /**
+ * Reverts the view to default settings
+ */
+ void resetToDefault();
}
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/ListTab.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/ListTab.java
index d1ab894a..f17fa639 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/ListTab.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/ListTab.java
@@ -6,21 +6,39 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Steven Spungin <steven@spungin.tv> - initial API and implementation, Bug 432555
+ * Steven Spungin <steven@spungin.tv> - initial API and implementation, Bug 432555, Bug 436889
*******************************************************************************/
package org.eclipse.e4.tools.emf.ui.internal.common.component.tabs;
+import java.io.StringReader;
+import java.io.StringWriter;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathFactory;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.tools.emf.ui.common.IModelResource;
import org.eclipse.e4.tools.emf.ui.internal.Messages;
@@ -75,9 +93,15 @@ import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
+import org.osgi.service.prefs.BackingStoreException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
/**
* A tab that contains a list EObjects, and provides editable columns for
@@ -90,9 +114,6 @@ public class ListTab implements IViewEObjects {
static final String ELIPSIS = "..."; //$NON-NLS-1$
- // The table will only include EObjects that define this attribute
- private static final String FILTER_ATTRIBUTE_ID = "elementId"; //$NON-NLS-1$
-
ConcurrentHashMap<String, List<EObject>> mapId_Object = new ConcurrentHashMap<String, List<EObject>>();
@Inject
@@ -126,14 +147,21 @@ public class ListTab implements IViewEObjects {
private Collection<?> highlightedItems;
- HashMap<String, EAttributeTableViewerColumn> defaultColumns = new HashMap<String, EAttributeTableViewerColumn>();
- HashMap<String, EAttributeTableViewerColumn> optionalColumns = new HashMap<String, EAttributeTableViewerColumn>();
+ protected Image imgMarkedItem;
+
+ LinkedHashMap<String, EAttributeTableViewerColumn> defaultColumns = new LinkedHashMap<String, EAttributeTableViewerColumn>();
+ LinkedHashMap<String, EAttributeTableViewerColumn> optionalColumns = new LinkedHashMap<String, EAttributeTableViewerColumn>();
+ LinkedHashMap<String, TableColumn> requiredColumns = new LinkedHashMap<String, TableColumn>();
+ private TableViewerColumn colItem;
+ private TableViewerColumn colGo;
+ private TableViewerColumn colGoXmi;
+ private TableViewerColumn colMarked;
private ToolItem filterByItem;
-
private ToolItem filterByAttribute;
-
- protected Image imgMarkedItem;
+ private String filterByAttrName;
+ private String filterByItemName;
+ private EmptyFilterOption filterByAttrEmptyOption;
@PreDestroy
public void preDestroy() {
@@ -143,6 +171,176 @@ public class ListTab implements IViewEObjects {
context.get(EMFDocumentResourceMediator.class).getDocument().removeDocumentListener(documentListener);
}
+ // save custom column and filter settings
+ public void saveSettings() {
+ IEclipsePreferences pref = InstanceScope.INSTANCE.getNode("org.eclipse.e4.tools.emf.ui"); //$NON-NLS-1$
+ try {
+ Document doc = DocUtil.createDocument("list-tab"); //$NON-NLS-1$
+ Element cols = DocUtil.createChild(doc.getDocumentElement(), "columns"); //$NON-NLS-1$
+
+ final ArrayList<TableColumn> allCols = TableViewerUtil.getColumnsInDisplayOrder(tvResults);
+ for (TableColumn col : allCols) {
+ String id;
+ if (requiredColumns.containsValue(col)) {
+ id = getKey(requiredColumns, col);
+ } else {
+ id = col.getText();
+ }
+ saveColumn(cols, id, col);
+ }
+
+ Element filters = DocUtil.createChild(doc.getDocumentElement(), "filters"); //$NON-NLS-1$
+ if (E.notEmpty(filterByAttrName)) {
+ Element filter = DocUtil.createChild(filters, "filter"); //$NON-NLS-1$
+ DocUtil.createChild(filter, "type").setTextContent("attribute"); //$NON-NLS-1$//$NON-NLS-2$
+ DocUtil.createChild(filter, "condition").setTextContent(filterByAttrName); //$NON-NLS-1$
+ DocUtil.createChild(filter, "emptyOption").setTextContent(filterByAttrEmptyOption.name()); //$NON-NLS-1$
+ }
+ if (E.notEmpty(filterByItemName)) {
+ Element filter = DocUtil.createChild(filters, "filter"); //$NON-NLS-1$
+ DocUtil.createChild(filter, "type").setTextContent("item"); //$NON-NLS-1$ //$NON-NLS-2$
+ DocUtil.createChild(filter, "condition").setTextContent(filterByItemName); //$NON-NLS-1$
+ }
+
+ pref.put("list-tab-xml", docToString(doc)); //$NON-NLS-1$
+ } catch (ParserConfigurationException e1) {
+ e1.printStackTrace();
+ } catch (TransformerException e) {
+ e.printStackTrace();
+ }
+
+ try {
+ pref.flush();
+ } catch (BackingStoreException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private String getKey(Map<String, ?> map, Object value) {
+ for (Entry<String, ?> entry : map.entrySet()) {
+ if (entry.getValue().equals(value)) {
+ return entry.getKey();
+ }
+ }
+ return null;
+ }
+
+ private void saveColumn(Element eleCols, String columnName, TableColumn objCol) {
+ Element col = DocUtil.createChild(eleCols, "column"); //$NON-NLS-1$
+
+ DocUtil.createChild(col, "attribute").setTextContent(columnName); //$NON-NLS-1$
+
+ Integer width = objCol.getWidth();
+ DocUtil.createChild(col, "width").setTextContent(width.toString()); //$NON-NLS-1$
+ }
+
+ // load custom column and filter settings
+ private void loadSettings() {
+ IEclipsePreferences pref = InstanceScope.INSTANCE.getNode("org.eclipse.e4.tools.emf.ui"); //$NON-NLS-1$
+ String xml = pref.get("list-tab-xml", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ if (E.notEmpty(xml)) {
+ try {
+ Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(xml)));
+ XPath xpath = XPathFactory.newInstance().newXPath();
+ NodeList list;
+
+ // restore columns and column widths
+ list = (NodeList) xpath.evaluate("//columns/column", doc, XPathConstants.NODESET); //$NON-NLS-1$
+ for (int i = 0; i < list.getLength(); i++) {
+ Element ele = (Element) list.item(i);
+ TableColumn col;
+ String colName = xpath.evaluate("attribute/text()", ele); //$NON-NLS-1$
+ if (colName.isEmpty()) {
+ continue;
+ }
+ col = requiredColumns.get(colName);
+ if (col == null) {
+ col = addColumn(colName).getTableViewerColumn().getColumn();
+ }
+
+ // move it to the end of the list.
+ int currentIndex = getVisibleColumnIndex(tvResults, col);
+ int[] order = tvResults.getTable().getColumnOrder();
+ for (int idx = 0; idx < order.length; idx++) {
+ if (order[idx] > currentIndex) {
+ order[idx]--;
+ } else if (order[idx] == currentIndex) {
+ order[idx] = order.length - 1;
+ }
+ }
+ tvResults.getTable().setColumnOrder(order);
+
+ // if ("Item".equals(colName)) { //$NON-NLS-1$
+ // col = colItem;
+ // } else if ("Item".equals(colName)) { //$NON-NLS-1$
+ // col = colItem;
+ // }
+
+ String sWidth = xpath.evaluate("width/text()", ele); //$NON-NLS-1$
+ try {
+ col.setWidth(Integer.parseInt(sWidth));
+ } catch (Exception e) {
+ }
+ }
+
+ // restore filters
+ list = (NodeList) xpath.evaluate("//filters/filter", doc, XPathConstants.NODESET); //$NON-NLS-1$
+ for (int i = 0; i < list.getLength(); i++) {
+ Element ele = (Element) list.item(i);
+ String type = xpath.evaluate("type/text()", ele); //$NON-NLS-1$
+ String condition = xpath.evaluate("condition/text()", ele); //$NON-NLS-1$
+ String emptyOption = xpath.evaluate("emptyOption/text()", ele); //$NON-NLS-1$
+ if ("item".equals(type)) { //$NON-NLS-1$
+ filterByItem(condition);
+ } else if ("attribute".equals(type)) { //$NON-NLS-1$
+ EmptyFilterOption emptyFilterOption;
+ try {
+ emptyFilterOption = EmptyFilterOption.valueOf(emptyOption);
+ } catch (Exception e) {
+ emptyFilterOption = EmptyFilterOption.INCLUDE;
+ }
+ filterByAttribute(condition, emptyFilterOption);
+ }
+ }
+ } catch (Exception e) {
+ }
+ }
+ }
+
+ // @Refactor
+ static public int getVisibleColumnIndex(TableViewer tvResults2, TableColumn col) {
+ int createOrder = Arrays.asList(tvResults2.getTable().getColumns()).indexOf(col);
+ if (createOrder == -1) {
+ return -1;
+ } else {
+ return tvResults2.getTable().getColumnOrder()[createOrder];
+ }
+ }
+
+ // @Refactor
+ static private String docToString(Document doc) throws TransformerException {
+ TransformerFactory tf = TransformerFactory.newInstance();
+ Transformer transformer = tf.newTransformer();
+ transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); //$NON-NLS-1$
+ StringWriter writer = new StringWriter();
+ transformer.transform(new DOMSource(doc), new StreamResult(writer));
+ String output = writer.getBuffer().toString().replaceAll("\n|\r", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ return output;
+ }
+
+ // @Refactor
+ static String join(Collection<String> items, String separator) {
+ StringBuilder sb = new StringBuilder();
+ for (String item : items) {
+ sb.append(item);
+ sb.append(separator);
+ }
+ if (sb.length() > 0) {
+ sb.setLength(sb.length() - separator.length());
+ }
+ return sb.toString();
+ }
+
@PostConstruct
public void postConstruct(final CTabFolder tabFolder) {
imageCache = new BundleImageCache(context.get(Display.class), getClass().getClassLoader());
@@ -198,7 +396,9 @@ public class ListTab implements IViewEObjects {
if (dlg.open() == dlg.OK) {
// Add Column
String attName = dlg.getFirstElement().toString();
- addColumn(attName);
+ EAttributeTableViewerColumn col = addColumn(attName);
+ col.getTableViewerColumn().getColumn().pack();
+ tvResults.refresh();
}
}
});
@@ -216,7 +416,6 @@ public class ListTab implements IViewEObjects {
col.dispose();
}
optionalColumns.clear();
- TableViewerUtil.refreshAndPack(tvResults);
}
});
}
@@ -230,33 +429,12 @@ public class ListTab implements IViewEObjects {
filterByItem.setImage(imageCache.create("/icons/full/obj16/filter_by_item.gif")); //$NON-NLS-1$
filterByItem.addSelectionListener(new SelectionAdapter() {
+
@Override
public void widgetSelected(SelectionEvent e) {
final TitleAreaFilterDialog dlg = createElementTypePicker(Messages.ListTab_filterByItem);
if (dlg.open() == Window.OK) {
- final String name = dlg.getFirstElement().toString();
- mapId_Object.clear();
- final ArrayList<EObject> filtered = new ArrayList<EObject>();
- for (EObject object : getAllEObjects()) {
- if (object.eClass().getName().equals(name)) {
- filtered.add(object);
- // filter.setText(Messages.ListTab_7 +
- // attFilter);
-
- }
-
- ViewerFilter viewerFilter = new ViewerFilter() {
-
- @Override
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- return filtered.contains(element);
- }
-
- };
- tvResults.setFilters(new ViewerFilter[] { viewerFilter });
- filterByItem.setText(Messages.ListTab_filterByItem + ELIPSIS + "(" + name + ")"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- filterByAttribute.setText(Messages.ListTab_filterByAttribute + ELIPSIS);
- }
+ filterByItem(dlg.getFirstElement().toString());
}
};
});
@@ -273,53 +451,7 @@ public class ListTab implements IViewEObjects {
public void widgetSelected(SelectionEvent e) {
TitleAreaFilterDialogWithEmptyOptions dlg = createEObjectAttributePicker(Messages.ListTab_filterByAttribute);
if (dlg.open() == dlg.OK) {
- final String attFilter = dlg.getFirstElement().toString();
- final EmptyFilterOption emptyOption = dlg.getEmptyFilterOption();
- mapId_Object.clear();
- final ArrayList<EObject> filtered = new ArrayList<EObject>();
- for (EObject object : getAllEObjects()) {
- if (EmfUtil.getAttribute(object, attFilter) != null) {
- filtered.add(object);
- ViewerFilter viewerFilter = new ViewerFilter() {
-
- @Override
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- // if filtering on attribute, always
- // reject if not defined for model
- // element
- if (EmfUtil.getAttribute((EObject) element, attFilter) == null) {
- return false;
- }
- switch (emptyOption) {
- case EXCLUDE:
- if (E.isEmpty(EmfUtil.getAttributeValue((EObject) element, attFilter))) {
- return false;
- } else {
- return filtered.contains(element);
- }
- case ONLY:
- if (E.notEmpty((EmfUtil.getAttributeValue((EObject) element, attFilter)))) {
- return false;
- } else {
- return true;
- }
- default:
- case INCLUDE:
- if (E.isEmpty(EmfUtil.getAttributeValue((EObject) element, attFilter))) {
- return true;
- } else {
- return filtered.contains(element);
- }
- }
- }
- };
- tvResults.setFilters(new ViewerFilter[] { viewerFilter });
- filterByAttribute.setText(Messages.ListTab_filterByAttribute + ELIPSIS + "(" + attFilter + ")"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- filterByItem.setText(Messages.ListTab_filterByItem + ELIPSIS);
-
- }
- }
- addColumn(attFilter);
+ filterByAttribute(dlg.getFirstElement().toString(), dlg.getEmptyFilterOption());
}
};
});
@@ -333,6 +465,8 @@ public class ListTab implements IViewEObjects {
filterRemove.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
+ filterByItemName = null;
+ filterByAttrName = null;
tvResults.setFilters(new ViewerFilter[0]);
filterByItem.setText(Messages.ListTab_filterByItem + ELIPSIS);
filterByAttribute.setText(Messages.ListTab_markAttribute + ELIPSIS);
@@ -353,8 +487,10 @@ public class ListTab implements IViewEObjects {
commandIds.add("org.eclipse.e4.tools.emf.ui.command.repair_duplicate_ids"); //$NON-NLS-1$
commandIds.add(E4ToolItemMenu.SEPARATOR);
commandIds.add("org.eclipse.e4.tools.emf.ui.command.unmark"); //$NON-NLS-1$
+ commandIds.add(E4ToolItemMenu.SEPARATOR);
+ commandIds.add("org.eclipse.e4.tools.emf.ui.command.autosizeColumns"); //$NON-NLS-1$
+ commandIds.add("org.eclipse.e4.tools.emf.ui.command.resetToDefault"); //$NON-NLS-1$
tiCommands.addCommands(commandIds);
-
}
tvResults = new TableViewer(composite, SWT.FULL_SELECTION);
@@ -370,9 +506,9 @@ public class ListTab implements IViewEObjects {
final Image imgForm = resourcePool.getImageUnchecked(ResourceProvider.IMG_Obj16_application_form);
final Image imgXmi = resourcePool.getImageUnchecked(ResourceProvider.IMG_Obj16_chart_organisation);
- final TableViewerColumn colGo = new TableViewerColumn(tvResults, SWT.NONE);
+ colGo = new TableViewerColumn(tvResults, SWT.NONE);
colGo.getColumn().setText(Messages.ListTab_col_go);
-
+ requiredColumns.put("GoTree", colGo.getColumn());
colGo.setLabelProvider(new ColumnLabelProvider() {
@Override
public Image getImage(Object element) {
@@ -385,9 +521,9 @@ public class ListTab implements IViewEObjects {
}
});
- final TableViewerColumn colGoXmi = new TableViewerColumn(tvResults, SWT.NONE);
+ colGoXmi = new TableViewerColumn(tvResults, SWT.NONE);
colGoXmi.getColumn().setText(Messages.ListTab_col_go);
-
+ requiredColumns.put("GoXmi", colGoXmi.getColumn());
colGoXmi.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
@@ -411,9 +547,10 @@ public class ListTab implements IViewEObjects {
}
});
- TableViewerColumn colMarked = new TableViewerColumn(tvResults, SWT.NONE);
+ colMarked = new TableViewerColumn(tvResults, SWT.NONE);
colMarked.getColumn().setWidth(16);
colMarked.getColumn().setText(Messages.ListTab_mark);
+ requiredColumns.put("Marked", colMarked.getColumn());
colMarked.setLabelProvider(new ColumnLabelProvider() {
@Override
public Image getImage(Object element) {
@@ -422,7 +559,7 @@ public class ListTab implements IViewEObjects {
try {
ret = imgMarkedItem;
} catch (Exception e) {
- } //$NON-NLS-1$
+ }
} else {
ret = null;
}
@@ -435,8 +572,9 @@ public class ListTab implements IViewEObjects {
}
});
- TableViewerColumn colItem = new TableViewerColumn(tvResults, SWT.NONE);
+ colItem = new TableViewerColumn(tvResults, SWT.NONE);
colItem.getColumn().setText(Messages.ListTab_col_item);
+ requiredColumns.put("Item", colItem.getColumn());
colItem.setLabelProvider(new ColumnLabelProvider_Markable() {
@Override
public String getText(Object element) {
@@ -447,20 +585,10 @@ public class ListTab implements IViewEObjects {
app.getContext().set("org.eclipse.e4.tools.active-object-viewer", this); //$NON-NLS-1$
- TableViewerColumn colId = new TableViewerColumn(tvResults, SWT.NONE);
- colId.getColumn().setText("elementId"); //$NON-NLS-1$
- colId.setLabelProvider(new ColumnLabelProvider_Markable() {
- @Override
- public String getText(Object element) {
- EObject eObject = (EObject) element;
- EAttribute eAtt = EmfUtil.getAttribute(eObject, "elementId"); //$NON-NLS-1$
- return super.getText(eObject.eGet(eAtt));
- }
- });
- colId.setEditingSupport(new EAttributeEditingSupport(tvResults, FILTER_ATTRIBUTE_ID, context));
+ EAttributeTableViewerColumn colId = new EAttributeTableViewerColumn(tvResults, "elementId", "elementId", context);
+ defaultColumns.put("elementId", colId); //$NON-NLS-1$
EAttributeTableViewerColumn colLabel = new EAttributeTableViewerColumn_Markable(tvResults, "label", "label", context); //$NON-NLS-1$ //$NON-NLS-2$
-
defaultColumns.put("label", colLabel); //$NON-NLS-1$
// Custom selection for marked items
@@ -492,12 +620,21 @@ public class ListTab implements IViewEObjects {
});
tvResults.getTable().setFocus();
+
+ for (EAttributeTableViewerColumn col : defaultColumns.values()) {
+ col.getTableViewerColumn().getColumn().setMoveable(true);
+ }
+ for (TableColumn col : requiredColumns.values()) {
+ col.setMoveable(true);
+ }
+
reload();
+ TableViewerUtil.refreshAndPack(tvResults);
+ loadSettings();
}
public void reload() {
tvResults.setInput(modelResource);
- TableViewerUtil.refreshAndPack(tvResults);
}
public TableViewer getViewer() {
@@ -628,13 +765,20 @@ public class ListTab implements IViewEObjects {
* Adds a column if it does not already exist
*
* @param attName
+ * @return The existing or newly created column
*/
- private void addColumn(String attName) {
- if (optionalColumns.containsKey(attName) == false && defaultColumns.containsKey(attName) == false) {
- EAttributeTableViewerColumn colName = new EAttributeTableViewerColumn_Markable(tvResults, attName, attName, context);
- TableViewerUtil.refreshAndPack(tvResults);
- optionalColumns.put(attName, colName);
+ private EAttributeTableViewerColumn addColumn(String attName) {
+ EAttributeTableViewerColumn colName = defaultColumns.get(attName);
+ if (colName == null) {
+ colName = optionalColumns.get(colName);
+ if (colName == null) {
+ colName = new EAttributeTableViewerColumn_Markable(tvResults, attName, attName, context);
+ optionalColumns.put(attName, colName);
+ colName.getTableViewerColumn().getColumn().setMoveable(true);
+ tvResults.refresh();
+ }
}
+ return colName;
}
private class EAttributeTableViewerColumn_Markable extends EAttributeTableViewerColumn {
@@ -675,4 +819,106 @@ public class ListTab implements IViewEObjects {
public boolean isHighlighted(Object element) {
return highlightedItems != null && highlightedItems.contains(element);
}
+
+ private void filterByItem(String name) {
+ filterByItemName = name;
+ filterByAttrName = null;
+ filterByAttrEmptyOption = null;
+ mapId_Object.clear();
+ final ArrayList<EObject> filtered = new ArrayList<EObject>();
+ for (EObject object : getAllEObjects()) {
+ if (object.eClass().getName().equals(filterByItemName)) {
+ filtered.add(object);
+ // filter.setText(Messages.ListTab_7 +
+ // attFilter);
+
+ }
+
+ ViewerFilter viewerFilter = new ViewerFilter() {
+
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ return filtered.contains(element);
+ }
+
+ };
+ tvResults.setFilters(new ViewerFilter[] { viewerFilter });
+ filterByItem.setText(Messages.ListTab_filterByItem + ELIPSIS + "(" + filterByItemName + ")"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ filterByAttribute.setText(Messages.ListTab_filterByAttribute + ELIPSIS);
+ }
+ }
+
+ private void filterByAttribute(String name, final EmptyFilterOption emptyOption) {
+ filterByAttrName = name;
+ filterByAttrEmptyOption = emptyOption;
+ filterByItemName = null;
+ mapId_Object.clear();
+ final ArrayList<EObject> filtered = new ArrayList<EObject>();
+ for (EObject object : getAllEObjects()) {
+ if (EmfUtil.getAttribute(object, filterByAttrName) != null) {
+ filtered.add(object);
+ ViewerFilter viewerFilter = new ViewerFilter() {
+
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ // if filtering on attribute, always
+ // reject if not defined for model
+ // element
+ if (EmfUtil.getAttribute((EObject) element, filterByAttrName) == null) {
+ return false;
+ }
+ switch (emptyOption) {
+ case EXCLUDE:
+ if (E.isEmpty(EmfUtil.getAttributeValue((EObject) element, filterByAttrName))) {
+ return false;
+ } else {
+ return filtered.contains(element);
+ }
+ case ONLY:
+ if (E.notEmpty((EmfUtil.getAttributeValue((EObject) element, filterByAttrName)))) {
+ return false;
+ } else {
+ return true;
+ }
+ default:
+ case INCLUDE:
+ if (E.isEmpty(EmfUtil.getAttributeValue((EObject) element, filterByAttrName))) {
+ return true;
+ } else {
+ return filtered.contains(element);
+ }
+ }
+ }
+ };
+ tvResults.setFilters(new ViewerFilter[] { viewerFilter });
+ filterByAttribute.setText(Messages.ListTab_filterByAttribute + ELIPSIS + "(" + filterByAttrName + ")"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ filterByItem.setText(Messages.ListTab_filterByItem + ELIPSIS);
+
+ }
+ }
+ TableViewerColumn viewerColumn = addColumn(filterByAttrName).getTableViewerColumn();
+ viewerColumn.getColumn().pack();
+ }
+
+ @Override
+ public void autosizeContent() {
+ for (TableColumn col : tvResults.getTable().getColumns()) {
+ col.pack();
+ if (col.getWidth() < 10) {
+ col.setWidth(10);
+ }
+ }
+ }
+
+ @Override
+ public void resetToDefault() {
+ for (EAttributeTableViewerColumn col : optionalColumns.values()) {
+ col.dispose();
+ }
+ optionalColumns.clear();
+
+ TableViewerUtil.resetColumnOrder(tvResults);
+ TableViewerUtil.packAllColumns(tvResults);
+ }
+
}
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/TableViewerUtil.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/TableViewerUtil.java
index 252cffd5..c1822324 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/TableViewerUtil.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/TableViewerUtil.java
@@ -11,6 +11,10 @@
package org.eclipse.e4.tools.emf.ui.internal.common.component.tabs;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+
import java.util.Arrays;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
@@ -22,16 +26,12 @@ import org.eclipse.swt.widgets.TableColumn;
public class TableViewerUtil {
static public void refreshAndPack(TableViewer viewer) {
viewer.refresh();
- for (TableColumn col : viewer.getTable().getColumns()) {
- col.pack();
- }
+ packAllColumns(viewer);
}
static public void updateAndPack(TableViewer viewer, Object object) {
viewer.update(object, null);
- for (TableColumn col : viewer.getTable().getColumns()) {
- col.pack();
- }
+ packAllColumns(viewer);
}
public static boolean isColumnClicked(TableViewer viewer, MouseEvent e, TableViewerColumn tvColumn) {
@@ -58,4 +58,31 @@ public class TableViewerUtil {
return cell.getElement();
}
}
+
+ public static void packAllColumns(TableViewer viewer) {
+ for (TableColumn col : viewer.getTable().getColumns()) {
+ col.pack();
+ }
+ }
+
+ static public void resetColumnOrder(TableViewer tvResults) {
+ int[] order = tvResults.getTable().getColumnOrder();
+ for (int i = 0; i < order.length; i++) {
+ order[i] = i;
+ }
+ tvResults.getTable().setColumnOrder(order);
+ }
+
+ static public ArrayList<TableColumn> getColumnsInDisplayOrder(TableViewer viewer) {
+ final ArrayList<TableColumn> allCols = new ArrayList<TableColumn>(Arrays.asList(viewer.getTable().getColumns()));
+ final int[] order = viewer.getTable().getColumnOrder();
+ Collections.sort(allCols, new Comparator<TableColumn>() {
+
+ @Override
+ public int compare(TableColumn o1, TableColumn o2) {
+ return order[allCols.indexOf(o1)] - order[allCols.indexOf(o2)];
+ }
+ });
+ return allCols;
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/handlers/AutosizeColumnsHandler.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/handlers/AutosizeColumnsHandler.java
new file mode 100644
index 00000000..b09dec25
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/handlers/AutosizeColumnsHandler.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2014 TwelveTone LLC 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:
+ * Steven Spungin <steven@spungin.tv> - initial API and implementation, Bug 436889
+ *******************************************************************************/
+
+package org.eclipse.e4.tools.emf.ui.internal.handlers;
+
+import javax.inject.Named;
+import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.tools.emf.ui.internal.common.component.tabs.IViewEObjects;
+
+public class AutosizeColumnsHandler extends MarkDuplicateItemsBase {
+ @Execute
+ public void execute(@Named(VIEWER_KEY) IViewEObjects viewer, IEclipseContext context) {
+ viewer.autosizeContent();
+ }
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/handlers/ResetToDefaultHandler.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/handlers/ResetToDefaultHandler.java
new file mode 100644
index 00000000..94116111
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/handlers/ResetToDefaultHandler.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2014 TwelveTone LLC 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:
+ * Steven Spungin <steven@spungin.tv> - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.e4.tools.emf.ui.internal.handlers;
+
+import javax.inject.Named;
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.tools.emf.ui.internal.common.component.tabs.IViewEObjects;
+
+public class ResetToDefaultHandler extends AbstractHandler {
+
+ @Execute
+ public void execute(@Named(VIEWER_KEY) IViewEObjects viewer) {
+ viewer.resetToDefault();
+ }
+
+} \ No newline at end of file

Back to the top