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

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

Introduction

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

Prototype

String NO_LABEL

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

Click Source Link

Document

The label for no buttons.

Usage

From source file:com.nokia.tools.theme.s60.ui.wizards.NewPackagePage2.java

License:Open Source License

public boolean performFinish() {
    File file = new File(selDestination);
    IBrandingManager branding = BrandingExtensionManager.getBrandingManager();
    Image image = null;//  w  ww. j a  va 2s  . c o m
    if (branding != null) {
        image = branding.getIconImageDescriptor().createImage();
    }

    // Check for password in keypairs
    KeyPair[] keyPairs = null;
    try {
        keyPairs = KeyPair.getKeyPairs();
    } catch (PackagingException e1) {
        e1.printStackTrace();
    }
    if (btnNoSign.getSelection() == false) {
        if (keyPairs.length > 0) {
            if (keyPairs[cboKeyPairs.getSelectionIndex()].getPassword() != null
                    && !("".equals(keyPairs[cboKeyPairs.getSelectionIndex()].getPassword().equals("")))) {
                if (txtPassword != null && !(keyPairs[cboKeyPairs.getSelectionIndex()].getPassword()
                        .equals(txtPassword.getText()))) {
                    MessageDialog dialog1 = new MessageDialog(
                            PlatformUI.getWorkbench().getDisplay().getActiveShell(),
                            com.nokia.tools.screen.ui.wizards.WizardMessages.New_Package_Mismatch_Password_Error_Message_Title,
                            image,
                            com.nokia.tools.screen.ui.wizards.WizardMessages.New_Package_Mismatch_Password_Error_Message,
                            1, new String[] { IDialogConstants.OK_LABEL }, 0);
                    getShell().setCursor(new Cursor(getShell().getDisplay(), SWT.CURSOR_ARROW));
                    dialog1.open();
                    if (image != null) {
                        image.dispose();
                    }
                    return false;
                }
            }
        }
    }
    // End key pairs password checks.

    if (file.exists()) {

        MessageDialog dialog = new MessageDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(),
                com.nokia.tools.screen.ui.wizards.WizardMessages.New_Package_Package_Exist_MsgBox_Title, image,
                com.nokia.tools.screen.ui.wizards.WizardMessages.New_Package_Package_Exist_MsgBox_Message, 3,
                new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
        int ret = dialog.open();
        if (image != null) {
            image.dispose();
        }
        if (ret != Window.OK) {
            return false;
        }
    }

    if (txtPassword != null) {
        getShell().setCursor(new Cursor(getShell().getDisplay(), SWT.CURSOR_WAIT));
        String cerFile = (String) context.getAttribute(PackagingAttribute.certificateFile.name());
        String keyFile = (String) context.getAttribute(PackagingAttribute.privateKeyFile.name());
        String password = (String) context.getAttribute(PackagingAttribute.passphrase.name());
        try {
            SymbianUtil.testKey(cerFile, keyFile, password, context);
        } catch (Exception e) {
            Activator.error(e);
            IBrandingManager branding1 = BrandingExtensionManager.getBrandingManager();
            Image image1 = null;
            if (branding1 != null) {
                image1 = branding1.getIconImageDescriptor().createImage();
            }
            MessageDialog dialog = new MessageDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(),
                    com.nokia.tools.screen.ui.wizards.WizardMessages.New_Package_Create_MsgBox_Error_Title,
                    image1,
                    com.nokia.tools.screen.ui.wizards.WizardMessages.New_Package_Create_MsgBox_Error_Message, 1,
                    new String[] { IDialogConstants.OK_LABEL }, 0);
            getShell().setCursor(new Cursor(getShell().getDisplay(), SWT.CURSOR_ARROW));
            dialog.open();
            if (image1 != null) {
                image1.dispose();
            }
            return false;
        }
        getShell().setCursor(new Cursor(getShell().getDisplay(), SWT.CURSOR_ARROW));
    }
    return true;
}

From source file:com.nokia.tools.variant.resourcelibrary.handlers.commands.ImportCommand.java

License:Open Source License

public static boolean openCheckDialog(FileSystemElement existing) {
    MessageDialog dialog = new MessageDialog(SWTUtil.getStandardDisplay().getActiveShell(),
            "Replace existing resource", null, "Replace existing resource " + existing.getName() + "?",
            MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
    return dialog.open() == 0 ? true : false;
}

From source file:com.palantir.typescript.Builders.java

License:Apache License

/**
 * Prompts user to rebuild either the project or the whole workspace.
 *
 * @param shell/* w  ww.  ja va  2 s . c om*/
 *            parent shell
 * @param onlyProject
 *            the project to be rebuilt or null if the whole workpsace has to be rebuilt
 * @return true if user accepted the recompilation
 */
public static boolean promptRecompile(Shell shell, IProject onlyProject) {
    String title = Resources.BUNDLE.getString("preferences.compiler.rebuild.dialog.title");
    String message = Resources.BUNDLE.getString("preferences.compiler.rebuild.dialog.message");
    String[] buttonLabels = new String[] { IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL,
            IDialogConstants.YES_LABEL };
    MessageDialog dialog = new MessageDialog(shell, title, null, message, MessageDialog.QUESTION, buttonLabels,
            2);
    int result = dialog.open();

    boolean process = false;
    if (result != 1) { // cancel
        process = true;

        // rebuild the workspace
        if (result == 2) {
            if (onlyProject != null) {
                Builders.rebuildProject(onlyProject);
            } else {
                Builders.rebuildWorkspace();
            }
        }
    }
    return process;
}

From source file:com.palantir.typescript.CompilerPreferencePage.java

License:Apache License

@Override
public boolean performOk() {
    final boolean process;

    // offer to rebuild the workspace if the compiler preferences were modified
    if (this.compilerPreferencesModified) {
        String title = Resources.BUNDLE.getString("preferences.compiler.rebuild.dialog.title");
        String message = Resources.BUNDLE.getString("preferences.compiler.rebuild.dialog.message");
        String[] buttonLabels = new String[] { IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL,
                IDialogConstants.YES_LABEL };
        MessageDialog dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION,
                buttonLabels, 2);// w  w  w .  j  ava  2s . c  o  m
        int result = dialog.open();

        if (result == 1) { // cancel
            process = false;
        } else {
            // yes/no
            process = super.performOk();

            // rebuild the workspace
            if (result == 2) {
                String name = Resources.BUNDLE.getString("preferences.compiler.rebuild.job.name");
                Job job = new Job(name) {
                    @Override
                    protected IStatus run(IProgressMonitor monitor) {
                        IWorkspace workspace = ResourcesPlugin.getWorkspace();

                        try {
                            workspace.build(IncrementalProjectBuilder.CLEAN_BUILD, monitor);
                            workspace.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
                        } catch (CoreException e) {
                            return e.getStatus();
                        }

                        return Status.OK_STATUS;
                    }
                };
                job.setRule(ResourcesPlugin.getWorkspace().getRuleFactory().buildRule());
                job.schedule();
            }
        }

        this.compilerPreferencesModified = false;
    } else {
        process = super.performOk();
    }

    return process;
}

From source file:com.persistent.winazureroles.WARComponents.java

License:Open Source License

/**
 * Listener method for remove button which
 * deletes the selected component.//from ww  w  .ja  va2  s . co  m
 */
protected void removeBtnListener() {
    int selIndex = tblViewer.getTable().getSelectionIndex();
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceRoot root = workspace.getRoot();
    WindowsAzureRoleComponent component = listComponents.get(selIndex);
    if (selIndex > -1) {
        try {
            /* First condition: Checks component is part of a JDK,
             * server configuration
             * Second condition: For not showing error message
             * "Disable Server JDK Configuration"
             * while removing server application
             * when server or JDK  is already disabled.
             */
            if (component.getIsPreconfigured() && (!(component.getType().equals(Messages.typeSrvApp)
                    && windowsAzureRole.getServerName() == null))) {
                PluginUtil.displayErrorDialog(getShell(), Messages.jdkDsblErrTtl, Messages.jdkDsblErrMsg);
            } else {
                boolean choice = MessageDialog.openQuestion(getShell(), Messages.cmpntRmvTtl,
                        Messages.cmpntRmvMsg);
                if (choice) {
                    String cmpntPath = String.format("%s%s%s%s%s",
                            root.getProject(waProjManager.getProjectName()).getLocation(), File.separator,
                            windowsAzureRole.getName(), Messages.approot, component.getDeployName());
                    File file = new File(cmpntPath);
                    // Check import source is equal to approot
                    if (component.getImportPath().isEmpty() && file.exists()) {
                        MessageDialog dialog = new MessageDialog(getShell(), Messages.cmpntSrcRmvTtl, null,
                                Messages.cmpntSrcRmvMsg, MessageDialog.QUESTION_WITH_CANCEL,
                                new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                                        IDialogConstants.CANCEL_LABEL },
                                0);
                        switch (dialog.open()) {
                        case 0:
                            //yes
                            component.delete();
                            tblViewer.refresh();
                            fileToDel.add(file);
                            break;
                        case 1:
                            //no
                            component.delete();
                            tblViewer.refresh();
                            break;
                        case 2:
                            //cancel
                            break;
                        default:
                            break;
                        }
                    } else {
                        component.delete();
                        tblViewer.refresh();
                        fileToDel.add(file);
                    }
                }
            }
            if (tblComponents.getItemCount() == 0) {
                // table is empty i.e. number of rows = 0
                btnRemove.setEnabled(false);
                btnEdit.setEnabled(false);
            }
        } catch (WindowsAzureInvalidProjectOperationException e) {
            PluginUtil.displayErrorDialogAndLog(getShell(), Messages.cmpntSetErrTtl, Messages.cmpntRmvErrMsg,
                    e);
        }
    }
    updateMoveButtons();
}

From source file:com.puppetlabs.geppetto.pp.dsl.ui.linked.ExtLinkedXtextEditor.java

License:Open Source License

@Override
protected void performSaveAs(IProgressMonitor progressMonitor) {

    Shell shell = getSite().getShell();/*from   w ww  .j  a v  a  2  s  .c  om*/
    final IEditorInput input = getEditorInput();

    // Customize save as if the file is linked, and it is in the special external link project
    //
    if (input instanceof IFileEditorInput && ((IFileEditorInput) input).getFile().isLinked()
            && ((IFileEditorInput) input).getFile().getProject().getName()
                    .equals(ExtLinkedFileHelper.AUTOLINK_PROJECT_NAME)) {
        final IEditorInput newInput;
        IDocumentProvider provider = getDocumentProvider();

        // 1. If file is "untitled" suggest last save location
        // 2. ...otherwise use the file's location (i.e. likely to be a rename in same folder)
        // 3. If a "last save location" is unknown, use user's home
        //
        String suggestedName = null;
        String suggestedPath = null;
        {
            // is it "untitled"
            java.net.URI uri = ((IURIEditorInput) input).getURI();
            String tmpProperty = null;
            try {
                tmpProperty = ((IFileEditorInput) input).getFile()
                        .getPersistentProperty(TmpFileStoreEditorInput.UNTITLED_PROPERTY);
            } catch (CoreException e) {
                // ignore - tmpProperty will be null
            }
            boolean isUntitled = tmpProperty != null && "true".equals(tmpProperty);

            // suggested name
            IPath oldPath = URIUtil.toPath(uri);
            // TODO: input.getName() is probably always correct
            suggestedName = isUntitled ? input.getName() : oldPath.lastSegment();

            // suggested path
            try {
                suggestedPath = isUntitled
                        ? ((IFileEditorInput) input).getFile().getWorkspace().getRoot()
                                .getPersistentProperty(LAST_SAVEAS_LOCATION)
                        : oldPath.toOSString();
            } catch (CoreException e) {
                // ignore, suggestedPath will be null
            }

            if (suggestedPath == null) {
                // get user.home
                suggestedPath = System.getProperty("user.home");
            }
        }
        FileDialog dialog = new FileDialog(shell, SWT.SAVE);
        if (suggestedName != null)
            dialog.setFileName(suggestedName);
        if (suggestedPath != null)
            dialog.setFilterPath(suggestedPath);

        dialog.setFilterExtensions(new String[] { "*.pp", "*.*" });
        String path = dialog.open();
        if (path == null) {
            if (progressMonitor != null)
                progressMonitor.setCanceled(true);
            return;
        }

        // Check whether file exists and if so, confirm overwrite
        final File localFile = new File(path);
        if (localFile.exists()) {
            MessageDialog overwriteDialog = new MessageDialog(shell, "Save As", null,
                    path + " already exists.\nDo you want to replace it?", MessageDialog.WARNING,
                    new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1); // 'No' is the default
            if (overwriteDialog.open() != Window.OK) {
                if (progressMonitor != null) {
                    progressMonitor.setCanceled(true);
                    return;
                }
            }
        }

        IFileStore fileStore;
        try {
            fileStore = EFS.getStore(localFile.toURI());
        } catch (CoreException ex) {
            EditorsPlugin.log(ex.getStatus());
            String title = "Problems During Save As...";
            String msg = "Save could not be completed. " + ex.getMessage();
            MessageDialog.openError(shell, title, msg);
            return;
        }

        IFile file = getWorkspaceFile(fileStore);
        if (file != null)
            newInput = new FileEditorInput(file);
        else {
            IURIEditorInput uriInput = new FileStoreEditorInput(fileStore);
            java.net.URI uri = uriInput.getURI();
            IFile linkedFile = ExtLinkedFileHelper.obtainLink(uri, false);

            newInput = new FileEditorInput(linkedFile);
        }

        if (provider == null) {
            // editor has been closed while the dialog was open
            return;
        }

        boolean success = false;
        try {

            provider.aboutToChange(newInput);
            provider.saveDocument(progressMonitor, newInput, provider.getDocument(input), true);
            success = true;

        } catch (CoreException x) {
            final IStatus status = x.getStatus();
            if (status == null || status.getSeverity() != IStatus.CANCEL) {
                String title = "Problems During Save As...";
                String msg = "Save could not be completed. " + x.getMessage();
                MessageDialog.openError(shell, title, msg);
            }
        } finally {
            provider.changed(newInput);
            if (success)
                setInput(newInput);
            // the linked file must be removed (esp. if it is an "untitled" link).
            ExtLinkedFileHelper.unlinkInput(((IFileEditorInput) input));
            // remember last saveAs location
            String lastLocation = URIUtil.toPath(((FileEditorInput) newInput).getURI()).toOSString();
            try {
                ((FileEditorInput) newInput).getFile().getWorkspace().getRoot()
                        .setPersistentProperty(LAST_SAVEAS_LOCATION, lastLocation);
            } catch (CoreException e) {
                // ignore
            }
        }

        if (progressMonitor != null)
            progressMonitor.setCanceled(!success);

        return;
    }

    super.performSaveAs(progressMonitor);
}

From source file:com.rcpcompany.uibindings.tests.application.ApplicationWorkbenchAdvisor.java

License:Open Source License

@Override
public boolean preShutdown() {
    final IManager manager = IManager.Factory.getManager();
    final EditingDomain editingDomain = manager.getEditingDomain();
    int res = 1; // == NO
    if (editingDomain.getCommandStack().canUndo()) {
        final IWorkbenchWindow window = getWorkbenchConfigurer().getWorkbench().getActiveWorkbenchWindow();
        final MessageDialog dialog = new MessageDialog(window.getShell(), "Save Shop?", null,
                "Changes has been made to the shop. Save these?", MessageDialog.QUESTION, new String[] {
                        IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
                0);//from   w ww.ja  v  a 2 s . co  m
        res = dialog.open();
        if (res == 0) {
            final ICommandService cs = (ICommandService) window.getService(ICommandService.class);
            final IHandlerService hs = (IHandlerService) window.getService(IHandlerService.class);

            try {
                final String c = manager.getCommandIDs().get(IWorkbenchCommandConstants.FILE_SAVE);
                final ParameterizedCommand command = cs.deserialize(c);
                hs.executeCommand(command, null);
            } catch (final Exception ex) {
                LogUtils.error(this, ex);
            }
        }
    }
    return res != 2;
}

From source file:com.redhat.ceylon.eclipse.code.preferences.CeylonBuildPathsBlock.java

License:Open Source License

public static IRemoveOldBinariesQuery getRemoveOldBinariesQuery(final Shell shell) {
    return new IRemoveOldBinariesQuery() {
        public boolean doQuery(final boolean removeFolder, final IPath oldOutputLocation)
                throws OperationCanceledException {
            final int[] res = new int[] { 1 };
            Display.getDefault().syncExec(new Runnable() {
                public void run() {
                    Shell sh = shell != null ? shell : JavaPlugin.getActiveWorkbenchShell();
                    String title = NewWizardMessages.BuildPathsBlock_RemoveBinariesDialog_title;
                    String message;
                    String pathLabel = BasicElementLabels.getPathLabel(oldOutputLocation, false);
                    if (removeFolder) {
                        message = Messages.format(
                                NewWizardMessages.BuildPathsBlock_RemoveOldOutputFolder_description, pathLabel);
                    } else {
                        message = Messages.format(
                                NewWizardMessages.BuildPathsBlock_RemoveBinariesDialog_description, pathLabel);
                    }//  w  ww  .  j av  a 2  s.  c  om
                    MessageDialog dialog = new MessageDialog(sh, title, null, message, MessageDialog.QUESTION,
                            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                                    IDialogConstants.CANCEL_LABEL },
                            0);
                    res[0] = dialog.open();
                }
            });
            if (res[0] == 0) {
                return true;
            } else if (res[0] == 1) {
                return false;
            }
            throw new OperationCanceledException();
        }
    };
}

From source file:com.safi.workshop.sqlexplorer.dbproduct.ConnectionJob.java

License:Open Source License

/**
 * Prompts the user for a new username/password to attempt login with; if the dialog is
 * cancelled then this.user is set to null.
 * /*from  w  ww .  j ava2  s .c  o m*/
 * @param message
 */
private void promptForPassword(final String message) {
    final Shell shell = SafiWorkshopEditorUtil.getSafiNavigator().getSite().getShell();

    // Switch to the UI thread to run the password dialog, but run it synchronously so we
    // wait for it to complete
    shell.getDisplay().syncExec(new Runnable() {
        public void run() {
            if (message != null) {
                String title = Messages.getString("Progress.Connection.Title") + ' ' + alias.getName();
                if (user != null && !alias.hasNoUserName())
                    title += '/' + user.getUserName();
                if (alias.hasNoUserName()) {
                    MessageDialog dlg = new MessageDialog(shell, title, null,
                            Messages.getString("Progress.Connection.ErrorMessage_Part1") + "\n\n" + message,
                            MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0);
                    dlg.open();
                    cancelled = true;
                    return;
                } else {
                    MessageDialog dlg = new MessageDialog(shell, title, null,
                            Messages.getString("Progress.Connection.ErrorMessage_Part1") + "\n\n" + message
                                    + "\n\n" + Messages.getString("Progress.Connection.ErrorMessage_Part2"),
                            MessageDialog.ERROR,
                            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
                    boolean retry = dlg.open() == 0;
                    if (!retry) {
                        cancelled = true;
                        return;
                    }
                }
            }

            Shell shell = Display.getCurrent().getActiveShell();
            PasswordConnDlg dlg = new PasswordConnDlg(shell, user.getAlias(), user);
            if (dlg.open() != Window.OK) {
                cancelled = true;
                return;
            }

            // Create a new user and add it to the alias
            User userTmp = new User(dlg.getUserName(), dlg.getPassword());
            userTmp.setAutoCommit(dlg.getAutoCommit());
            userTmp.setCommitOnClose(dlg.getCommitOnClose());
            user = alias.addUser(userTmp);
        }
    });
}

From source file:com.safi.workshop.sqlexplorer.dialogs.SaveOutsideProjectDlg.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true);
    createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, false);
}