use of org.pentaho.di.ui.core.dialog.ShowMessageDialog in project pentaho-kettle by pentaho.
the class UserDefinedJavaClassDialog method createPlugin.
protected boolean createPlugin() {
// Create a step with the information in this dialog
UserDefinedJavaClassMeta udjcMeta = new UserDefinedJavaClassMeta();
getInfo(udjcMeta);
try {
String pluginName = "Processor";
for (UserDefinedJavaClassDef def : udjcMeta.getDefinitions()) {
if (def.isTransformClass()) {
pluginName = def.getClassName();
}
}
File pluginFile = new File(String.format("plugins/steps/%s/%s.step.xml", pluginName, pluginName));
pluginFile.getParentFile().mkdirs();
PrintWriter pw = new PrintWriter(new FileWriter(pluginFile));
StringBuilder outXML = new StringBuilder("<step>\n");
outXML.append(String.format("\t<name>%s</name>\n", stepname));
outXML.append("\t<type>UserDefinedJavaClass</type>\n");
outXML.append("\t<description/>\n\t");
outXML.append(udjcMeta.getXML());
outXML.append("</step>");
pw.println(outXML.toString());
pw.flush();
pw.close();
ShowMessageDialog msgDialog = new ShowMessageDialog(shell, SWT.ICON_INFORMATION | SWT.OK, BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.Plugin.CreateSuccess"), BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.Plugin.CreatedFile", pluginFile.getPath()), false);
msgDialog.open();
} catch (IOException e) {
e.printStackTrace();
new ErrorDialog(shell, BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.Plugin.CreateErrorTitle"), BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.Plugin.CreateErrorMessage", stepname), e);
}
return true;
}
use of org.pentaho.di.ui.core.dialog.ShowMessageDialog in project pentaho-cassandra-plugin by pentaho.
the class CassandraInputDialog method popupSchemaInfo.
protected void popupSchemaInfo() {
Connection conn = null;
Keyspace kSpace = null;
try {
String hostS = transMeta.environmentSubstitute(m_hostText.getText());
String portS = transMeta.environmentSubstitute(m_portText.getText());
String userS = m_userText.getText();
String passS = m_passText.getText();
if (!Utils.isEmpty(userS) && !Utils.isEmpty(passS)) {
userS = transMeta.environmentSubstitute(userS);
passS = transMeta.environmentSubstitute(passS);
}
String keyspaceS = transMeta.environmentSubstitute(m_keyspaceText.getText());
String cqlText = transMeta.environmentSubstitute(m_cqlText.getText());
try {
Map<String, String> opts = new HashMap<String, String>();
opts.put(CassandraUtils.CQLOptions.CQLVERSION_OPTION, CassandraUtils.CQLOptions.CQL3_STRING);
conn = CassandraUtils.getCassandraConnection(hostS, Integer.parseInt(portS), userS, passS, ConnectionFactory.Driver.BINARY_CQL3_PROTOCOL, opts);
conn.setHosts(hostS);
conn.setDefaultPort(Integer.parseInt(portS));
conn.setUsername(userS);
conn.setPassword(passS);
kSpace = conn.getKeyspace(keyspaceS);
} catch (Exception e) {
logError(// $NON-NLS-1$
BaseMessages.getString(PKG, "CassandraInputDialog.Error.ProblemGettingSchemaInfo.Message") + ":\n\n" + e.getLocalizedMessage(), // $NON-NLS-1$
e);
new ErrorDialog(shell, BaseMessages.getString(PKG, // $NON-NLS-1$
"CassandraInputDialog.Error.ProblemGettingSchemaInfo.Title"), // $NON-NLS-1$
BaseMessages.getString(PKG, "CassandraInputDialog.Error.ProblemGettingSchemaInfo.Message") + ":\n\n" + e.getLocalizedMessage(), // $NON-NLS-1$
e);
return;
}
String table = CassandraUtils.getTableNameFromCQLSelectQuery(cqlText);
if (Utils.isEmpty(table)) {
// $NON-NLS-1$
throw new Exception(BaseMessages.getString(PKG, "CassandraInput.Error.NoFromClauseInQuery"));
}
if (!kSpace.tableExists(table)) {
throw new Exception(BaseMessages.getString(PKG, "CassandraInput.Error.NonExistentTable", CassandraUtils.removeQuotes(table), // $NON-NLS-1$
keyspaceS));
}
String schemaDescription = kSpace.getTableMetaData(table).describe();
ShowMessageDialog smd = new ShowMessageDialog(shell, SWT.ICON_INFORMATION | SWT.OK, "Schema info", schemaDescription, // $NON-NLS-1$
true);
smd.open();
} catch (Exception e1) {
logError(// $NON-NLS-1$
BaseMessages.getString(PKG, "CassandraInputDialog.Error.ProblemGettingSchemaInfo.Message") + ":\n\n" + e1.getMessage(), // $NON-NLS-1$
e1);
new ErrorDialog(shell, // $NON-NLS-1$
BaseMessages.getString(PKG, "CassandraInputDialog.Error.ProblemGettingSchemaInfo.Title"), // $NON-NLS-1$
BaseMessages.getString(PKG, "CassandraInputDialog.Error.ProblemGettingSchemaInfo.Message") + ":\n\n" + e1.getMessage(), // $NON-NLS-1$
e1);
} finally {
if (conn != null) {
try {
conn.closeConnection();
} catch (Exception e) {
log.logError(e.getLocalizedMessage(), e);
// TODO popup another error dialog
}
}
}
}
use of org.pentaho.di.ui.core.dialog.ShowMessageDialog in project pentaho-cassandra-plugin by pentaho.
the class CassandraOutputDialog method popupSchemaInfo.
protected void popupSchemaInfo() {
Connection conn = null;
Keyspace kSpace = null;
try {
String hostS = transMeta.environmentSubstitute(m_hostText.getText());
String portS = transMeta.environmentSubstitute(m_portText.getText());
String userS = m_userText.getText();
String passS = m_passText.getText();
if (!Utils.isEmpty(userS) && !Utils.isEmpty(passS)) {
userS = transMeta.environmentSubstitute(userS);
passS = transMeta.environmentSubstitute(passS);
}
String keyspaceS = transMeta.environmentSubstitute(m_keyspaceText.getText());
try {
Map<String, String> opts = new HashMap<String, String>();
opts.put(CassandraUtils.CQLOptions.CQLVERSION_OPTION, CassandraUtils.CQLOptions.CQL3_STRING);
conn = CassandraUtils.getCassandraConnection(hostS, Integer.parseInt(portS), userS, passS, ConnectionFactory.Driver.BINARY_CQL3_PROTOCOL, opts);
conn.setHosts(hostS);
conn.setDefaultPort(Integer.parseInt(portS));
conn.setUsername(userS);
conn.setPassword(passS);
kSpace = conn.getKeyspace(keyspaceS);
} catch (Exception e) {
logError(// $NON-NLS-1$
BaseMessages.getString(PKG, "CassandraOutputDialog.Error.ProblemGettingSchemaInfo.Message") + ":\n\n" + e.getLocalizedMessage(), // $NON-NLS-1$
e);
new ErrorDialog(shell, BaseMessages.getString(PKG, // $NON-NLS-1$
"CassandraOutputDialog.Error.ProblemGettingSchemaInfo.Title"), // $NON-NLS-1$
BaseMessages.getString(PKG, "CassandraOutputDialog.Error.ProblemGettingSchemaInfo.Message") + ":\n\n" + e.getLocalizedMessage(), // $NON-NLS-1$
e);
return;
}
String table = transMeta.environmentSubstitute(m_tableCombo.getText());
if (Utils.isEmpty(table)) {
// $NON-NLS-1$
throw new Exception("No table name specified!");
}
table = CassandraUtils.cql3MixedCaseQuote(table);
// if (!CassandraColumnMetaData.tableExists(conn, table)) {
if (!kSpace.tableExists(table)) {
throw new Exception(// $NON-NLS-1$ //$NON-NLS-2$
"The table '" + table + "' does not " + "seem to exist in the keyspace '" + // $NON-NLS-1$
keyspaceS);
}
ITableMetaData cassMeta = kSpace.getTableMetaData(table);
// CassandraColumnMetaData cassMeta = new CassandraColumnMetaData(conn,
// table);
String schemaDescription = cassMeta.describe();
ShowMessageDialog smd = // $NON-NLS-1$
new ShowMessageDialog(shell, SWT.ICON_INFORMATION | SWT.OK, "Schema info", schemaDescription, true);
smd.open();
} catch (Exception e1) {
logError(// $NON-NLS-1$
BaseMessages.getString(PKG, "CassandraOutputDialog.Error.ProblemGettingSchemaInfo.Message") + ":\n\n" + e1.getMessage(), // $NON-NLS-1$
e1);
new ErrorDialog(shell, BaseMessages.getString(PKG, // $NON-NLS-1$
"CassandraOutputDialog.Error.ProblemGettingSchemaInfo.Title"), // $NON-NLS-1$
BaseMessages.getString(PKG, "CassandraOutputDialog.Error.ProblemGettingSchemaInfo.Message") + ":\n\n" + e1.getMessage(), // $NON-NLS-1$
e1);
} finally {
if (conn != null) {
try {
conn.closeConnection();
} catch (Exception e) {
// TODO popup another error dialog
e.printStackTrace();
}
}
}
}
use of org.pentaho.di.ui.core.dialog.ShowMessageDialog in project pentaho-kettle by pentaho.
the class DataOverrideHandler method showMessage.
@Override
protected void showMessage(String message, boolean scroll) {
Shell parent = getShell();
ShowMessageDialog msgDialog = new ShowMessageDialog(parent, SWT.ICON_INFORMATION | SWT.OK, BaseMessages.getString(PKG, "DatabaseDialog.DatabaseConnectionTest.title"), message, scroll);
msgDialog.open();
}
use of org.pentaho.di.ui.core.dialog.ShowMessageDialog in project pentaho-kettle by pentaho.
the class Spoon method onLoginError.
private void onLoginError(Throwable t) {
if (t instanceof KettleAuthException) {
ShowMessageDialog dialog = new ShowMessageDialog(loginDialog.getShell(), SWT.OK | SWT.ICON_ERROR, BaseMessages.getString(PKG, "Spoon.Dialog.LoginFailed.Title"), t.getLocalizedMessage());
dialog.open();
} else {
new ErrorDialog(loginDialog.getShell(), BaseMessages.getString(PKG, "Spoon.Dialog.LoginFailed.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.LoginFailed.Message", t), t);
}
}
Aggregations