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

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

Introduction

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

Prototype

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

Source Link

Document

Convenience method to open a simple confirm (OK/Cancel) dialog.

Usage

From source file:com.softberries.klerk.gui.editors.ProductsEditor.java

License:Open Source License

@Override
protected void deleteButtonClicked() {
    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    if (this.getSelectedProduct() == null || this.getSelectedProduct().getId() == null) {
        MessageDialog.openInformation(shell, "Information", "Nothing to delete");
        return;/*ww w . ja  va2s  . c  o m*/
    }
    boolean confirmed = MessageDialog.openConfirm(shell, "Confirm",
            "Are you sure you want to delete this product?");
    if (confirmed) {
        ProductDao dao = new ProductDao(DB_FOLDER_PATH);
        try {
            dao.delete(this.getSelectedProduct().getId());
            closeOpenedEditorForThisItem(new ProductEditorInput(this.getSelectedProduct()));
            ProductsModelProvider.INSTANCE.getProducts().remove(this.getSelectedProduct());
            this.setSelectedProduct(null);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        viewer.setInput(ProductsModelProvider.INSTANCE.getProducts());
        viewer.refresh();
    }
}

From source file:com.steelejr.eclipse.aws.marketplace.wizard.NewFeatureUtil.java

public static boolean installInstallableUnit(final IInstallableUnit[] unitsToInstall) {

    final boolean[] install = new boolean[1];
    final Display display = Display.getCurrent();
    display.syncExec(new Runnable() {

        @Override/* w  w  w .j av  a  2 s.com*/
        public void run() {
            install[0] = MessageDialog.openConfirm(display.getActiveShell(), "Confirm Installation",
                    "Are you sure you want to install this software?");
        }
    });

    // They pressed cancel on the message dialog,
    // so close the license wizard.
    if (!install[0]) {
        return true;
    }

    Job job = new Job("Installing New Feature") {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            IProvisioningAgent agent = NewFeatureUtil.getAgent();
            IPlanner planner = (IPlanner) agent.getService(IPlanner.SERVICE_NAME);

            IProfileRegistry registry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
            IProfile profile = registry.getProfile(IProfileRegistry.SELF);

            IProfileChangeRequest profileChangeRequest = planner.createChangeRequest(profile);
            profileChangeRequest.add(unitsToInstall[0]);

            ProvisioningContext context = new ProvisioningContext(agent);

            IProvisioningPlan plan = planner.getProvisioningPlan(profileChangeRequest, context, monitor);

            IEngine engine = (IEngine) agent.getService(IEngine.SERVICE_NAME);
            return engine.perform(plan, PhaseSetFactory.createDefaultPhaseSet(), monitor);
        }
    };

    // Ask user for restart once installation is complete.
    ProvisioningOperationRunner por = new ProvisioningOperationRunner(ProvisioningUI.getDefaultUI());
    por.manageJob(job, ProvisioningJob.RESTART_OR_APPLY);
    job.setUser(true);
    job.schedule();

    return true;
}

From source file:com.surelogic.common.ui.dialogs.ManageLicensesMediator.java

/**
 * Uninstalls a set of licenses.//w w w . ja v  a 2  s.  c  om
 * 
 * @param selection
 *          the licenses to uninstall.
 */
void uninstallLicenses(List<PossiblyActivatedSLLicense> selection) {
    final int count = selection.size();
    if (count < 1)
        return;
    boolean anyActivatedWithANetCheck = false;
    for (PossiblyActivatedSLLicense license : selection) {
        if (license.isActivated() && license.getSignedSLLicense().getLicense().performNetCheck()) {
            anyActivatedWithANetCheck = true;
            break;
        }
    }
    String confirmMsg = I18N.msg("common.manage.licenses.dialog.uninstall.msg", count > 1 ? count + " licenses"
            : "\"" + selection.get(0).getSignedSLLicense().getLicense().getProduct().toString() + "\" license");
    if (anyActivatedWithANetCheck)
        confirmMsg = confirmMsg + I18N.msg("common.manage.licenses.dialog.uninstall.netcheckwarn");
    if (!MessageDialog.openConfirm(getShell(), I18N.msg("common.manage.licenses.dialog.uninstall.title"),
            confirmMsg)) {
        return; // bail
    }
    try {
        SLLicenseUtility.tryToUninstallLicenses(selection, EclipseUtility.getEclipseVersion());
    } catch (Exception e) {
        final int code = 142;
        final String msg = I18N.err(code, e.getMessage());
        final SLStatus status = SLStatus.createErrorStatus(code, msg, e);
        final String errorDialogTitle = I18N.msg("common.manage.licenses.dialog.uninstall.failure");
        ErrorDialogUtility.open(getShell(), errorDialogTitle, SLEclipseStatusUtility.convert(status));
    }
    updateTableContents();
    updateButtonState();
}

From source file:com.surelogic.common.ui.dialogs.ManageLicensesMediator.java

/**
 * Activates or renews a set of licenses.
 * //from  ww  w  .j ava  2 s .c  om
 * @param selection
 *          the licenses to renew or activate.
 * @param activation
 *          {@true} if this action is a license activation, {@code} false if
 *          this action is a license renewal.
 */
void activateRenewLicenses(List<PossiblyActivatedSLLicense> selection, boolean activation) {
    final int count = selection.size();
    if (count < 1)
        return;

    final String passive = activation ? "Activation" : "Renewal";
    final String active = activation ? "Activate" : "Renew";

    if (!MessageDialog.openConfirm(getShell(),
            I18N.msg("common.manage.licenses.dialog.activaterenew.title", passive),
            I18N.msg("common.manage.licenses.dialog.activaterenew.msg", active,
                    count > 1 ? count + " licenses"
                            : "\"" + selection.get(0).getSignedSLLicense().getLicense().getProduct().toString()
                                    + "\" license"))) {
        return; // bail
    }

    try {
        SLLicenseUtility.tryToActivateRenewLicenses(selection, SLUtility.getMacAddressesOfThisMachine(),
                EclipseUtility.getEclipseVersion());
    } catch (Exception e) {
        final int code = 144;
        final String msg = I18N.err(code, e.getMessage());
        final SLStatus status = SLStatus.createErrorStatus(code, msg, e);
        final String errorDialogTitle = I18N.msg("common.manage.licenses.dialog.activaterenew.failure", active);
        ErrorDialogUtility.open(getShell(), errorDialogTitle, SLEclipseStatusUtility.convert(status));
    }
    updateTableContents();
    updateButtonState();
}

From source file:com.symbian.smt.gui.exportwizards.ExportSelectionPage.java

License:Open Source License

public boolean copyFile() {
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceRoot workspaceRoot = workspace.getRoot();

    IProject project = workspaceRoot.getProject(list.getItem(list.getSelectionIndex()));

    IScopeContext projectScope = new ProjectScope(project);
    PersistentDataStore store = new PersistentDataStore(projectScope.getNode(Activator.PLUGIN_ID));

    IFile projectFile = project.getFile(store.getOutputFilename());

    File toFile = new File(text.getText());

    if (toFile.isDirectory()) {
        MessageDialog.openError(getShell(), "Error", toFile.toString() + " is a directory");
        Logger.log(toFile.toString() + " is a directory");
        return false;
    }/* w  ww.  j  a va2 s . c  o m*/

    if (!projectFile.exists()) {
        MessageDialog.openError(getShell(), "Error", "The project " + list.getItem(list.getSelectionIndex())
                + " does not contain a System Model Diagram");
        return false;
    }

    if (toFile.exists()) {
        if (!MessageDialog.openConfirm(getShell(), "Overwrite?",
                "Do you wish to overwrite the file " + toFile.toString() + "?")) {
            return false;
        }
    }

    try {
        FileChannel in = new FileInputStream(projectFile.getRawLocation().toOSString()).getChannel();
        FileChannel out = new FileOutputStream(text.getText()).getChannel();

        try {
            in.transferTo(0, in.size(), out);
            in.close();
            out.close();
        } catch (IOException e) {
            MessageDialog.openError(getShell(), "Error", e.getMessage());
            Logger.log(e.getMessage(), e);
            return false;
        }

    } catch (FileNotFoundException e) {
        MessageDialog.openError(getShell(), "Error", e.getMessage());
        Logger.log(e.getMessage(), e);
        return false;
    }

    return true;
}

From source file:com.tencent.wstt.apt.util.TestSenceUtil.java

License:Open Source License

/**
* @Description ?? //from  www  . j av a  2 s  .co  m
* @param @return   
* @return boolean 
* @throws
 */
public static boolean verifyTestSence() {
    //
    if (TestSence.getInstance().pkgInfos.size() == 0) {
        String info = "";
        APTConsoleFactory.getInstance().APTPrint(info);
        MessageDialog.openWarning(PlatformUI.getWorkbench().getDisplay().getActiveShell(), "??", info);
        return false;
    }

    //?
    int testItemCount = 0;
    for (int i = 0; i < Constant.TEST_ITEM_COUNT; i++) {
        if (TestSence.getInstance().itemTestSwitch[i]) {
            testItemCount++;
        }
    }

    if (testItemCount == 0) {
        String info = "";
        APTConsoleFactory.getInstance().APTPrint(info);
        MessageDialog.openWarning(PlatformUI.getWorkbench().getDisplay().getActiveShell(), "??", info);
        return false;
    }

    if (TestSence.getInstance().itemTestSwitch[Constant.MEM_INDEX] && testItemCount > 1) {
        String info = "?CPU?CPU";
        APTConsoleFactory.getInstance().APTPrint(info);
        if (!MessageDialog.openConfirm(PlatformUI.getWorkbench().getDisplay().getActiveShell(), "??",
                info)) {
            return false;
        }
    }

    if (TestSence.getInstance().itemTestPeriod[Constant.CPU_INDEX] < Constant.TOP_UPDATE_PERIOD * 1000) {
        String info = "CPU3";
        APTConsoleFactory.getInstance().APTPrint(info);
        MessageDialog.openWarning(PlatformUI.getWorkbench().getDisplay().getActiveShell(), "??", info);
        return false;
    }

    return true;
}

From source file:com.testify.ecfeed.ui.modelif.ClassInterface.java

License:Open Source License

public boolean setQualifiedName(String newName) {
    if (newName.equals(getQualifiedName())) {
        return false;
    }//  w ww . j  av  a 2s  .  co m
    if (getImplementationStatus(getTarget()) != EImplementationStatus.NOT_IMPLEMENTED) {
        if (MessageDialog.openConfirm(Display.getCurrent().getActiveShell(),
                Messages.DIALOG_RENAME_IMPLEMENTED_CLASS_TITLE,
                Messages.DIALOG_RENAME_IMPLEMENTED_CLASS_MESSAGE) == false) {
            return false;
        }
    }
    return execute(FactoryRenameOperation.getRenameOperation(getTarget(), newName),
            Messages.DIALOG_RENAME_CLASS_PROBLEM_TITLE);
}

From source file:com.testify.ecfeed.ui.modelif.MethodInterface.java

License:Open Source License

public boolean generateTestSuite() {
    TestSuiteGenerationSupport testGenerationSupport = new TestSuiteGenerationSupport(getTarget());
    testGenerationSupport.proceed();//from  w  w  w. jav a2s.  c o  m
    if (testGenerationSupport.hasData() == false)
        return false;

    String testSuiteName = testGenerationSupport.getTestSuiteName();
    List<List<ChoiceNode>> testData = testGenerationSupport.getGeneratedData();

    int dataLength = testData.size();
    if (dataLength < 0 && (testGenerationSupport.wasCancelled() == false)) {
        MessageDialog.openInformation(Display.getDefault().getActiveShell(),
                Messages.DIALOG_ADD_TEST_SUITE_PROBLEM_TITLE,
                Messages.DIALOG_EMPTY_TEST_SUITE_GENERATED_MESSAGE);
        return false;
    }
    if (testData.size() > Constants.TEST_SUITE_SIZE_WARNING_LIMIT) {
        if (MessageDialog.openConfirm(Display.getDefault().getActiveShell(),
                Messages.DIALOG_LARGE_TEST_SUITE_GENERATED_TITLE,
                Messages.DIALOG_LARGE_TEST_SUITE_GENERATED_MESSAGE(dataLength)) == false) {
            return false;
        }
    }
    IModelOperation operation = new MethodOperationAddTestSuite(getTarget(), testSuiteName, testData,
            fAdapterProvider);
    return execute(operation, Messages.DIALOG_ADD_TEST_SUITE_PROBLEM_TITLE);
}

From source file:com.tsqm.plugin.preferences.MetricsPreferencePage.java

License:Open Source License

@Override
protected void contributeButtons(Composite parent) {
    ((GridLayout) parent.getLayout()).numColumns += 1;
    super.contributeButtons(parent);
    /**/*ww  w. j a  v a  2s  .  co m*/
     * Button clearCache = new Button(parent,SWT.PUSH); clearCache.setText("Clear Cache"); clearCache.addSelectionListener(new SelectionListener() {
     * 
     * public void widgetSelected(SelectionEvent e) { if (MessageDialog.openConfirm(getShell(), "Clear Cache", "This will remove all stored metrics and force recalculation.\nAre you sure?" )) Cache.singleton.clear(); }
     * 
     * public void widgetDefaultSelected(SelectionEvent e) { } });
     */
    Button eraseMarkers = new Button(parent, SWT.PUSH);
    eraseMarkers.setText("Erase All Warnings");
    eraseMarkers.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            if (MessageDialog.openConfirm(getShell(), "Erase warnings",
                    "This will remove all out of range warnings.\nRecalculation is needed to get them back.\nAre you sure?")) {
                try {
                    ResourcesPlugin.getWorkspace().getRoot().deleteMarkers(
                            "net.sourceforge.metrics.outofrangemarker", true, IResource.DEPTH_INFINITE);
                } catch (CoreException x) {
                    System.out.println("Could not delete markers " + x.toString());
                }
            }
        }

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

From source file:com.tsqm.plugin.preferences.RangePage.java

License:Open Source License

@Override
protected void performDefaults() {
    if (MessageDialog.openConfirm(getShell(), "Please Confirm",
            "Resets all values to those specified in manifests.\nCancel will not undo this.\nAre you Sure?")) {
        TableItem[] items = tv.getTable().getItems();
        if (items != null) {
            for (TableItem item : items) {
                MetricDescriptor md = (MetricDescriptor) item.getData();
                if (md != null) {
                    md.resetToDefaults();
                }/*from w w w. j a v  a2s .  c o m*/
            }
        }
        tv.getTable().removeAll();
        populateTable();
    }
    super.performDefaults();
}