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

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

Introduction

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

Prototype

String YES_LABEL

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

Click Source Link

Document

The label for yes buttons.

Usage

From source file:org.eclipse.birt.report.designer.ui.ide.wizards.WizardSaveAsPage.java

License:Open Source License

/**
 * Get the saving path/*w  w w  . j a  v a2 s.c  o m*/
 * 
 * @return the saving path
 */
public IPath getResult() {

    IPath path = resourceGroup.getContainerFullPath().append(resourceGroup.getResource());

    // If the user does not supply a file extension and if the save
    // as dialog was provided a default file name append the extension
    // of the default filename to the new name
    if (path.getFileExtension() == null) {
        if (originalFile != null && originalFile.getFileExtension() != null)
            path = path.addFileExtension(originalFile.getFileExtension());
        else if (originalName != null) {
            int pos = originalName.lastIndexOf('.');
            if (++pos > 0 && pos < originalName.length())
                path = path.addFileExtension(originalName.substring(pos));
        }
    }

    // If the path already exists then confirm overwrite.
    IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);

    if (file.exists()) {
        String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                IDialogConstants.CANCEL_LABEL };
        String question = Messages.getFormattedString("WizardSaveAsPage.OverwriteQuestion", //$NON-NLS-1$
                new Object[] { path.toOSString() });
        MessageDialog d = new MessageDialog(getShell(), Messages.getString("WizardSaveAsPage.Question"), //$NON-NLS-1$
                null, question, MessageDialog.QUESTION, buttons, 0);
        int overwrite = d.open();
        switch (overwrite) {
        case 0: // Yes
            break;
        case 1: // No
            return null;
        case 2: // Cancel
        default:
            return Path.EMPTY;
        }
    }

    return path;
}

From source file:org.eclipse.birt.report.designer.ui.internal.rcp.dialogs.SaveAsDialog.java

License:Open Source License

protected void okPressed() {
    // Get new path.
    IPath path = support.getFileLocationFullPath().append(support.getFileName());

    // If the user does not supply a file extension and the save
    // as dialog was provided a default file name, then append the extension
    // of the default filename to the new name
    if (!ReportPlugin.getDefault().isReportDesignFile(path.toOSString())) {
        String[] parts = support.getInitialFileName().split("\\."); //$NON-NLS-1$
        path = path.addFileExtension(parts[parts.length - 1]);
    }/*from  ww w.  j av  a2 s  .co  m*/

    // If the path already exists then confirm overwrite.
    File file = path.toFile();
    if (file.exists()) {
        String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                IDialogConstants.CANCEL_LABEL };

        String question = Messages.getFormattedString("SaveAsDialog.overwriteQuestion", //$NON-NLS-1$
                new Object[] { path.toOSString() });
        MessageDialog d = new MessageDialog(getShell(), Messages.getString("SaveAsDialog.Question"), //$NON-NLS-1$
                null, question, MessageDialog.QUESTION, buttons, 0);
        int overwrite = d.open();
        switch (overwrite) {
        case 0: // Yes
            break;
        case 1: // No
            return;
        case 2: // Cancel
        default:
            cancelPressed();
            return;
        }
    }

    // Store path and close.
    result = path;
    close();
}

From source file:org.eclipse.birt.report.designer.ui.lib.explorer.dialog.PublishResourceWizard.java

License:Open Source License

private boolean publishiLibrary() {
    // copy to library folder

    if (!(new File(filePath).exists())) {
        ExceptionUtil.openError(Messages.getString("PublishResourceAction.wizard.errorTitle"), //$NON-NLS-1$
                Messages.getString("PublishResourceAction.wizard.message.SourceFileNotExist")); //$NON-NLS-1$

        return false;
    }//from w  w w  . j  a v a 2s  . c  om

    File targetFile = getTargetFile();

    if (targetFile == null) {
        ExceptionUtil.openError(Messages.getString("PublishResourceAction.wizard.errorTitle"), //$NON-NLS-1$
                Messages.getString("PublishResourceAction.wizard.notvalidfolder")); //$NON-NLS-1$

        return false;
    }

    if (new File(filePath).compareTo(targetFile) == 0) {
        ExceptionUtil.openError(Messages.getString("PublishResourceAction.wizard.errorTitle"), //$NON-NLS-1$
                Messages.getString("PublishResourceAction.wizard.message")); //$NON-NLS-1$
        return false;
    }

    int overwrite = Window.OK;
    try {
        if (targetFile.exists()) {
            String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                    IDialogConstants.CANCEL_LABEL };

            String question = Messages.getFormattedString("SaveAsDialog.overwriteQuestion", //$NON-NLS-1$
                    new Object[] { targetFile.getAbsolutePath() });

            MessageDialog d = new MessageDialog(UIUtil.getDefaultShell(),
                    Messages.getString("SaveAsDialog.Question"), //$NON-NLS-1$
                    null, question, MessageDialog.QUESTION, buttons, 0);

            overwrite = d.open();
        }
        if (overwrite == Window.OK
                && (targetFile.exists() || (!targetFile.exists() && targetFile.createNewFile()))) {
            doCopy(filePath, targetFile);

            IReportResourceSynchronizer synchronizer = ReportPlugin.getDefault()
                    .getResourceSynchronizerService();

            if (synchronizer != null) {
                synchronizer.notifyResourceChanged(
                        new ReportResourceChangeEvent(this, Path.fromOSString(targetFile.getAbsolutePath()),
                                IReportResourceChangeEvent.NewResource));
            }
        }
    } catch (IOException e) {
        ExceptionUtil.handle(e);
    }

    return overwrite != 2;
}

From source file:org.eclipse.bpmn2.modeler.ui.editor.BPMN2MultiPageEditor.java

License:Open Source License

@Override
protected void createPages() {
    tabFolder = (CTabFolder) getContainer();
    tabFolder.addCTabFolder2Listener(new CTabFolder2Listener() {

        @Override// w  w w.j av a2 s  .  co  m
        public void close(CTabFolderEvent event) {
            // System.out.println("Convert phase should be here");

            if (event.item.getData() == sourceViewer)
                removeSourceViewer();
            else if (event.item.getData() instanceof DiagramEditor) {
                // TODO: checking modification:
                String MESSAGE = "Resource has been modified. Save changes?";
                int choice = -1;
                DiagramEditor editor = (DiagramEditor) event.item.getData();
                if (editor.isDirty()) {
                    // ASK FOR SAVE:
                    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
                    String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                            IDialogConstants.CANCEL_LABEL };
                    MessageDialog d = new MessageDialog(shell, WorkbenchMessages.Save_Resource, null, MESSAGE,
                            MessageDialog.QUESTION, buttons, 0) {
                        protected int getShellStyle() {
                            return super.getShellStyle() | SWT.SHEET;
                        }
                    };
                    choice = d.open();
                    switch (choice) {
                    case ISaveablePart2.YES: // yes                     
                        editor.doSave(new NullProgressMonitor());
                        break;
                    case ISaveablePart2.NO: // no
                        System.out.println("no");
                        break;
                    default:
                    case ISaveablePart2.CANCEL: // cancel
                        System.out.println("cancel");
                        event.doit = false;
                        return;
                    }
                }
                removeEventViewer(editor);
            }
        }

        @Override
        public void minimize(CTabFolderEvent event) {
        }

        @Override
        public void maximize(CTabFolderEvent event) {
        }

        @Override
        public void restore(CTabFolderEvent event) {
        }

        @Override
        public void showList(CTabFolderEvent event) {
        }

    });
    tabFolder.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            int pageIndex = tabFolder.getSelectionIndex();
            if (pageIndex >= 0 && pageIndex < bpmnDiagrams.size() && designEditor != null) {
                BPMNDiagram bpmnDiagram = bpmnDiagrams.get(pageIndex);
                designEditor.selectBpmnDiagram(bpmnDiagram);
            }
        }
    });

    // defer editor layout until all pages have been created
    tabFolder.setLayoutDeferred(true);

    createDesignEditor();

    Display.getDefault().asyncExec(new Runnable() {
        public void run() {
            setActivePage(0);
            designEditor.selectBpmnDiagram(bpmnDiagrams.get(0));
            tabFolder.setLayoutDeferred(false);
            tabFolder.setTabPosition(SWT.TOP);
            updateTabs();
        }
    });
}

From source file:org.eclipse.bpmn2.modeler.ui.editor.BPMN2MultiPageEditor.java

License:Open Source License

public void createEventViewer(ReceiveTask task, String nid, String text, EEventBaseScript ebs) {
    boolean recreateDiagram = false;
    EventViewer eventView = null;/*from  w  w w  . j av a  2  s .  co  m*/
    for (EditorPart ed : mapping.keySet()) {
        if (ed instanceof EventViewer) {
            if (((EventViewer) ed).id.equals(nid)) {
                setActivePage(((EventViewer) ed).index);
                return;
            }
        }
    }
    try {
        int pageIndex = tabFolder.getItemCount();
        IContainer folder = designEditor.getModelFile().getParent();

        IFile target = null;
        try {
            if (folder instanceof Container) {
                target = ((Container) folder).getFile(nid + ".evb");
                target = ResourcesPlugin.getWorkspace().getRoot()
                        .getFile(folder.getFullPath().addTrailingSeparator().append(nid + ".evb"));
            } else
                log.error("cannot get file '" + nid + ".evb' from folder " + folder);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (target.exists()) {
            log.debug("target exists -> check matching and openfile?");
            String lastFileHash = task.getFileHash();
            String lastScriptHash = task.getScriptHash();
            if (task.getEventScript() == null || lastFileHash == null || lastScriptHash == null) {
                recreateDiagram = true;
            } else {
                String fileHash = HashUtil.getHash(target.getContents());
                String scriptHash = HashUtil.getHash(task.getEventScript());
                if (!fileHash.equals(lastFileHash) || !scriptHash.equals(lastScriptHash)) {
                    // TODO inform user that target file will be overrided!!!
                    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
                    String[] buttons = new String[] { IDialogConstants.YES_LABEL,
                            //IDialogConstants.NO_LABEL,
                            IDialogConstants.CANCEL_LABEL };
                    @SuppressWarnings("restriction")
                    MessageDialog d = new MessageDialog(shell, "Override exist file?", null,
                            ".evb file and the script are inconsistent. Do you want to override .evb file?",
                            MessageDialog.QUESTION, buttons, 0) {
                        protected int getShellStyle() {
                            return super.getShellStyle() | SWT.SHEET;
                        }
                    };
                    int choice = d.open();
                    switch (choice) {
                    case ISaveablePart2.YES: // yes                     
                        //editor.doSave(new NullProgressMonitor());
                        break;
                    case ISaveablePart2.NO: // no
                        System.out.println("no");
                        return;
                    default:
                    case ISaveablePart2.CANCEL: // cancel
                        System.out.println("cancel");
                        //event.doit = false;
                        return;
                    }
                    recreateDiagram = true;
                }
            }
        } else
            recreateDiagram = true;

        if (recreateDiagram) {
            recreateDiagram = true;
            log.debug("create file " + nid + ".evb and try to open it");
            // create & convert!
            final Diagram diagram = Graphiti.getPeCreateService().createDiagram(ProviderID, nid + ".evb", true);
            URI uri = URI.createPlatformResourceURI(target.getFullPath().toString(), true);
            // FileService
            @SuppressWarnings("restriction")
            final TransactionalEditingDomain editingDomain = GraphitiUiInternal.getEmfService()
                    .createResourceSetAndEditingDomain();
            final ResourceSet resourceSet = editingDomain.getResourceSet();
            final Resource resource = resourceSet.createResource(uri);
            final CommandStack cmdStack = editingDomain.getCommandStack();
            cmdStack.execute(new RecordingCommand(editingDomain) {

                @Override
                protected void doExecute() {
                    resource.setTrackingModification(true);
                    resource.getContents().add(diagram);

                }
            });
            save(editingDomain, Collections.<Resource, Map<?, ?>>emptyMap());
            editingDomain.dispose();
        }
        // FileEditorInput input = new FileEditorInput();
        String id = GraphitiUi.getExtensionManager().getDiagramTypeProviderId(ProviderID);
        DiagramEditorInput input = new DiagramEditorInput(
                // This is, folks, it works :D
                //URI.createFileURI(target.getLocation().toOSString()),
                //URI.createFileURI(target.getFullPath().toOSString()),
                URI.createPlatformResourceURI(target.getFullPath().toString(), true), id);

        eventView = new EventViewer(task, nid, pageIndex, recreateDiagram, ebs);//TODO
        addPage(pageIndex, eventView, input);
        tabFolder.getItem(pageIndex).setShowClose(true);

        setPageText(pageIndex, nid);
        setActivePage(pageIndex);

        updateTabs();
    } catch (Exception e) {
        e.printStackTrace();
        if (eventView != null)
            eventView.dispose();
    }
}

From source file:org.eclipse.buckminster.ui.internal.CertificateTrustInquiryUIDialog.java

License:Open Source License

public static boolean promptUser(Shell shell, String title, String message, CertPath certPath) {
    String[] buttonLabels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
            Messages.certificate_details_with_dots };
    CertificateTrustInquiryUIDialog dlg = new CertificateTrustInquiryUIDialog(shell, title, null, message,
            WARNING, buttonLabels, 2, certPath);
    return dlg.open() == 0;
}

From source file:org.eclipse.cdt.core.testplugin.util.VerifyDialog.java

License:Open Source License

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

From source file:org.eclipse.cdt.cpp.ui.internal.actions.ConfigureAction.java

License:Open Source License

public void run() {
    //boolean execute = true;
    int configureUpdate = 0; // 0 == ok do update, 1 == no update , 2 == cancel action
    boolean configFilesExist = false;
    boolean sourceExistInTopLevelDir = false;

    Shell shell = _dataStore.getDomainNotifier().findShell();

    if (sourceFilesExist()) {
        sourceExistInTopLevelDir = true;
    }/*from   ww w.  ja  v  a  2s  .  c o  m*/

    if (_command.getValue().equals("CONFIGURE") && sourceExistInTopLevelDir && !doesAutoconfSupportExist()) {
        dialogHas2Buttons = true;
        String str1 = "";
        String message;
        String[] extraLabel = new String[] { "Program", "Static Lib", "Shared Lib" };
        String title = "Creating configure script";
        message = new String("\nPlease select one of the following targets for your project" + str1);
        box = new CustomMessageDialog(shell, title, null, message, 3,
                new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 1 << 4, 0,
                extraLabel, this, targetKey);

        dialogButtonPushed = box.open();
    }

    else if (_command.getValue().equals("CONFIGURE")) {
        String str1 = new String();
        String message;
        String[] extraLabel = new String[] { "Do not show this dialog again" };
        String title = "Generating and running configure script";
        ModelInterface api = _plugin.getModelInterface();
        project = (IProject) api.findResource(_subject);

        // checking if automatic updating is enabled from the autoconf preferences page
        ArrayList autoUpdateConfigure = org.eclipse.cdt.cpp.ui.internal.CppPlugin
                .readProperty(configureUpdatePreferenceKey);
        if (!autoUpdateConfigure.isEmpty()) {
            String preference = (String) autoUpdateConfigure.get(0);
            if (preference.equals("Yes"))
                enableConfigureUpdate = true;
            else
                enableConfigureUpdate = false;
        }

        if (doesAutoconfSupportExist()) {
            configFilesExist = true;
            String[] buttonTitles = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                    IDialogConstants.CANCEL_LABEL };
            dialogHas2Buttons = false;
            if (enableConfigureUpdate) {

                if (isProjectImported(project, projectStatusKey)) {
                    str1 = new String(
                            "\nWould you like the system to update and generate missing configuration files?");
                } else {
                    dialogHas2Buttons = true;
                    buttonTitles = new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL };
                }

                if (doesFileExist("configure")) {
                    if (!configureIsUptodate(_subject)) {
                        message = new String(
                                "\nRegenerating and running configure script - configure is not up to date "
                                        + str1);
                    } else {
                        dialogHas2Buttons = true;
                        buttonTitles = new String[] { IDialogConstants.OK_LABEL,
                                IDialogConstants.CANCEL_LABEL };
                        message = new String("\nRunning configure script - configure is up to date");
                    }
                } else
                    message = new String("\nGenerating and running configure script" + str1);

                box = new CustomMessageDialog(shell, title, null, message, 3, buttonTitles, 0, extraLabel, this,
                        configueDialogPrefernceKey, project);
                int result = box.open();
                if (result != -1)
                    if (dialogHas2Buttons)
                        configureUpdate = result + 1;
                    else
                        configureUpdate = result;
                else
                    configureUpdate = 0;

            } else {
                message = new String("\nUsing existing configuration files to create and run configure script");
                box = new CustomMessageDialog(shell, title, null, message, 2,
                        new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0,
                        extraLabel, this, configueDialogPrefernceKey, project);
                int result = box.open();
                if (result != -1)
                    configureUpdate = result + 1;
                else
                    configureUpdate = 1;
                // 0 is equiv to 1 ie run with no update , 
                //and 1 is equiv to 2 which is to cancel the action so we need to increment
            }
        } else {
            configFilesExist = false;
            message = new String("\nGenerating and running configure script");

            box = new CustomMessageDialog(shell, title, null, message, 2,
                    new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0, extraLabel,
                    this, configueDialogPrefernceKey, project);
            int result = box.open();
            if (result != -1)
                if (result == 1)
                    configureUpdate = result + 1;
                else
                    configureUpdate = 0;

        }
    }

    if (configureUpdate == 1 && configFilesExist) {
        if (configureIsUptodate(_subject)) {
            //System.out.println("\n C_CONFIGURE_NO_UPDATE # 1A");
            DataElement configureCmd = _dataStore.localDescriptorQuery(_subject.getDescriptor(),
                    "C_RUN_CONFIGURE_NO_UPDATE");
            DataElement status = _dataStore.command(configureCmd, _subject);
            ModelInterface api = ModelInterface.getInstance();
            api.monitorStatus(status);
            api.showView("org.eclipse.cdt.cpp.ui.CppOutputViewPart", status);
            RunThread thread = new RunThread(_subject, status);
            thread.start();
        } else {
            //System.out.println("\n C_CONFIGURE_NO_UPDATE # 1B");
            DataElement configureCmd = _dataStore.localDescriptorQuery(_subject.getDescriptor(),
                    "C_CONFIGURE_NO_UPDATE");
            DataElement status = _dataStore.command(configureCmd, _subject);
            ModelInterface api = ModelInterface.getInstance();
            api.monitorStatus(status);
            api.showView("org.eclipse.cdt.cpp.ui.CppOutputViewPart", status);
            RunThread thread = new RunThread(_subject, status);
            thread.start();
        }
    } else if (configureUpdate == 0 && targetType == DEFAULT && dialogButtonPushed != 1) {
        //System.out.println("\n "+"C_" + _command.getValue()+" # 2");
        DataElement configureCmd = _dataStore.localDescriptorQuery(_subject.getDescriptor(),
                "C_" + _command.getValue());
        DataElement status = _dataStore.command(configureCmd, _subject);
        ModelInterface api = ModelInterface.getInstance();
        api.monitorStatus(status);
        api.showView("org.eclipse.cdt.cpp.ui.CppOutputViewPart", status);
        RunThread thread = new RunThread(_subject, status);
        thread.start();
    }
    // "Progarm" target
    else if (configureUpdate == 0 && targetType == PROGRAM_TARGET && dialogButtonPushed != 1)
    // targetSelection 0 means no selection was made and it will default to program
    {
        //System.out.println("\nC_CONFIGURE_PROGRAM # 3");
        DataElement configureCmd = _dataStore.localDescriptorQuery(_subject.getDescriptor(),
                "C_CONFIGURE_PROGRAM");
        DataElement status = _dataStore.command(configureCmd, _subject);
        ModelInterface api = ModelInterface.getInstance();
        api.monitorStatus(status);
        api.showView("org.eclipse.cdt.cpp.ui.CppOutputViewPart", status);
        RunThread thread = new RunThread(_subject, status);
        thread.start();
    }

    // Static Target
    else if (configureUpdate == 0 && targetType == STATIC_TARGET && dialogButtonPushed != 1) {
        //System.out.println("\nC_CONFIGURE_STATIC # 4");
        DataElement configureCmd = _dataStore.localDescriptorQuery(_subject.getDescriptor(),
                "C_CONFIGURE_STATIC");
        DataElement status = _dataStore.command(configureCmd, _subject);
        ModelInterface api = ModelInterface.getInstance();
        api.monitorStatus(status);
        api.showView("org.eclipse.cdt.cpp.ui.CppOutputViewPart", status);
        RunThread thread = new RunThread(_subject, status);
        thread.start();
    } else if (configureUpdate == 0 && targetType == SHARED_TARGET & dialogButtonPushed != 1) {
        //System.out.println("\nC_CONFIGURE_SHARED # 5");
        DataElement configureCmd = _dataStore.localDescriptorQuery(_subject.getDescriptor(),
                "C_CONFIGURE_SHARED");
        DataElement status = _dataStore.command(configureCmd, _subject);
        ModelInterface api = ModelInterface.getInstance();
        api.monitorStatus(status);
        api.showView("org.eclipse.cdt.cpp.ui.CppOutputViewPart", status);
        RunThread thread = new RunThread(_subject, status);
        thread.start();
    }

}

From source file:org.eclipse.cdt.cpp.ui.internal.actions.CreateConfigureAction.java

License:Open Source License

public void run() {
    boolean execute = true;
    int createUpdate = 0; // 0 == ok do update, 1 == no update , 2 == cancel action
    boolean configfilesExist = false;

    Shell shell = _dataStore.getDomainNotifier().findShell();

    ModelInterface pluginApi = _plugin.getModelInterface();
    project = (IProject) pluginApi.findResource(_subject);

    if (_command.getValue().equals("CREATE_CONFIGURE")) {
        String str1 = new String();
        String message;//from  w ww  .j  a  v  a  2 s .  c o m
        String[] extraLabel = new String[] { "Do not show this dialog again" };
        String title = "Creating configure script";
        String[] buttonTitles = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                IDialogConstants.CANCEL_LABEL };

        // checking if automatic updating is enabled from the autoconf preferences page
        ArrayList autoUpdateCreate = org.eclipse.cdt.cpp.ui.internal.CppPlugin
                .readProperty(updatePreferenceKey);
        if (!autoUpdateCreate.isEmpty()) {
            String preference = (String) autoUpdateCreate.get(0);
            if (preference.equals("Yes"))
                enableCreateUpdate = true;
            else
                enableCreateUpdate = false;
        }

        if (doesAutoconfSupportExist()) {
            configfilesExist = true;
            if (enableCreateUpdate) {

                if (isProjectImported(project, projectStatusKey)) {
                    str1 = new String(
                            "\nWould you like the system to update and generate missing configuration files?");
                } else {
                    buttonTitles = new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL };
                }
                if (doesFileExist("configure"))
                    message = new String(
                            "\nRegenerating project configuration script - configure is not up to date "
                                    + str1);
                else
                    message = new String("\nGenerating project configuration script." + str1);
                box = new CustomMessageDialog(shell, title, null, message, 3, buttonTitles, 0, extraLabel, this,
                        dialogPrefernceKey, project);
                int result = box.open();
                if (result != -1)
                    if (buttonTitles.length == 2 && result == 1)// has 2 buttons and cancel pressed
                        createUpdate = result + 1;
                    else
                        createUpdate = result;
                else
                    createUpdate = 0;

            } else {
                message = new String("\nUsing existing configuration files to create the configure script");
                buttonTitles = new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL };
                box = new CustomMessageDialog(shell, title, null, message, 2, buttonTitles, 0, extraLabel, this,
                        dialogPrefernceKey, project);
                int result = box.open();
                if (result != -1)
                    createUpdate = result + 1;
                else
                    createUpdate = 1;
                // 0 is equiv to 1 ie run with no update , 
                //and 1 is equiv to 2 which is to cancel the action so we need to increment
            }
        } else {
            configfilesExist = false;
            message = new String("\nCreating configuration files to generate configure script");
            box = new CustomMessageDialog(shell, title, null, message, 2,
                    new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0, extraLabel,
                    this, dialogPrefernceKey, project);
            int result = box.open();
            if (result != -1)
                if (result == 1)
                    createUpdate = result + 1;
                else
                    createUpdate = 0;

        }
    }

    if (execute) {
        if (createUpdate == 1 && configfilesExist) {
            DataElement configureCmd = _dataStore.localDescriptorQuery(_subject.getDescriptor(),
                    "C_CREATE_CONFIGURE_NO_UPDATE");
            DataElement status = _dataStore.command(configureCmd, _subject);
            ModelInterface api = ModelInterface.getInstance();
            api.monitorStatus(status);
            api.showView("org.eclipse.cdt.cpp.ui.CppOutputViewPart", status);
            RunThread thread = new RunThread(_subject, status);
            thread.start();
        } else if (createUpdate == 0) {
            DataElement configureCmd = _dataStore.localDescriptorQuery(_subject.getDescriptor(),
                    "C_" + _command.getValue());
            DataElement status = _dataStore.command(configureCmd, _subject);
            ModelInterface api = ModelInterface.getInstance();
            api.monitorStatus(status);
            api.showView("org.eclipse.cdt.cpp.ui.CppOutputViewPart", status);
            RunThread thread = new RunThread(_subject, status);
            thread.start();
        }
    }
}

From source file:org.eclipse.cdt.cpp.ui.internal.actions.DeleteProjectAction.java

License:Open Source License

public void run() {
    ModelInterface api = ModelInterface.getInstance();
    IProject project = api.findProjectResource(_subject);
    if (project != null) {
        Shell shell = api.getDummyShell();
        String msg = "About to delete project \'" + project.getName() + "\'.\n";
        msg += "Delete all its contents under " + project.getLocation().toOSString() + " as well?";
        String title = "Delete Project Contents";

        MessageDialog dialog = new MessageDialog(shell, title, null, // accept the default window icon
                msg, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL,
                        IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
                0); // yes is the default
        int code = dialog.open();
        boolean deleteContent = false;
        switch (code) {
        case 0: // Yes
            deleteContent = true;/*  w  ww  . j  av a2 s  .  c  o  m*/
            break;
        case 1: // No
            deleteContent = false;
            break;
        default: // CANCEL
            return;
        }

        DeleteOperation op = new DeleteOperation(project, api, deleteContent);
        ProgressMonitorDialog progressDlg = new ProgressMonitorDialog(shell);
        try {
            progressDlg.run(true, true, op);
        } catch (InterruptedException e) {
            System.out.println(e);
        } catch (InvocationTargetException e) {
            System.out.println(e);
        }
    }
}