From d676295386e887df397f79062a6570568532410f Mon Sep 17 00:00:00 2001 From: Johannes Eder <eder@fortiss.org> Date: Tue, 21 Jul 2020 10:39:05 +0200 Subject: [PATCH] removed library button from navigator * removed unused LibraryView class Issue-Ref: 4043 Issue-Url: https://af3-developer.fortiss.org/issues/4043 Signed-off-by: Johannes Eder <eder@fortiss.org> --- .../tooling/kernel/ui/internal/.ratings | 4 +- .../internal/ModelEditorBindingService.java | 10 +- .../kernel/ui/internal/NavigatorService.java | 8 +- .../tooling/kernel/ui/internal/views/.ratings | 2 +- .../kernel/ui/internal/views/LibraryView.java | 267 ------------------ .../ui/internal/views/NavigatorViewPart.java | 28 -- .../kernel/ui/internal/views/library/.ratings | 2 +- .../views/library/LibraryViewPart.java | 1 + .../tooling/kernel/ui/service/.ratings | 2 +- .../kernel/ui/service/INavigatorService.java | 3 - 10 files changed, 15 insertions(+), 312 deletions(-) delete mode 100644 org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/LibraryView.java diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/.ratings b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/.ratings index 47d763c0b..dd697c8d8 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/.ratings +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/.ratings @@ -3,8 +3,8 @@ AllocationEditPartFactoryService.java 81bd227736013f1157ba9d0f79a9f3deefe10064 G ContextMenuService.java ca3c899293f25b70ce8e5f0d86ca2f9683329d81 GREEN EditPartFactoryService.java e9180c0020f1769d9e24ef3c08f9ca5599dbc5c3 GREEN MarkerService.java 208f97f3ccabf0947702a17ddca23d8766a268f4 GREEN -ModelEditorBindingService.java 577f5db41abf240291434dbad6bc6b0fde1eeb2b GREEN +ModelEditorBindingService.java d980691db4b700714c0669050014d08751354d5e YELLOW ModelElementHandlerService.java eeb07f6926012aa98256d452d1e554a5486dc657 GREEN -NavigatorService.java 2b1361eac805996e22e5409dafff9707fbac3376 GREEN +NavigatorService.java 1d773dde3791ddf7051616fe249558e7e307757d YELLOW ToolingKernelUIInternal.java a70d19883dfb315d860233156d8524cf1ac2952f GREEN TutorialUIService.java b1d632eca91b4feb583f3930cd6ee4722dd9bfed GREEN diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/ModelEditorBindingService.java b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/ModelEditorBindingService.java index 577f5db41..d980691db 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/ModelEditorBindingService.java +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/ModelEditorBindingService.java @@ -28,6 +28,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.conqat.ide.commons.ui.ui.WorkbenchUtils; import org.eclipse.emf.common.command.CommandStackListener; import org.eclipse.emf.ecore.EObject; import org.eclipse.ui.IEditorPart; @@ -58,9 +59,9 @@ import org.fortiss.tooling.kernel.ui.extension.ModelEditorNotAvailableBinding; import org.fortiss.tooling.kernel.ui.internal.editor.ExtendableMultiPageEditor; import org.fortiss.tooling.kernel.ui.internal.editor.ModelElementEditorInput; import org.fortiss.tooling.kernel.ui.internal.introspection.items.ModelEditorBindingServiceIntrospectionDetailsItem; +import org.fortiss.tooling.kernel.ui.internal.views.library.LibraryViewPart; import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService; import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService; -import org.fortiss.tooling.kernel.ui.service.INavigatorService; /** * This class implements the {@link IModelEditorBindingService} interface. @@ -141,7 +142,12 @@ public class ModelEditorBindingService extends EObjectAwareServiceBase<IModelEdi IModelElementHandlerService.getInstance().getModelElementHandler(libElement); if(handler != null) { EObject displayedElement = handler.handleOpenModelElementRequest(libElement); - INavigatorService.getInstance().setLibraryViewActive(); + try { + WorkbenchUtils.getActiveWorkbenchPage().showView(LibraryViewPart.ID); + } catch(PartInitException e) { + error(ToolingKernelActivator.getDefault(), + "Could not open Library View with ID " + LibraryViewPart.ID, e); + } openInEditor(displayedElement); } return; diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/NavigatorService.java b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/NavigatorService.java index 2b1361eac..1d773dde3 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/NavigatorService.java +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/NavigatorService.java @@ -89,7 +89,7 @@ public class NavigatorService implements INavigatorService, IPersistencyServiceL public String getIntrospectionDescription() { return getIntrospectionLabel() + "\n\nThis service manages the model element navigator view including the handling of" + - "\nsaveables, the dirty state, and the expert and library mode."; + "\nsaveables, the dirty state, and the expert mode."; } /** Initializes the service. */ @@ -362,12 +362,6 @@ public class NavigatorService implements INavigatorService, IPersistencyServiceL saveablesChanged(SaveablesLifecycleEvent.DIRTY_CHANGED, element, false); } - /** {@inheritDoc} */ - @Override - public void setLibraryViewActive() { - getNavigatorViewPart().setLibraryViewActive(); - } - /** {@inheritDoc} */ @Override public void tutorialStarted(ITutorialProvider provider) { diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/.ratings b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/.ratings index a841f867f..4f5450a5b 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/.ratings +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/.ratings @@ -9,4 +9,4 @@ ModelElementsViewFX.java b1d03d57b67bf2c7b1d8da0ad3b16ea7d59efab5 GREEN NavigatorNewMenu.java a35e391960d1dacbe7f77982e53e1891e9382d5a GREEN NavigatorTreeContentComparator.java d9f1354cfdff78b104b28887d2397e5ca0e9755b GREEN NavigatorTreeContentProvider.java 1fbe97bebf3805cc1af190cecd784fc1cfd12306 GREEN -NavigatorViewPart.java 79872dfaab92f20e8767cff84b66dc9e173601d1 GREEN +NavigatorViewPart.java d0d93194b40a7ecd171d0f4703a784e1fdbe9346 YELLOW diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/LibraryView.java b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/LibraryView.java deleted file mode 100644 index 44107622d..000000000 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/LibraryView.java +++ /dev/null @@ -1,267 +0,0 @@ -/*-------------------------------------------------------------------------+ -| Copyright 2011 fortiss GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.tooling.kernel.ui.internal.views; - -import static org.fortiss.tooling.kernel.utils.EcoreUtils.filterOutInstanceOf; -import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getParentElement; - -import java.util.List; -import java.util.Set; - -import org.conqat.ide.commons.ui.jface.TreeContentProviderBase; -import org.conqat.ide.commons.ui.ui.EmptyPartListener; -import org.conqat.lib.commons.collections.IdentityHashSet; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.swt.SWT; -import org.eclipse.swt.dnd.Transfer; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.dialogs.FilteredTree; -import org.eclipse.ui.dialogs.PatternFilter; -import org.eclipse.ui.part.ViewPart; -import org.fortiss.tooling.kernel.extension.data.LibraryPrototype; -import org.fortiss.tooling.kernel.extension.data.Prototype; -import org.fortiss.tooling.kernel.extension.data.PrototypeCategory; -import org.fortiss.tooling.kernel.model.ILibraryElement; -import org.fortiss.tooling.kernel.service.IPrototypeService; -import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler; -import org.fortiss.tooling.kernel.ui.extension.base.EditorBase; -import org.fortiss.tooling.kernel.ui.internal.editor.ExtendableMultiPageEditor; -import org.fortiss.tooling.kernel.ui.listener.ExtendableMultiPageEditorPageChangeListener; -import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService; - -/** - * {@link ViewPart} for the model element library view. - * - * @author hoelzl - * @author eder - */ -public class LibraryView extends ViewPart { - - /** The viewer. */ - private TreeViewer viewer; - - /** Filter text field for the tree viewer. */ - private FilteredTree filteredTree; - - /** Current active {@link ExtendableMultiPageEditor}. */ - private ExtendableMultiPageEditor activeBindingEditor = null; - - /** Stores the editor activation listener. */ - private EditorActivationListener editorActivationListener = new EditorActivationListener(); - - /** The container object used. */ - private EObject containerObject = null; - - /** The prototypes supported by the current editor. */ - private Set<Prototype> supportedBaseClasses = new IdentityHashSet<Prototype>(); - - /** Listener for reacting to changes of the embedded editor. */ - private final ExtendableMultiPageEditorPageChangeListener bindingEditorPageChangeListener = - new ExtendableMultiPageEditorPageChangeListener() { - @Override - public void pageChanged() { - updateEditorFilters(activeBindingEditor.getActiveModelEditor()); - } - }; - - /** {@inheritDoc} */ - @Override - public void createPartControl(Composite parent) { - PatternFilter patternFilter = new PatternFilter(); - patternFilter.setIncludeLeadingWildcard(true); - - filteredTree = new FilteredTree(parent, SWT.H_SCROLL | SWT.V_SCROLL, patternFilter, false); - viewer = filteredTree.getViewer(); - - viewer.setContentProvider(new LibraryTreeContentProvider()); - viewer.setLabelProvider(new LibraryLabelProvider()); - - LibraryViewDragSourceAdapter dndAdapter = new LibraryViewDragSourceAdapter(viewer); - viewer.addDragSupport(dndAdapter.getSupportedDNDOperations(), - new Transfer[] {dndAdapter.getPreferredTransfer()}, dndAdapter); - - viewer.setInput(IPrototypeService.getInstance().getAllTopLevelPrototypesCategories()); - - viewer.addFilter(new LibraryViewerFilter()); - - getViewSite().setSelectionProvider(viewer); - getSite().getWorkbenchWindow().getPartService().addPartListener(editorActivationListener); - } - - /** Switches to the given workbench editor part. */ - private void switchWorkbenchEditor(IEditorPart editor) { - if(activeBindingEditor != null) { - activeBindingEditor.removeBindingEditorListener(bindingEditorPageChangeListener); - activeBindingEditor = null; - } - - if(editor instanceof ExtendableMultiPageEditor) { - activeBindingEditor = (ExtendableMultiPageEditor)editor; - activeBindingEditor.addBindingEditorListener(bindingEditorPageChangeListener); - updateEditorFilters(activeBindingEditor.getActiveModelEditor()); - } else if(editor != null) { - updateEditorFilters(editor); - } - } - - /** Updates the filters according to the given editor. */ - @SuppressWarnings("unchecked") - private void updateEditorFilters(IEditorPart editor) { - supportedBaseClasses.clear(); - if(editor instanceof EditorBase && - ((EditorBase<? extends EObject>)editor).enableLibraryView()) { - EditorBase<? extends EObject> editorBase = (EditorBase<? extends EObject>)editor; - containerObject = editorBase.getEditedObject(); - - for(Class<? extends EObject> clazz : editorBase.getVisibleEObjectTypes()) { - List<Prototype> composablePrototypes = - IPrototypeService.getInstance().getComposablePrototypes(clazz); - if(getParentElement(containerObject, ILibraryElement.class, true) == null) { - supportedBaseClasses.addAll(composablePrototypes); - } else { - supportedBaseClasses.addAll( - filterOutInstanceOf(LibraryPrototype.class, composablePrototypes)); - } - } - } else { - containerObject = null; - } - - if(!viewer.getControl().isDisposed()) { - viewer.refresh(); - viewer.expandAll(); - } - } - - /** {@inheritDoc} */ - @Override - public void setFocus() { - viewer.getControl().setFocus(); - } - - /** The label provider used in the library view. */ - private class LibraryLabelProvider extends LabelProvider { - - /** {@inheritDoc} */ - @Override - public String getText(Object element) { - if(element instanceof Prototype) { - Prototype prototype = (Prototype)element; - return prototype.getName(); - } - if(element instanceof PrototypeCategory) { - return ((PrototypeCategory)element).getName(); - } - return super.getText(element); - } - - /** {@inheritDoc} */ - @Override - public Image getImage(Object element) { - if(element instanceof Prototype) { - // delegate to the model element handlers - EObject prototype = ((Prototype)element).getPrototype(); - IModelElementHandler<EObject> handler = - IModelElementHandlerService.getInstance().getModelElementHandler(prototype); - if(handler != null) { - return handler.getIcon(prototype); - } - } - if(element instanceof PrototypeCategory && - ((PrototypeCategory)element).getChildren().length > 0) { - return getImage(((PrototypeCategory)element).getChildren()[0]); - } - return super.getImage(element); - } - } - - /** The content provider used in the library view. */ - private class LibraryTreeContentProvider extends TreeContentProviderBase { - - /** {@inheritDoc} */ - @SuppressWarnings("rawtypes") - @Override - public Object[] getElements(Object inputElement) { - if(inputElement instanceof Object[]) { - return (Object[])inputElement; - } - if(inputElement instanceof List) { - return ((List)inputElement).toArray(); - } - return new Object[0]; - } - - /** {@inheritDoc} */ - @Override - public Object[] getChildren(Object parentElement) { - if(parentElement instanceof PrototypeCategory) { - return ((PrototypeCategory)parentElement).getChildren(); - } - return new Object[0]; - } - } - - /** The filter used in the library view. */ - private class LibraryViewerFilter extends ViewerFilter { - - /** {@inheritDoc} */ - @Override - public boolean select(Viewer viewer, Object parentElement, Object element) { - if(containerObject == null || supportedBaseClasses.isEmpty()) { - return false; - } - if(element instanceof PrototypeCategory) { - PrototypeCategory pc = (PrototypeCategory)element; - for(Object child : pc.getChildren()) { - if(select(viewer, pc, child)) { - return true; - } - } - return false; - } - return supportedBaseClasses.contains(element); - } - } - - /** If an editor in a different Project is opened the Model is reinitialized */ - private class EditorActivationListener extends EmptyPartListener { - - /** Change the tree viewer content whenever workbench part changes. */ - @Override - public void partActivated(IWorkbenchPart workbenchPart) { - if(!(workbenchPart instanceof IEditorPart)) { - return; - } - - Control control = viewer.getControl(); - if(control == null || control.isDisposed()) { - return; - } - - IEditorPart part = (IEditorPart)workbenchPart; - viewer.setInput(IPrototypeService.getInstance().getAllTopLevelPrototypesCategories()); - switchWorkbenchEditor(part); - } - } -} diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/NavigatorViewPart.java b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/NavigatorViewPart.java index 79872dfaa..d0d93194b 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/NavigatorViewPart.java +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/NavigatorViewPart.java @@ -99,9 +99,6 @@ public final class NavigatorViewPart extends ViewPart implements ISelectionListe /** Toggle expert view filter action. */ private Action toggleExpertViewAction = null; - /** Change to library/non-library view action. */ - private Action toggleLibraryViewAction = null; - /** Dialog setting ID for the link with editor action flag. */ private static final String LINK_WITH_EDITOR_FLAG = "navigatorSettingLinkWithEditor"; @@ -226,19 +223,6 @@ public final class NavigatorViewPart extends ViewPart implements ISelectionListe linkWithEditorAction.setToolTipText("Link with editor"); linkWithEditorAction.setChecked(settings.getBoolean(LINK_WITH_EDITOR_FLAG)); - toggleLibraryViewAction = new Action("Toggle library view", SWT.TOGGLE) { - - @Override - public void run() { - ((NavigatorTreeContentProvider)viewer.getContentProvider()).toggleLibraryView(); - viewer.refresh(); - } - }; - - toggleLibraryViewAction.setImageDescriptor( - ToolingKernelUIActivator.getImageDescriptor("icons/library.png")); - toggleLibraryViewAction.setToolTipText("Toggle library view"); - toggleExpertViewAction = new Action("Toggle expert view", SWT.TOGGLE) { @Override @@ -259,7 +243,6 @@ public final class NavigatorViewPart extends ViewPart implements ISelectionListe toolBarManager.insertAfter("additions", toggleExpertViewAction); toolBarManager.insertAfter("additions", linkWithEditorAction); - toolBarManager.insertAfter("additions", toggleLibraryViewAction); } /** Creates the context menu. */ @@ -418,17 +401,6 @@ public final class NavigatorViewPart extends ViewPart implements ISelectionListe return INavigatorService.getInstance().isExpertViewActive(); } - /** Sets the library view to be active. */ - public void setLibraryViewActive() { - NavigatorTreeContentProvider contentProvider = - (NavigatorTreeContentProvider)viewer.getContentProvider(); - if(!contentProvider.isLibraryViewActive()) { - contentProvider.toggleLibraryView(); - viewer.refresh(); - toggleLibraryViewAction.setChecked(true); - } - } - /** Refreshes the viewer and reveals the given element. */ public void refreshAndReveal(Object element) { elementToBeRevealed = element; diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/library/.ratings b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/library/.ratings index 70cb60bb7..67e41b1a6 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/library/.ratings +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/library/.ratings @@ -1,2 +1,2 @@ LibraryTreeContentProvider.java dadf37cf8e54da481aac354d2c1b1360a018ea31 YELLOW -LibraryViewPart.java 7bdae7fdacca2d3d21e619473a6aa18d171e6deb YELLOW +LibraryViewPart.java ec13bcdbe0c577bb4594be3b93c4b5ba16a003cc YELLOW diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/library/LibraryViewPart.java b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/library/LibraryViewPart.java index 7bdae7fda..ec13bcdbe 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/library/LibraryViewPart.java +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/library/LibraryViewPart.java @@ -176,6 +176,7 @@ public final class LibraryViewPart extends ViewPart implements ISelectionListene @Override public void setFocus() { viewer.getControl().setFocus(); + viewer.refresh(); } /** Reveals the given element in the navigator view. */ diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/service/.ratings b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/service/.ratings index 1ded5ea76..7a8c22d91 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/service/.ratings +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/service/.ratings @@ -5,5 +5,5 @@ IEditPartFactoryService.java c448bff63fb81f57037c9f1dc5319859c12d0c4d GREEN IMarkerService.java d433e838e387dd2fe61b8dea7395ebb7203ae39b GREEN IModelEditorBindingService.java ce2ae1957e2232bb0fac1d1d262103f9adfc5266 GREEN IModelElementHandlerService.java 748ffd22d6836a5599f8785f023469eb58c80ece GREEN -INavigatorService.java 8d2ffeb6f075d3abea904b84d8a40090d97837fd GREEN +INavigatorService.java 8fc66f7e554cfb547f2ce65dec9f48ac0559c54e YELLOW ITutorialUIService.java 72707c60c3d23d8ffc5c579cb9b022bb614eb094 GREEN diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/service/INavigatorService.java b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/service/INavigatorService.java index 8d2ffeb6f..8fc66f7e5 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/service/INavigatorService.java +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/service/INavigatorService.java @@ -73,7 +73,4 @@ public interface INavigatorService { /** Refreshes the navigator view part. */ void refresh(); - - /** Sets the library view active. */ - void setLibraryViewActive(); } -- GitLab