-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make overlay scrolling configurable via the palette settings
This adds a new checkbox to the settings dialog that allows the user to replace the overlay scrollbar with the native scrollbar. Linux only, as the overlay is not available on any other platforms. Resolves #569
- Loading branch information
Showing
17 changed files
with
397 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 120 additions & 0 deletions
120
org.eclipse.gef.tests/src/org/eclipse/gef/test/swtbot/AbstractSWTBotEditorTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 IBM Corporation 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: | ||
* IBM Corporation - 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(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
org.eclipse.gef.tests/src/org/eclipse/gef/test/swtbot/PaletteSettingsDialogTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.