use of org.eclipse.ui.internal.ide.IDEWorkbenchPlugin in project liferay-ide by liferay.
the class ChooseWorkspaceWithPreferenceDialog method _createButtons.
@SuppressWarnings("unchecked")
private boolean _createButtons(Composite parent) {
IConfigurationElement[] settings = SettingsTransfer.getSettingsTransfers();
IDEWorkbenchPlugin idePlugin = IDEWorkbenchPlugin.getDefault();
String[] enabledSettings = _getEnabledSettings(idePlugin.getDialogSettings().getSection(_WORKBENCH_SETTINGS));
Composite panel = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(1, false);
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
panel.setLayout(layout);
panel.setFont(parent.getFont());
Group group = new Group(panel, SWT.NONE);
group.setText("Copy Settings");
group.setLayout(layout);
group.setFont(parent.getFont());
for (int i = 0; i < settings.length; i++) {
IConfigurationElement settingsTransfer = settings[i];
Button button = new Button(group, SWT.CHECK);
button.setText(settings[i].getAttribute(_ATT_NAME));
String helpId = settings[i].getAttribute(_ATT_HELP_CONTEXT);
if (helpId != null) {
IWorkbench workbench = PlatformUI.getWorkbench();
workbench.getHelpSystem().setHelp(button, helpId);
}
if (ListUtil.isNotEmpty(enabledSettings)) {
String id = settings[i].getAttribute(_ATT_ID);
for (int j = 0; j < enabledSettings.length; j++) {
if ((enabledSettings[j] != null) && enabledSettings[j].equals(id)) {
button.setSelection(true);
_selectedSettings.add(settingsTransfer);
break;
}
}
}
button.setBackground(parent.getBackground());
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (button.getSelection()) {
_selectedSettings.add(settingsTransfer);
} else {
_selectedSettings.remove(settingsTransfer);
}
}
});
}
if (ListUtil.isNotEmpty(enabledSettings)) {
return true;
}
return false;
}
use of org.eclipse.ui.internal.ide.IDEWorkbenchPlugin in project liferay-ide by liferay.
the class ChooseWorkspaceWithPreferenceDialog method _saveSettings.
/**
* Save the ids of the selected elements.
*
* @param selectionIDs
*/
private void _saveSettings(String[] selectionIDs) {
IDEWorkbenchPlugin idePlugin = IDEWorkbenchPlugin.getDefault();
IDialogSettings settings = idePlugin.getDialogSettings().getSection(_WORKBENCH_SETTINGS);
if (settings == null) {
settings = idePlugin.getDialogSettings().addNewSection(_WORKBENCH_SETTINGS);
}
settings.put(_ENABLED_TRANSFERS, selectionIDs);
}
use of org.eclipse.ui.internal.ide.IDEWorkbenchPlugin in project liferay-ide by liferay.
the class UIUtil method switchToLiferayPerspective.
public static void switchToLiferayPerspective(String perspectiveId, boolean confirm) {
// Retrieve the new project open perspective preference setting
String perspSetting = PrefUtil.getAPIPreferenceStore().getString(IDE.Preferences.PROJECT_OPEN_NEW_PERSPECTIVE);
IDEWorkbenchPlugin plugin = IDEWorkbenchPlugin.getDefault();
String promptSetting = plugin.getPreferenceStore().getString(IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE);
if (!(promptSetting.equals(MessageDialogWithToggle.PROMPT)) && perspSetting.equals(IWorkbenchPreferenceConstants.NO_NEW_PERSPECTIVE)) {
return;
}
// Map perspective id to descriptor.
IWorkbench workbench = PlatformUI.getWorkbench();
IPerspectiveRegistry reg = workbench.getPerspectiveRegistry();
IPerspectiveDescriptor finalPersp = reg.findPerspectiveWithId(perspectiveId);
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
if (window != null) {
IWorkbenchPage page = window.getActivePage();
if (page != null) {
IPerspectiveDescriptor currentPersp = page.getPerspective();
if (finalPersp.equals(currentPersp)) {
return;
}
}
if (confirm && !_confirmPerspectiveSwitch(window, finalPersp)) {
return;
}
}
// replace active perspective setting otherwise
_replaceCurrentPerspective(finalPersp);
}
Aggregations