diff options
author | Steven Spungin | 2014-07-26 01:33:50 +0000 |
---|---|---|
committer | Steven Spungin | 2014-07-26 01:38:19 +0000 |
commit | fc6811f8bcb8f40312917429a747d458898b186e (patch) | |
tree | f321789f038a8fecf45e4db1aa657714280cf293 | |
parent | 8f11d5098da7803f2ae7129981967c3226cdcaf6 (diff) | |
download | org.eclipse.e4.tools-fc6811f8bcb8f40312917429a747d458898b186e.tar.gz org.eclipse.e4.tools-fc6811f8bcb8f40312917429a747d458898b186e.tar.xz org.eclipse.e4.tools-fc6811f8bcb8f40312917429a747d458898b186e.zip |
Bug 440469 - [model editor] add option to disable list tab persistenceI20140727-2200I20140726-2200I20140725-2200
of filter and columns
Change-Id: I1625b0ffa9cdede39f350939a8380460fec12fef
Signed-off-by: Steven Spungin <steven@spungin.tv>
3 files changed, 101 insertions, 54 deletions
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/ModelEditorPreferencePage.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/ModelEditorPreferencePage.java index 2b501574..acb7735f 100644 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/ModelEditorPreferencePage.java +++ b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/ModelEditorPreferencePage.java @@ -1,7 +1,7 @@ /******************************************************************************* * * Contributors: - * Steven Spungin <steven@spungin.tv> - Bug 431735, Bug 437890 + * Steven Spungin <steven@spungin.tv> - Bug 431735, Bug 437890, Bug 440469 ******************************************************************************/ package org.eclipse.e4.tools.emf.editor3x; @@ -28,6 +28,8 @@ public class ModelEditorPreferencePage extends PreferencePage implements IWorkbe private ColorFieldEditor fColorValueNotVisible; private ColorFieldEditor fColorValueNotVisibleAndRendered; private BooleanFieldEditor fShowSearch; + private BooleanFieldEditor fRememberColumns; + private BooleanFieldEditor fRememberFilters; public ModelEditorPreferencePage() { } @@ -100,7 +102,7 @@ public class ModelEditorPreferencePage extends PreferencePage implements IWorkbe fShowXMIId.setPreferenceStore(getPreferenceStore()); fShowXMIId.load(); } - + { Composite container = new Composite(group, SWT.NONE); container.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false, 2, 1)); @@ -109,6 +111,29 @@ public class ModelEditorPreferencePage extends PreferencePage implements IWorkbe fShowSearch.setPreferenceStore(getPreferenceStore()); fShowSearch.load(); } + + } + + { + Group group = new Group(result, SWT.NONE); + group.setText("List Tab"); + group.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false, 2, 1)); + group.setLayout(new GridLayout(2, false)); + + { + Composite container = new Composite(group, SWT.NONE); + container.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false, 2, 1)); + + fRememberColumns = new BooleanFieldEditor("list-tab-remember-columns", "Remember column settings when reopening editor ", container); + fRememberColumns.setPage(this); + fRememberColumns.setPreferenceStore(getPreferenceStore()); + fRememberColumns.load(); + + fRememberFilters = new BooleanFieldEditor("list-tab-remember-filters", "Remember filter settings when reopening editor", container); + fRememberFilters.setPage(this); + fRememberFilters.setPreferenceStore(getPreferenceStore()); + fRememberFilters.load(); + } } return result; @@ -122,6 +147,8 @@ public class ModelEditorPreferencePage extends PreferencePage implements IWorkbe fColorValueNotVisible.store(); fColorValueNotVisibleAndRendered.store(); fShowSearch.store(); + fRememberColumns.store(); + fRememberFilters.store(); return super.performOk(); } @@ -133,6 +160,8 @@ public class ModelEditorPreferencePage extends PreferencePage implements IWorkbe fColorValueNotVisible.loadDefault(); fColorValueNotVisibleAndRendered.loadDefault(); fShowSearch.loadDefault(); + fRememberColumns.loadDefault(); + fRememberFilters.loadDefault(); super.performDefaults(); } diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/PreferenceInitializer.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/PreferenceInitializer.java index 7a9d2fcc..e3d81434 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/PreferenceInitializer.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/PreferenceInitializer.java @@ -1,7 +1,7 @@ /******************************************************************************* * * Contributors: - * Steven Spungin <steven@spungin.tv> - Bug 431735, Bug 437890 + * Steven Spungin <steven@spungin.tv> - Bug 431735, Bug 437890, Bug 440469 ******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal; @@ -36,12 +36,20 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer { if (pref.get("autoCreateElementId", null) == null) { //$NON-NLS-1$ pref.putBoolean("autoCreateElementId", true); //$NON-NLS-1$ } - + // TODO: After XMI tab is not forced disabled, this should default to // true if (pref.get("tab-form-search-show", null) == null) { //$NON-NLS-1$ pref.putBoolean("tab-form-search-show", false); //$NON-NLS-1$ } + + if (pref.get("list-tab-remember-filters", null) == null) { //$NON-NLS-1$ + pref.putBoolean("list-tab-remember-filters", false); //$NON-NLS-1$ + } + + if (pref.get("list-tab-remember-columns", null) == null) { //$NON-NLS-1$ + pref.putBoolean("list-tab-remember-columns", false); //$NON-NLS-1$ + } } } 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 667cc819..c779244b 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,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Steven Spungin <steven@spungin.tv> - initial API and implementation, Bug 432555, Bug 436889, Bug 437372 + * Steven Spungin <steven@spungin.tv> - initial API and implementation, Bug 432555, Bug 436889, Bug 437372, Bug 440469 *******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.component.tabs; @@ -237,69 +237,79 @@ public class ListTab implements IViewEObjects { // load custom column and filter settings private void loadSettings() { IEclipsePreferences pref = InstanceScope.INSTANCE.getNode("org.eclipse.e4.tools.emf.ui"); //$NON-NLS-1$ + + boolean restoreColumns = pref.getBoolean("list-tab-remember-columns", false); //$NON-NLS-1$ + boolean restoreFilters = pref.getBoolean("list-tab-remember-filters", false); //$NON-NLS-1$ + if (!restoreColumns && !restoreFilters) { + return; + } + 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; + if (restoreColumns) { + // 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(); + } - // 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 = TableViewerUtil.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; + // move it to the end of the list. + int currentIndex = TableViewerUtil.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); + tvResults.getTable().setColumnOrder(order); - // if ("Item".equals(colName)) { //$NON-NLS-1$ - // col = colItem; - // } else if ("Item".equals(colName)) { //$NON-NLS-1$ - // col = colItem; - // } + // 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) { + 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; + if (restoreFilters) { + // 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); } - filterByAttribute(condition, emptyFilterOption); } } } catch (Exception e) { |