Commit 5a01c08b authored by Alexander Diewald's avatar Alexander Diewald

Navigator: Cleanup & documentation

Issue-Ref: 3922
Issue-Url: https://af3-developer.fortiss.org/issues/3922Signed-off-by: Alexander Diewald's avatarAlexander Diewald <diewald@fortiss.org>
parent 8c2a2628
LinkWithEditorPartListener.java 7ffa9dc9c26eca23ff85d6828ef693afe5c2367d YELLOW LinkWithEditorPartListener.java 7ffa9dc9c26eca23ff85d6828ef693afe5c2367d YELLOW
NavigatorController.java 0f9a57f5520425f3dfd698781a214c79163eb171 RED NavigatorController.java cc00f6f62d19bc57280d7d350dff93108cc2c5fd YELLOW
NavigatorDoubleClickHandler.java 0f04e10d9ba387195934d8510377053297c8f9cc RED NavigatorDoubleClickHandler.java 0f04e10d9ba387195934d8510377053297c8f9cc RED
NavigatorTreeContentComparator.java 17c35d3a680214de66a4e6c21429a2d7a8a19aa4 RED NavigatorTreeContentComparator.java 17c35d3a680214de66a4e6c21429a2d7a8a19aa4 RED
NavigatorTreeContentProvider.java 00a0d3aa1bab3721faf67c340c183bb23db0e4e9 RED NavigatorTreeContentProvider.java 00a0d3aa1bab3721faf67c340c183bb23db0e4e9 RED
NavigatorTreeUIProvider.java 5b696e995d6f892a70bdf3a0030c1c03d97996f7 RED NavigatorTreeUIProvider.java 5b696e995d6f892a70bdf3a0030c1c03d97996f7 RED
NavigatorViewPart.java 78819215c2b9a33a4f6bc31ed5091a42f5c0638a RED NavigatorViewPart.java dc951ab6747b7eab4b005b2e7e8c1a46f9f7d12c RED
...@@ -26,14 +26,12 @@ import org.eclipse.core.runtime.IStatus; ...@@ -26,14 +26,12 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.action.Action; import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.ui.ISelectionListener; import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IViewSite; import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.part.ViewPart; import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.progress.UIJob; import org.eclipse.ui.progress.UIJob;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeUIProviderBase; import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeUIProviderBase;
...@@ -52,28 +50,14 @@ import javafx.scene.control.TreeView; ...@@ -52,28 +50,14 @@ import javafx.scene.control.TreeView;
* {@link ViewPart} of the model navigator provided by the tooling kernel. * {@link ViewPart} of the model navigator provided by the tooling kernel.
* *
* @author hoelzl * @author hoelzl
* @author diewald
*/ */
public final class NavigatorController extends CompositeFXControllerBase<TreeView<Object>, Node> public final class NavigatorController extends CompositeFXControllerBase<TreeView<Object>, Node>
implements ContextMenuContextProvider, ISelectionListener, ISelectionChangedListener { implements ContextMenuContextProvider, ISelectionListener, ISelectionChangedListener {
/** Stores the menu manager. */
private MenuManager menuManager;
/** Stores the toggle action flag for editor linkage. */
private boolean isLinkedWithEditor = false;
/** Stores the toggle action for editor linkage. */
private Action linkWithEditorAction = null;
/** Toggle expert view filter action. */
private Action toggleExpertViewAction = null;
/** Change to library/non-library view action. */ /** Change to library/non-library view action. */
private Action toggleLibraryViewAction = null; private Action toggleLibraryViewAction = null;
/** Dialog setting ID for the link with editor action flag. */
private static final String LINK_WITH_EDITOR_FLAG = "navigatorSettingLinkWithEditor";
/** /**
* Element used to ensure that the selection of the {@link NavigatorTreeUIProvider} is not * Element used to ensure that the selection of the {@link NavigatorTreeUIProvider} is not
* empty. * empty.
...@@ -83,19 +67,24 @@ public final class NavigatorController extends CompositeFXControllerBase<TreeVie ...@@ -83,19 +67,24 @@ public final class NavigatorController extends CompositeFXControllerBase<TreeVie
/** References the constructed {@link DynamicTreeViewer} "controller". */ /** References the constructed {@link DynamicTreeViewer} "controller". */
protected DynamicTreeViewer<Object> dynTreeViewer; protected DynamicTreeViewer<Object> dynTreeViewer;
/** Provides model elements that shall be shown in the navigator. */
protected NavigatorTreeContentProvider contentProvider; protected NavigatorTreeContentProvider contentProvider;
/** Provides the names and images of elements visible in the navigator. */ /** Provides the names and images of elements visible in the navigator. */
private DynamicTreeUIProviderBase<Object> uiProvider; private DynamicTreeUIProviderBase<Object> uiProvider;
private IWorkbenchSite site; /** {@link IViewSite} of the parent {@link ViewPart}. */
private IViewSite site;
/** Constructor. */ /** Constructor. */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public NavigatorController() { public NavigatorController() {
} }
public void setSite(IWorkbenchSite site) { /**
* Sets the {@link IViewSite} of the parent {@link ViewPart}. Available only after construction.
*/
public void setSite(IViewSite site) {
this.site = site; this.site = site;
} }
...@@ -122,10 +111,6 @@ public final class NavigatorController extends CompositeFXControllerBase<TreeVie ...@@ -122,10 +111,6 @@ public final class NavigatorController extends CompositeFXControllerBase<TreeVie
dynTreeViewer.setDoubleClickHandler(new NavigatorDoubleClickHandler()); dynTreeViewer.setDoubleClickHandler(new NavigatorDoubleClickHandler());
// view.addSelectionChangedListener(this); // view.addSelectionChangedListener(this);
getSelectionService().addSelectionListener(this); getSelectionService().addSelectionListener(this);
// TODO(AD): Check correctness of the IViewSite cast and replace the site field with this
// type if applicable
IActionService.getInstance().registerGlobalActions(((IViewSite)site).getActionBars());
} }
/** Stores the UI update job. */ /** Stores the UI update job. */
...@@ -144,24 +129,6 @@ public final class NavigatorController extends CompositeFXControllerBase<TreeVie ...@@ -144,24 +129,6 @@ public final class NavigatorController extends CompositeFXControllerBase<TreeVie
} }
}; };
/** Creates the part listener and the view action. */
// private void createLinkWithEditorAction() {
// 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");
//
// toolBarManager.insertAfter("additions", toggleLibraryViewAction);
// }
/** Refreshes the navigator view. */ /** Refreshes the navigator view. */
public void refresh() { public void refresh() {
updateUI.schedule(); updateUI.schedule();
...@@ -198,6 +165,7 @@ public final class NavigatorController extends CompositeFXControllerBase<TreeVie ...@@ -198,6 +165,7 @@ public final class NavigatorController extends CompositeFXControllerBase<TreeVie
} }
} }
/** Removes all registrations of listeners etc. performed by this controller. */
/* package */ void deregister() { /* package */ void deregister() {
NavigatorService.getInstance().setNavigatorController(null); NavigatorService.getInstance().setNavigatorController(null);
getSelectionService().removeSelectionListener(this); getSelectionService().removeSelectionListener(this);
...@@ -216,10 +184,12 @@ public final class NavigatorController extends CompositeFXControllerBase<TreeVie ...@@ -216,10 +184,12 @@ public final class NavigatorController extends CompositeFXControllerBase<TreeVie
return getEObjectElements(getSelection()); return getEObjectElements(getSelection());
} }
/** Returns the {@link ISelection} of the navigator. */
public ISelection getSelection() { public ISelection getSelection() {
return site.getSelectionProvider().getSelection(); return site.getSelectionProvider().getSelection();
} }
/** Programmatically sets the {@link ISelection} of the navigator. */
public void setSelection(ISelection selection) { public void setSelection(ISelection selection) {
site.getSelectionProvider().setSelection(selection); site.getSelectionProvider().setSelection(selection);
} }
......
...@@ -29,6 +29,7 @@ import org.eclipse.ui.IEditorPart; ...@@ -29,6 +29,7 @@ import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IPartListener2; import org.eclipse.ui.IPartListener2;
import org.eclipse.ui.ISaveablePart; import org.eclipse.ui.ISaveablePart;
import org.eclipse.ui.ISaveablesSource; import org.eclipse.ui.ISaveablesSource;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.Saveable; import org.eclipse.ui.Saveable;
import org.eclipse.ui.views.properties.IPropertySheetPage; import org.eclipse.ui.views.properties.IPropertySheetPage;
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor; import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
...@@ -41,12 +42,16 @@ import org.fortiss.tooling.kernel.ui.ToolingKernelUIActivator; ...@@ -41,12 +42,16 @@ import org.fortiss.tooling.kernel.ui.ToolingKernelUIActivator;
import org.fortiss.tooling.kernel.ui.internal.NavigatorService; import org.fortiss.tooling.kernel.ui.internal.NavigatorService;
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.service.IActionService;
import org.fortiss.tooling.kernel.ui.service.INavigatorService; import org.fortiss.tooling.kernel.ui.service.INavigatorService;
import javafx.scene.Scene; import javafx.scene.Scene;
/** /**
* {@link AF3FXViewPart} presenting a navigation view to the users. The actual logic is implemented
* in the {@link NavigatorController}.
* *
* @author hoelzl
* @author diewald * @author diewald
*/ */
public class NavigatorViewPart extends AF3FXViewPart public class NavigatorViewPart extends AF3FXViewPart
...@@ -80,13 +85,15 @@ public class NavigatorViewPart extends AF3FXViewPart ...@@ -80,13 +85,15 @@ public class NavigatorViewPart extends AF3FXViewPart
// NOTE: All post-construct created eclipse objects must be set here. Also, the // NOTE: All post-construct created eclipse objects must be set here. Also, the
// initialization routine must be called here, since the reflective call from the FXML // initialization routine must be called here, since the reflective call from the FXML
// engine is not performed here. // engine is not performed here.
controller.setSite(getSite()); IViewSite site = (IViewSite)getSite();
controller.setSite(site);
controller.initialize(); controller.initialize();
// Actions and Listeners. // Actions and Listeners.
String additionString = createToolbarAdditions(); String additionString = createToolbarAdditions();
createExpertViewToggle(additionString); createExpertViewToggle(additionString);
createLinkWithEditorAction(additionString); createLinkWithEditorAction(additionString);
IActionService.getInstance().registerGlobalActions(site.getActionBars());
return super.createFxScene(); return super.createFxScene();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment