Search in sources :

Example 46 with EnterTextDialog

use of org.pentaho.di.ui.core.dialog.EnterTextDialog in project pentaho-kettle by pentaho.

the class XMLInputDialog method preview.

// Preview the data
private void preview() {
    try {
        // Create the XML input step
        XMLInputMeta oneMeta = new XMLInputMeta();
        getInfo(oneMeta);
        // check if the path is given
        if (!checkInputPositionsFilled(oneMeta)) {
            return;
        }
        TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
        EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "XMLInputDialog.NumberRows.DialogTitle"), BaseMessages.getString(PKG, "XMLInputDialog.NumberRows.DialogMessage"));
        int previewSize = numberDialog.open();
        if (previewSize > 0) {
            TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, previewMeta, new String[] { wStepname.getText() }, new int[] { previewSize });
            progressDialog.open();
            if (!progressDialog.isCancelled()) {
                Trans trans = progressDialog.getTrans();
                String loggingText = progressDialog.getLoggingText();
                if (trans.getResult() != null && trans.getResult().getNrErrors() > 0) {
                    EnterTextDialog etd = new EnterTextDialog(shell, BaseMessages.getString(PKG, "System.Dialog.PreviewError.Title"), BaseMessages.getString(PKG, "System.Dialog.PreviewError.Message"), loggingText, true);
                    etd.setReadOnly();
                    etd.open();
                }
                PreviewRowsDialog prd = new PreviewRowsDialog(shell, transMeta, SWT.NONE, wStepname.getText(), progressDialog.getPreviewRowsMeta(wStepname.getText()), progressDialog.getPreviewRows(wStepname.getText()), loggingText);
                prd.open();
            }
        }
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "XMLInputDialog.ErrorPreviewingData.DialogTitle"), BaseMessages.getString(PKG, "XMLInputDialog.ErrorPreviewingData.DialogMessage"), e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) TransPreviewProgressDialog(org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog) TransMeta(org.pentaho.di.trans.TransMeta) EnterTextDialog(org.pentaho.di.ui.core.dialog.EnterTextDialog) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) EnterNumberDialog(org.pentaho.di.ui.core.dialog.EnterNumberDialog) XMLInputMeta(org.pentaho.di.trans.steps.xmlinput.XMLInputMeta) Trans(org.pentaho.di.trans.Trans)

Example 47 with EnterTextDialog

use of org.pentaho.di.ui.core.dialog.EnterTextDialog in project pentaho-kettle by pentaho.

the class Spoon method exportAllXMLFile.

/**
 * Export this job or transformation including all depending resources to a single zip file.
 */
public void exportAllXMLFile() {
    ResourceExportInterface resourceExportInterface = getActiveTransformation();
    if (resourceExportInterface == null) {
        resourceExportInterface = getActiveJob();
    }
    if (resourceExportInterface == null) {
        // nothing to do here, prevent an NPE
        return;
    }
    // 
    try {
        String zipFilename = null;
        while (Utils.isEmpty(zipFilename)) {
            FileDialog dialog = new FileDialog(shell, SWT.SAVE);
            dialog.setText(BaseMessages.getString(PKG, "Spoon.ExportResourceSelectZipFile"));
            dialog.setFilterExtensions(new String[] { "*.zip;*.ZIP", "*" });
            dialog.setFilterNames(new String[] { BaseMessages.getString(PKG, "System.FileType.ZIPFiles"), BaseMessages.getString(PKG, "System.FileType.AllFiles") });
            setFilterPath(dialog);
            if (dialog.open() != null) {
                lastDirOpened = dialog.getFilterPath();
                zipFilename = dialog.getFilterPath() + Const.FILE_SEPARATOR + dialog.getFileName();
                FileObject zipFileObject = KettleVFS.getFileObject(zipFilename);
                if (zipFileObject.exists()) {
                    MessageBox box = new MessageBox(shell, SWT.YES | SWT.NO | SWT.CANCEL);
                    box.setMessage(BaseMessages.getString(PKG, "Spoon.ExportResourceZipFileExists.Message", zipFilename));
                    box.setText(BaseMessages.getString(PKG, "Spoon.ExportResourceZipFileExists.Title"));
                    int answer = box.open();
                    if (answer == SWT.CANCEL) {
                        return;
                    }
                    if (answer == SWT.NO) {
                        zipFilename = null;
                    }
                }
            } else {
                return;
            }
        }
        // Export the resources linked to the currently loaded file...
        // 
        TopLevelResource topLevelResource = ResourceUtil.serializeResourceExportInterface(zipFilename, resourceExportInterface, (VariableSpace) resourceExportInterface, rep, metaStore);
        String message = ResourceUtil.getExplanation(zipFilename, topLevelResource.getResourceName(), resourceExportInterface);
        /*
       * // Add the ZIP file as a repository to the repository list... // RepositoriesMeta repositoriesMeta = new
       * RepositoriesMeta(); repositoriesMeta.readData();
       *
       * KettleFileRepositoryMeta fileRepositoryMeta = new KettleFileRepositoryMeta(
       * KettleFileRepositoryMeta.REPOSITORY_TYPE_ID, "Export " + baseFileName, "Export to file : " + zipFilename,
       * "zip://" + zipFilename + "!"); fileRepositoryMeta.setReadOnly(true); // A ZIP file is read-only int nr = 2;
       * String baseName = fileRepositoryMeta.getName(); while
       * (repositoriesMeta.findRepository(fileRepositoryMeta.getName()) != null) { fileRepositoryMeta.setName(baseName +
       * " " + nr); nr++; }
       *
       * repositoriesMeta.addRepository(fileRepositoryMeta); repositoriesMeta.writeData();
       */
        // Show some information concerning all this work...
        EnterTextDialog enterTextDialog = new EnterTextDialog(shell, BaseMessages.getString(PKG, "Spoon.Dialog.ResourceSerialized"), BaseMessages.getString(PKG, "Spoon.Dialog.ResourceSerializedSuccesfully"), message);
        enterTextDialog.setReadOnly();
        enterTextDialog.open();
    } catch (Exception e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Error"), BaseMessages.getString(PKG, "Spoon.ErrorExportingFile"), e);
    }
}
Also used : TopLevelResource(org.pentaho.di.resource.TopLevelResource) ResourceExportInterface(org.pentaho.di.resource.ResourceExportInterface) EnterTextDialog(org.pentaho.di.ui.core.dialog.EnterTextDialog) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) FileObject(org.apache.commons.vfs2.FileObject) KettlePropertiesFileDialog(org.pentaho.di.ui.core.dialog.KettlePropertiesFileDialog) FileDialog(org.eclipse.swt.widgets.FileDialog) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) SWTException(org.eclipse.swt.SWTException) KettleRowException(org.pentaho.di.core.exception.KettleRowException) FileSystemException(org.apache.commons.vfs2.FileSystemException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) KettleValueException(org.pentaho.di.core.exception.KettleValueException) KettleAuthException(org.pentaho.di.core.exception.KettleAuthException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) LifecycleException(org.pentaho.di.core.lifecycle.LifecycleException) KettleMissingPluginsException(org.pentaho.di.core.exception.KettleMissingPluginsException) KettleFileException(org.pentaho.di.core.exception.KettleFileException) KettleException(org.pentaho.di.core.exception.KettleException) MalformedURLException(java.net.MalformedURLException) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 48 with EnterTextDialog

use of org.pentaho.di.ui.core.dialog.EnterTextDialog in project pentaho-kettle by pentaho.

the class Spoon method exportAllFileRepository.

/**
 * Export this job or transformation including all depending resources to a single ZIP file containing a file
 * repository.
 */
public void exportAllFileRepository() {
    ResourceExportInterface resourceExportInterface = getActiveTransformation();
    if (resourceExportInterface == null) {
        resourceExportInterface = getActiveJob();
    }
    if (resourceExportInterface == null) {
        // nothing to do here, prevent an NPE
        return;
    }
    // 
    try {
        String zipFilename = null;
        while (Utils.isEmpty(zipFilename)) {
            FileDialog dialog = new FileDialog(shell, SWT.SAVE);
            dialog.setText(BaseMessages.getString(PKG, "Spoon.ExportResourceSelectZipFile"));
            dialog.setFilterExtensions(new String[] { "*.zip;*.ZIP", "*" });
            dialog.setFilterNames(new String[] { BaseMessages.getString(PKG, "System.FileType.ZIPFiles"), BaseMessages.getString(PKG, "System.FileType.AllFiles") });
            setFilterPath(dialog);
            if (dialog.open() != null) {
                lastDirOpened = dialog.getFilterPath();
                zipFilename = dialog.getFilterPath() + Const.FILE_SEPARATOR + dialog.getFileName();
                FileObject zipFileObject = KettleVFS.getFileObject(zipFilename);
                if (zipFileObject.exists()) {
                    MessageBox box = new MessageBox(shell, SWT.YES | SWT.NO | SWT.CANCEL);
                    box.setMessage(BaseMessages.getString(PKG, "Spoon.ExportResourceZipFileExists.Message", zipFilename));
                    box.setText(BaseMessages.getString(PKG, "Spoon.ExportResourceZipFileExists.Title"));
                    int answer = box.open();
                    if (answer == SWT.CANCEL) {
                        return;
                    }
                    if (answer == SWT.NO) {
                        zipFilename = null;
                    }
                }
            } else {
                return;
            }
        }
        // Export the resources linked to the currently loaded file...
        // 
        TopLevelResource topLevelResource = ResourceUtil.serializeResourceExportInterface(zipFilename, resourceExportInterface, (VariableSpace) resourceExportInterface, rep, metaStore);
        String message = ResourceUtil.getExplanation(zipFilename, topLevelResource.getResourceName(), resourceExportInterface);
        /*
       * // Add the ZIP file as a repository to the repository list... // RepositoriesMeta repositoriesMeta = new
       * RepositoriesMeta(); repositoriesMeta.readData();
       *
       * KettleFileRepositoryMeta fileRepositoryMeta = new KettleFileRepositoryMeta(
       * KettleFileRepositoryMeta.REPOSITORY_TYPE_ID, "Export " + baseFileName, "Export to file : " + zipFilename,
       * "zip://" + zipFilename + "!"); fileRepositoryMeta.setReadOnly(true); // A ZIP file is read-only int nr = 2;
       * String baseName = fileRepositoryMeta.getName(); while
       * (repositoriesMeta.findRepository(fileRepositoryMeta.getName()) != null) { fileRepositoryMeta.setName(baseName +
       * " " + nr); nr++; }
       *
       * repositoriesMeta.addRepository(fileRepositoryMeta); repositoriesMeta.writeData();
       */
        // Show some information concerning all this work...
        // 
        EnterTextDialog enterTextDialog = new EnterTextDialog(shell, BaseMessages.getString(PKG, "Spoon.Dialog.ResourceSerialized"), BaseMessages.getString(PKG, "Spoon.Dialog.ResourceSerializedSuccesfully"), message);
        enterTextDialog.setReadOnly();
        enterTextDialog.open();
    } catch (Exception e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Error"), BaseMessages.getString(PKG, "Spoon.ErrorExportingFile"), e);
    }
}
Also used : TopLevelResource(org.pentaho.di.resource.TopLevelResource) ResourceExportInterface(org.pentaho.di.resource.ResourceExportInterface) EnterTextDialog(org.pentaho.di.ui.core.dialog.EnterTextDialog) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) FileObject(org.apache.commons.vfs2.FileObject) KettlePropertiesFileDialog(org.pentaho.di.ui.core.dialog.KettlePropertiesFileDialog) FileDialog(org.eclipse.swt.widgets.FileDialog) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) SWTException(org.eclipse.swt.SWTException) KettleRowException(org.pentaho.di.core.exception.KettleRowException) FileSystemException(org.apache.commons.vfs2.FileSystemException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) KettleValueException(org.pentaho.di.core.exception.KettleValueException) KettleAuthException(org.pentaho.di.core.exception.KettleAuthException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) LifecycleException(org.pentaho.di.core.lifecycle.LifecycleException) KettleMissingPluginsException(org.pentaho.di.core.exception.KettleMissingPluginsException) KettleFileException(org.pentaho.di.core.exception.KettleFileException) KettleException(org.pentaho.di.core.exception.KettleException) MalformedURLException(java.net.MalformedURLException) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 49 with EnterTextDialog

use of org.pentaho.di.ui.core.dialog.EnterTextDialog in project pentaho-kettle by pentaho.

the class SpoonSlave method remove.

protected void remove() {
    TreeEntry treeEntry = getTreeEntry();
    if (treeEntry == null) {
        return;
    }
    if (treeEntry.isTransformation()) {
        // Transformation
        SlaveServerTransStatus transStatus = slaveServerStatus.findTransStatus(treeEntry.name, treeEntry.id);
        if (transStatus != null) {
            if (!transStatus.isRunning() && !transStatus.isPaused() && !transStatus.isStopped()) {
                try {
                    WebResult webResult = slaveServer.removeTransformation(treeEntry.name, transStatus.getId());
                    if (WebResult.STRING_OK.equalsIgnoreCase(webResult.getResult())) {
                        // Force refresh in order to give faster visual feedback and reengage the timer
                        wTree.deselectAll();
                        engageViewAndLogUpdateTimer();
                    } else {
                        EnterTextDialog dialog = new EnterTextDialog(shell, BaseMessages.getString(PKG, "SpoonSlave.ErrorRemovingTrans.Title"), BaseMessages.getString(PKG, "SpoonSlave.ErrorRemovingTrans.Message"), webResult.getMessage());
                        dialog.setReadOnly();
                        dialog.open();
                    }
                } catch (Exception e) {
                    new ErrorDialog(shell, BaseMessages.getString(PKG, "SpoonSlave.ErrorRemovingTrans.Title"), BaseMessages.getString(PKG, "SpoonSlave.ErrorRemovingTrans.Message"), e);
                }
            }
        }
    } else if (treeEntry.isJob()) {
        // Job
        SlaveServerJobStatus jobStatus = slaveServerStatus.findJobStatus(treeEntry.name, treeEntry.id);
        if (jobStatus != null) {
            if (!jobStatus.isRunning()) {
                try {
                    WebResult webResult = slaveServer.removeJob(treeEntry.name, jobStatus.getId());
                    if (WebResult.STRING_OK.equalsIgnoreCase(webResult.getResult())) {
                        // Force refresh in order to give faster visual feedback and reengage the timer
                        wTree.deselectAll();
                        engageViewAndLogUpdateTimer();
                    } else {
                        EnterTextDialog dialog = new EnterTextDialog(shell, BaseMessages.getString(PKG, "SpoonSlave.ErrorRemovingJob.Title"), BaseMessages.getString(PKG, "SpoonSlave.ErrorRemovingJob.Message"), webResult.getMessage());
                        dialog.setReadOnly();
                        dialog.open();
                    }
                } catch (Exception e) {
                    new ErrorDialog(shell, BaseMessages.getString(PKG, "SpoonSlave.ErrorRemovingJob.Title"), BaseMessages.getString(PKG, "SpoonSlave.ErrorRemovingJob.Message"), e);
                }
            }
        }
    }
}
Also used : SlaveServerJobStatus(org.pentaho.di.www.SlaveServerJobStatus) SlaveServerTransStatus(org.pentaho.di.www.SlaveServerTransStatus) EnterTextDialog(org.pentaho.di.ui.core.dialog.EnterTextDialog) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) WebResult(org.pentaho.di.www.WebResult)

Example 50 with EnterTextDialog

use of org.pentaho.di.ui.core.dialog.EnterTextDialog in project pentaho-kettle by pentaho.

the class SpoonSlave method stop.

protected void stop() {
    TreeEntry treeEntry = getTreeEntry();
    if (treeEntry == null) {
        return;
    }
    if (treeEntry.isTransformation()) {
        // Transformation
        SlaveServerTransStatus transStatus = slaveServerStatus.findTransStatus(treeEntry.name, treeEntry.id);
        if (transStatus != null) {
            if (transStatus.isRunning() || transStatus.isPaused()) {
                try {
                    WebResult webResult = slaveServer.stopTransformation(treeEntry.name, transStatus.getId());
                    if (!WebResult.STRING_OK.equalsIgnoreCase(webResult.getResult())) {
                        EnterTextDialog dialog = new EnterTextDialog(shell, BaseMessages.getString(PKG, "SpoonSlave.ErrorStoppingTrans.Title"), BaseMessages.getString(PKG, "SpoonSlave.ErrorStoppingTrans.Message"), webResult.getMessage());
                        dialog.setReadOnly();
                        dialog.open();
                    }
                } catch (Exception e) {
                    new ErrorDialog(shell, BaseMessages.getString(PKG, "SpoonSlave.ErrorStoppingTrans.Title"), BaseMessages.getString(PKG, "SpoonSlave.ErrorStoppingTrans.Message"), e);
                }
            }
        }
    } else if (treeEntry.isJob()) {
        // Job
        SlaveServerJobStatus jobStatus = slaveServerStatus.findJobStatus(treeEntry.name, treeEntry.id);
        if (jobStatus != null) {
            if (jobStatus.isRunning()) {
                try {
                    WebResult webResult = slaveServer.stopJob(treeEntry.name, jobStatus.getId());
                    if (!WebResult.STRING_OK.equalsIgnoreCase(webResult.getResult())) {
                        EnterTextDialog dialog = new EnterTextDialog(shell, BaseMessages.getString(PKG, "SpoonSlave.ErrorStoppingJob.Title"), BaseMessages.getString(PKG, "SpoonSlave.ErrorStoppingJob.Message"), webResult.getMessage());
                        dialog.setReadOnly();
                        dialog.open();
                    }
                } catch (Exception e) {
                    new ErrorDialog(shell, BaseMessages.getString(PKG, "SpoonSlave.ErrorStoppingJob.Title"), BaseMessages.getString(PKG, "SpoonSlave.ErrorStoppingJob.Message"), e);
                }
            }
        }
    }
}
Also used : SlaveServerJobStatus(org.pentaho.di.www.SlaveServerJobStatus) SlaveServerTransStatus(org.pentaho.di.www.SlaveServerTransStatus) EnterTextDialog(org.pentaho.di.ui.core.dialog.EnterTextDialog) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) WebResult(org.pentaho.di.www.WebResult)

Aggregations

EnterTextDialog (org.pentaho.di.ui.core.dialog.EnterTextDialog)70 EnterNumberDialog (org.pentaho.di.ui.core.dialog.EnterNumberDialog)48 Trans (org.pentaho.di.trans.Trans)47 TransMeta (org.pentaho.di.trans.TransMeta)47 PreviewRowsDialog (org.pentaho.di.ui.core.dialog.PreviewRowsDialog)47 TransPreviewProgressDialog (org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog)47 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)44 KettleException (org.pentaho.di.core.exception.KettleException)35 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)17 MessageBox (org.eclipse.swt.widgets.MessageBox)15 IOException (java.io.IOException)7 InputStream (java.io.InputStream)6 FileObject (org.apache.commons.vfs2.FileObject)6 InputStreamReader (java.io.InputStreamReader)5 Point (org.eclipse.swt.graphics.Point)5 TableItem (org.eclipse.swt.widgets.TableItem)5 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)5 FileDialog (org.eclipse.swt.widgets.FileDialog)4 KettleStepException (org.pentaho.di.core.exception.KettleStepException)4 DecimalFormat (java.text.DecimalFormat)3