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.sap.dirigible.ide.template.ui.db.wizard.DataStructureTemplateStructurePage.java

License:Open Source License

private void removeClicked() {
    TreeItem[] selection = typeViewer.getTree().getSelection();
    List<Integer> removeIndexes = new ArrayList<Integer>();

    if (selection != null && selection.length > 0 && MessageDialog.openQuestion(null, REMOVE_COLUMN,
            ARE_YOU_SURE_YOU_WANT_TO_REMOVE_THE_SELECTED_COLUMN)) {

        for (TreeItem nextSelection : selection) {
            removeIndexes.add(typeViewer.getTree().indexOf(nextSelection));
        }/*from  w w w  .  ja  va 2  s .  c  o m*/

        columnDefinitions = (ColumnDefinition[]) typeViewer.getInput();
        columnDefinitions = removeColumnsFromTable(columnDefinitions, removeIndexes);
        typeViewer.setInput(columnDefinitions);
        updateColumnDefinitions();
        checkPageStatus();
    }
}

From source file:com.siteview.mde.internal.ui.editor.monitor.ExtensionPointsSection.java

License:Open Source License

private void handleDelete() {
    Object[] selection = ((IStructuredSelection) pointTable.getSelection()).toArray();
    for (int i = 0; i < selection.length; i++) {
        Object object = selection[i];
        if (object != null && object instanceof IMonitorExtensionPoint) {
            IStructuredSelection newSelection = null;
            IMonitorExtensionPoint ep = (IMonitorExtensionPoint) object;
            IMonitorBase plugin = ep.getMonitorBase();
            IMonitorExtensionPoint[] points = plugin.getExtensionPoints();
            int index = getNewSelectionIndex(getArrayIndex(points, ep), points.length);
            if (index != -1)
                newSelection = new StructuredSelection(points[index]);
            try {
                String schema = ep.getSchema();
                if (schema != null && schema.length() > 0) {
                    IProject project = ep.getModel().getUnderlyingResource().getProject();
                    IFile schemaFile = project.getFile(schema);
                    if (schemaFile != null && schemaFile.exists())
                        if (MessageDialog.openQuestion(getSection().getShell(),
                                MDEUIMessages.ExtensionPointsSection_title,
                                NLS.bind(MDEUIMessages.ExtensionPointsSection_message1,
                                        schemaFile.getProjectRelativePath().toString())))
                            schemaFile.delete(true, true, new NullProgressMonitor());
                }//ww w  . j ava 2 s  . c  o m
                plugin.remove(ep);
                if (newSelection != null)
                    pointTable.setSelection(newSelection);

            } catch (CoreException e) {
                MDEPlugin.logException(e);
            }
        }
    }
}

From source file:com.siteview.mde.internal.ui.editor.monitor.MonitorOverviewPage.java

License:Open Source License

public void linkActivated(HyperlinkEvent e) {
    String href = (String) e.getHref();
    // try page references
    if (href.equals("dependencies")) //$NON-NLS-1$
        getEditor().setActivePage(DependenciesPage.PAGE_ID);
    else if (href.equals("runtime")) //$NON-NLS-1$
        getEditor().setActivePage(RuntimePage.PAGE_ID);
    else if (href.equals("extensions")) { //$NON-NLS-1$
        if (getEditor().setActivePage(ExtensionsPage.PAGE_ID) == null)
            activateExtensionPages(ExtensionsPage.PAGE_ID);
    } else if (href.equals("ex-points")) { //$NON-NLS-1$
        if (getEditor().setActivePage(ExtensionPointsPage.PAGE_ID) == null)
            activateExtensionPages(ExtensionPointsPage.PAGE_ID);
    } else if (href.equals("build")) { //$NON-NLS-1$
        if (!getMDEEditor().hasInputContext(BuildInputContext.CONTEXT_ID)) {
            if (!MessageDialog.openQuestion(MDEPlugin.getActiveWorkbenchShell(),
                    MDEUIMessages.OverviewPage_buildTitle, MDEUIMessages.OverviewPage_buildQuestion))
                return;
            IFile file = PDEProject.getBuildProperties(getMDEEditor().getCommonProject());
            WorkspaceBuildModel model = new WorkspaceBuildModel(file);
            model.save();/*from www.j  ava2 s .  c om*/
            IEditorInput in = new FileEditorInput(file);
            getMDEEditor().getContextManager().putContext(in, new BuildInputContext(getMDEEditor(), in, false));
        }
        getEditor().setActivePage(BuildPage.PAGE_ID);
    } else if (href.equals("export")) { //$NON-NLS-1$
        getExportAction().run();
    } else if (href.equals("action.convert")) { //$NON-NLS-1$
        handleConvert();
    } else if (href.equals("organize")) { //$NON-NLS-1$
        getEditor().doSave(null);
        OrganizeManifestsAction organizeAction = new OrganizeManifestsAction();
        organizeAction.selectionChanged(null, new StructuredSelection(getMDEEditor().getCommonProject()));
        organizeAction.run(null);
    } else if (href.equals("externalize")) { //$NON-NLS-1$
        getEditor().doSave(null);
        GetNonExternalizedStringsAction externalizeAction = new GetNonExternalizedStringsAction();
        externalizeAction.selectionChanged(null, new StructuredSelection(getMDEEditor().getCommonProject()));
        externalizeAction.run(null);
    } else
        super.linkActivated(e);
}

From source file:com.siteview.mde.internal.ui.editor.schema.SchemaPreviewLauncher.java

License:Open Source License

/**
 * @param file/*from w w  w. jav a  2s.  co m*/
 */
private void handleUnsavedOpenSchemaEditor(IFile file) {
    // Get the open schema editor with the specified underlying file
    // (if there is any)
    SchemaEditor editor = PDEModelUtility.getOpenSchemaEditor(file);
    // Ensure we have a dirty editor
    if (editor == null) {
        // No matching open editor found
        return;
    } else if (editor.isDirty() == false) {
        // Matching open editor found that is NOT dirty
        return;
    }
    // Matching open editor found that IS dirty
    // Open a dialog asking the user whether they would like to save the
    // editor
    boolean doSave = MessageDialog.openQuestion(Display.getDefault().getActiveShell(),
            MDEUIMessages.SchemaPreviewLauncher_msgEditorHasUnsavedChanges,
            MDEUIMessages.SchemaPreviewLauncher_msgSaveChanges);
    // Save the editor if the user indicated so
    if (doSave) {
        editor.doSave(new NullProgressMonitor());
    }
}

From source file:com.siteview.mde.internal.ui.preferences.PDECompilersConfigurationBlock.java

License:Open Source License

/**
 * Performs the save operation on the working cop manager
 *//*from ww  w. ja va 2s  .c  o  m*/
private void save() {
    if (fDirty) {
        try {
            ArrayList changes = new ArrayList();
            collectChanges(fLookupOrder[0], changes);
            if (changes.size() > 0) {
                if (fRebuildcount < 1) {
                    fRebuildcount++;
                    fManager.applyChanges();
                    String message = MDEUIMessages.PDECompilersConfigurationBlock_settings_changed_all;
                    if (fProject != null) {
                        message = MessageFormat.format(
                                MDEUIMessages.PDECompilersConfigurationBlock_setting_changed_project,
                                new String[] { fProject.getName() });
                    }
                    if (MessageDialog.openQuestion(fParent.getShell(),
                            MDEUIMessages.PDECompilersConfigurationBlock_settings_changed, message)) {
                        doFullBuild();
                    }
                }
            }
            fDirty = false;
        } catch (BackingStoreException bse) {
            MDEPlugin.log(bse);
        }
    }
}

From source file:com.siteview.mde.internal.ui.samples.ShowSampleAction.java

License:Open Source License

/**
 * Ensure the sample feature is present. If not present, attempt to install it.
 * /*from   ww w.j  a v a 2  s.c o m*/
 * @return <code>true</code> if the sample features are present, and
 * <code>false</code> otherwise.
 */
private boolean ensureSampleFeaturePresent() {
    IProfile profile = getProfile();
    if (profile == null)
        return false;
    if (checkFeature(profile))
        return true;
    // the feature is not present - ask to download
    if (MessageDialog.openQuestion(MDEPlugin.getActiveWorkbenchShell(), MDEUIMessages.ShowSampleAction_msgTitle,
            MDEUIMessages.ShowSampleAction_msgDesc)) {
        return downloadFeature();
    }
    return false;
}

From source file:com.siteview.mde.internal.ui.wizards.exports.AntGeneratingExportWizard.java

License:Open Source License

protected boolean confirmDelete() {
    if (!fPage.doExportToDirectory()) {
        File zipFile = new File(fPage.getDestination(), fPage.getFileName());
        if (zipFile.exists()) {
            if (!MessageDialog.openQuestion(getContainer().getShell(),
                    MDEUIMessages.BaseExportWizard_confirmReplace_title,
                    NLS.bind(MDEUIMessages.BaseExportWizard_confirmReplace_desc, zipFile.getAbsolutePath())))
                return false;
            zipFile.delete();//from  w  w  w .jav a 2 s.  c  o m
        }
    }
    return true;
}

From source file:com.siteview.mde.internal.ui.wizards.extension.PointSelectionPage.java

License:Open Source License

public boolean finish() {
    String point = IdUtil.getFullId(fCurrentPoint, fModel);

    try {//from   w  w w.  ja v  a  2  s  .  c  om
        IMonitorExtension extension = fModel.getFactory().createExtension();
        // Set the point attribute
        // The point value overrides an auto-generated value
        extension.setPoint(point);
        fModel.getMonitorBase().add(extension);

        // Recursively auto-insert required child elements and attributes 
        // respecting multiplicity
        ISchemaElement schemaElement = null;
        // Get the extension's schema
        Object object = extension.getSchema();
        if ((object != null) && (object instanceof Schema)) {
            Schema schema = (Schema) object;
            if (extension instanceof MonitorExtensionNode) {
                // Get the extension's XML element name
                String elementName = ((MonitorExtensionNode) extension).getXMLTagName();
                // Find the extension's corresponding schema element
                schemaElement = schema.findElement(elementName);
            }
            // If there is an associated schema, do the auto-insert
            if (schemaElement != null) {
                XMLInsertionComputer.computeInsertion(schemaElement, extension);
            }
        }

        String pluginID = fCurrentPoint.getMonitorBase().getId();
        if (!(fCurrentPoint instanceof MonitorExtensionPointNode) && !fAvailableImports.contains(pluginID)
                && !(fCurrentPoint.getMonitorBase() instanceof IFragment)) {
            if (MessageDialog.openQuestion(getShell(),
                    MDEUIMessages.NewExtensionWizard_PointSelectionPage_dependencyTitle,
                    NLS.bind(MDEUIMessages.NewExtensionWizard_PointSelectionPage_dependencyMessage,
                            new String[] { pluginID, fCurrentPoint.getId() }))) {
                IMonitorImport importNode = fModel.getMonitorFactory().createImport();
                importNode.setId(pluginID);
                fModel.getMonitorBase().add(importNode);
            }
        }
    } catch (CoreException e) {
        MDEPlugin.logException(e);
    }
    return true;
}

From source file:com.siteview.mde.internal.ui.wizards.extension.PointSelectionPage.java

License:Open Source License

public void checkModel() {
    IWizardNode node = getSelectedNode();
    if (node == null)
        return;//from   ww  w . j a v  a  2 s.  c om
    IWizard wizard = node.getWizard();
    if (wizard instanceof NewExtensionTemplateWizard) {
        if (((NewExtensionTemplateWizard) wizard).updatedDependencies()) {
            if (MessageDialog.openQuestion(getShell(), MDEUIMessages.PointSelectionPage_newDepFound,
                    MDEUIMessages.PointSelectionPage_newDepMessage)) {
                fWizard.getEditor().doSave(new NullProgressMonitor());
            }
        }
    }
}

From source file:com.siteview.mde.internal.ui.wizards.feature.AbstractCreateFeatureOperation.java

License:Open Source License

protected boolean shouldOverwriteFeature() {
    return !fLocation.append(fProject.getName()).toFile().exists()
            || MessageDialog.openQuestion(MDEPlugin.getActiveWorkbenchShell(),
                    this instanceof CreateFeaturePatchOperation ? MDEUIMessages.FeaturePatch_wtitle
                            : MDEUIMessages.NewFeatureWizard_wtitle,
                    MDEUIMessages.NewFeatureWizard_overwriteFeature);
}