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();
}
}
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();
}
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);
}
}
}
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;
}
}
}
}
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;
}
}
Aggregations