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

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

Introduction

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

Prototype

int WARNING

To view the source code for org.eclipse.jface.dialogs MessageDialog WARNING.

Click Source Link

Document

Constant for the warning image, or a simple dialog with the warning image and a single OK button (value 4).

Usage

From source file:org.pentaho.big.data.plugins.common.ui.NamedClusterDialogImpl.java

License:Apache License

public void ok() {
    result = namedCluster.getName();/*from   w  w  w .j  a  v a 2s  . c om*/
    if (StringUtils.isBlank(result)) {
        MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
        mb.setText(BaseMessages.getString(PKG, "NamedClusterDialog.Error"));
        mb.setMessage(BaseMessages.getString(PKG, "NamedClusterDialog.ClusterNameMissing"));
        mb.open();
        return;
    } else if (newClusterCheck || !originalNamedCluster.getName().equals(result)) {
        // check that the getName does not already exist
        try {
            NamedCluster fetched = namedClusterService.read(result, Spoon.getInstance().getMetaStore());
            if (fetched != null) {

                String title = BaseMessages.getString(PKG, "NamedClusterDialog.ClusterNameExists.Title");
                String message = BaseMessages.getString(PKG, "NamedClusterDialog.ClusterNameExists", result);
                String replaceButton = BaseMessages.getString(PKG,
                        "NamedClusterDialog.ClusterNameExists.Replace");
                String doNotReplaceButton = BaseMessages.getString(PKG,
                        "NamedClusterDialog.ClusterNameExists.DoNotReplace");
                MessageDialog dialog = new MessageDialog(shell, title, null, message, MessageDialog.WARNING,
                        new String[] { replaceButton, doNotReplaceButton }, 0);

                // there already exists a cluster with the new getName, ask the user
                if (RESULT_NO == dialog.open()) {
                    // do not exist dialog
                    return;
                }
            }
        } catch (MetaStoreException ignored) {
            // the lookup failed, the cluster does not exist, move on to dispose
        }
    }
    dispose();
}

From source file:org.pentaho.di.trans.steps.hbaseinput.HBaseInputDialog.java

License:Apache License

protected void ok() {
    if (Const.isEmpty(m_stepnameText.getText())) {
        MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
        mb.setText(Messages.getString("System.StepJobEntryNameMissing.Title"));
        mb.setMessage(Messages.getString("System.JobEntryNameMissing.Msg"));
        mb.open();/*from  ww  w .  j av  a  2 s  .  com*/
        return;
    }
    if (namedClusterWidget.getSelectedNamedCluster() == null) {
        MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
        mb.setText(Messages.getString("Dialog.Error"));
        mb.setMessage(Messages.getString("HBaseInputDialog.NamedClusterNotSelected.Msg"));
        mb.open();
        return;
    } else {
        NamedCluster nc = namedClusterWidget.getSelectedNamedCluster();
        if (StringUtils.isEmpty(nc.getZooKeeperHost())) {
            MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
            mb.setText(Messages.getString("Dialog.Error"));
            mb.setMessage(Messages.getString("HBaseInputDialog.NamedClusterMissingValues.Msg"));
            mb.open();
            return;
        }
    }

    stepname = m_stepnameText.getText();

    updateMetaConnectionDetails(m_currentMeta);

    m_currentMeta.setKeyStartValue(m_keyStartText.getText());
    m_currentMeta.setKeyStopValue(m_keyStopText.getText());
    m_currentMeta.setScannerCacheSize(m_scanCacheText.getText());
    m_currentMeta.setMatchAnyFilter(m_matchAnyBut.getSelection());

    int numNonEmpty = m_fieldsView.nrNonEmpty();
    if (numNonEmpty > 0) {
        List<HBaseValueMeta> outputFields = new ArrayList<HBaseValueMeta>();

        for (int i = 0; i < numNonEmpty; i++) {
            TableItem item = m_fieldsView.getNonEmpty(i);
            String alias = item.getText(1).trim();
            String isKey = item.getText(2).trim();
            String family = item.getText(3).trim();
            String column = item.getText(4).trim();
            String type = item.getText(5).trim();
            String format = item.getText(6).trim();

            HBaseValueMeta vm = new HBaseValueMeta(
                    family + HBaseValueMeta.SEPARATOR + column + HBaseValueMeta.SEPARATOR + alias,
                    ValueMeta.getType(type), -1, -1);

            vm.setTableName(m_mappedTableNamesCombo.getText());
            vm.setMappingName(m_mappingNamesCombo.getText());
            vm.setKey(isKey.equalsIgnoreCase("Y"));
            String indexItems = m_indexedLookup.get(alias);
            if (indexItems != null) {
                Object[] values = HBaseValueMeta.stringIndexListToObjects(indexItems);
                vm.setIndex(values);
                vm.setStorageType(ValueMetaInterface.STORAGE_TYPE_INDEXED);
            }
            vm.setConversionMask(format);

            outputFields.add(vm);
        }
        m_currentMeta.setOutputFields(outputFields);
    } else {
        m_currentMeta.setOutputFields(null); // output everything
    }

    numNonEmpty = m_filtersView.nrNonEmpty();
    if (numNonEmpty > 0) {
        List<ColumnFilter> filters = new ArrayList<ColumnFilter>();

        for (int i = 0; i < m_filtersView.nrNonEmpty(); i++) {
            TableItem item = m_filtersView.getNonEmpty(i);
            String alias = item.getText(1).trim();
            String type = item.getText(2).trim();
            String operator = item.getText(3).trim();
            String comparison = item.getText(4).trim();
            String signed = item.getText(6).trim();
            String format = item.getText(5).trim();
            ColumnFilter f = new ColumnFilter(alias);
            f.setFieldType(type);
            f.setComparisonOperator(ColumnFilter.stringToOpp(operator));
            f.setConstant(comparison);
            f.setSignedComparison(signed.equalsIgnoreCase("Y"));
            f.setFormat(format);
            filters.add(f);
        }

        m_currentMeta.setColumnFilters(filters);
    } else {
        m_currentMeta.setColumnFilters(null);
    }

    if (m_storeMappingInStepMetaData.getSelection()) {
        if (Const.isEmpty(m_mappingNamesCombo.getText())) {
            List<String> problems = new ArrayList<String>();

            Mapping toSet = m_mappingEditor.getMapping(false, problems);
            if (problems.size() > 0) {
                StringBuffer p = new StringBuffer();
                for (String s : problems) {
                    p.append(s).append("\n");
                }
                MessageDialog md = new MessageDialog(shell,
                        BaseMessages
                                .getString(
                                        HBaseInputMeta.PKG, "HBaseInputDialog.Error.IssuesWithMapping.Title"),
                        null,
                        BaseMessages.getString(HBaseInputMeta.PKG,
                                "HBaseInputDialog.Error.IssuesWithMapping") + ":\n\n" + p.toString(),
                        MessageDialog.WARNING,
                        new String[] {
                                BaseMessages.getString(HBaseInputMeta.PKG,
                                        "HBaseInputDialog.Error.IssuesWithMapping.ButtonOK"),
                                BaseMessages.getString(HBaseInputMeta.PKG,
                                        "HBaseInputDialog.Error.IssuesWithMapping.ButtonCancel") },
                        0);
                MessageDialog.setDefaultImage(GUIResource.getInstance().getImageSpoon());
                int idx = md.open() & 0xFF;
                if (idx == 1 || idx == 255 /* 255 = escape pressed */ ) {
                    return; // Cancel
                }
            }
            m_currentMeta.setMapping(toSet);
        } else {
            MappingAdmin admin = new MappingAdmin();
            try {
                HBaseConnection connection = getHBaseConnection();
                admin.setConnection(connection);
                Mapping current = null;

                current = admin.getMapping(transMeta.environmentSubstitute(m_mappedTableNamesCombo.getText()),
                        transMeta.environmentSubstitute(m_mappingNamesCombo.getText()));

                m_currentMeta.setMapping(current);
                m_currentMeta.setSourceMappingName("");
            } catch (Exception e) {
                logError(Messages.getString("HBaseInputDialog.ErrorMessage.UnableToGetMapping") + " \""
                        + transMeta.environmentSubstitute(m_mappedTableNamesCombo.getText() + ","
                                + transMeta.environmentSubstitute(m_mappingNamesCombo.getText()) + "\""),
                        e);
                new ErrorDialog(shell, Messages.getString("HBaseInputDialog.ErrorMessage.UnableToGetMapping"),
                        Messages.getString("HBaseInputDialog.ErrorMessage.UnableToGetMapping") + " \""
                                + transMeta.environmentSubstitute(m_mappedTableNamesCombo.getText() + ","
                                        + transMeta.environmentSubstitute(m_mappingNamesCombo.getText())
                                        + "\""),
                        e);
            }
        }
    } else {
        // we're going to use a mapping stored in HBase - null out any stored
        // mapping
        m_currentMeta.setMapping(null);
    }

    if (!m_originalMeta.equals(m_currentMeta)) {
        m_currentMeta.setChanged();
        changed = m_currentMeta.hasChanged();
    }

    dispose();
}

From source file:org.pentaho.di.trans.steps.hbaseoutput.HBaseOutputDialog.java

License:Apache License

protected void ok() {
    if (Const.isEmpty(m_stepnameText.getText())) {
        MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
        mb.setText(BaseMessages.getString(HBaseOutputMeta.PKG, "System.StepJobEntryNameMissing.Title"));
        mb.setMessage(BaseMessages.getString(HBaseOutputMeta.PKG, "System.JobEntryNameMissing.Msg"));
        mb.open();/* w  w  w . jav a 2 s  .  c om*/
        return;
    }
    if (namedClusterWidget.getSelectedNamedCluster() == null) {
        MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
        mb.setText(BaseMessages.getString(HBaseOutputMeta.PKG, "Dialog.Error"));
        mb.setMessage(
                BaseMessages.getString(HBaseOutputMeta.PKG, "HBaseOutputDialog.NamedClusterNotSelected.Msg"));
        mb.open();
        return;
    } else {
        NamedCluster nc = namedClusterWidget.getSelectedNamedCluster();
        if (StringUtils.isEmpty(nc.getZooKeeperHost())) {
            MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
            mb.setText(BaseMessages.getString(HBaseOutputMeta.PKG, "Dialog.Error"));
            mb.setMessage(BaseMessages.getString(HBaseOutputMeta.PKG,
                    "HBaseOutputDialog.NamedClusterMissingValues.Msg"));
            mb.open();
            return;
        }
    }

    stepname = m_stepnameText.getText();

    updateMetaConnectionDetails(m_currentMeta);

    if (m_storeMappingInStepMetaData.getSelection()) {
        if (Const.isEmpty(m_mappingNamesCombo.getText())) {
            List<String> problems = new ArrayList<String>();
            Mapping toSet = m_mappingEditor.getMapping(false, problems);
            if (problems.size() > 0) {
                StringBuffer p = new StringBuffer();
                for (String s : problems) {
                    p.append(s).append("\n");
                }
                MessageDialog md = new MessageDialog(shell, BaseMessages
                        .getString(HBaseOutputMeta.PKG, "HBaseOutputDialog.Error.IssuesWithMapping.Title"),
                        null,
                        BaseMessages.getString(HBaseOutputMeta.PKG,
                                "HBaseOutputDialog.Error.IssuesWithMapping") + ":\n\n" + p.toString(),
                        MessageDialog.WARNING,
                        new String[] {
                                BaseMessages.getString(HBaseOutputMeta.PKG,
                                        "HBaseOutputDialog.Error.IssuesWithMapping.ButtonOK"),
                                BaseMessages.getString(HBaseOutputMeta.PKG,
                                        "HBaseOutputDialog.Error.IssuesWithMapping.ButtonCancel") },
                        0);
                MessageDialog.setDefaultImage(GUIResource.getInstance().getImageSpoon());
                int idx = md.open() & 0xFF;
                if (idx == 1 || idx == 255 /* 255 = escape pressed */ ) {
                    return; // Cancel
                }
            }
            m_currentMeta.setMapping(toSet);
        } else {
            MappingAdmin admin = new MappingAdmin();
            try {
                HBaseConnection connection = getHBaseConnection();
                admin.setConnection(connection);
                Mapping current = null;

                current = admin.getMapping(transMeta.environmentSubstitute(m_mappedTableNamesCombo.getText()),
                        transMeta.environmentSubstitute(m_mappingNamesCombo.getText()));

                m_currentMeta.setMapping(current);
                m_currentMeta.setTargetMappingName("");
            } catch (Exception e) {
                logError(Messages.getString("HBaseOutputDialog.ErrorMessage.UnableToGetMapping") + " \""
                        + transMeta.environmentSubstitute(m_mappedTableNamesCombo.getText() + ","
                                + transMeta.environmentSubstitute(m_mappingNamesCombo.getText()) + "\""),
                        e);
                new ErrorDialog(shell, Messages.getString("HBaseOutputDialog.ErrorMessage.UnableToGetMapping"),
                        Messages.getString("HBaseOutputDialog.ErrorMessage.UnableToGetMapping") + " \""
                                + transMeta.environmentSubstitute(m_mappedTableNamesCombo.getText() + ","
                                        + transMeta.environmentSubstitute(m_mappingNamesCombo.getText())
                                        + "\""),
                        e);
            }
        }
    } else {
        // we're going to use a mapping stored in HBase - null out any stored
        // mapping
        m_currentMeta.setMapping(null);
    }

    if (!m_originalMeta.equals(m_currentMeta)) {
        m_currentMeta.setChanged();
        changed = m_currentMeta.hasChanged();
    }

    dispose();
}

From source file:org.pentaho.di.trans.steps.hbaserowdecoder.HBaseRowDecoderDialog.java

License:Apache License

protected void ok() {
    if (Const.isEmpty(m_stepnameText.getText())) {
        return;//from  w  w  w . j  av a2 s  .  co m
    }

    stepname = m_stepnameText.getText();

    m_currentMeta.setIncomingKeyField(m_incomingKeyCombo.getText());
    m_currentMeta.setIncomingResultField(m_incomingResultCombo.getText());
    List<String> problems = new ArrayList<String>();
    Mapping mapping = m_mappingEditor.getMapping(false, problems);
    if (problems.size() > 0) {
        StringBuffer p = new StringBuffer();
        for (String s : problems) {
            p.append(s).append("\n");
        }
        MessageDialog md = new MessageDialog(shell,
                BaseMessages.getString(PKG, "HBaseRowDecoderDialog.Error.IssuesWithMapping.Title"), null,
                BaseMessages.getString(PKG,
                        "HBaseRowDecoderDialog.Error.IssuesWithMapping") + ":\n\n" + p.toString(),
                MessageDialog.WARNING,
                new String[] {
                        BaseMessages.getString(PKG, "HBaseRowDecoderDialog.Error.IssuesWithMapping.ButtonOK"),
                        BaseMessages.getString(PKG,
                                "HBaseRowDecoderDialog.Error.IssuesWithMapping.ButtonCancel") },
                0);
        MessageDialog.setDefaultImage(GUIResource.getInstance().getImageSpoon());
        int idx = md.open() & 0xFF;
        if (idx == 1 || idx == 255 /* 255 = escape pressed */ ) {
            return; // Cancel
        }
    }
    if (mapping != null) {
        m_currentMeta.setMapping(mapping);
    }

    if (!m_originalMeta.equals(m_currentMeta)) {
        m_currentMeta.setChanged();
        changed = m_currentMeta.hasChanged();
    }

    dispose();
}

From source file:org.pentaho.di.ui.core.gui.GUIResource.java

License:Apache License

/**
 * Generic popup with a toggle option//  w  w  w .jav  a  2 s . c o  m
 *
 * @param dialogTitle
 * @param image
 * @param message
 * @param dialogImageType
 * @param buttonLabels
 * @param defaultIndex
 * @param toggleMessage
 * @param toggleState
 * @return
 */
public Object[] messageDialogWithToggle(Shell shell, String dialogTitle, Image image, String message,
        int dialogImageType, String[] buttonLabels, int defaultIndex, String toggleMessage,
        boolean toggleState) {
    int imageType = 0;
    switch (dialogImageType) {
    case Const.WARNING:
        imageType = MessageDialog.WARNING;
        break;
    default:
        break;
    }

    MessageDialogWithToggle md = new MessageDialogWithToggle(shell, dialogTitle, image, message, imageType,
            buttonLabels, defaultIndex, toggleMessage, toggleState);
    int idx = md.open();
    return new Object[] { Integer.valueOf(idx), Boolean.valueOf(md.getToggleState()) };
}

From source file:org.pentaho.di.ui.core.namedcluster.dialog.NamedClusterDialog.java

License:Apache License

public void ok() {
    result = namedCluster.getName();//from  w w  w  .  ja  va2  s .c o m
    if (StringUtils.isBlank(result)) {
        MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
        mb.setText(BaseMessages.getString(PKG, "NamedClusterDialog.Error"));
        mb.setMessage(BaseMessages.getString(PKG, "NamedClusterDialog.ClusterNameMissing"));
        mb.open();
        return;
    } else if (newClusterCheck || !originalNamedCluster.getName().equals(result)) {
        // check that the name does not already exist
        try {
            NamedCluster fetched = NamedClusterUIHelper.getNamedCluster(result);
            if (fetched != null) {

                String title = BaseMessages.getString(PKG, "NamedClusterDialog.ClusterNameExists.Title");
                String message = BaseMessages.getString(PKG, "NamedClusterDialog.ClusterNameExists", result);
                String replaceButton = BaseMessages.getString(PKG,
                        "NamedClusterDialog.ClusterNameExists.Replace");
                String doNotReplaceButton = BaseMessages.getString(PKG,
                        "NamedClusterDialog.ClusterNameExists.DoNotReplace");
                MessageDialog dialog = new MessageDialog(shell, title, null, message, MessageDialog.WARNING,
                        new String[] { replaceButton, doNotReplaceButton }, 0);

                // there already exists a cluster with the new name, ask the user
                if (RESULT_NO == dialog.open()) {
                    // do not exist dialog
                    return;
                }
            }
        } catch (MetaStoreException ignored) {
            // the lookup failed, the cluster does not exist, move on to dispose
        }
    }
    dispose();
}

From source file:org.pentaho.di.ui.spoon.job.JobGraph.java

License:Apache License

/**
 * Go from serial to parallel to serial execution
 */// w w  w.j  a va  2 s .  c om
public void editEntryParallel() {

    JobEntryCopy je = getJobEntry();
    JobEntryCopy jeOld = (JobEntryCopy) je.clone_deep();

    je.setLaunchingInParallel(!je.isLaunchingInParallel());
    JobEntryCopy jeNew = (JobEntryCopy) je.clone_deep();

    spoon.addUndoChange(jobMeta, new JobEntryCopy[] { jeOld }, new JobEntryCopy[] { jeNew },
            new int[] { jobMeta.indexOfJobEntry(jeNew) });
    jobMeta.setChanged();

    if (getJobEntry().isLaunchingInParallel()) {
        // Show a warning (optional)
        //
        if ("Y".equalsIgnoreCase(spoon.props.getCustomParameter(STRING_PARALLEL_WARNING_PARAMETER, "Y"))) {
            MessageDialogWithToggle md = new MessageDialogWithToggle(shell,
                    BaseMessages.getString(PKG, "JobGraph.ParallelJobEntriesWarning.DialogTitle"), null,
                    BaseMessages.getString(PKG, "JobGraph.ParallelJobEntriesWarning.DialogMessage", Const.CR)
                            + Const.CR,
                    MessageDialog.WARNING,
                    new String[] { BaseMessages.getString(PKG, "JobGraph.ParallelJobEntriesWarning.Option1") },
                    0, BaseMessages.getString(PKG, "JobGraph.ParallelJobEntriesWarning.Option2"),
                    "N".equalsIgnoreCase(
                            spoon.props.getCustomParameter(STRING_PARALLEL_WARNING_PARAMETER, "Y")));
            MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
            md.open();
            spoon.props.setCustomParameter(STRING_PARALLEL_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y");
            spoon.props.saveProps();
        }
    }
    spoon.refreshGraph();

}

From source file:org.pentaho.di.ui.spoon.Spoon.java

License:Apache License

public void verifyCopyDistribute(TransMeta transMeta, StepMeta fr) {
    List<StepMeta> nextSteps = transMeta.findNextSteps(fr);
    int nrNextSteps = nextSteps.size();

    // don't show it for 3 or more hops, by then you should have had the
    // message//from   w w w. j av  a 2s . c o m
    if (nrNextSteps == 2) {
        boolean distributes = fr.getStepMetaInterface().excludeFromCopyDistributeVerification();
        boolean customDistribution = false;

        if (props.showCopyOrDistributeWarning()
                && !fr.getStepMetaInterface().excludeFromCopyDistributeVerification()) {
            MessageDialogWithToggle md = new MessageDialogWithToggle(shell,
                    BaseMessages.getString(PKG, "System.Warning"), null,
                    BaseMessages.getString(PKG, "Spoon.Dialog.CopyOrDistribute.Message", fr.getName(),
                            Integer.toString(nrNextSteps)),
                    MessageDialog.WARNING, getRowDistributionLabels(), 0,
                    BaseMessages.getString(PKG, "Spoon.Message.Warning.NotShowWarning"),
                    !props.showCopyOrDistributeWarning());
            MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
            int idx = md.open();
            props.setShowCopyOrDistributeWarning(!md.getToggleState());
            props.saveProps();

            distributes = idx == Spoon.MESSAGE_DIALOG_WITH_TOGGLE_YES_BUTTON_ID;
            customDistribution = idx == Spoon.MESSAGE_DIALOG_WITH_TOGGLE_CUSTOM_DISTRIBUTION_BUTTON_ID;
        }

        if (distributes) {
            fr.setDistributes(true);
            fr.setRowDistribution(null);
        } else if (customDistribution) {

            RowDistributionInterface rowDistribution = getActiveTransGraph()
                    .askUserForCustomDistributionMethod();

            fr.setDistributes(true);
            fr.setRowDistribution(rowDistribution);
        } else {
            fr.setDistributes(false);
            fr.setDistributes(false);
        }

        refreshTree();
        refreshGraph();
    }
}

From source file:org.pentaho.di.ui.spoon.Spoon.java

License:Apache License

public boolean quitFile(boolean canCancel) throws KettleException {
    if (log.isDetailed()) {
        log.logDetailed(BaseMessages.getString(PKG, "Spoon.Log.QuitApplication")); // "Quit application."
    }/*from  w  w  w.  ja v a  2 s . c o  m*/

    boolean exit = true;

    saveSettings();

    if (props.showExitWarning() && canCancel) {
        // Display message: are you sure you want to exit?
        //
        MessageDialogWithToggle md = new MessageDialogWithToggle(shell,
                BaseMessages.getString(PKG, "System.Warning"), // "Warning!"
                null, BaseMessages.getString(PKG, "Spoon.Message.Warning.PromptExit"), MessageDialog.WARNING,
                new String[] {
                        // "Yes",
                        BaseMessages.getString(PKG, "Spoon.Message.Warning.Yes"),
                        // "No"
                        BaseMessages.getString(PKG, "Spoon.Message.Warning.No") },
                1,
                // "Please, don't show this warning anymore."
                BaseMessages.getString(PKG, "Spoon.Message.Warning.NotShowWarning"), !props.showExitWarning());
        MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
        int idx = md.open();
        props.setExitWarningShown(!md.getToggleState());
        props.saveProps();
        if ((idx & 0xFF) == 1) {
            return false; // No selected: don't exit!
        }
    }

    // Check all tabs to see if we can close them...
    //
    List<TabMapEntry> list = delegates.tabs.getTabs();

    for (TabMapEntry mapEntry : list) {
        TabItemInterface itemInterface = mapEntry.getObject();

        if (!itemInterface.canBeClosed()) {
            // Show the tab
            tabfolder.setSelected(mapEntry.getTabItem());

            // Unsaved work that needs to changes to be applied?
            //
            int reply = itemInterface.showChangedWarning();
            if (reply == SWT.YES) {
                exit = itemInterface.applyChanges();
            } else {
                if (reply == SWT.CANCEL) {
                    return false;
                } else { // SWT.NO
                    exit = true;
                }
            }
        }
    }

    if (exit || !canCancel) {
        // we have asked about it all and we're still here. Now close
        // all the tabs, stop the running transformations
        for (TabMapEntry mapEntry : list) {
            if (!mapEntry.getObject().canBeClosed()) {
                // Unsaved transformation?
                //
                if (mapEntry.getObject() instanceof TransGraph) {
                    TransMeta transMeta = (TransMeta) mapEntry.getObject().getManagedObject();
                    if (transMeta.hasChanged()) {
                        delegates.tabs.removeTab(mapEntry);
                    }
                }
                // A running transformation?
                //
                if (mapEntry.getObject() instanceof TransGraph) {
                    TransGraph transGraph = (TransGraph) mapEntry.getObject();
                    if (transGraph.isRunning()) {
                        transGraph.stop();
                        delegates.tabs.removeTab(mapEntry);
                    }
                }
            }
        }
    }

    // and now we call the listeners

    try {
        lifecycleSupport.onExit(this);
    } catch (LifecycleException e) {
        MessageBox box = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
        box.setMessage(e.getMessage());
        box.open();
    }

    if (exit) {
        // on windows [...].swt.ole.win32.OleClientSite.OnInPlaceDeactivate can
        // cause the focus to move to an already disposed tab, resulting in a NPE
        // so we first move the focus to somewhere else
        if (this.designTreeToolbar != null && !this.designTreeToolbar.isDisposed()) {
            this.designTreeToolbar.forceFocus();
        }

        close();
    }

    return exit;
}

From source file:org.pentaho.di.ui.trans.step.BaseStepDialog.java

License:Apache License

static MessageDialog getFieldsChoiceDialog(Shell shell, int existingFields, int newFields) {
    MessageDialog messageDialog = new MessageDialog(shell,
            BaseMessages.getString(PKG, "BaseStepDialog.GetFieldsChoice.Title"), // "Warning!"
            null,/*  w w  w  . j a v  a2  s . com*/
            BaseMessages.getString(
                    PKG, "BaseStepDialog.GetFieldsChoice.Message", "" + existingFields, "" + newFields),
            MessageDialog.WARNING,
            new String[] { BaseMessages.getString(PKG, "BaseStepDialog.AddNew"),
                    BaseMessages.getString(PKG, "BaseStepDialog.Add"),
                    BaseMessages.getString(PKG, "BaseStepDialog.ClearAndAdd"),
                    BaseMessages.getString(PKG, "BaseStepDialog.Cancel"), },
            0);
    MessageDialog.setDefaultImage(GUIResource.getInstance().getImageSpoon());
    return messageDialog;
}