Search in sources :

Example 51 with EnterSelectionDialog

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

the class Spoon method exploreDatabase.

public void exploreDatabase() {
    if (RepositorySecurityUI.verifyOperations(shell, rep, RepositoryOperation.EXPLORE_DATABASE)) {
        return;
    }
    // Show a minimal window to allow you to quickly select the database
    // connection to explore
    // 
    List<DatabaseMeta> databases = new ArrayList<>();
    // First load the connections from the loaded file
    // 
    HasDatabasesInterface databasesInterface = getActiveHasDatabasesInterface();
    if (databasesInterface != null) {
        databases.addAll(databasesInterface.getDatabases());
    }
    // 
    if (rep != null) {
        try {
            List<DatabaseMeta> list = rep.readDatabases();
            for (DatabaseMeta databaseMeta : list) {
                int index = databases.indexOf(databaseMeta);
                if (index < 0) {
                    databases.add(databaseMeta);
                } else {
                    databases.set(index, databaseMeta);
                }
            }
        } catch (KettleException e) {
            log.logError("Unexpected repository error", e.getMessage());
        }
    }
    if (databases.size() == 0) {
        return;
    }
    // OK, get a list of all the database names...
    // 
    String[] databaseNames = new String[databases.size()];
    for (int i = 0; i < databases.size(); i++) {
        databaseNames[i] = databases.get(i).getName();
    }
    // show the shell...
    // 
    EnterSelectionDialog dialog = new EnterSelectionDialog(shell, databaseNames, BaseMessages.getString(PKG, "Spoon.ExploreDB.SelectDB.Title"), BaseMessages.getString(PKG, "Spoon.ExploreDB.SelectDB.Message"));
    String name = dialog.open();
    if (name != null) {
        selectionObject = DatabaseMeta.findDatabase(databases, name);
        exploreDB();
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ArrayList(java.util.ArrayList) HasDatabasesInterface(org.pentaho.di.trans.HasDatabasesInterface) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) EnterSelectionDialog(org.pentaho.di.ui.core.dialog.EnterSelectionDialog)

Example 52 with EnterSelectionDialog

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

the class Spoon method editClustering.

/**
 * Select a clustering schema for this step.
 *
 * @param stepMetas The steps (at least one!) to set the clustering schema for.
 */
public void editClustering(TransMeta transMeta, List<StepMeta> stepMetas) {
    String[] clusterSchemaNames = transMeta.getClusterSchemaNames();
    StepMeta stepMeta = stepMetas.get(0);
    int idx = -1;
    if (stepMeta.getClusterSchema() != null) {
        idx = transMeta.getClusterSchemas().indexOf(stepMeta.getClusterSchema());
    }
    EnterSelectionDialog dialog = new EnterSelectionDialog(shell, clusterSchemaNames, BaseMessages.getString(PKG, "Spoon.Dialog.SelectClusteringSchema.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.SelectClusteringSchema.Message"));
    String schemaName = dialog.open(idx);
    if (schemaName == null) {
        for (StepMeta step : stepMetas) {
            step.setClusterSchema(null);
        }
    } else {
        ClusterSchema clusterSchema = transMeta.findClusterSchema(schemaName);
        for (StepMeta step : stepMetas) {
            step.setClusterSchema(clusterSchema);
        }
    }
    transMeta.setChanged();
    refreshTree();
    refreshGraph();
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) StepMeta(org.pentaho.di.trans.step.StepMeta) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) EnterSelectionDialog(org.pentaho.di.ui.core.dialog.EnterSelectionDialog) ClusterSchema(org.pentaho.di.cluster.ClusterSchema)

Example 53 with EnterSelectionDialog

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

the class SpoonSlave method sniff.

protected void sniff() {
    TreeItem[] ti = wTree.getSelection();
    if (ti.length == 1) {
        TreeItem treeItem = ti[0];
        String[] path = ConstUI.getTreeStrings(treeItem);
        // Make sure we're positioned on a step
        if (path.length <= 2) {
            return;
        }
        String name = path[1];
        String step = path[2];
        String copy = treeItem.getText(1);
        EnterNumberDialog numberDialog = new EnterNumberDialog(shell, PropsUI.getInstance().getDefaultPreviewSize(), BaseMessages.getString(PKG, "SpoonSlave.SniffSizeQuestion.Title"), BaseMessages.getString(PKG, "SpoonSlave.SniffSizeQuestion.Message"));
        int lines = numberDialog.open();
        if (lines <= 0) {
            return;
        }
        EnterSelectionDialog selectionDialog = new EnterSelectionDialog(shell, new String[] { SniffStepServlet.TYPE_INPUT, SniffStepServlet.TYPE_OUTPUT }, BaseMessages.getString(PKG, "SpoonSlave.SniffTypeQuestion.Title"), BaseMessages.getString(PKG, "SpoonSlave.SniffTypeQuestion.Message"));
        String type = selectionDialog.open(1);
        if (type == null) {
            return;
        }
        try {
            String xml = slaveServer.sniffStep(name, step, copy, lines, type);
            Document doc = XMLHandler.loadXMLString(xml);
            Node node = XMLHandler.getSubNode(doc, SniffStepServlet.XML_TAG);
            Node metaNode = XMLHandler.getSubNode(node, RowMeta.XML_META_TAG);
            RowMetaInterface rowMeta = new RowMeta(metaNode);
            int nrRows = Const.toInt(XMLHandler.getTagValue(node, "nr_rows"), 0);
            List<Object[]> rowBuffer = new ArrayList<Object[]>();
            for (int i = 0; i < nrRows; i++) {
                Node dataNode = XMLHandler.getSubNodeByNr(node, RowMeta.XML_DATA_TAG, i);
                Object[] row = rowMeta.getRow(dataNode);
                rowBuffer.add(row);
            }
            PreviewRowsDialog prd = new PreviewRowsDialog(shell, new Variables(), SWT.NONE, step, rowMeta, rowBuffer);
            prd.open();
        } catch (Exception e) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "SpoonSlave.ErrorSniffingStep.Title"), BaseMessages.getString(PKG, "SpoonSlave.ErrorSniffingStep.Message"), e);
        }
    }
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) RowMeta(org.pentaho.di.core.row.RowMeta) Node(org.w3c.dom.Node) ArrayList(java.util.ArrayList) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) Document(org.w3c.dom.Document) Variables(org.pentaho.di.core.variables.Variables) EnterNumberDialog(org.pentaho.di.ui.core.dialog.EnterNumberDialog) EnterSelectionDialog(org.pentaho.di.ui.core.dialog.EnterSelectionDialog)

Example 54 with EnterSelectionDialog

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

the class AddSequenceDialog method getSchemaNames.

private void getSchemaNames() {
    if (wSchema.isDisposed()) {
        return;
    }
    DatabaseMeta databaseMeta = transMeta.findDatabase(wConnection.getText());
    if (databaseMeta != null) {
        Database database = new Database(loggingObject, databaseMeta);
        try {
            database.connect();
            String[] schemas = database.getSchemas();
            if (null != schemas && schemas.length > 0) {
                schemas = Const.sortStrings(schemas);
                EnterSelectionDialog dialog = new EnterSelectionDialog(shell, schemas, BaseMessages.getString(PKG, "AddSequenceDialog.SelectSequence.Title", wConnection.getText()), BaseMessages.getString(PKG, "AddSequenceDialog.SelectSequence.Message"));
                String d = dialog.open();
                if (d != null) {
                    wSchema.setText(Const.NVL(d.toString(), ""));
                }
            } else {
                MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
                mb.setMessage(BaseMessages.getString(PKG, "AddSequenceDialog.NoSchema.Message"));
                mb.setText(BaseMessages.getString(PKG, "AddSequenceDialog.NoSchema.Title"));
                mb.open();
            }
        } catch (Exception e) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "AddSequenceDialog.ErrorGettingSchemas"), e);
        } finally {
            if (database != null) {
                database.disconnect();
                database = null;
            }
        }
    }
}
Also used : Database(org.pentaho.di.core.database.Database) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) EnterSelectionDialog(org.pentaho.di.ui.core.dialog.EnterSelectionDialog) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 55 with EnterSelectionDialog

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

the class TransGraph method askUserForCustomDistributionMethod.

public RowDistributionInterface askUserForCustomDistributionMethod() {
    List<PluginInterface> plugins = PluginRegistry.getInstance().getPlugins(RowDistributionPluginType.class);
    if (Utils.isEmpty(plugins)) {
        return null;
    }
    List<String> choices = new ArrayList<>();
    for (PluginInterface plugin : plugins) {
        choices.add(plugin.getName() + " : " + plugin.getDescription());
    }
    EnterSelectionDialog dialog = new EnterSelectionDialog(shell, choices.toArray(new String[choices.size()]), "Select distribution method", "Please select the row distribution method:");
    if (dialog.open() != null) {
        PluginInterface plugin = plugins.get(dialog.getSelectionNr());
        try {
            return (RowDistributionInterface) PluginRegistry.getInstance().loadClass(plugin);
        } catch (Exception e) {
            new ErrorDialog(shell, "Error", "Error loading row distribution plugin class", e);
            return null;
        }
    } else {
        return null;
    }
}
Also used : SpoonUiExtenderPluginInterface(org.pentaho.di.ui.spoon.SpoonUiExtenderPluginInterface) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) ArrayList(java.util.ArrayList) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowDistributionInterface(org.pentaho.di.trans.step.RowDistributionInterface) EnterSelectionDialog(org.pentaho.di.ui.core.dialog.EnterSelectionDialog) XulException(org.pentaho.ui.xul.XulException) InvocationTargetException(java.lang.reflect.InvocationTargetException) KettleValueException(org.pentaho.di.core.exception.KettleValueException) KettleStepException(org.pentaho.di.core.exception.KettleStepException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) KettleException(org.pentaho.di.core.exception.KettleException)

Aggregations

EnterSelectionDialog (org.pentaho.di.ui.core.dialog.EnterSelectionDialog)75 MessageBox (org.eclipse.swt.widgets.MessageBox)42 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)42 KettleException (org.pentaho.di.core.exception.KettleException)41 SelectionEvent (org.eclipse.swt.events.SelectionEvent)30 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)29 ModifyEvent (org.eclipse.swt.events.ModifyEvent)28 ModifyListener (org.eclipse.swt.events.ModifyListener)28 ShellEvent (org.eclipse.swt.events.ShellEvent)28 FormAttachment (org.eclipse.swt.layout.FormAttachment)28 FormData (org.eclipse.swt.layout.FormData)28 FormLayout (org.eclipse.swt.layout.FormLayout)28 Event (org.eclipse.swt.widgets.Event)28 Listener (org.eclipse.swt.widgets.Listener)28 Shell (org.eclipse.swt.widgets.Shell)28 ShellAdapter (org.eclipse.swt.events.ShellAdapter)27 Button (org.eclipse.swt.widgets.Button)27 Display (org.eclipse.swt.widgets.Display)27 Label (org.eclipse.swt.widgets.Label)27 Text (org.eclipse.swt.widgets.Text)27