diff --git a/gama.core/src/gama/gaml/compilation/kernel/GamaBundleLoader.java b/gama.core/src/gama/gaml/compilation/kernel/GamaBundleLoader.java index 56ab560bb1..e835b86362 100644 --- a/gama.core/src/gama/gaml/compilation/kernel/GamaBundleLoader.java +++ b/gama.core/src/gama/gaml/compilation/kernel/GamaBundleLoader.java @@ -1,7 +1,7 @@ /******************************************************************************************************* * * GamaBundleLoader.java, in gama.core, is part of the source code of the GAMA modeling and simulation platform - * . + * (v.1.9.3). * * (c) 2007-2024 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU) * @@ -159,6 +159,9 @@ public static void ERROR(final String message, final Exception e) { private static final Set GAMA_CORE_DISPLAY_PLUGINS = Set.of("gama.ui.display.java2d", "gama.ui.display.opengl"); + /** The Constant GAMA_DIAGRAM_EDITOR_PLUGIN. */ + private static final String GAMA_DIAGRAM_EDITOR_PLUGIN = "gama.ui.diagram"; + /** The model plugins. */ private static final Multimap MODEL_PLUGINS = ArrayListMultimap.create(); @@ -524,7 +527,13 @@ public static boolean isDisplayPlugin(final String s) { */ public static void addDisplayPlugin(final String plugin) { GAMA_DISPLAY_PLUGINS_NAMES.add(plugin); - } + /** + * Checks if is diagram editor loaded. + * + * @return true, if is diagram editor loaded + */ + public static boolean isDiagramEditorLoaded() { return Platform.getBundle(GAMA_DIAGRAM_EDITOR_PLUGIN) != null; } + } \ No newline at end of file diff --git a/gama.product/gama.product b/gama.product/gama.product index 915bca5639..5d4f223baf 100644 --- a/gama.product/gama.product +++ b/gama.product/gama.product @@ -1,7 +1,7 @@ - + @@ -120,11 +120,11 @@ - - + + diff --git a/gama.ui.editor/src/gaml/compiler/ui/editor/GamlEditor.java b/gama.ui.editor/src/gaml/compiler/ui/editor/GamlEditor.java index a045c09060..6f8c9adf64 100644 --- a/gama.ui.editor/src/gaml/compiler/ui/editor/GamlEditor.java +++ b/gama.ui.editor/src/gaml/compiler/ui/editor/GamlEditor.java @@ -1,7 +1,7 @@ /******************************************************************************************************* * - * GamlEditor.java, in gama.ui.shared.modeling, is part of the source code of the GAMA modeling and simulation platform - * . + * GamlEditor.java, in gama.ui.editor, is part of the source code of the GAMA modeling and simulation platform + * (v.1.9.3). * * (c) 2007-2024 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU) * @@ -201,6 +201,9 @@ protected static IPreferenceStore getPreferences() { } + /** The diagram opener. */ + static IDiagramOpener diagramOpener; + /** The images. */ static Map images = new HashMap(); @@ -478,7 +481,6 @@ public void createPartControl(final Composite compo) { // toolbarParent.setBackground(IGamaColors.WHITE.color()); // Asking the editor to fill the rest - // final int style = GamaToolbarFactory.REDUCED_VIEW_TOOLBAR_HEIGHT.getValue() ? SWT.NONE : SWT.BORDER; final var editor = new Composite(toolbarParent, SWT.NONE); final var data = new GridData(SWT.FILL, SWT.FILL, true, true); editor.setLayoutData(data); @@ -1136,4 +1138,23 @@ protected CompositeRuler createCompositeRuler() { */ public URI getURI() { return fileURI; } + /** + * + */ + public void switchToDiagram() { + if (diagramOpener != null) { diagramOpener.open(this); } + } + + /** + * Switch to text. + */ + public void switchToText() { + if (diagramOpener != null) { diagramOpener.close(this); } + } + + /** + * @param generateDiagramHandler + */ + public static void setDiagramOpener(final IDiagramOpener opener) { diagramOpener = opener; } + } diff --git a/gama.ui.editor/src/gaml/compiler/ui/editor/IDiagramOpener.java b/gama.ui.editor/src/gaml/compiler/ui/editor/IDiagramOpener.java new file mode 100644 index 0000000000..9b2e6a47e5 --- /dev/null +++ b/gama.ui.editor/src/gaml/compiler/ui/editor/IDiagramOpener.java @@ -0,0 +1,32 @@ +/******************************************************************************************************* + * + * IDiagramOpener.java, in gama.ui.editor, is part of the source code of the GAMA modeling and simulation platform + * (v.1.9.3). + * + * (c) 2007-2024 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU) + * + * Visit https://github.com/gama-platform/gama for license information and contacts. + * + ********************************************************************************************************/ +package gaml.compiler.ui.editor; + +/** + * The class IDiagramOpener. + * + * @author drogoul + * @since 28 févr. 2024 + * + */ +public interface IDiagramOpener { + + /** + * Open. + */ + void open(GamlEditor editor); + + /** + * Close. + */ + void close(GamlEditor editor); + +} diff --git a/gama.ui.editor/src/gaml/compiler/ui/editor/toolbar/EditorToolbar.java b/gama.ui.editor/src/gaml/compiler/ui/editor/toolbar/EditorToolbar.java index e5275994ab..95b84dc767 100644 --- a/gama.ui.editor/src/gaml/compiler/ui/editor/toolbar/EditorToolbar.java +++ b/gama.ui.editor/src/gaml/compiler/ui/editor/toolbar/EditorToolbar.java @@ -1,7 +1,7 @@ /******************************************************************************************************* * - * EditorToolbar.java, in gama.ui.shared.modeling, is part of the source code of the GAMA modeling and simulation - * platform . + * EditorToolbar.java, in gama.ui.editor, is part of the source code of the GAMA modeling and simulation platform + * (v.1.9.3). * * (c) 2007-2024 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU) * @@ -28,6 +28,7 @@ import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.widgets.ToolItem; +import gama.gaml.compilation.kernel.GamaBundleLoader; import gama.ui.shared.bindings.GamaKeyBindings; import gama.ui.shared.utils.WorkbenchHelper; import gama.ui.shared.views.toolbar.GamaToolbarSimple; @@ -43,7 +44,7 @@ public class EditorToolbar { /** The previous. */ - ToolItem next, previous; + ToolItem next, previous, diagram; /** The find. */ EditorSearchControls find; @@ -108,6 +109,16 @@ public void widgetSelected(final SelectionEvent e) { editor.openOutlinePopup(); } }); + if (GamaBundleLoader.isDiagramEditorLoaded()) { + diagram = toolbar.button("editor/command.graphical", null, "Switch to diagram", new SelectionAdapter() { + + @Override + public void widgetSelected(final SelectionEvent e) { + if (editor == null) return; + editor.switchToDiagram(); + } + }); + } // Attaching listeners to the global commands in order to enable/disable the // toolbar items diff --git a/gama.ui.shared/icons/editor/command.graphical.png b/gama.ui.shared/icons/editor/command.graphical.png new file mode 100644 index 0000000000..9000925e15 Binary files /dev/null and b/gama.ui.shared/icons/editor/command.graphical.png differ diff --git a/gama.ui.shared/icons/editor/command.graphical@2x.png b/gama.ui.shared/icons/editor/command.graphical@2x.png new file mode 100644 index 0000000000..46e4ab6045 Binary files /dev/null and b/gama.ui.shared/icons/editor/command.graphical@2x.png differ diff --git a/gama.ui.shared/icons/editor/command.graphical_disabled.png b/gama.ui.shared/icons/editor/command.graphical_disabled.png new file mode 100644 index 0000000000..608612b306 Binary files /dev/null and b/gama.ui.shared/icons/editor/command.graphical_disabled.png differ diff --git a/gama.ui.shared/icons/editor/command.graphical_disabled@2x.png b/gama.ui.shared/icons/editor/command.graphical_disabled@2x.png new file mode 100644 index 0000000000..ea3ec9fc22 Binary files /dev/null and b/gama.ui.shared/icons/editor/command.graphical_disabled@2x.png differ