Search in sources :

Example 56 with MessageDialogWithToggle

use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project pentaho-kettle by pentaho.

the class Spoon method saveToRepositoryConfirmed.

public boolean saveToRepositoryConfirmed(EngineMetaInterface meta) throws KettleException {
    if (!Utils.isEmpty(meta.getName()) && rep != null) {
        ObjectId existingId = null;
        if (meta instanceof TransMeta) {
            existingId = rep.getTransformationID(meta.getName(), meta.getRepositoryDirectory());
        }
        if (meta instanceof JobMeta) {
            existingId = rep.getJobId(meta.getName(), meta.getRepositoryDirectory());
        }
        boolean saved = false;
        if (meta.getObjectId() == null) {
            meta.setObjectId(existingId);
        }
        try {
            shell.setCursor(cursor_hourglass);
            // created and or modified...
            if (meta.getCreatedDate() == null) {
                meta.setCreatedDate(new Date());
                if (capabilities.supportsUsers()) {
                    meta.setCreatedUser(rep.getUserInfo().getLogin());
                }
            }
            // Keep info on who & when this transformation was
            // changed...
            meta.setModifiedDate(new Date());
            if (capabilities.supportsUsers()) {
                meta.setModifiedUser(rep.getUserInfo().getLogin());
            }
            boolean versioningEnabled = true;
            boolean versionCommentsEnabled = true;
            String fullPath = getJobTransfFullPath(meta);
            RepositorySecurityProvider repositorySecurityProvider = rep != null && rep.getSecurityProvider() != null ? rep.getSecurityProvider() : null;
            if (repositorySecurityProvider != null && fullPath != null) {
                versioningEnabled = repositorySecurityProvider.isVersioningEnabled(fullPath);
                versionCommentsEnabled = repositorySecurityProvider.allowsVersionComments(fullPath);
            }
            // Finally before saving, ask for a version comment (if
            // applicable)
            // 
            String versionComment = null;
            boolean versionOk;
            if (!versioningEnabled || !versionCommentsEnabled) {
                versionOk = true;
                versionComment = "";
            } else {
                versionOk = false;
            }
            while (!versionOk) {
                versionComment = RepositorySecurityUI.getVersionComment(shell, rep, meta.getName(), fullPath, false);
                // if the version comment is null, the user hit cancel, exit.
                if (rep != null && rep.getSecurityProvider() != null && rep.getSecurityProvider().allowsVersionComments(fullPath) && versionComment == null) {
                    return false;
                }
                if (Utils.isEmpty(versionComment) && rep.getSecurityProvider().isVersioningEnabled(fullPath) && rep.getSecurityProvider().isVersionCommentMandatory()) {
                    if (!RepositorySecurityUI.showVersionCommentMandatoryDialog(shell)) {
                        // no, I don't want to enter a
                        return false;
                    // version comment and yes,
                    // it's mandatory.
                    }
                } else {
                    versionOk = true;
                }
            }
            if (versionOk) {
                SaveProgressDialog spd = new SaveProgressDialog(shell, rep, meta, versionComment);
                if (spd.open()) {
                    saved = true;
                    if (!props.getSaveConfirmation()) {
                        MessageDialogWithToggle md = new MessageDialogWithToggle(shell, BaseMessages.getString(PKG, "Spoon.Message.Warning.SaveOK"), null, BaseMessages.getString(PKG, "Spoon.Message.Warning.TransformationWasStored"), MessageDialog.QUESTION, new String[] { BaseMessages.getString(PKG, "Spoon.Message.Warning.OK") }, 0, BaseMessages.getString(PKG, "Spoon.Message.Warning.NotShowThisMessage"), props.getSaveConfirmation());
                        MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
                        md.open();
                        props.setSaveConfirmation(md.getToggleState());
                    }
                    // Handle last opened files...
                    props.addLastFile(meta.getFileType(), meta.getName(), meta.getRepositoryDirectory().getPath(), true, getRepositoryName(), getUsername(), null, null);
                    saveSettings();
                    addMenuLast();
                    setShellText();
                }
            }
        } finally {
            shell.setCursor(null);
        }
        return saved;
    } else {
        MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
        // "There is no repository connection available."
        mb.setMessage(BaseMessages.getString(PKG, "Spoon.Dialog.NoRepositoryConnection.Message"));
        // "No repository available."
        mb.setText(BaseMessages.getString(PKG, "Spoon.Dialog.NoRepositoryConnection.Title"));
        mb.open();
    }
    return false;
}
Also used : RepositorySecurityProvider(org.pentaho.di.repository.RepositorySecurityProvider) JobMeta(org.pentaho.di.job.JobMeta) SaveProgressDialog(org.pentaho.di.ui.spoon.dialog.SaveProgressDialog) ObjectId(org.pentaho.di.repository.ObjectId) TransMeta(org.pentaho.di.trans.TransMeta) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) Date(java.util.Date) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 57 with MessageDialogWithToggle

use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project pentaho-kettle by pentaho.

the class Spoon method verifyCopyDistribute.

public void verifyCopyDistribute(TransMeta transMeta, StepMeta fr) {
    List<StepMeta> nextSteps = transMeta.findNextSteps(fr);
    int nrNextSteps = nextSteps.size();
    // message
    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();
    }
}
Also used : MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) RowDistributionInterface(org.pentaho.di.trans.step.RowDistributionInterface) StepMeta(org.pentaho.di.trans.step.StepMeta) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 58 with MessageDialogWithToggle

use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project pentaho-kettle by pentaho.

the class MergeRowsDialog method ok.

private void ok() {
    if (Utils.isEmpty(wStepname.getText())) {
        return;
    }
    List<StreamInterface> infoStreams = input.getStepIOMeta().getInfoStreams();
    infoStreams.get(0).setStepMeta(transMeta.findStep(wReference.getText()));
    infoStreams.get(1).setStepMeta(transMeta.findStep(wCompare.getText()));
    input.setFlagField(wFlagfield.getText());
    int nrKeys = wKeys.nrNonEmpty();
    int nrValues = wValues.nrNonEmpty();
    input.allocate(nrKeys, nrValues);
    // CHECKSTYLE:Indentation:OFF
    for (int i = 0; i < nrKeys; i++) {
        TableItem item = wKeys.getNonEmpty(i);
        input.getKeyFields()[i] = item.getText(1);
    }
    // CHECKSTYLE:Indentation:OFF
    for (int i = 0; i < nrValues; i++) {
        TableItem item = wValues.getNonEmpty(i);
        input.getValueFields()[i] = item.getText(1);
    }
    // return value
    stepname = wStepname.getText();
    // PDI-13509 Fix
    if (nrKeys > 0 && "Y".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y"))) {
        MessageDialogWithToggle md = new MessageDialogWithToggle(shell, BaseMessages.getString(PKG, "MergeRowsDialog.MergeRowsWarningDialog.DialogTitle"), null, BaseMessages.getString(PKG, "MergeRowsDialog.MergeRowsWarningDialog.DialogMessage", Const.CR) + Const.CR, MessageDialog.WARNING, new String[] { BaseMessages.getString(PKG, "MergeRowsDialog.MergeRowsWarningDialog.Option1") }, 0, BaseMessages.getString(PKG, "MergeRowsDialog.MergeRowsWarningDialog.Option2"), "N".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y")));
        MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
        md.open();
        props.setCustomParameter(STRING_SORT_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y");
        props.saveProps();
    }
    dispose();
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) StreamInterface(org.pentaho.di.trans.step.errorhandling.StreamInterface)

Example 59 with MessageDialogWithToggle

use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project pentaho-kettle by pentaho.

the class MultiMergeJoinDialog method ok.

private void ok() {
    if (Utils.isEmpty(wStepname.getText())) {
        return;
    }
    getMeta(joinMeta);
    // Show a warning (optional)
    if ("Y".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y"))) {
        MessageDialogWithToggle md = new MessageDialogWithToggle(shell, BaseMessages.getString(PKG, "MultiMergeJoinDialog.InputNeedSort.DialogTitle"), null, BaseMessages.getString(PKG, "MultiMergeJoinDialog.InputNeedSort.DialogMessage", Const.CR) + Const.CR, MessageDialog.WARNING, new String[] { BaseMessages.getString(PKG, "MultiMergeJoinDialog.InputNeedSort.Option1") }, 0, BaseMessages.getString(PKG, "MultiMergeJoinDialog.InputNeedSort.Option2"), "N".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y")));
        MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
        md.open();
        props.setCustomParameter(STRING_SORT_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y");
        props.saveProps();
    }
    // return value
    stepname = wStepname.getText();
    dispose();
}
Also used : MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle)

Example 60 with MessageDialogWithToggle

use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project pentaho-kettle by pentaho.

the class PaloCellInputDialog method showPaloLibWarningDialog.

public static void showPaloLibWarningDialog(Shell shell) {
    PropsUI props = PropsUI.getInstance();
    if ("Y".equalsIgnoreCase(props.getCustomParameter(STRING_PALO_LIB_WARNING_PARAMETER, "Y"))) {
        MessageDialogWithToggle md = new MessageDialogWithToggle(shell, BaseMessages.getString(PKG, "PaloCellInputDialog.PaloLibWarningDialog.DialogTitle"), null, BaseMessages.getString(PKG, "PaloCellInputDialog.PaloLibWarningDialog.DialogMessage", Const.CR) + Const.CR, MessageDialog.WARNING, new String[] { BaseMessages.getString(PKG, "PaloCellInputDialog.PaloLibWarningDialog.Option1") }, 0, BaseMessages.getString(PKG, "PaloCellInputDialog.PaloLibWarningDialog.Option2"), "N".equalsIgnoreCase(props.getCustomParameter(STRING_PALO_LIB_WARNING_PARAMETER, "Y")));
        MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
        md.open();
        props.setCustomParameter(STRING_PALO_LIB_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y");
        props.saveProps();
    }
}
Also used : MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) PropsUI(org.pentaho.di.ui.core.PropsUI)

Aggregations

MessageDialogWithToggle (org.eclipse.jface.dialogs.MessageDialogWithToggle)65 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)16 TableItem (org.eclipse.swt.widgets.TableItem)8 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)6 Point (org.pentaho.di.core.gui.Point)6 ArrayList (java.util.ArrayList)5 Shell (org.eclipse.swt.widgets.Shell)5 IOException (java.io.IOException)4 IProject (org.eclipse.core.resources.IProject)4 File (java.io.File)3 Display (org.eclipse.swt.widgets.Display)3 MessageBox (org.eclipse.swt.widgets.MessageBox)3 BackingStoreException (org.osgi.service.prefs.BackingStoreException)3 QueryEditorPart (com.cubrid.common.ui.query.editor.QueryEditorPart)2 JobFamily (com.cubrid.common.ui.spi.progress.JobFamily)2 List (java.util.List)2 Job (org.eclipse.core.runtime.jobs.Job)2 IPerspectiveDescriptor (org.eclipse.ui.IPerspectiveDescriptor)2 ConnectionContainer (org.knime.core.node.workflow.ConnectionContainer)2 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)2