diff options
author | Lucas Bullen | 2017-09-27 19:04:49 +0000 |
---|---|---|
committer | Lucas Bullen | 2017-09-29 16:22:48 +0000 |
commit | 448060f3d02df89a42ce6fbc5c72567d9cc746c6 (patch) | |
tree | ed4db4af96f054b69bf6dee8e6cdfb0f9247c63c | |
parent | b2c693171d1aef1336e325b1327bb750eb1346f4 (diff) | |
download | eclipse.platform.ui-448060f3d02df89a42ce6fbc5c72567d9cc746c6.tar.gz eclipse.platform.ui-448060f3d02df89a42ce6fbc5c72567d9cc746c6.tar.xz eclipse.platform.ui-448060f3d02df89a42ce6fbc5c72567d9cc746c6.zip |
Bug 500051 - Add option to import/export preferences from Dialog
Buttons on preferences view linking to Import/Export Wizards
Change-Id: Ie614eb37d4a88f1fca9e8261e4c39936eac4d95c
Signed-off-by: Lucas Bullen <lbullen@redhat.com>
3 files changed, 82 insertions, 0 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java index 262226b6da2..1aa2e1b6f35 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java @@ -16,6 +16,7 @@ * Alain Bernard <alain.bernard1224@gmail.com> - Bug 281490 * Patrik Suzzi <psuzzi@gmail.com> - Bug 491785, 368977, 501811, 511198 * Kaloyan Raev <kaloyan.r@zend.com> - Bug 322002 + * Lucas Bullen (Red Hat Inc.) - Bug 500051 *******************************************************************************/ package org.eclipse.ui.internal; @@ -452,6 +453,10 @@ public class WorkbenchMessages extends NLS { public static String PreferenceNode_errorMessage; public static String PreferenceNode_NotFound; public static String Preference_note; + public static String Preference_importTooltip; + public static String Preference_exportTooltip; + public static String Preference_import; + public static String Preference_export; // --- Workbench --- public static String WorkbenchPreference_showMultipleEditorTabsButton; diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/FilteredPreferenceDialog.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/FilteredPreferenceDialog.java index 7c10125fa23..212ec746194 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/FilteredPreferenceDialog.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/FilteredPreferenceDialog.java @@ -10,6 +10,7 @@ * Oakland Software (Francis Upton) <francisu@ieee.org> - bug 219273 * Lars Vogel <Lars.Vogel@gmail.com> - Bug 440810 * Stefan Xenos <sxenos@google.com> - Bug 466793 + * Lucas Bullen (Red Hat Inc.) - Bug 500051 *******************************************************************************/ package org.eclipse.ui.internal.dialogs; @@ -36,12 +37,15 @@ import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.ViewerFilter; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.events.FocusAdapter; import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.GridData; @@ -49,11 +53,14 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Link; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.Sash; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; +import org.eclipse.swt.widgets.ToolBar; +import org.eclipse.swt.widgets.ToolItem; import org.eclipse.ui.ActiveShellExpression; import org.eclipse.ui.IWorkbenchCommandConstants; import org.eclipse.ui.PlatformUI; @@ -66,6 +73,8 @@ import org.eclipse.ui.internal.IWorkbenchGraphicConstants; import org.eclipse.ui.internal.WorkbenchImages; import org.eclipse.ui.internal.WorkbenchMessages; import org.eclipse.ui.internal.misc.StatusUtil; +import org.eclipse.ui.internal.wizards.preferences.PreferencesExportWizard; +import org.eclipse.ui.internal.wizards.preferences.PreferencesImportWizard; import org.eclipse.ui.model.IContributionService; import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; import org.eclipse.ui.preferences.IWorkingCopyManager; @@ -181,6 +190,10 @@ public abstract class FilteredPreferenceDialog extends PreferenceDialog private boolean locked; + private Image importImage; + + private Image exportImage; + /** * Creates a new preference dialog under the control of the given preference * manager. @@ -356,6 +369,61 @@ public abstract class FilteredPreferenceDialog extends PreferenceDialog } @Override + protected Control createHelpControl(Composite parent) { + Control control = super.createHelpControl(parent); + if (control instanceof ToolBar) { + ToolBar toolBar = (ToolBar) control; + + new ToolItem(toolBar, SWT.SEPARATOR).setWidth(0); + + ToolItem importButton = new ToolItem(toolBar, SWT.PUSH); + importImage = WorkbenchImages.getImageDescriptor(IWorkbenchGraphicConstants.IMG_ETOOL_IMPORT_WIZ) + .createImage(); + importButton.setImage(importImage); + importButton.setToolTipText(WorkbenchMessages.Preference_importTooltip); + importButton.addListener(SWT.Selection, e -> openImportWizard(parent)); + + new ToolItem(toolBar, SWT.SEPARATOR).setWidth(0); + + ToolItem exportButton = new ToolItem(toolBar, SWT.PUSH); + exportImage = WorkbenchImages.getImageDescriptor(IWorkbenchGraphicConstants.IMG_ETOOL_EXPORT_WIZ) + .createImage(); + exportButton.setImage(exportImage); + exportButton.setToolTipText(WorkbenchMessages.Preference_exportTooltip); + exportButton.addListener(SWT.Selection, e -> openExportWizard(parent)); + } else if (control instanceof Link) { + Composite linkParent = ((Link) control).getParent(); + Link importLink = new Link(linkParent, SWT.WRAP | SWT.NO_FOCUS); + ((GridLayout) parent.getLayout()).numColumns++; + importLink.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER)); + importLink.setText(" <a>" + WorkbenchMessages.Preference_import + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$ + importLink.addListener(SWT.Selection, e -> openImportWizard(parent)); + + Link exportLink = new Link(linkParent, SWT.WRAP | SWT.NO_FOCUS); + ((GridLayout) parent.getLayout()).numColumns++; + exportLink.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER)); + exportLink.setText(" <a>" + WorkbenchMessages.Preference_export + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$ + exportLink.addListener(SWT.Selection, e -> openExportWizard(parent)); + } + return control; + } + + private void openImportWizard(Composite parent) { + Wizard importWizard = new PreferencesImportWizard(); + WizardDialog wizardDialog = new WizardDialog(parent.getShell(), importWizard); + wizardDialog.open(); + if (wizardDialog.getReturnCode() == 0) { + parent.getShell().close(); + } + } + + private void openExportWizard(Composite parent) { + Wizard exportWizard = new PreferencesExportWizard(); + WizardDialog wizardDialog = new WizardDialog(parent.getShell(), exportWizard); + wizardDialog.open(); + } + + @Override public IPreferencePage getCurrentPage() { return super.getCurrentPage(); } @@ -607,6 +675,10 @@ public abstract class FilteredPreferenceDialog extends PreferenceDialog } removeKeyScrolling(); history.dispose(); + if (importImage != null) + importImage.dispose(); + if (exportImage != null) + exportImage.dispose(); return super.close(); } diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/messages.properties b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/messages.properties index dd8ed9c2c32..e55a1d9afaf 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/messages.properties +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/messages.properties @@ -20,6 +20,7 @@ # Lars Vogel <Lars.Vogel@vogella.com> - Bug 407432 # Patrik Suzzi <psuzzi@gmail.com> - Bug 491572, 491785, 501811, 511198 # Kaloyan Raev <kaloyan.r@zend.com> - Bug 322002 +# Lucas Bullen (Red Hat Inc.) - Bug 500051 ############################################################################### # package: org.eclipse.ui @@ -401,6 +402,10 @@ NewProject_title = New Project PreferenceNode_errorMessage = Unable to create the selected preference page. PreferenceNode_NotFound = {0} not found Preference_note = Note: +Preference_importTooltip = Import Preferences +Preference_exportTooltip = Export Preferences +Preference_import = Import +Preference_export = Export # --- Workbench --- WorkbenchPreference_showMultipleEditorTabsButton = Show &multiple editor tabs |