Search in sources :

Example 1 with IDEWorkbenchPlugin

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;
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IWorkbench(org.eclipse.ui.IWorkbench) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IDEWorkbenchPlugin(org.eclipse.ui.internal.ide.IDEWorkbenchPlugin)

Example 2 with IDEWorkbenchPlugin

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);
}
Also used : IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) IDEWorkbenchPlugin(org.eclipse.ui.internal.ide.IDEWorkbenchPlugin)

Example 3 with IDEWorkbenchPlugin

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);
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IPerspectiveRegistry(org.eclipse.ui.IPerspectiveRegistry) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IPerspectiveDescriptor(org.eclipse.ui.IPerspectiveDescriptor) IDEWorkbenchPlugin(org.eclipse.ui.internal.ide.IDEWorkbenchPlugin)

Aggregations

IDEWorkbenchPlugin (org.eclipse.ui.internal.ide.IDEWorkbenchPlugin)3 IWorkbench (org.eclipse.ui.IWorkbench)2 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 Group (org.eclipse.swt.widgets.Group)1 IPerspectiveDescriptor (org.eclipse.ui.IPerspectiveDescriptor)1 IPerspectiveRegistry (org.eclipse.ui.IPerspectiveRegistry)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1