Search in sources :

Example 1 with KaleoUI

use of com.liferay.ide.kaleo.ui.KaleoUI in project liferay-ide by liferay.

the class WorkflowDefinitionEditor method createPages.

@Override
protected void createPages() {
    super.createPages();
    try {
        IWorkbench workBench = PlatformUI.getWorkbench();
        IWorkbenchWindow workBenchWindow = workBench.getActiveWorkbenchWindow();
        IWorkbenchPage workBenchPage = workBenchWindow.getActivePage();
        IPerspectiveDescriptor descripter = workBenchPage.getPerspective();
        String id = descripter.getId();
        if (WorkflowDesignerPerspectiveFactory.ID.equals(id)) {
            return;
        }
    } catch (Exception e) {
    }
    KaleoUI kaleoUI = KaleoUI.getDefault();
    IPreferenceStore preferenceStore = kaleoUI.getPreferenceStore();
    String perspectiveSwitch = preferenceStore.getString(KaleoUIPreferenceConstants.EDITOR_PERSPECTIVE_SWITCH);
    boolean remember = false;
    boolean openPerspective = false;
    if (MessageDialogWithToggle.PROMPT.equals(perspectiveSwitch)) {
        String descriptFile = "This kind of file is associated with the Kaleo Designer perspective.\n\n";
        String descriptPerspective = "This perspective is designed to support Kaleo Workflow development. ";
        String descriptPlace = "It places the Properties and Palette views in optimal location relative to the editor area.\n\n";
        String descriptHint = "Do you want to open this perspective now?";
        MessageDialogWithToggle toggleDialog = MessageDialogWithToggle.openYesNoQuestion(getSite().getShell(), "Open Kaleo Designer Perspective?", descriptFile + descriptPerspective + descriptPlace + descriptHint, "Remember my decision", false, KaleoUI.getDefault().getPreferenceStore(), KaleoUIPreferenceConstants.EDITOR_PERSPECTIVE_SWITCH);
        remember = toggleDialog.getToggleState();
        openPerspective = toggleDialog.getReturnCode() == IDialogConstants.YES_ID;
        if (remember) {
            KaleoUI.getPrefStore().setValue(KaleoUIPreferenceConstants.EDITOR_PERSPECTIVE_SWITCH, openPerspective ? MessageDialogWithToggle.ALWAYS : MessageDialogWithToggle.NEVER);
        }
    } else if (MessageDialogWithToggle.ALWAYS.equals(perspectiveSwitch)) {
        openPerspective = true;
    }
    if (openPerspective) {
        _switchToKaleoDesignerPerspective();
    }
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) IPerspectiveDescriptor(org.eclipse.ui.IPerspectiveDescriptor) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) JSONException(org.json.JSONException) PartInitException(org.eclipse.ui.PartInitException) KaleoUI(com.liferay.ide.kaleo.ui.KaleoUI)

Aggregations

KaleoUI (com.liferay.ide.kaleo.ui.KaleoUI)1 MessageDialogWithToggle (org.eclipse.jface.dialogs.MessageDialogWithToggle)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 IPerspectiveDescriptor (org.eclipse.ui.IPerspectiveDescriptor)1 IWorkbench (org.eclipse.ui.IWorkbench)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 PartInitException (org.eclipse.ui.PartInitException)1 JSONException (org.json.JSONException)1