Example usage for org.eclipse.jface.dialogs MessageDialog openQuestion

List of usage examples for org.eclipse.jface.dialogs MessageDialog openQuestion

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs MessageDialog openQuestion.

Prototype

public static boolean openQuestion(Shell parent, String title, String message) 

Source Link

Document

Convenience method to open a simple Yes/No question dialog.

Usage

From source file:com.nokia.s60tools.compatibilityanalyser.ui.views.MainView.java

License:Open Source License

/**
 * The method displays a message asking whether to restart the analysis with default core
 * tools set. If yes, it modifies the corresponding fields to invoke analysis with
 * default core tools set./*from   w w w.ja va  2s .c  o  m*/
 */
public void reStartAnalysisUsingSameData(String title, String message) {
    feedbackMessageTitle = title;
    feedbackMessage = message;
    Runnable showErrorMessageRunnable = new Runnable() {
        public void run() {
            if (MessageDialog.openQuestion(tableviewer.getControl().getShell(), "Confirmation",
                    feedbackMessage)) {
                String defaultToolsPath = CompatibilityAnalyserPlugin.getDefaltCoretoolsPath();
                if (defaultToolsPath == null)
                    MessageDialog.openError(tableviewer.getControl().getShell(), feedbackMessageTitle,
                            Messages.getString("HeaderAnalyserEngine.ToolsPluginDoesNotContainCoreComponents"));
                else {
                    engine.getCurrentSdkData().useDefaultCoreTools = true;
                    engine.getCurrentSdkData().useLocalCoreTools = false;
                    engine.getCurrentSdkData().useSdkCoreTools = false;
                    engine.getCurrentSdkData().useWebServerCoreTools = false;
                    engine.getCurrentSdkData().coreToolsPath = defaultToolsPath;
                    startAnalysis(engine);
                }
            }
            feedbackMessage = "";
        }
    };
    Display.getDefault().asyncExec(showErrorMessageRunnable);
}

From source file:com.nokia.s60tools.compatibilityanalyser.ui.views.MainView.java

License:Open Source License

/**
 * The method displays a message asking whether to restart the filteration with default core
 * tools set. If yes, it modifies the corresponding fields to invoke filteration with
 * default core tools set./*w  w  w  .ja v a  2  s.c om*/
 */
public void reStartFilterationUsingSameData(String title, String message) {
    feedbackMessageTitle = title;
    feedbackMessage = message;
    Runnable showErrorMessageRunnable = new Runnable() {
        public void run() {
            if (MessageDialog.openQuestion(tableviewer.getControl().getShell(), "Confirmation",
                    feedbackMessage)) {
                String defaultToolsPath = CompatibilityAnalyserPlugin.getDefaltCoretoolsPath();
                if (defaultToolsPath == null)
                    MessageDialog.openError(tableviewer.getControl().getShell(), feedbackMessageTitle,
                            Messages.getString("HeaderAnalyserEngine.ToolsPluginDoesNotContainCoreComponents"));
                else {
                    data.useDefaultCoreTools = true;
                    data.useLocalCoreTools = false;
                    data.useSdkCoreTools = false;
                    data.useWebServerCoreTools = false;
                    data.bcFilterPath = defaultToolsPath;
                    startFilteration(data);
                }
            }
            feedbackMessage = "";
        }
    };
    Display.getDefault().asyncExec(showErrorMessageRunnable);
}

From source file:com.nokia.s60tools.imaker.internal.viewers.DebugTab.java

License:Open Source License

private Control createControl(CTabFolder parent) {
    Composite top = new Composite(parent, SWT.NONE);
    top.setLayout(new GridLayout(2, false));
    top.setLayoutData(new GridData(GridData.FILL_BOTH));
    setHelpForControl(top, ImageFlasherHelpContextIDs.IMAKERDIALOG_CONTENTTAB);

    // create table
    Composite tableComp = getNewComposite(top);
    Table table = new Table(tableComp, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
    GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
    gridData.heightHint = 180;/* w  ww . j  a  va  2 s . c o m*/
    table.setLayoutData(gridData);
    table.addKeyListener(new KeyListener() {

        public void keyReleased(KeyEvent e) {
            if ((e.character == ' ')) {
                StructuredSelection ss = (StructuredSelection) tableViewer.getSelection();
                Iterator it = ss.iterator();
                while (it.hasNext()) {
                    IbyEntry entry = (IbyEntry) it.next();
                    entry.setEnabled(!entry.isEnabled());
                    tableViewer.refresh(entry);
                }
            }
        }

        public void keyPressed(KeyEvent e) {
        }
    });

    // create controls
    Composite controls = getNewComposite(top);
    Button button = new Button(controls, SWT.PUSH | SWT.LEFT);
    button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    button.setText(Messages.getString("DebugTab.2"));
    button.setToolTipText(Messages.getString("DebugTab.3"));
    button.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            IbyEntry entry = factory.createIbyEntry();
            ImageContent input = getInput();
            FileToImage file = new FileToImage();
            AddEditFileToTransferDialog dialog = new AddEditFileToTransferDialog(getControl().getShell(), file);
            dialog.setTitle(Messages.getString("FileTransferTab.8"));
            if (dialog.open() != Window.OK) {
                return;
            }
            entry.setEnabled(file.getEnabled());
            entry.setFile(file.getHostPath().substring(2));
            entry.setTarget(file.getTargetPath());
            input.getEntries().add(entry);
            tableViewer.refresh();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });

    button = new Button(controls, SWT.PUSH | SWT.LEFT);
    button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    button.setText(Messages.getString("DebugTab.4"));
    button.setToolTipText(Messages.getString("DebugTab.5"));
    button.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            deleteSelection();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });

    button = new Button(controls, SWT.PUSH | SWT.LEFT);
    button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    button.setText(Messages.getString("DebugTab.24"));
    button.setToolTipText(Messages.getString("DebugTab.25"));
    button.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            duplicateSelection();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });

    button = new Button(controls, SWT.PUSH | SWT.LEFT);
    button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    button.setText(Messages.getString("DebugTab.6"));
    button.setToolTipText(Messages.getString("DebugTab.7"));
    button.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            ImageContent input = getInput();
            if (input != null) {

                if (!input.getEntries().isEmpty()) {
                    boolean confirm = MessageDialog.openQuestion(getControl().getShell(), "Remove Entries",
                            "Clear the list before adding new entries, if any?");
                    if (confirm) {
                        input.getEntries().clear();
                    }
                }
                projectManager.populate(input);
                tableViewer.refresh();
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });

    Composite enableButtons = new Composite(top, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    enableButtons.setLayout(layout);
    enableButtons.setLayoutData(new GridData());

    button = new Button(enableButtons, SWT.PUSH | SWT.LEFT);
    button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    button.setText(Messages.getString("DebugTab.8"));
    button.setToolTipText(Messages.getString("DebugTab.9"));
    button.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            ImageContent ic = getInput();
            if (ic != null) {
                for (IbyEntry entry : ic.getEntries()) {
                    entry.setEnabled(true);
                }
                tableViewer.refresh();
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });

    button = new Button(enableButtons, SWT.PUSH | SWT.LEFT);
    button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    button.setText(Messages.getString("DebugTab.10"));
    button.setToolTipText(Messages.getString("DebugTab.11"));
    button.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            ImageContent ic = getInput();
            if (ic != null) {
                for (IbyEntry entry : ic.getEntries()) {
                    entry.setEnabled(false);
                }
                tableViewer.refresh();
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });

    tableViewer = new TableViewer(table);

    tableViewer.getTable().setHeaderVisible(true);
    tableViewer.getTable().setLinesVisible(true);

    tableViewer.setContentProvider(new DebugContentProvider());

    createColumns(tableViewer);

    tableViewer.getTable().addKeyListener(new KeyListener() {

        public void keyReleased(KeyEvent e) {
            if (e.character == SWT.DEL) {
                deleteSelection();
            }
        }

        public void keyPressed(KeyEvent e) {
        }
    });
    tableViewer.setInput(getDefaultInput());
    return top;
}

From source file:com.nokia.s60tools.swmtanalyser.ui.actions.SwmtAnalyser.java

License:Open Source License

/**
 * Analyse given logs files.//from  w  ww . ja v a2  s  .com
 * @param swmtFiles list of swmt log files to be analysed
 */
public void analyse(ArrayList<String> swmtFilePaths) {
    if (swmtFilePaths != null) {
        inputs = swmtFilePaths;
        cycleData = new ArrayList<CycleData>();

        isCancelled = false;
        IRunnableWithProgress op = new IRunnableWithProgress() {
            public void run(IProgressMonitor monitor) {
                monitor.beginTask("Reading log files..", 10);
                status = logReader.getCycleDataArrayFromLogFiles(inputs, cycleData, monitor);
                if (monitor.isCanceled())
                    isCancelled = true;

                monitor.done();
            }
        };

        IWorkbench wb = PlatformUI.getWorkbench();
        IWorkbenchWindow win = wb.getActiveWorkbenchWindow();

        Shell shell = win != null ? win.getShell() : null;
        try {
            new ProgressMonitorDialog(shell).run(true, true, op);
        } catch (InvocationTargetException e) {
            e.printStackTrace();
            return;
        } catch (InterruptedException e) {
            e.printStackTrace();
            return;
        }

        if (isCancelled)
            return;

        if (status != null) {
            MessageDialog.openError(Display.getCurrent().getActiveShell(), "SWMT Analyser", status);
            return;
        } else if (cycleData.size() > 1) {
            cycleData = logReader.checkCycleOrder(cycleData);
            if (cycleData == null) {
                MessageDialog.openError(Display.getCurrent().getActiveShell(), "SWMT Analyser",
                        "Invalid order of the log files. The selected files must be in consecutive order and must start from the first cycle.");
                return;
            }

            if (!logReader.checkRomInfo(cycleData)) {
                MessageDialog.openError(Display.getCurrent().getActiveShell(), "SWMT Analyser",
                        "Selected logs do not have common ROM Checksum and Version. Hence, they cannot be compared.");
                return;
            }
            int ret = logReader.checkTimeStamp(cycleData);
            if (ret != 0) {
                MessageDialog.openError(Display.getCurrent().getActiveShell(), "SWMT Analyser",
                        "In selected logs, the time stamp of log cycle " + ret + " is lesser than log cycle "
                                + (ret - 1) + ". Hence, they cannot be analysed together.");
                return;
            }
        } else if (cycleData.size() == 1 && cycleData.get(0).getCycleNumber() != 1) {
            boolean ok = MessageDialog.openQuestion(Display.getCurrent().getActiveShell(), "SWMT Analyser",
                    "This is a delta file. It does not contain the complete information.  Do you still want to continue ?");
            if (!ok)
                return;
        }

        //Files are valid and the cycle numbers are in order.
        //So, get overview information to be displayed in the editor view
        OverviewData ov = logReader.getOverviewInformationFromCyclesData(cycleData.toArray(new CycleData[0]),
                cycleData.size());

        Runnable runnable = new Runnable() {
            public void run() {
                for (int i = 0; i < cycleData.size(); i++) {
                    CycleData cycle = cycleData.get(i);
                    cycle.clear();

                    try {
                        SwmtParser.parseSwmtLog(cycle.getFileName(), cycle);
                    } catch (SwmtFormatException e) {
                        parserError = e.getMessage();
                        Runnable runnable = new Runnable() {
                            public void run() {
                                MessageDialog.openError(Display.getCurrent().getActiveShell(), "SWMT Analyser",
                                        "Error while parsing the log file " + parserError);
                            }
                        };
                        Display.getDefault().asyncExec(runnable);
                        return;
                    }
                }
            }
        };
        Display.getDefault().syncExec(runnable);

        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        try {
            IEditorDescriptor descriptor = PlatformUI.getWorkbench().getEditorRegistry()
                    .findEditor(SWMT_EDITOR_ID);
            if (descriptor == null) {
                MessageDialog.openError(Display.getDefault().getActiveShell(), "SWMT Analyser",
                        "SWMT Editor is not found");
                return;
            }

            ParsedData logData = new ParsedData();
            logData.setParsedData(cycleData);
            page.openEditor(new SWMTEditorInput(logData, ov), descriptor.getId(), true,
                    IWorkbenchPage.MATCH_INPUT);

        } catch (PartInitException e) {
            e.printStackTrace();
        }
    } else {
        MessageDialog.openError(Display.getCurrent().getActiveShell(), "SWMT Analyser",
                "Invalid input. Unable to open SWMT Editor");
        return;
    }
}

From source file:com.nokia.s60tools.swmtanalyser.wizards.ReportGenerationWizard.java

License:Open Source License

public boolean performFinish() {

    fileName = comments_page.getFileName();
    String comment = comments_page.getComments();
    boolean isOverviewReport = comments_page.isOverviewReportSelected();
    ReportCreationJob engine = new ReportCreationJob("Creating report", fileName, comment, ov,
            this.rom_checkSum, this.rom_version, issues_tree, isOverviewReport);
    engine.setUser(true);/*from w  w w .j ava2 s  .c  o  m*/
    engine.schedule();

    //Ask user whether to open the created pdf file or not
    Runnable p = new Runnable() {
        public void run() {
            if (MessageDialog.openQuestion(Display.getCurrent().getActiveShell(), "Confirmation",
                    "Would you like to open the saved report?")) //$NON-NLS-1$
            {
                Program p = Program.findProgram(".pdf");
                if (p != null)
                    p.execute(fileName);
            }
        }
    };
    Display.getDefault().asyncExec(p);
    return true;
}

From source file:com.nokia.sdt.symbian.ui.appeditor.ApplicationEditor.java

License:Open Source License

/**
 * Pose any dialog implied by the preflight info, return true
 * if it's ok to continue, false to cancel.
 *///from   www .j  a  v a2  s.  c om
private boolean queryPreflightInfo(PreflightInfo pi) {
    boolean result = true;
    if (pi.dialogMessage != null) {
        result = MessageDialog.openQuestion(getEditorSite().getShell(),
                Messages.getString("ApplicationEditor.confirmAppChangesDialogTitle"), pi.dialogMessage); //$NON-NLS-1$
    }
    return result;
}

From source file:com.nokia.sdt.symbian.workspace.impl.DesignFileDeletedJob.java

License:Open Source License

IStatus handleViewDesignDeleted(IProgressMonitor monitor) {
    IStatus result;/*from  w w w  .  ja v  a2  s .  c o m*/
    IFile designFile = specifier.getModelFile();
    String relativePath = designFile.getProjectRelativePath().toString();
    if (DesignReferenceJobUtilities.isViewReferencedInApplication(specifier, relativePath)) {
        String title = Messages.getString("DesignerDataModelSpecifier.dialogTitle"); //$NON-NLS-1$
        String fmt = Messages.getString("DesignerDataModelSpecifier.1"); //$NON-NLS-1$
        Object params[] = { designFile.getFullPath().toString() };
        String msg = MessageFormat.format(fmt, params);
        boolean proceed = true;
        if (!WorkbenchUtils.isJUnitRunning()) {
            proceed = MessageDialog
                    .openQuestion(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, msg);
        }
        if (proceed) {

            String path = designFile.getProjectRelativePath().toString();
            result = DesignReferenceJobUtilities.removeViewDesignReference(specifier.getProjectContext(), path,
                    monitor);
        } else {
            result = Status.OK_STATUS;
        }
    } else {
        result = Status.OK_STATUS;
    }
    specifier.dispose();
    return result;
}

From source file:com.nokia.sdt.symbian.workspace.impl.DesignFileMovedJob.java

License:Open Source License

IStatus handleViewDesignMoved(IProgressMonitor monitor) {
    IStatus result = Status.OK_STATUS;/*from  w w  w .j  a  v  a 2  s .  c  o m*/
    IFile designFile = specifier.getModelFile();
    IFile oldFile = ResourcesPlugin.getWorkspace().getRoot().getFile(oldPath);
    IProject oldProject = oldFile.getProject();
    IProject newProject = designFile.getProject();
    if (newProject != null && newProject == oldProject) {
        boolean isDesignFile = SymbianModelUtils.isDesignName(designFile.getName());
        if (isDesignFile) {
            // Only ask the user about updating the app model if the design is currently referenced
            String oldRelativePath = oldPath.removeFirstSegments(1).toString();
            if (DesignReferenceJobUtilities.isViewReferencedInApplication(specifier, oldRelativePath)) {

                String title = Messages.getString("DesignerDataModelSpecifier.dialogTitle"); //$NON-NLS-1$
                String fmt = Messages.getString("DesignerDataModelSpecifier.0"); //$NON-NLS-1$
                Object params[] = { designFile.getFullPath().toString() };
                String msg = MessageFormat.format(fmt, params);
                boolean proceed = true;
                if (!WorkbenchUtils.isJUnitRunning()) {
                    proceed = MessageDialog.openQuestion(
                            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, msg);
                }
                if (proceed) {
                    String newRelativePath = designFile.getProjectRelativePath().toString();
                    result = DesignReferenceJobUtilities.renameViewDesignReference(specifier, oldRelativePath,
                            newRelativePath, monitor);
                }
            }
        } else {
            // Changed the file extension, we will no longer treat it as a design
            String title = Messages.getString("DesignerDataModelSpecifier.dialogTitle"); //$NON-NLS-1$
            String fmt = Messages.getString("DesignerDataModelSpecifier.changeViewDesignExtension"); //$NON-NLS-1$
            Object params[] = { designFile.getFullPath().toString() };
            String msg = MessageFormat.format(fmt, params);
            boolean proceed = true;
            if (!WorkbenchUtils.isJUnitRunning()) {
                proceed = MessageDialog.openQuestion(
                        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, msg);
            }
            if (proceed) {
                IProjectContext pc = WorkspaceContext.getContext().getContextForProject(oldProject);
                if (pc != null) {
                    result = DesignReferenceJobUtilities.removeViewDesignReference(pc,
                            oldFile.getProjectRelativePath().toString(), monitor);
                }
            }
            specifier.dispose();
        }
    } else {
        // moved to a different project
        String title = Messages.getString("DesignerDataModelSpecifier.dialogTitle"); //$NON-NLS-1$
        String fmt = Messages.getString("DesignerDataModelSpecifier.moveViewDesignAcrossProjects"); //$NON-NLS-1$
        Object params[] = { designFile.getFullPath().toString() };
        String msg = MessageFormat.format(fmt, params);
        boolean proceed = true;
        if (!WorkbenchUtils.isJUnitRunning()) {
            proceed = MessageDialog
                    .openQuestion(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, msg);
        }
        if (proceed) {
            IProjectContext pc = WorkspaceContext.getContext().getContextForProject(oldProject);
            if (pc != null) {
                result = DesignReferenceJobUtilities.removeViewDesignReference(pc,
                        oldFile.getProjectRelativePath().toString(), monitor);
            }
        }
        if (newProject == null) {
            specifier.dispose();
        }
    }
    return result;
}

From source file:com.nokia.sdt.uidesigner.ui.AbstractDesignerDataModelEditor.java

License:Open Source License

/**
 * Does the work of loading the input, but assumes the progress monitor has begun and does not end it
 * @param monitor/*from   ww  w  .j ava2s .  c  o  m*/
 * @return IStatus
 */
protected IStatus doLoadInput(IProgressMonitor monitor) {
    IFile file = ResourceUtil.getFile(getEditorInput());

    if ((file == null) || !file.exists()) {
        if (file != null && !file.getProject().isOpen())
            return EditorUtils.makeOrReportEditorOpenStatus(
                    Strings.getString("AbstractDesignerDataModelEditor.LoadFailedProjectClosedError"), null); //$NON-NLS-1$
        return EditorUtils.makeOrReportEditorOpenStatus(
                Strings.getString("AbstractDesignerDataModelEditor.LoadFailedNoFileError"), null); //$NON-NLS-1$
    }

    WorkspaceContext wc = WorkspaceContext.getContext();
    IDesignerDataModelSpecifier modelSpecifier = wc.findSpecifierForResource(file);
    boolean neededUpdating = false;
    IProject project = file.getProject();

    // first we check if the project needs updating
    IProjectUpdateManager pum = CarbideUpdaterPlugin.getProjectUpdateManager();
    if (modelSpecifier == null && pum.projectNeedsUpdate(project, null)) {
        EditorUtils.tryToUpdateProject(project);
        modelSpecifier = wc.findSpecifierForResource(file);
        neededUpdating = true;
    }

    if (modelSpecifier == null) {
        String errorString = neededUpdating
                ? Strings.getString("AbstractDesignerDataModelEditor.LoadFailedNeedsUpdatingError") //$NON-NLS-1$
                : Strings.getString("AbstractDesignerDataModelEditor.LoadFailedNoSpecifierError"); //$NON-NLS-1$
        return EditorUtils.makeOrReportEditorOpenStatus(errorString, null);
    }

    monitor.worked(1);

    String failureMsg = modelSpecifier.isEditable();
    if (failureMsg != null)
        return EditorUtils.makeOrReportEditorOpenStatus(failureMsg, null); //$NON-NLS-1$

    StatusHolder holder = new StatusHolder();
    dataModel = EditorUtils.loadModel(modelSpecifier, holder);
    IStatus status = holder.getStatus();
    if (status != null && !status.isOK())
        return status;

    // now check if the model needs updating
    if (!neededUpdating && !dataModel.isModelUpToDate()) {
        boolean wantsUpdate = MessageDialog.openQuestion((Shell) getAdapter(Shell.class),
                Strings.getString("AbstractDesignerDataModelEditor.LoadUpgradeQueryTitle"), //$NON-NLS-1$
                Strings.getString("AbstractDesignerDataModelEditor.LoadUpgradeQuery")); //$NON-NLS-1$
        if (wantsUpdate) {
            dataModel.dispose();
            EditorUtils.tryToUpgradeProjectDesigns(project);
            dataModel = EditorUtils.loadModel(modelSpecifier, holder);
            status = holder.getStatus();
            if (status != null && !status.isOK())
                return status;
        }
    }

    Check.checkState(dataModel != null);
    resourceListener = new DesignerDataModelEditorResourceListener(this);
    commandStack.initialize(getSite().getShell(), dataModel);
    EditorServices.addEditor(this);

    monitor.worked(1);

    enableExternalChangeListeners();

    monitor.worked(1);

    return Status.OK_STATUS;
}

From source file:com.nokia.sdt.uidesigner.ui.DesignerDataModelEditorResourceListener.java

License:Open Source License

protected void handleFileRemoved(final boolean alwaysAsk) {
    synchronized (this) {
        if (isSaving)
            return;

        // This can safely be set this here, because the only possible outcome
        // is saving or closing the editor. In either case, no other questions need be asked.
        isSaving = true;//from w w  w .  j  a va2s .  c  o  m
    }

    WorkspaceJob wsJob = new WorkspaceJob("") {

        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            Display.getDefault().syncExec(new Runnable() {
                public void run() {
                    boolean hasProject = false;
                    IFile file = getFile();
                    if (file != null) {
                        IProject project = file.getProject();
                        hasProject = (project != null) && project.exists();
                    }
                    if (hasProject && (alwaysAsk || getEditorPart().isDirty())) {
                        String messageFmt = Strings.getString("DesignerEditorResourceListener.DeletedQuestion"); //$NON-NLS-1$
                        String message = MessageFormat.format(messageFmt,
                                new Object[] { getEditorPart().getTitle() });
                        if (MessageDialog.openQuestion(getEditorPart().getSite().getShell(),
                                Strings.getString("DesignerEditorResourceListener.DeletedTitle"), message)) { //$NON-NLS-1$
                            saveEditor();
                        } else
                            closeEditor();
                    } else
                        closeEditor();
                }
            });

            return Status.OK_STATUS;
        }
    };
    wsJob.setRule(getFile().getProject());
    wsJob.setPriority(WorkspaceContext.QUERY_SAVE_CHANGES_ON_DELETE_PRIORITY);
    wsJob.setUser(false);
    wsJob.setSystem(true);
    wsJob.schedule();
}