diff --git a/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/editor/DesignContextMenuProvider.java b/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/editor/DesignContextMenuProvider.java index 142cc8b9f..75afa526a 100644 --- a/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/editor/DesignContextMenuProvider.java +++ b/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/editor/DesignContextMenuProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2021 Google, Inc. * 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 @@ -7,6 +7,7 @@ * * Contributors: * Google, Inc. - initial API and implementation + * Marcel du Preez - buildContextMenu alterations made to allow preferences to be set via external sources *******************************************************************************/ package org.eclipse.wb.internal.core.editor; @@ -17,11 +18,13 @@ import org.eclipse.wb.gef.core.EditPart; import org.eclipse.wb.gef.core.IEditPartViewer; import org.eclipse.wb.internal.core.editor.actions.DesignPageActions; +import org.eclipse.wb.internal.core.editor.constants.IEditorPreferenceConstants; import org.eclipse.wb.internal.core.utils.execution.ExecutionUtils; import org.eclipse.wb.internal.core.utils.execution.RunnableEx; import org.eclipse.wb.internal.gef.core.ContextMenuProvider; import org.eclipse.wb.internal.gef.core.MultiSelectionContextMenuProvider; +import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.Separator; @@ -95,6 +98,11 @@ protected void preprocessSelection(List editParts) { @Override protected void buildContextMenu(final EditPart editPart, final IMenuManager manager) { addGroups(manager); + //When Windowbuilder Basic is active Toolbar actions and Object Info actions are hidden from the context menu + boolean wbBasic = InstanceScope.INSTANCE.getNode( + IEditorPreferenceConstants.WB_BASIC_PREFERENCE_NODE).getBoolean( + IEditorPreferenceConstants.WB_BASIC, + false); // edit { manager.appendToGroup(IContextMenuConstants.GROUP_EDIT, m_pageActions.getCutAction()); @@ -104,17 +112,21 @@ protected void buildContextMenu(final EditPart editPart, final IMenuManager mana } // edit2 { - manager.appendToGroup(IContextMenuConstants.GROUP_EDIT2, m_pageActions.getTestAction()); - manager.appendToGroup(IContextMenuConstants.GROUP_EDIT2, m_pageActions.getRefreshAction()); + if (!wbBasic) { + manager.appendToGroup(IContextMenuConstants.GROUP_EDIT2, m_pageActions.getTestAction()); + manager.appendToGroup(IContextMenuConstants.GROUP_EDIT2, m_pageActions.getRefreshAction()); + } } // send notification - if (editPart.getModel() instanceof ObjectInfo) { - ExecutionUtils.runLog(new RunnableEx() { - public void run() throws Exception { - ObjectInfo object = (ObjectInfo) editPart.getModel(); - object.getBroadcastObject().addContextMenu(m_selectedObjects, object, manager); - } - }); + if (!wbBasic) { + if (editPart.getModel() instanceof ObjectInfo) { + ExecutionUtils.runLog(new RunnableEx() { + public void run() throws Exception { + ObjectInfo object = (ObjectInfo) editPart.getModel(); + object.getBroadcastObject().addContextMenu(m_selectedObjects, object, manager); + } + }); + } } } } diff --git a/org.eclipse.wb.core/META-INF/MANIFEST.MF b/org.eclipse.wb.core/META-INF/MANIFEST.MF index 6d87b1d1d..7a462d6ed 100644 --- a/org.eclipse.wb.core/META-INF/MANIFEST.MF +++ b/org.eclipse.wb.core/META-INF/MANIFEST.MF @@ -58,6 +58,7 @@ Export-Package: org.eclipse.wb.core.branding, org.eclipse.wb.internal.core.editor.actions, org.eclipse.wb.internal.core.editor.actions.assistant, org.eclipse.wb.internal.core.editor.actions.errors, + org.eclipse.wb.internal.core.editor.constants, org.eclipse.wb.internal.core.editor.describer, org.eclipse.wb.internal.core.editor.errors, org.eclipse.wb.internal.core.editor.errors.report2, diff --git a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/editor/constants/IEditorPreferenceConstants.java b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/editor/constants/IEditorPreferenceConstants.java new file mode 100644 index 000000000..e5b987795 --- /dev/null +++ b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/editor/constants/IEditorPreferenceConstants.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2021, 2021 DSA Daten- und Systemtechnik GmbH. (https://www.dsa.de) + * 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: + * Marcel du Preez - initial implementation +*********************************************************************************/ +package org.eclipse.wb.internal.core.editor.constants; + +/** + * This interface contains the constants used to alter preferences for Windowbuilder. + * + */ +public interface IEditorPreferenceConstants { + //The node to use for the Windowbuilder basic preference + public static String WB_BASIC_PREFERENCE_NODE = + "org.eclipse.wb.internal.core.editor.constants.preferences"; + //Windowbuilder basic is a simplified version of Windowbuilder, containing fewer UI elements. + public static String WB_BASIC = "windowbuilderBasic"; +}