瀏覽代碼

#767 add possibility to replace sct diagram editors outline

Johannes Dicks 9 年之前
父節點
當前提交
0845a045d5

+ 9 - 0
plugins/org.yakindu.sct.domain.generic/src/org/yakindu/sct/domain/generic/modules/GenericEditorModule.java

@@ -14,7 +14,9 @@ import org.eclipse.xtext.service.AbstractGenericModule;
 import org.yakindu.sct.refactoring.proposals.RefactoringProposalProvider;
 import org.yakindu.sct.ui.editor.editor.proposals.SmartEditProposalProvider;
 import org.yakindu.sct.ui.editor.proposals.IEditProposalProvider;
+import org.yakindu.sct.ui.editor.providers.DefaultSCTOutlineFactory;
 import org.yakindu.sct.ui.editor.providers.DefaultSCTPaletteFactory;
+import org.yakindu.sct.ui.editor.providers.ISCTOutlineFactory;
 import org.yakindu.sct.ui.editor.providers.ISCTPaletteFactory;
 
 import com.google.inject.Binder;
@@ -24,6 +26,8 @@ import com.google.inject.multibindings.Multibinder;
  * This module registers services that are intended to be used by the graphical editor.
  * 
  * @author terfloth
+ * @author muelder - add palette factory
+ * @author dicks - add outline factory
  *
  */
 public class GenericEditorModule extends AbstractGenericModule {
@@ -39,5 +43,10 @@ public class GenericEditorModule extends AbstractGenericModule {
 	public Class<? extends ISCTPaletteFactory> bindISCTPaletteFactory() {
 		return DefaultSCTPaletteFactory.class;
 	}
+	public Class<? extends ISCTOutlineFactory> bindISCTOutlineFactory() {
+		return DefaultSCTOutlineFactory.class;
+	}
+	
+	
 	
 }

+ 19 - 2
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editor/StatechartDiagramEditor.java

@@ -36,6 +36,7 @@ import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.help.IWorkbenchHelpSystem;
 import org.eclipse.ui.ide.IGotoMarker;
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
 import org.eclipse.xtext.ui.XtextProjectHelper;
 import org.yakindu.base.xtext.utils.gmf.resource.DirtyStateListener;
 import org.yakindu.sct.domain.extension.DomainRegistry;
@@ -46,13 +47,13 @@ import org.yakindu.sct.ui.editor.DiagramActivator;
 import org.yakindu.sct.ui.editor.partitioning.DiagramPartitioningEditor;
 import org.yakindu.sct.ui.editor.partitioning.DiagramPartitioningUtil;
 import org.yakindu.sct.ui.editor.proposals.ContentProposalViewerKeyHandler;
+import org.yakindu.sct.ui.editor.providers.ISCTOutlineFactory;
 import org.yakindu.sct.ui.editor.utils.HelpContextIds;
 import org.yakindu.sct.ui.editor.validation.SCTValidationJob;
 
 import com.google.inject.Injector;
 
 /**
- * 
  * @author andreas muelder - Initial contribution and API
  * @author martin esser
  */
@@ -95,6 +96,17 @@ public class StatechartDiagramEditor extends DiagramPartitioningEditor implement
 		super(true);
 	}
 
+	@Override
+	public Object getAdapter(@SuppressWarnings("rawtypes") Class type) {
+		if (IContentOutlinePage.class.equals(type)) {
+			IDomainInjectorProvider injectorProvider = DomainRegistry.getDomainDescriptor(getDiagram().getElement())
+					.getDomainInjectorProvider();
+			ISCTOutlineFactory instance = injectorProvider.getEditorInjector().getInstance(ISCTOutlineFactory.class);
+			return instance.createOutline(this);
+		}
+		return super.getAdapter(type);
+	}
+
 	@Override
 	public void init(IEditorSite site, IEditorInput input) throws PartInitException {
 		super.init(site, input);
@@ -207,9 +219,14 @@ public class StatechartDiagramEditor extends DiagramPartitioningEditor implement
 		}
 		super.dispose();
 	}
-	
+
 	@Override
 	protected int getInitialPaletteSize() {
 		return 175;
 	}
+
+	public IContentOutlinePage getDefaultOutline() {
+		return (IContentOutlinePage) super.getAdapter(IContentOutlinePage.class);
+	}
+
 }

+ 29 - 0
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/providers/DefaultSCTOutlineFactory.java

@@ -0,0 +1,29 @@
+/**
+ * Copyright (c) 2016 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.ui.editor.providers;
+
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
+import org.yakindu.sct.ui.editor.editor.StatechartDiagramEditor;
+
+/**
+ * Provide default implementations for the gef based StatechartDiagram editors outline. 
+ * 
+ * @author Johannes Dicks - Initial contribution and API
+ *
+ */
+public class DefaultSCTOutlineFactory implements ISCTOutlineFactory {
+
+	@Override
+	public IContentOutlinePage createOutline(StatechartDiagramEditor statechartDiagramEditor) {
+		return statechartDiagramEditor.getDefaultOutline();
+	}
+
+}

+ 31 - 0
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/providers/ISCTOutlineFactory.java

@@ -0,0 +1,31 @@
+/**
+ * Copyright (c) 2016 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.ui.editor.providers;
+
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
+import org.yakindu.sct.ui.editor.editor.StatechartDiagramEditor;
+
+/**
+ * 
+ * @author Johannes Dicks - Initial contribution and API
+ *
+ */
+public interface ISCTOutlineFactory {
+	
+	/**
+	 * Creates an implementation of an {@link IContentOutlinePage} which will be shown if the editor is active.
+	 * 
+	 * @param statechartDiagramEditor current editors instance
+	 * @return an instance of an outline
+	 */
+	IContentOutlinePage createOutline(StatechartDiagramEditor statechartDiagramEditor);
+
+}