Search in sources :

Example 1 with ShowMessageDialog

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;
}
Also used : FileWriter(java.io.FileWriter) ShowMessageDialog(org.pentaho.di.ui.core.dialog.ShowMessageDialog) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) UserDefinedJavaClassMeta(org.pentaho.di.trans.steps.userdefinedjavaclass.UserDefinedJavaClassMeta) UserDefinedJavaClassDef(org.pentaho.di.trans.steps.userdefinedjavaclass.UserDefinedJavaClassDef) IOException(java.io.IOException) File(java.io.File) PrintWriter(java.io.PrintWriter)

Example 2 with ShowMessageDialog

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
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) Keyspace(org.pentaho.cassandra.spi.Keyspace) ShowMessageDialog(org.pentaho.di.ui.core.dialog.ShowMessageDialog) Connection(org.pentaho.cassandra.spi.Connection) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog)

Example 3 with ShowMessageDialog

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();
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) Keyspace(org.pentaho.cassandra.spi.Keyspace) ShowMessageDialog(org.pentaho.di.ui.core.dialog.ShowMessageDialog) Connection(org.pentaho.cassandra.spi.Connection) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) ITableMetaData(org.pentaho.cassandra.spi.ITableMetaData) KettleException(org.pentaho.di.core.exception.KettleException)

Example 4 with ShowMessageDialog

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();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ShowMessageDialog(org.pentaho.di.ui.core.dialog.ShowMessageDialog)

Example 5 with ShowMessageDialog

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);
    }
}
Also used : ShowMessageDialog(org.pentaho.di.ui.core.dialog.ShowMessageDialog) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) KettleAuthException(org.pentaho.di.core.exception.KettleAuthException)

Aggregations

ShowMessageDialog (org.pentaho.di.ui.core.dialog.ShowMessageDialog)7 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)5 HashMap (java.util.HashMap)2 Connection (org.pentaho.cassandra.spi.Connection)2 Keyspace (org.pentaho.cassandra.spi.Keyspace)2 KettleException (org.pentaho.di.core.exception.KettleException)2 File (java.io.File)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 ShellAdapter (org.eclipse.swt.events.ShellAdapter)1 ShellEvent (org.eclipse.swt.events.ShellEvent)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormData (org.eclipse.swt.layout.FormData)1 FormLayout (org.eclipse.swt.layout.FormLayout)1 Button (org.eclipse.swt.widgets.Button)1 Event (org.eclipse.swt.widgets.Event)1 Label (org.eclipse.swt.widgets.Label)1