diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/Messages.java b/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/Messages.java index 5f50236db..467ec7b64 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/Messages.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/Messages.java @@ -25,6 +25,8 @@ public class Messages extends NLS { public static String TreeModelView_5; + public static String TreeModelView_6; + public static String TreeModelViewerDragDropHandler_0; static { // initialize resource bundle diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/TreeModelView.java b/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/TreeModelView.java index f5146411d..bae20f8f7 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/TreeModelView.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/TreeModelView.java @@ -7,6 +7,7 @@ import java.beans.PropertyChangeEvent; import java.io.IOException; +import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -138,6 +139,9 @@ public TreeModelView() { @Override public void doCreatePartControl(Composite parent) { + // Help + PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID); + GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; @@ -147,13 +151,10 @@ public void doCreatePartControl(Composite parent) { fTreeViewer = new TreeModelViewer(parent, SWT.NULL); fTreeViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); - fTreeViewer.setInput(IEditorModelManager.INSTANCE); - + // Drill down fDrillDownAdapter = new DrillDownAdapter(fTreeViewer); - /* - * Listen to Double-click and press Return Action - */ + // Listen to Double-click and press Return Action fTreeViewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { @@ -188,14 +189,14 @@ public void selectionChanged(SelectionChangedEvent event) { // Drag support new TreeModelViewerDragDropHandler(fTreeViewer); - // Expand tree elements - TreeStateHelper.INSTANCE.restoreExpandedTreeElements(fTreeViewer); + // Set model input now + fTreeViewer.setInput(IEditorModelManager.INSTANCE); + // Expand tree elements after model input + TreeStateHelper.INSTANCE.restoreExpandedTreeElements(fTreeViewer); + // This will update previous Undo/Redo text if Tree was closed before updateActions(); - - // Help - PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID); } @Override @@ -575,18 +576,25 @@ class FolderFilter extends ViewerFilter { @Override public boolean select(Viewer viewer, Object parentElement, Object element) { - return element instanceof IFolder ? ((IFolder)element).getType() != type : true; + return element instanceof IFolder folder ? folder.getType() != type : true; } } // Filter folder action class FolderFilterAction extends Action { - ViewerFilter filter; + FolderFilter filter; + String prefsKey; FolderFilterAction(FolderType type) { - setText(StringUtils.escapeAmpersandsInText(type.getLabel())); - setChecked(true); filter = new FolderFilter(type); + setText(StringUtils.escapeAmpersandsInText(type.getLabel())); + prefsKey = "modelTreeFolderHidden_" + type.getName(); //$NON-NLS-1$ + + boolean hidden = ArchiPlugin.PREFERENCES.getBoolean(prefsKey); + setChecked(!hidden); + if(hidden) { + getViewer().addFilter(filter); + } } @Override @@ -597,21 +605,40 @@ public void run() { else { getViewer().addFilter(filter); } + + ArchiPlugin.PREFERENCES.setValue(prefsKey, !isChecked()); } } MenuManager filterMenu = new MenuManager(Messages.TreeModelView_5); manager.add(filterMenu); - filterMenu.add(new FolderFilterAction(FolderType.STRATEGY)); - filterMenu.add(new FolderFilterAction(FolderType.BUSINESS)); - filterMenu.add(new FolderFilterAction(FolderType.APPLICATION)); - filterMenu.add(new FolderFilterAction(FolderType.TECHNOLOGY)); - filterMenu.add(new FolderFilterAction(FolderType.MOTIVATION)); - filterMenu.add(new FolderFilterAction(FolderType.IMPLEMENTATION_MIGRATION)); - filterMenu.add(new FolderFilterAction(FolderType.OTHER)); - filterMenu.add(new FolderFilterAction(FolderType.RELATIONS)); - filterMenu.add(new FolderFilterAction(FolderType.DIAGRAMS)); + List actions = new ArrayList<>(); + actions.add(new FolderFilterAction(FolderType.STRATEGY)); + actions.add(new FolderFilterAction(FolderType.BUSINESS)); + actions.add(new FolderFilterAction(FolderType.APPLICATION)); + actions.add(new FolderFilterAction(FolderType.TECHNOLOGY)); + actions.add(new FolderFilterAction(FolderType.MOTIVATION)); + actions.add(new FolderFilterAction(FolderType.IMPLEMENTATION_MIGRATION)); + actions.add(new FolderFilterAction(FolderType.OTHER)); + actions.add(new FolderFilterAction(FolderType.RELATIONS)); + actions.add(new FolderFilterAction(FolderType.DIAGRAMS)); + + for(Action action : actions) { + filterMenu.add(action); + } + + filterMenu.add(new Separator()); + + filterMenu.add(new Action(Messages.TreeModelView_6) { + @Override + public void run() { + for(Action action : actions) { + action.setChecked(true); + action.run(); + } + } + }); } /** diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/messages.properties b/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/messages.properties index 8c9204a39..dc37d81f3 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/messages.properties +++ b/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/messages.properties @@ -6,6 +6,7 @@ TreeModelView_2=Model Tree TreeModelView_3=Collapse TreeModelView_4=Expand TreeModelView_5=Visible Folders +TreeModelView_6=Show All TreeModelViewerDragDropHandler_0=Move Elements diff --git a/com.archimatetool.help/help/Images/model-tree-folderfilter.png b/com.archimatetool.help/help/Images/model-tree-folderfilter.png index e2d58cc66..97723fc16 100644 Binary files a/com.archimatetool.help/help/Images/model-tree-folderfilter.png and b/com.archimatetool.help/help/Images/model-tree-folderfilter.png differ diff --git a/com.archimatetool.help/help/Text/model_tree_working.html b/com.archimatetool.help/help/Text/model_tree_working.html index 44ee5b2fe..7cc85e99d 100644 --- a/com.archimatetool.help/help/Text/model_tree_working.html +++ b/com.archimatetool.help/help/Text/model_tree_working.html @@ -87,7 +87,7 @@

Drill Down

Hiding Folders

-

It is possible to hide top-level folders in the Model Tree. A common use case is that the "Relations" folder's contents might get very long and unwieldy. To hide a folder click the drop-down menu in the Model Tree toolbar and tick or untick the folder you wish to hide or show in the "Visible Folders" sub-menu.

+

It's possible to hide top-level folders in the Model Tree. A common use case is that the "Relations" folder's contents might get very big and unwieldy. To hide a folder, click the drop-down menu in the Model Tree toolbar and check or uncheck the folder you wish to hide or show in the "Visible Folders" sub-menu. Note that these settings persist between sessions and when closing and re-opening the Model Tree.

Showing or hiding top-level folders