Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make overlay scrolling configurable via the palette settings #592

Merged
merged 1 commit into from
Oct 20, 2024
Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# GEF Classic 3.22.0

## GEF
- _Linux Only_ The overlay scrolling of the palette can be configured via the _PaletteViewerPreferences.PREFERENCE_SCROLLBARS_MODE_ preference. Supported values are _SWT.NONE_ and _SWT.SCROLLBAR_OVERLAY_.

## Zest
- Integration of Zest 2.0 development branch. See the [wiki](https://github.com/eclipse/gef-classic/wiki/Zest#zest-2x) for more details. In case only default layout algorithms are used, the initial migration should be seamless. Otherwise the algorithms can be adapted to run in legacy mode by extending `AbstractLayoutAlgorithm.Zest1` or have to be re-implemented using the new API by extending `AbstractLayoutAlgorithm`. Note that this legacy mode will be removed in a future release. The following list contains the most significant, deprecated features:
- `ContinuousLayoutAlgorithm` and `Stoppable`, with no replacement.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/*******************************************************************************
* Copyright (c) 2024 Patrick Ziegler and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Patrick Ziegler - initial API and implementation
*******************************************************************************/

package org.eclipse.gef.test.swtbot;

import org.eclipse.swt.widgets.Display;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWizard;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
import org.eclipse.ui.intro.IIntroManager;
import org.eclipse.ui.intro.IIntroPart;
import org.eclipse.ui.wizards.IWizardDescriptor;
import org.eclipse.ui.wizards.IWizardRegistry;

import org.junit.After;
import org.junit.Before;
import org.osgi.framework.Bundle;

@SuppressWarnings("nls")
public abstract class AbstractSWTBotEditorTests extends AbstractSWTBotTests {
private static final String PROJECT_NAME = "TestProject";

@Before
@Override
public void setUp() throws Exception {
super.setUp();
// This bundle disables the examples via an activityPatternBinding
Bundle bundle = Platform.getBundle("org.eclipse.gef.examples.ui.capabilities");
if (bundle != null) {
bundle.uninstall();
}
IWorkbench wb = PlatformUI.getWorkbench();
Display display = wb.getDisplay();
// Close "Welcome" page
IIntroManager im = wb.getIntroManager();
IIntroPart intro = wb.getIntroManager().getIntro();
if (intro != null) {
display.syncExec(() -> im.closeIntro(intro));
}
// Switch to the "Resource" perspective
display.syncCall(() -> {
IWorkbenchWindow ww = wb.getActiveWorkbenchWindow();
return wb.showPerspective("org.eclipse.ui.resourcePerspective", ww);
});
// Create & open new test project
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
display.syncCall(() -> {
if (!project.exists()) {
project.create(null);
}
project.open(null);
return null;
});
// Create new example file
IWizardRegistry wr = wb.getNewWizardRegistry();
IWizardDescriptor wd = wr.findWizard(getWizardId());
display.syncCall(() -> {
IWorkbenchWizard wizard = wd.createWizard();
wizard.init(wb, new StructuredSelection(project));
WizardDialog wizardDialog = new WizardDialog(display.getActiveShell(), wizard);
wizardDialog.setBlockOnOpen(false);
wizardDialog.open();
WizardNewFileCreationPage wizardPage = (WizardNewFileCreationPage) wizardDialog.getCurrentPage();
wizardPage.setFileName(getFileName());
wizard.performFinish();
wizardDialog.close();
return null;
});
}

@After
@Override
public void tearDown() throws Exception {
IWorkbench wb = PlatformUI.getWorkbench();
Display display = wb.getDisplay();
// Close all open editors
display.syncCall(() -> {
IWorkbenchWindow ww = wb.getActiveWorkbenchWindow();
IWorkbenchPage page = ww.getActivePage();
return page.closeAllEditors(false);
});
// Delete test project
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
display.syncCall(() -> {
project.delete(true, null);
return null;
});
super.tearDown();
}

/**
* @return The id of the wizard with which the test resources is created.
*/
protected abstract String getWizardId();

/**
* @return The file name (with extension) of the test resource.
*/
protected abstract String getFileName();

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,41 +21,25 @@

import org.eclipse.swt.widgets.Display;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.ILogListener;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefViewer;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWizard;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
import org.eclipse.ui.intro.IIntroManager;
import org.eclipse.ui.intro.IIntroPart;
import org.eclipse.ui.wizards.IWizardDescriptor;
import org.eclipse.ui.wizards.IWizardRegistry;

import org.eclipse.draw2d.FigureCanvas;

import org.eclipse.gef.EditPart;

import org.junit.After;
import org.junit.Before;
import org.osgi.framework.Bundle;

/**
* To be able to execute these tests in the Eclipse IDE, the tests must
* <b>NOT</b> be run in the UI thread.
*/
@SuppressWarnings("nls")
public abstract class AbstractSWTBotTests {
private static final String PROJECT_NAME = "TestProject";
private ILogListener problemListener;
private List<Throwable> problems;
protected SWTGefBot bot;
Expand All @@ -68,48 +52,6 @@ public void setUp() throws Exception {
Make sure that "Run in UI thread" is unchecked in your launch configuration or that useUIThread is set to false in the pom.xml
""");
}
// This bundle disables the examples via an activityPatternBinding
Bundle bundle = Platform.getBundle("org.eclipse.gef.examples.ui.capabilities");
if (bundle != null) {
bundle.uninstall();
}
IWorkbench wb = PlatformUI.getWorkbench();
Display display = wb.getDisplay();
// Close "Welcome" page
IIntroManager im = wb.getIntroManager();
IIntroPart intro = wb.getIntroManager().getIntro();
if (intro != null) {
display.syncExec(() -> im.closeIntro(intro));
}
// Switch to the "Resource" perspective
display.syncCall(() -> {
IWorkbenchWindow ww = wb.getActiveWorkbenchWindow();
return wb.showPerspective("org.eclipse.ui.resourcePerspective", ww);
});
// Create & open new test project
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
display.syncCall(() -> {
if (!project.exists()) {
project.create(null);
}
project.open(null);
return null;
});
// Create new example file
IWizardRegistry wr = wb.getNewWizardRegistry();
IWizardDescriptor wd = wr.findWizard(getWizardId());
display.syncCall(() -> {
IWorkbenchWizard wizard = wd.createWizard();
wizard.init(wb, new StructuredSelection(project));
WizardDialog wizardDialog = new WizardDialog(display.getActiveShell(), wizard);
wizardDialog.setBlockOnOpen(false);
wizardDialog.open();
WizardNewFileCreationPage wizardPage = (WizardNewFileCreationPage) wizardDialog.getCurrentPage();
wizardPage.setFileName(getFileName());
wizard.performFinish();
wizardDialog.close();
return null;
});
// Keep track of all unchecked exceptions
problems = new ArrayList<>();
problemListener = (status, plugin) -> {
Expand Down Expand Up @@ -144,36 +86,12 @@ private static final boolean isRelevant(Throwable throwable) {

@After
public void tearDown() throws Exception {
IWorkbench wb = PlatformUI.getWorkbench();
Display display = wb.getDisplay();
// Close all open editors
display.syncCall(() -> {
IWorkbenchWindow ww = wb.getActiveWorkbenchWindow();
IWorkbenchPage page = ww.getActivePage();
return page.closeAllEditors(false);
});
// Delete test project
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
display.syncCall(() -> {
project.delete(true, null);
return null;
});
// Cleanup problem listener and check for exceptions
Platform.removeLogListener(problemListener);
problems.forEach(Throwable::printStackTrace);
assertTrue("Test threw an unchecked exception. Check logs for details", problems.isEmpty());
}

/**
* @return The id of the wizard with which the test resources is created.
*/
protected abstract String getWizardId();

/**
* @return The file name (with extension) of the test resource.
*/
protected abstract String getFileName();

/**
* Convenience method that forces an update of the GEF viewer. This is necessary
* when e.g. moving a figure, as the new position of the edit part is calculated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.junit.Test;

@SuppressWarnings("nls")
public class FlowDiagramTests extends AbstractSWTBotTests {
public class FlowDiagramTests extends AbstractSWTBotEditorTests {

/**
* Tests whether new palette items can be added to the viewer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import org.junit.Test;

@SuppressWarnings("nls")
public class LogicDiagramTests extends AbstractSWTBotTests {
public class LogicDiagramTests extends AbstractSWTBotEditorTests {

/**
* Tests that when the ruler is enabled, moving the ruler also moves all
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*******************************************************************************
* Copyright (c) 2024 Patrick Ziegler and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Patrick Ziegler - initial API and implementation
*******************************************************************************/

package org.eclipse.gef.test.swtbot;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;

import org.eclipse.core.runtime.Platform;
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.ui.PlatformUI;

import org.eclipse.gef.internal.ui.palette.InternalPaletteSettingsDialog;
import org.eclipse.gef.ui.palette.DefaultPaletteViewerPreferences;
import org.eclipse.gef.ui.palette.PaletteViewerPreferences;
import org.eclipse.gef.ui.palette.customize.PaletteSettingsDialog;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class PaletteSettingsDialogTests extends AbstractSWTBotTests {
private SWTBotShell settingsDialog;
private PaletteViewerPreferences preferences;

@Before
@Override
public void setUp() throws Exception {
super.setUp();
preferences = new DefaultPaletteViewerPreferences();
settingsDialog = UIThreadRunnable.syncExec(() -> {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
PaletteSettingsDialog settings = new InternalPaletteSettingsDialog(shell, preferences);
settings.setBlockOnOpen(false);
settings.open();
return bot.shell("Palette Settings"); //$NON-NLS-1$
});
}

@Override
@After
public void tearDown() throws Exception {
settingsDialog.close();
super.tearDown();
}

@Test
public void testOverlayScrollingPreferences() {
assumeTrue(Platform.OS_LINUX.equals(Platform.getOS()));

SWTBotCheckBox checkbox = settingsDialog.bot().checkBox("Enable Overlay Scrolling"); //$NON-NLS-1$
assertEquals(preferences.getScrollbarsMode(), SWT.SCROLLBAR_OVERLAY);
assertTrue(checkbox.isChecked());

checkbox.click();
assertEquals(preferences.getScrollbarsMode(), SWT.NONE);
assertFalse(checkbox.isChecked());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
@Suite.SuiteClasses({
FlowDiagramTests.class,
LogicDiagramTests.class,
ShapesDiagramTests.class
ShapesDiagramTests.class,
PaletteSettingsDialogTests.class
})
public class SWTBotTestSuite {
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import org.junit.Test;

@SuppressWarnings("nls")
public class ShapesDiagramTests extends AbstractSWTBotTests {
public class ShapesDiagramTests extends AbstractSWTBotEditorTests {

/**
* Tests whether edit parts can be properly resized.
Expand Down
8 changes: 8 additions & 0 deletions org.eclipse.gef/.settings/.api_filters
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/gef/ui/palette/DefaultPaletteViewerPreferences.java" type="org.eclipse.gef.ui.palette.DefaultPaletteViewerPreferences">
<filter id="576725006">
<message_arguments>
<message_argument value="PaletteViewerPreferences"/>
<message_argument value="DefaultPaletteViewerPreferences"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/gef/ui/palette/PinDrawerAction.java" type="org.eclipse.gef.ui.palette.PinDrawerAction">
<filter id="643850349">
<message_arguments>
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.gef/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Export-Package: org.eclipse.gef,
org.eclipse.gef.handles,
org.eclipse.gef.internal;x-friends:="org.eclipse.gef.examples.text,org.eclipse.gef.examples.logic",
org.eclipse.gef.internal.icons;x-internal:=true,
org.eclipse.gef.internal.ui.palette;x-internal:=true,
org.eclipse.gef.internal.ui.palette;x-friends:="org.eclipse.gef.tests",
org.eclipse.gef.internal.ui.palette.editparts;x-internal:=true,
org.eclipse.gef.internal.ui.rulers;x-friends:="org.eclipse.gef.tests",
org.eclipse.gef.palette,
Expand Down
Loading
Loading