Skip to content
Snippets Groups Projects
Commit d6762953 authored by Johannes Eder's avatar Johannes Eder
Browse files

removed library button from navigator

* removed unused LibraryView class

Issue-Ref: 4043
Issue-Url: https://af3-developer.fortiss.org/issues/4043



Signed-off-by: default avatarJohannes Eder <eder@fortiss.org>
parent e773306e
No related branches found
No related tags found
1 merge request!1214043
Showing
with 15 additions and 312 deletions
...@@ -3,8 +3,8 @@ AllocationEditPartFactoryService.java 81bd227736013f1157ba9d0f79a9f3deefe10064 G ...@@ -3,8 +3,8 @@ AllocationEditPartFactoryService.java 81bd227736013f1157ba9d0f79a9f3deefe10064 G
ContextMenuService.java ca3c899293f25b70ce8e5f0d86ca2f9683329d81 GREEN ContextMenuService.java ca3c899293f25b70ce8e5f0d86ca2f9683329d81 GREEN
EditPartFactoryService.java e9180c0020f1769d9e24ef3c08f9ca5599dbc5c3 GREEN EditPartFactoryService.java e9180c0020f1769d9e24ef3c08f9ca5599dbc5c3 GREEN
MarkerService.java 208f97f3ccabf0947702a17ddca23d8766a268f4 GREEN MarkerService.java 208f97f3ccabf0947702a17ddca23d8766a268f4 GREEN
ModelEditorBindingService.java 577f5db41abf240291434dbad6bc6b0fde1eeb2b GREEN ModelEditorBindingService.java d980691db4b700714c0669050014d08751354d5e YELLOW
ModelElementHandlerService.java eeb07f6926012aa98256d452d1e554a5486dc657 GREEN ModelElementHandlerService.java eeb07f6926012aa98256d452d1e554a5486dc657 GREEN
NavigatorService.java 2b1361eac805996e22e5409dafff9707fbac3376 GREEN NavigatorService.java 1d773dde3791ddf7051616fe249558e7e307757d YELLOW
ToolingKernelUIInternal.java a70d19883dfb315d860233156d8524cf1ac2952f GREEN ToolingKernelUIInternal.java a70d19883dfb315d860233156d8524cf1ac2952f GREEN
TutorialUIService.java b1d632eca91b4feb583f3930cd6ee4722dd9bfed GREEN TutorialUIService.java b1d632eca91b4feb583f3930cd6ee4722dd9bfed GREEN
...@@ -28,6 +28,7 @@ import java.util.HashMap; ...@@ -28,6 +28,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.conqat.ide.commons.ui.ui.WorkbenchUtils;
import org.eclipse.emf.common.command.CommandStackListener; import org.eclipse.emf.common.command.CommandStackListener;
import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EObject;
import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorPart;
...@@ -58,9 +59,9 @@ import org.fortiss.tooling.kernel.ui.extension.ModelEditorNotAvailableBinding; ...@@ -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.ExtendableMultiPageEditor;
import org.fortiss.tooling.kernel.ui.internal.editor.ModelElementEditorInput; 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.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.IModelEditorBindingService;
import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService; import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
import org.fortiss.tooling.kernel.ui.service.INavigatorService;
/** /**
* This class implements the {@link IModelEditorBindingService} interface. * This class implements the {@link IModelEditorBindingService} interface.
...@@ -141,7 +142,12 @@ public class ModelEditorBindingService extends EObjectAwareServiceBase<IModelEdi ...@@ -141,7 +142,12 @@ public class ModelEditorBindingService extends EObjectAwareServiceBase<IModelEdi
IModelElementHandlerService.getInstance().getModelElementHandler(libElement); IModelElementHandlerService.getInstance().getModelElementHandler(libElement);
if(handler != null) { if(handler != null) {
EObject displayedElement = handler.handleOpenModelElementRequest(libElement); 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); openInEditor(displayedElement);
} }
return; return;
......
...@@ -89,7 +89,7 @@ public class NavigatorService implements INavigatorService, IPersistencyServiceL ...@@ -89,7 +89,7 @@ public class NavigatorService implements INavigatorService, IPersistencyServiceL
public String getIntrospectionDescription() { public String getIntrospectionDescription() {
return getIntrospectionLabel() + return getIntrospectionLabel() +
"\n\nThis service manages the model element navigator view including the handling of" + "\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. */ /** Initializes the service. */
...@@ -362,12 +362,6 @@ public class NavigatorService implements INavigatorService, IPersistencyServiceL ...@@ -362,12 +362,6 @@ public class NavigatorService implements INavigatorService, IPersistencyServiceL
saveablesChanged(SaveablesLifecycleEvent.DIRTY_CHANGED, element, false); saveablesChanged(SaveablesLifecycleEvent.DIRTY_CHANGED, element, false);
} }
/** {@inheritDoc} */
@Override
public void setLibraryViewActive() {
getNavigatorViewPart().setLibraryViewActive();
}
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void tutorialStarted(ITutorialProvider provider) { public void tutorialStarted(ITutorialProvider provider) {
......
...@@ -9,4 +9,4 @@ ModelElementsViewFX.java b1d03d57b67bf2c7b1d8da0ad3b16ea7d59efab5 GREEN ...@@ -9,4 +9,4 @@ ModelElementsViewFX.java b1d03d57b67bf2c7b1d8da0ad3b16ea7d59efab5 GREEN
NavigatorNewMenu.java a35e391960d1dacbe7f77982e53e1891e9382d5a GREEN NavigatorNewMenu.java a35e391960d1dacbe7f77982e53e1891e9382d5a GREEN
NavigatorTreeContentComparator.java d9f1354cfdff78b104b28887d2397e5ca0e9755b GREEN NavigatorTreeContentComparator.java d9f1354cfdff78b104b28887d2397e5ca0e9755b GREEN
NavigatorTreeContentProvider.java 1fbe97bebf3805cc1af190cecd784fc1cfd12306 GREEN NavigatorTreeContentProvider.java 1fbe97bebf3805cc1af190cecd784fc1cfd12306 GREEN
NavigatorViewPart.java 79872dfaab92f20e8767cff84b66dc9e173601d1 GREEN NavigatorViewPart.java d0d93194b40a7ecd171d0f4703a784e1fdbe9346 YELLOW
/*-------------------------------------------------------------------------+
| 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);
}
}
}
...@@ -99,9 +99,6 @@ public final class NavigatorViewPart extends ViewPart implements ISelectionListe ...@@ -99,9 +99,6 @@ public final class NavigatorViewPart extends ViewPart implements ISelectionListe
/** Toggle expert view filter action. */ /** Toggle expert view filter action. */
private Action toggleExpertViewAction = null; 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. */ /** Dialog setting ID for the link with editor action flag. */
private static final String LINK_WITH_EDITOR_FLAG = "navigatorSettingLinkWithEditor"; private static final String LINK_WITH_EDITOR_FLAG = "navigatorSettingLinkWithEditor";
...@@ -226,19 +223,6 @@ public final class NavigatorViewPart extends ViewPart implements ISelectionListe ...@@ -226,19 +223,6 @@ public final class NavigatorViewPart extends ViewPart implements ISelectionListe
linkWithEditorAction.setToolTipText("Link with editor"); linkWithEditorAction.setToolTipText("Link with editor");
linkWithEditorAction.setChecked(settings.getBoolean(LINK_WITH_EDITOR_FLAG)); 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) { toggleExpertViewAction = new Action("Toggle expert view", SWT.TOGGLE) {
@Override @Override
...@@ -259,7 +243,6 @@ public final class NavigatorViewPart extends ViewPart implements ISelectionListe ...@@ -259,7 +243,6 @@ public final class NavigatorViewPart extends ViewPart implements ISelectionListe
toolBarManager.insertAfter("additions", toggleExpertViewAction); toolBarManager.insertAfter("additions", toggleExpertViewAction);
toolBarManager.insertAfter("additions", linkWithEditorAction); toolBarManager.insertAfter("additions", linkWithEditorAction);
toolBarManager.insertAfter("additions", toggleLibraryViewAction);
} }
/** Creates the context menu. */ /** Creates the context menu. */
...@@ -418,17 +401,6 @@ public final class NavigatorViewPart extends ViewPart implements ISelectionListe ...@@ -418,17 +401,6 @@ public final class NavigatorViewPart extends ViewPart implements ISelectionListe
return INavigatorService.getInstance().isExpertViewActive(); 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. */ /** Refreshes the viewer and reveals the given element. */
public void refreshAndReveal(Object element) { public void refreshAndReveal(Object element) {
elementToBeRevealed = element; elementToBeRevealed = element;
......
LibraryTreeContentProvider.java dadf37cf8e54da481aac354d2c1b1360a018ea31 YELLOW LibraryTreeContentProvider.java dadf37cf8e54da481aac354d2c1b1360a018ea31 YELLOW
LibraryViewPart.java 7bdae7fdacca2d3d21e619473a6aa18d171e6deb YELLOW LibraryViewPart.java ec13bcdbe0c577bb4594be3b93c4b5ba16a003cc YELLOW
...@@ -176,6 +176,7 @@ public final class LibraryViewPart extends ViewPart implements ISelectionListene ...@@ -176,6 +176,7 @@ public final class LibraryViewPart extends ViewPart implements ISelectionListene
@Override @Override
public void setFocus() { public void setFocus() {
viewer.getControl().setFocus(); viewer.getControl().setFocus();
viewer.refresh();
} }
/** Reveals the given element in the navigator view. */ /** Reveals the given element in the navigator view. */
......
...@@ -5,5 +5,5 @@ IEditPartFactoryService.java c448bff63fb81f57037c9f1dc5319859c12d0c4d GREEN ...@@ -5,5 +5,5 @@ IEditPartFactoryService.java c448bff63fb81f57037c9f1dc5319859c12d0c4d GREEN
IMarkerService.java d433e838e387dd2fe61b8dea7395ebb7203ae39b GREEN IMarkerService.java d433e838e387dd2fe61b8dea7395ebb7203ae39b GREEN
IModelEditorBindingService.java ce2ae1957e2232bb0fac1d1d262103f9adfc5266 GREEN IModelEditorBindingService.java ce2ae1957e2232bb0fac1d1d262103f9adfc5266 GREEN
IModelElementHandlerService.java 748ffd22d6836a5599f8785f023469eb58c80ece GREEN IModelElementHandlerService.java 748ffd22d6836a5599f8785f023469eb58c80ece GREEN
INavigatorService.java 8d2ffeb6f075d3abea904b84d8a40090d97837fd GREEN INavigatorService.java 8fc66f7e554cfb547f2ce65dec9f48ac0559c54e YELLOW
ITutorialUIService.java 72707c60c3d23d8ffc5c579cb9b022bb614eb094 GREEN ITutorialUIService.java 72707c60c3d23d8ffc5c579cb9b022bb614eb094 GREEN
...@@ -73,7 +73,4 @@ public interface INavigatorService { ...@@ -73,7 +73,4 @@ public interface INavigatorService {
/** Refreshes the navigator view part. */ /** Refreshes the navigator view part. */
void refresh(); void refresh();
/** Sets the library view active. */
void setLibraryViewActive();
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment