Example usage for org.eclipse.jface.dialogs IDialogConstants NO_ID

List of usage examples for org.eclipse.jface.dialogs IDialogConstants NO_ID

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs IDialogConstants NO_ID.

Prototype

int NO_ID

To view the source code for org.eclipse.jface.dialogs IDialogConstants NO_ID.

Click Source Link

Document

Button id for a "No" button (value 3).

Usage

From source file:org.springframework.ide.eclipse.boot.dash.cloudfoundry.deployment.ManifestDiffDialog.java

License:Open Source License

protected void buttonPressed(int buttonId) {
    switch (buttonId) {
    case IDialogConstants.NO_ID:
        fCompareEditorInput.cancelPressed();
        setReturnCode(buttonId);// w  w w. jav  a  2 s  . co m
        close();
        break;
    case IDialogConstants.YES_ID:
        if (fCompareEditorInput.isDirty()) {
            if (!fCompareEditorInput.okPressed())
                return;
        } else {
            fCompareEditorInput.cancelPressed();
        }
        setReturnCode(buttonId);
        close();
        break;
    case IDialogConstants.CANCEL_ID:
        fCompareEditorInput.cancelPressed();
        super.buttonPressed(buttonId);
        break;
    default:
        super.buttonPressed(buttonId);
    }
}

From source file:org.springframework.ide.eclipse.boot.dash.cloudfoundry.deployment.ManifestDiffDialog.java

License:Open Source License

public static Result getResultForCode(int buttonId) {
    switch (buttonId) {
    case IDialogConstants.NO_ID:
        return Result.FORGET_MANIFEST;
    case IDialogConstants.YES_ID:
        return Result.USE_MANIFEST;
    case IDialogConstants.CANCEL_ID:
        return Result.CANCELED;
    default:/*  w w  w . ja  v  a  2s  .c o m*/
        throw new IllegalArgumentException("Unknown button ID");
    }
}

From source file:org.talend.mdm.repository.ui.wizards.imports.ImportServerObjectWizard.java

License:Open Source License

private int isOveride(String name, String obTypeName) {

    final MessageDialog dialog = new MessageDialog(getShell(), Messages.Confirm_Overwrite, null,
            Messages.bind(Messages.Confirm_Overwrite_Info, obTypeName, name), MessageDialog.QUESTION,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL,
                    IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
            0);/*from  w  ww.j ava 2 s  .c o  m*/
    dialog.open();
    int result = dialog.getReturnCode();
    if (result == 0) {
        return IDialogConstants.YES_ID;
    }
    if (result == 1) {
        return IDialogConstants.YES_TO_ALL_ID;
    }
    if (result == 2) {
        return IDialogConstants.NO_ID;
    }
    return IDialogConstants.CANCEL_ID;

}

From source file:org.talend.mdm.repository.ui.wizards.imports.ImportServerObjectWizard.java

License:Open Source License

public List<String> doImport(Object[] objs, IProgressMonitor monitor) {
    monitor.beginTask(Messages.Import_Objects, objs.length);
    List<String> importedIds = new LinkedList<String>();
    ImportService.setImporting(true);/*ww w  .  j  a  va  2 s  .  c  o  m*/

    List<Integer> types = new ArrayList<Integer>();
    types.add(TreeObject.CUSTOM_FORM);
    types.add(TreeObject.DATA_CLUSTER);
    types.add(TreeObject.DATA_MODEL);
    types.add(TreeObject.TRANSFORMER);
    types.add(TreeObject.ROUTING_RULE);
    types.add(TreeObject.MENU);
    types.add(TreeObject.ROLE);
    types.add(TreeObject.STORED_PROCEDURE);
    types.add(TreeObject.VIEW);
    types.add(TreeObject.WORKFLOW_PROCESS);
    IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
    for (Object obj : objs) {
        try {
            TreeObject treeObj = (TreeObject) obj;
            monitor.subTask(treeObj.getDisplayName());
            String treeObjName = treeObj.getName();
            MDMServerObject eobj = handleSpecialTreeObject(treeObj);
            if (treeObj.getType() == TreeObject.WORKFLOW_PROCESS) {
                continue;
            }
            if (eobj == null) {
                if (!types.contains(treeObj.getType()) || treeObj.getWsObject() == null
                        || ("JCAAdapers".equals(treeObj.getName()) //$NON-NLS-1$
                                && treeObj.getType() == TreeObject.DATA_CLUSTER)) {
                    continue;
                }
                eobj = (MDMServerObject) Bean2EObjUtil.getInstance().convertFromBean2EObj(treeObj.getWsObject(),
                        null);
            }
            eobj.setLastServerName(serverDef.getName());

            ERepositoryObjectType type = RepositoryQueryService.getRepositoryObjectType(treeObj.getType());
            String uniqueName = getUniqueName(treeObj, treeObjName);
            MDMServerObjectItem item = RepositoryQueryService.findServerObjectItemByNameWithDeleted(type,
                    uniqueName, true);

            if (item != null) {
                if (!isOverrideAll) {
                    int result = isOveride(treeObj.getName(), TreeObject.getTypeName(treeObj.getType()));
                    if (result == IDialogConstants.CANCEL_ID) {
                        ImportService.setImporting(false);
                        return importedIds;
                    }
                    if (result == IDialogConstants.YES_TO_ALL_ID) {
                        isOverrideAll = true;
                    }
                    if (result == IDialogConstants.NO_ID) {
                        break;
                    }
                }

                if (!RepositoryResourceUtil.isLockedItem(item)) {
                    try {
                        factory.lock(item);
                    } catch (PersistenceException e1) {
                        log.error(e1.getMessage(), e1);
                    } catch (LoginException e1) {
                        log.error(e1.getMessage(), e1);
                    }

                    item.setMDMServerObject(eobj);
                    item.getState().setDeleted(false);
                    // save
                    RepositoryResourceUtil.saveItem(item, false);

                    try {
                        factory.unlock(item);
                    } catch (PersistenceException e) {
                        log.error(e.getMessage(), e);
                    } catch (LoginException e) {
                        log.error(e.getMessage(), e);
                    }
                    importedIds.add(item.getProperty().getId());
                }

                CommandManager.getInstance().removeCommandStack(item.getProperty().getId());
            } else {
                IRepositoryNodeConfiguration config = RepositoryNodeConfigurationManager.getConfiguration(type);
                item = (MDMServerObjectItem) config.getResourceProvider().createNewItem(type);
                item.setMDMServerObject(eobj);
                ItemState itemState = PropertiesFactory.eINSTANCE.createItemState();

                itemState.setPath(caculatePath(treeObj));
                handlePath(itemState, type);
                item.setState(itemState);
                String version = getVersion(treeObj);

                if (RepositoryResourceUtil.createItem(item, uniqueName, version, false, false)) {
                    importedIds.add(item.getProperty().getId());
                }

            }
        } catch (IOException e) {
            log.error(e.getMessage(), e);
        }
        monitor.worked(1);
    }
    ImportService.setImporting(false);
    monitor.done();
    return importedIds;
}

From source file:org.talend.metadata.managment.ui.wizard.metadata.ShowAddedContextdialog.java

License:Open Source License

@Override
protected void buttonPressed(int buttonId) {
    if (IDialogConstants.YES_ID == buttonId) {
        okPressed();/*  w  w w.  j a va  2s  .  c  o m*/
    } else if (IDialogConstants.NO_ID == buttonId) {
        cancelPressed();
    }
}

From source file:org.teiid.designer.ui.editors.ModelEditorManager.java

License:Open Source License

/**
 * Show Dialog asking user if the editor should be opened.
 * @param shell the shell//  ww w  . ja va2 s .c o m
 * @return 'true' if should be opened, 'false' if not
 */
public static boolean showDialogShouldOpenEditor(Shell shell) {
    boolean shouldOpen = false;

    // Show the dialog
    MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoCancelQuestion(shell, OPEN_EDITOR_TITLE,
            OPEN_EDITOR_MESSAGE, ALWAY_FORCE_OPEN_MESSAGE, false, UiPlugin.getDefault().getPreferenceStore(),
            AUTO_OPEN_EDITOR_IF_NEEDED);
    int result = dialog.getReturnCode();
    switch (result) {
    // yes, ok
    case IDialogConstants.YES_ID:
    case IDialogConstants.OK_ID:
        shouldOpen = true;
        break;
    // no
    case IDialogConstants.NO_ID:
        shouldOpen = false;
        break;
    }

    return shouldOpen;
}

From source file:org.wso2.developerstudio.eclipse.platform.ui.dialogs.TrustCertificateDialog.java

License:Open Source License

protected void createButtonsForButtonBar(Composite parent) {
    createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, false);
    createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true);
    createButton(parent, TEMP_ALLOW_ID, "Allow this once", false);
}

From source file:org.wso2.developerstudio.eclipse.updater.ui.UpdaterDialog.java

License:Open Source License

protected void createButtonsForButtonBar(Composite parent) {
    // Change parent layout data to fill the whole bar
    parent.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    installBtn = createButton(parent, IDialogConstants.NO_ID, INSTALL_BTN_TXT, true);
    installBtn.setEnabled(false);/*from www  .  jav a  2 s  .  c  o m*/
    installBtn.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event e) {
            switch (e.type) {
            case SWT.Selection:
                if (tabFolder.getSelection()[0].getText().equals(ALL_FEATURES_TAB_TITLE)) {
                    updateManager.setSelectedFeaturesToInstall(selectedFeatures);
                    updateManager.installSelectedFeatures(new NullProgressMonitor());
                } else if (tabFolder.getSelection()[0].getText().equals(UPDATES_TAB_TITLE)) {
                    updateManager.setSelectedUpdates(selectedUpdates);
                    updateManager.installSelectedUpdates(new NullProgressMonitor());
                }
                dialog.close();
                break;
            }
        }
    });

    // Create a spacer label
    Label spacer = new Label(parent, SWT.NONE);
    spacer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    // Update layout of the parent composite to count the spacer
    GridLayout layout = (GridLayout) parent.getLayout();
    layout.numColumns++;
    layout.makeColumnsEqualWidth = false;
    createButton(parent, IDialogConstants.CANCEL_ID, CANCEL_BTN_TXT, false);
}

From source file:org2.eclipse.php.internal.debug.core.launching.PHPLaunchUtilities.java

License:Open Source License

/**
 * Notify the existence of a previous PHP debug session in case the user launched a new session.
 * /*from  ww w .j  a  va 2 s .  c o m*/
 * @param newLaunchConfiguration
 * @param newLaunch
 * @return True, if the launch can be continued; False, otherwise.
 * @throws CoreException
 */
public static boolean notifyPreviousLaunches(ILaunch newLaunch) throws CoreException {
    // In case the new launch is not a debug launch, we have no problem.
    if (!ILaunchManager.DEBUG_MODE.equals(newLaunch.getLaunchMode())) {
        return true;
    }
    // If there are no active debug launches, return true and continue with the new launch.
    if (!hasPHPDebugLaunch()) {
        return true;
    }

    // Check whether we should ask the user.
    final IPreferenceStore store = PHPDebugEPLPlugin.getDefault().getPreferenceStore();
    String option = store.getString(ALLOW_MULTIPLE_LAUNCHES);
    if (MessageDialogWithToggle.ALWAYS.equals(option)) {
        // If always, then we should always allow the launch
        return true;
    }
    if (MessageDialogWithToggle.NEVER.equals(option)) {
        // We should never allow the launch, so display a message describing the situation.
        final Display disp = Display.getDefault();
        disp.syncExec(new Runnable() {
            public void run() {
                MessageDialog.openInformation(disp.getActiveShell(),
                        PHPDebugCoreMessages.PHPLaunchUtilities_phpLaunchTitle,
                        PHPDebugCoreMessages.PHPLaunchUtilities_activeLaunchDetected);
            }
        });
        return false;
    }

    final DialogResultHolder resultHolder = new DialogResultHolder();
    final Display disp = Display.getDefault();
    disp.syncExec(new Runnable() {
        public void run() {
            // Display a dialog to notify the existence of a previous active launch.
            MessageDialogWithToggle m = MessageDialogWithToggle.openYesNoQuestion(disp.getActiveShell(),
                    PHPDebugCoreMessages.PHPLaunchUtilities_confirmation,
                    PHPDebugCoreMessages.PHPLaunchUtilities_multipleLaunchesPrompt,
                    PHPDebugCoreMessages.PHPLaunchUtilities_rememberDecision, false, store,
                    ALLOW_MULTIPLE_LAUNCHES);
            resultHolder.setReturnCode(m.getReturnCode());
        }
    });
    switch (resultHolder.getReturnCode()) {
    case IDialogConstants.YES_ID:
    case IDialogConstants.OK_ID:
        return true;
    case IDialogConstants.NO_ID:
        return false;
    }
    return true;
}

From source file:org2.eclipse.php.internal.debug.core.launching.PHPLaunchUtilities.java

License:Open Source License

private static boolean shouldSwitchToPreviousPerspective(String perspectiveID) {
    // check whether we should ask the user.
    IPreferenceStore store = PHPDebugEPLPlugin.getDefault().getPreferenceStore();
    String option = store.getString(SWITCH_BACK_TO_PREVIOUS_PERSPECTIVE);
    if (MessageDialogWithToggle.ALWAYS.equals(option)) {
        return true;
    }/*from w ww. j  ava 2  s  .  c om*/
    if (MessageDialogWithToggle.NEVER.equals(option)) {
        return false;
    }

    // Check whether the desired perspective is already active.
    IPerspectiveRegistry registry = PlatformUI.getWorkbench().getPerspectiveRegistry();
    IPerspectiveDescriptor perspective = registry.findPerspectiveWithId(perspectiveID);
    if (perspective == null) {
        return false;
    }

    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window != null) {
        IWorkbenchPage page = window.getActivePage();
        if (page != null) {
            IPerspectiveDescriptor current = page.getPerspective();
            if (current != null && current.getId().equals(perspectiveID)) {
                return false;
            }
        }

        // Ask the user whether to switch
        MessageDialogWithToggle m = MessageDialogWithToggle.openYesNoQuestion(window.getShell(),
                PHPDebugCoreMessages.PHPLaunchUtilities_PHPPerspectiveSwitchTitle,
                NLS.bind(PHPDebugCoreMessages.PHPLaunchUtilities_PHPPerspectiveSwitchMessage,
                        new String[] { perspective.getLabel() }),
                PHPDebugCoreMessages.PHPLaunchUtilities_rememberDecision, false, store,
                SWITCH_BACK_TO_PREVIOUS_PERSPECTIVE);

        int result = m.getReturnCode();
        switch (result) {
        case IDialogConstants.YES_ID:
        case IDialogConstants.OK_ID:
            return true;
        case IDialogConstants.NO_ID:
            return false;
        }
    }
    return false;
}