Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/*******************************************************************************
* 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
* http://www.eclipse.org/legal/epl-v10.html
*
* 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;

Expand All @@ -22,6 +23,7 @@
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;

Expand Down Expand Up @@ -95,6 +97,16 @@ protected void preprocessSelection(List<EditPart> editParts) {
@Override
protected void buildContextMenu(final EditPart editPart, final IMenuManager manager) {
addGroups(manager);
//Toolbar actions refer to the actions that also occur on the WB toolbar such as the Refresh and Preview action
boolean includeToolbarActions =
InstanceScope.INSTANCE.getNode("org.eclipse.wb.contextMenu").getBoolean(
"toolbarActions",
true);
//The object Info actions refer to those actions that are specific to the object the context menu is generated for
boolean includeObjectInfoActions =
InstanceScope.INSTANCE.getNode("org.eclipse.wb.contextMenu").getBoolean(
"objectInfoActions",
true);
// edit
{
manager.appendToGroup(IContextMenuConstants.GROUP_EDIT, m_pageActions.getCutAction());
Expand All @@ -104,17 +116,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 (includeToolbarActions) {
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 (includeObjectInfoActions) {
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);
}
});
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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.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_UI_PREFERENCE_NODE =
"org.eclipse.wb.core.editor.constants.preferences";
//Windowbuilder basic is a simplified version of Windowbuilder, containing fewer UI elements.
public static String WB_BASIC_UI = "basicUserInterface";
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
/*******************************************************************************
* Copyright (c) 2011 Google, Inc.
* Copyright (c) 2011, 2022 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Google, Inc. - initial API and implementation
* Marcel du Preez - Hiding/showing of buttons depending on WB Basic preference
*******************************************************************************/
package org.eclipse.wb.internal.core.editor.errors;

import org.eclipse.wb.core.branding.BrandingUtils;
import org.eclipse.wb.core.branding.IBrandingDescription;
import org.eclipse.wb.core.controls.BrowserComposite;
import org.eclipse.wb.core.editor.constants.IEditorPreferenceConstants;
import org.eclipse.wb.internal.core.DesignerPlugin;
import org.eclipse.wb.internal.core.EnvironmentUtils;
import org.eclipse.wb.internal.core.editor.Messages;
Expand All @@ -23,9 +25,8 @@
import org.eclipse.wb.internal.core.utils.ui.GridLayoutFactory;
import org.eclipse.wb.internal.core.utils.ui.SwtResourceManager;

import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
Expand All @@ -50,6 +51,7 @@ public abstract class ExceptionComposite extends Composite {
private BrowserComposite m_browserComposite;
private Image m_screenshotImage;
private int m_sourcePosition;
private final boolean wbBasic;

////////////////////////////////////////////////////////////////////////////
//
Expand All @@ -58,6 +60,10 @@ public abstract class ExceptionComposite extends Composite {
////////////////////////////////////////////////////////////////////////////
public ExceptionComposite(Composite parent, int style) {
super(parent, style);
wbBasic = InstanceScope.INSTANCE.getNode(
IEditorPreferenceConstants.WB_BASIC_UI_PREFERENCE_NODE).getBoolean(
IEditorPreferenceConstants.WB_BASIC_UI,
true);
// create GUI elements
GridLayoutFactory.create(this);
{
Expand All @@ -72,9 +78,10 @@ public ExceptionComposite(Composite parent, int style) {
{
Link label = new Link(titleComposite, SWT.WRAP | SWT.NO_FOCUS);
GridDataFactory.create(label).alignHL().grabH().alignVM();
label.setText(MessageFormat.format(
Messages.ExceptionComposite_message,
BrandingUtils.getBranding().getProductName()));
label.setText(
MessageFormat.format(
Messages.ExceptionComposite_message,
BrandingUtils.getBranding().getProductName()));
label.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
Expand Down Expand Up @@ -104,9 +111,10 @@ public void widgetSelected(SelectionEvent event) {
Button contactSupportButton = new Button(buttonsComposite, SWT.NONE);
GridDataFactory.create(contactSupportButton).fillH();
contactSupportButton.setText(Messages.ExceptionComposite_reportButton);
contactSupportButton.setImage(EnvironmentUtils.IS_MAC
? null
: DesignerPlugin.getImage("actions/errors/support32.png"));
contactSupportButton.setImage(
EnvironmentUtils.IS_MAC
? null
: DesignerPlugin.getImage("actions/errors/support32.png"));
contactSupportButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Expand All @@ -115,20 +123,23 @@ public void widgetSelected(SelectionEvent e) {
dialog.open();
}
});
contactSupportButton.setVisible(!wbBasic);
}
{
Button refreshButton = new Button(buttonsComposite, SWT.NONE);
GridDataFactory.create(refreshButton).fillH();
refreshButton.setText(Messages.ExceptionComposite_reparseButton);
refreshButton.setImage(EnvironmentUtils.IS_MAC
? null
: DesignerPlugin.getImage("actions/errors/refresh32.png"));
refreshButton.setImage(
EnvironmentUtils.IS_MAC
? null
: DesignerPlugin.getImage("actions/errors/refresh32.png"));
refreshButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doRefresh();
}
});
refreshButton.setVisible(!wbBasic);
}
{
m_switchButton = new Button(buttonsComposite, SWT.NONE);
Expand All @@ -140,14 +151,13 @@ public void widgetSelected(SelectionEvent ev) {
doShowSource(m_sourcePosition);
}
});
m_switchButton.setVisible(!wbBasic);
}
}
// dispose
addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
if (m_screenshotImage != null) {
m_screenshotImage.dispose();
}
addDisposeListener(e -> {
if (m_screenshotImage != null) {
m_screenshotImage.dispose();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
/*******************************************************************************
* Copyright (c) 2011 Google, Inc.
* Copyright (c) 2011, 2022 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Google, Inc. - initial API and implementation
* Marcel du Preez - Hiding/showing of buttons depending on WB Basic preference
*******************************************************************************/
package org.eclipse.wb.internal.core.editor.errors;

import org.eclipse.wb.core.controls.BrowserComposite;
import org.eclipse.wb.core.editor.constants.IEditorPreferenceConstants;
import org.eclipse.wb.internal.core.DesignerPlugin;
import org.eclipse.wb.internal.core.EnvironmentUtils;
import org.eclipse.wb.internal.core.editor.Messages;
Expand All @@ -19,6 +21,7 @@
import org.eclipse.wb.internal.core.utils.ui.GridLayoutFactory;
import org.eclipse.wb.internal.core.utils.ui.SwtResourceManager;

import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
Expand All @@ -39,6 +42,7 @@ public abstract class WarningComposite extends Composite {
private final BrowserComposite m_browser;
private final Label m_titleLabel;
private int m_sourcePosition;
private final boolean wbBasic;

////////////////////////////////////////////////////////////////////////////
//
Expand All @@ -47,6 +51,10 @@ public abstract class WarningComposite extends Composite {
////////////////////////////////////////////////////////////////////////////
public WarningComposite(Composite parent, int style) {
super(parent, style);
wbBasic = InstanceScope.INSTANCE.getNode(
IEditorPreferenceConstants.WB_BASIC_UI_PREFERENCE_NODE).getBoolean(
IEditorPreferenceConstants.WB_BASIC_UI,
true);
GridLayoutFactory.create(this);
{
Composite titleComposite = new Composite(this, SWT.NONE);
Expand All @@ -58,10 +66,8 @@ public WarningComposite(Composite parent, int style) {
}
{
m_titleLabel = new Label(titleComposite, SWT.NONE);
m_titleLabel.setFont(SwtResourceManager.getFont(
getFont().getFontData()[0].getName(),
14,
SWT.BOLD));
m_titleLabel.setFont(
SwtResourceManager.getFont(getFont().getFontData()[0].getName(), 14, SWT.BOLD));
}
}
{
Expand All @@ -84,15 +90,16 @@ protected void createButtons(Composite buttonsComposite) {
Button refreshButton = new Button(buttonsComposite, SWT.NONE);
GridDataFactory.create(refreshButton).fillH();
refreshButton.setText(Messages.WarningComposite_refreshButton);
refreshButton.setImage(EnvironmentUtils.IS_MAC
? null
: DesignerPlugin.getImage("actions/errors/refresh32.png"));
refreshButton.setImage(
EnvironmentUtils.IS_MAC ? null : DesignerPlugin.getImage("actions/errors/refresh32.png"));
refreshButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doRefresh();
}
});
//If not Windowbuilder Basic then button should be visible
refreshButton.setVisible(!wbBasic);
}
{
m_switchButton = new Button(buttonsComposite, SWT.NONE);
Expand All @@ -104,6 +111,8 @@ public void widgetSelected(SelectionEvent e) {
doShowSource(m_sourcePosition);
}
});
//If not Windowbuilder Basic then button should be visible
m_switchButton.setVisible(!wbBasic);
}
}

Expand Down