/** * Save the ids of the selected elements. * * @param selectionIDs */ private void saveSettings(String[] selectionIDs) { IDialogSettings settings = IDEWorkbenchPlugin.getDefault().getDialogSettings().getSection(WORKBENCH_SETTINGS); if (settings == null) settings = IDEWorkbenchPlugin.getDefault().getDialogSettings().addNewSection(WORKBENCH_SETTINGS); settings.put(ENABLED_TRANSFERS, selectionIDs); }
/** * Create the buttons for the settings transfer. * * @param toolkit * @param sectionClient * @return boolean <code>true</code> if any were selected */ private boolean createButtons(FormToolkit toolkit, Composite sectionClient) { IConfigurationElement[] settings = SettingsTransfer.getSettingsTransfers(); String[] enabledSettings = getEnabledSettings( IDEWorkbenchPlugin.getDefault().getDialogSettings().getSection(WORKBENCH_SETTINGS)); for (int i = 0; i < settings.length; i++) { final IConfigurationElement settingsTransfer = settings[i]; final Button button = toolkit.createButton(sectionClient, settings[i].getAttribute(ATT_NAME), SWT.CHECK); String helpId = settings[i].getAttribute(ATT_HELP_CONTEXT); if (helpId != null) PlatformUI.getWorkbench().getHelpSystem().setHelp(button, helpId); if (enabledSettings != null && enabledSettings.length > 0) { String id = settings[i].getAttribute(ATT_ID); for (int j = 0; j < enabledSettings.length; j++) { if (enabledSettings[j].equals(id)) { button.setSelection(true); selectedSettings.add(settingsTransfer); break; } } } button.setBackground(sectionClient.getBackground()); button.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (button.getSelection()) selectedSettings.add(settingsTransfer); else selectedSettings.remove(settingsTransfer); } }); } return enabledSettings != null && enabledSettings.length > 0; }