Search in sources :

Example 6 with ShowMessageDialog

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

the class PurRepositoryRevisionBrowserDialog method open.

public String open() {
    try {
        props.setLook(shell);
        FormLayout formLayout = new FormLayout();
        formLayout.marginWidth = Const.FORM_MARGIN;
        formLayout.marginHeight = Const.FORM_MARGIN;
        shell.setLayout(formLayout);
        shell.setImage(GUIResource.getInstance().getImageVersionBrowser());
        // int middle = props.getMiddlePct();
        int margin = Const.MARGIN;
        revisions = revisionService.getRevisions(element);
        // Mmm, if we don't get any rows in the buffer: show a dialog box.
        if (revisions == null || revisions.size() == 0) {
            ShowMessageDialog dialog = new ShowMessageDialog(shell, SWT.OK | SWT.ICON_WARNING, BaseMessages.getString(PKG, "PurRepositoryRevisionBrowserDialog.NoRevisions.Text"), BaseMessages.getString(PKG, "PurRepositoryRevisionBrowserDialog.NoRevisions.Message"));
            dialog.open();
            shell.dispose();
            return null;
        }
        wlFields = new Label(shell, SWT.LEFT);
        wlFields.setText("Revision history of " + elementDescription);
        props.setLook(wlFields);
        fdlFields = new FormData();
        fdlFields.left = new FormAttachment(0, 0);
        fdlFields.right = new FormAttachment(100, 0);
        fdlFields.top = new FormAttachment(0, margin);
        wlFields.setLayoutData(fdlFields);
        ColumnInfo[] colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "PurRepositoryRevisionBrowserDialog.Columns.Revision.Name"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "PurRepositoryRevisionBrowserDialog.Columns.Revision.Comment"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "PurRepositoryRevisionBrowserDialog.Columns.Revision.Date"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "PurRepositoryRevisionBrowserDialog.Columns.Revision.Login"), ColumnInfo.COLUMN_TYPE_TEXT, false, true) };
        wFields = new TableView(new Variables(), shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE, colinf, 0, null, props);
        wFields.setReadonly(true);
        fdFields = new FormData();
        fdFields.left = new FormAttachment(0, 0);
        fdFields.top = new FormAttachment(wlFields, margin);
        fdFields.right = new FormAttachment(100, 0);
        fdFields.bottom = new FormAttachment(100, -50);
        wFields.setLayoutData(fdFields);
        wFields.table.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                int index = wFields.getSelectionIndex();
                if (index >= 0) {
                    String[] item = wFields.getItem(index);
                    if (item != null && item.length > 0) {
                        selectedRevision = item[0];
                    }
                }
            }

            public void widgetDefaultSelected(SelectionEvent event) {
                ok();
            }
        });
        wOpen = new Button(shell, SWT.PUSH);
        // $NON-NLS-1$
        wOpen.setText(BaseMessages.getString("System.Button.Open"));
        lsOpen = new Listener() {

            public void handleEvent(Event e) {
                ok();
            }
        };
        wOpen.addListener(SWT.Selection, lsOpen);
        wClose = new Button(shell, SWT.PUSH);
        // $NON-NLS-1$
        wClose.setText(BaseMessages.getString("System.Button.Close"));
        lsClose = new Listener() {

            public void handleEvent(Event e) {
                cancel();
            }
        };
        wClose.addListener(SWT.Selection, lsClose);
        BaseStepDialog.positionBottomButtons(shell, new Button[] { wOpen, wClose }, margin, null);
        // Detect X or ALT-F4 or something that kills this window...
        shell.addShellListener(new ShellAdapter() {

            public void shellClosed(ShellEvent e) {
                cancel();
            }
        });
        getData();
        BaseStepDialog.setSize(shell);
        shell.open();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch())
                display.sleep();
        }
        return selectedRevision;
    } catch (Exception e) {
        new ErrorDialog(shell, "Error browsing versions", "There was an error browsing the version history of element " + element, e);
        return null;
    }
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ShellAdapter(org.eclipse.swt.events.ShellAdapter) Listener(org.eclipse.swt.widgets.Listener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) ColumnInfo(org.pentaho.di.ui.core.widget.ColumnInfo) ShellEvent(org.eclipse.swt.events.ShellEvent) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) KettleException(org.pentaho.di.core.exception.KettleException) Variables(org.pentaho.di.core.variables.Variables) Button(org.eclipse.swt.widgets.Button) ShowMessageDialog(org.pentaho.di.ui.core.dialog.ShowMessageDialog) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Event(org.eclipse.swt.widgets.Event) ShellEvent(org.eclipse.swt.events.ShellEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) TableView(org.pentaho.di.ui.core.widget.TableView)

Example 7 with ShowMessageDialog

use of org.pentaho.di.ui.core.dialog.ShowMessageDialog in project pentaho-cassandra-plugin by pentaho.

the class CassandraInputDialog method checkForUnresolved.

private boolean checkForUnresolved(CassandraInputMeta meta, String title) {
    String query = transMeta.environmentSubstitute(meta.getCQLSelectQuery());
    // $NON-NLS-1$ //$NON-NLS-2$
    boolean notOk = (query.contains("${") || query.contains("?{"));
    if (notOk) {
        ShowMessageDialog smd = new ShowMessageDialog(shell, SWT.ICON_WARNING | SWT.OK, title, BaseMessages.getString(PKG, // $NON-NLS-1$
        "CassandraInputDialog.Warning.Message.CassandraQueryContainsUnresolvedVarsFieldSubs"));
        smd.open();
    }
    return !notOk;
}
Also used : ShowMessageDialog(org.pentaho.di.ui.core.dialog.ShowMessageDialog)

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