Search in sources :

Example 6 with EnterStringDialog

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

the class Translator2 method search.

protected void search(String searchLocale) {
    // Ask for the search string...
    // 
    EnterStringDialog dialog = new EnterStringDialog(shell, Const.NVL(searchString, ""), BaseMessages.getString(PKG, "i18nDialog.SearchKey"), BaseMessages.getString(PKG, "i18nDialog.SearchLocale1") + " '" + Const.NVL(searchLocale, "") + "' " + BaseMessages.getString(PKG, "i18nDialog.SearchLocale2"));
    searchString = dialog.open();
    lastFoundKey = null;
    searchAgain(searchLocale);
}
Also used : EnterStringDialog(org.pentaho.di.ui.core.dialog.EnterStringDialog)

Example 7 with EnterStringDialog

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

the class TransGraph method copies.

public void copies(StepMeta stepMeta) {
    final boolean multipleOK = checkNumberOfCopies(transMeta, stepMeta);
    selectedSteps = null;
    String tt = BaseMessages.getString(PKG, "TransGraph.Dialog.NrOfCopiesOfStep.Title");
    String mt = BaseMessages.getString(PKG, "TransGraph.Dialog.NrOfCopiesOfStep.Message");
    EnterStringDialog nd = new EnterStringDialog(shell, stepMeta.getCopiesString(), tt, mt, true, transMeta);
    String cop = nd.open();
    if (!Utils.isEmpty(cop)) {
        int copies = Const.toInt(transMeta.environmentSubstitute(cop), -1);
        if (copies > 1 && !multipleOK) {
            cop = "1";
            MessageBox mb = new MessageBox(shell, SWT.YES | SWT.ICON_WARNING);
            mb.setMessage(BaseMessages.getString(PKG, "TransGraph.Dialog.MultipleCopiesAreNotAllowedHere.Message"));
            mb.setText(BaseMessages.getString(PKG, "TransGraph.Dialog.MultipleCopiesAreNotAllowedHere.Title"));
            mb.open();
        }
        String cps = stepMeta.getCopiesString();
        if ((cps != null && !cps.equals(cop)) || (cps == null && cop != null)) {
            stepMeta.setChanged();
        }
        stepMeta.setCopiesString(cop);
        spoon.refreshGraph();
    }
}
Also used : EnterStringDialog(org.pentaho.di.ui.core.dialog.EnterStringDialog) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 8 with EnterStringDialog

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

the class RepositoryExplorerDialog method createDirectory.

public void createDirectory(TreeItem ti, RepositoryDirectoryInterface repdir) {
    EnterStringDialog esd = new EnterStringDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Directory.Create.AskName.Default"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Directory.Create.AskName.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Directory.Create.AskName.Message"));
    String newdir = esd.open();
    if (newdir != null) {
        RepositoryDirectoryInterface rd = new RepositoryDirectory(repdir, newdir);
        String[] path = rd.getPathArray();
        RepositoryDirectoryInterface exists = directoryTree.findDirectory(path);
        if (exists == null) {
            try {
                rep.saveRepositoryDirectory(rd);
            } catch (Exception exception) {
                new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Directory.Create.UnexpectedError.Message1") + newdir + BaseMessages.getString(PKG, "RepositoryExplorerDialog.Directory.Create.UnexpectedError.Message2") + repdir.getPath() + "]", BaseMessages.getString(PKG, "RepositoryExplorerDialog.Directory.Create.UnexpectedError.Title"), exception);
            }
        } else {
            MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
            mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Directory.Create.AlreadyExists.Message1") + newdir + BaseMessages.getString(PKG, "RepositoryExplorerDialog.Directory.Create.AlreadyExists.Message2") + repdir.getPath() + BaseMessages.getString(PKG, "RepositoryExplorerDialog.Directory.Create.AlreadyExists.Message3"));
            mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Directory.Create.AlreadyExists.Title"));
            mb.open();
        }
    }
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) EnterStringDialog(org.pentaho.di.ui.core.dialog.EnterStringDialog) IOException(java.io.IOException) KettleException(org.pentaho.di.core.exception.KettleException) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 9 with EnterStringDialog

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

the class SelectDirectoryDialog method setTreeMenu.

public void setTreeMenu() {
    Menu mTree = null;
    // use SWT.SINGLE in wTree!!!!
    TreeItem[] ti = wTree.getSelection();
    if (ti.length == 1) {
        mTree = new Menu(wTree);
        /*
       * NEW Sub-directory
       */
        MenuItem miNew = new MenuItem(mTree, SWT.CASCADE);
        miNew.setText(BaseMessages.getString(PKG, "SelectDirectoryDialog.PopupMenu.Directory.New"));
        miNew.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                if (!readOnly) {
                    TreeItem ti = wTree.getSelection()[0];
                    String[] str = ConstUI.getTreeStrings(ti);
                    // 
                    // In which directory do we want create a subdirectory?
                    // 
                    RepositoryDirectoryInterface dir = repositoryTree.findDirectory(str);
                    if (dir != null) {
                        // 
                        // What's the name of the new directory?
                        // 
                        EnterStringDialog etd = new EnterStringDialog(shell, BaseMessages.getString(PKG, "SelectDirectoryDialog.Dialog.EnterDirectoryName.Title"), BaseMessages.getString(PKG, "SelectDirectoryDialog.Dialog.EnterDirectoryName.Message"), BaseMessages.getString(PKG, "SelectDirectoryDialog.Dialog.EnterDirectoryName.Default"));
                        String newdir = etd.open();
                        if (newdir != null) {
                            RepositoryDirectory subdir = new RepositoryDirectory(dir, newdir);
                            try {
                                rep.saveRepositoryDirectory(subdir);
                                dir.addSubdirectory(subdir);
                                TreeItem tiNew = new TreeItem(ti, SWT.NONE);
                                tiNew.setText(newdir);
                                tiNew.setImage(GUIResource.getInstance().getImageFolder());
                                wTree.setSelection(new TreeItem[] { tiNew });
                            } catch (Exception exception) {
                                new ErrorDialog(shell, BaseMessages.getString(PKG, "SelectDirectoryDialog.Dialog.UnableToCreateDirectory.Message"), BaseMessages.getString(PKG, "SelectDirectoryDialog.Dialog.UnableToCreateDirectory.Title"), exception);
                            }
                        }
                    } else {
                        MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
                        mb.setMessage(BaseMessages.getString(PKG, "SelectDirectoryDialog.Dialog.UnableToLocateDirectory.Message"));
                        mb.setText(BaseMessages.getString(PKG, "SelectDirectoryDialog.Dialog.UnableToLocateDirectory.Title"));
                        mb.open();
                    }
                } else {
                    MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
                    mb.setMessage(BaseMessages.getString(PKG, "SelectDirectoryDialog.Dialog.PermissionDenied.Message1") + (rep.getUserInfo() == null ? "" : rep.getUserInfo().getLogin()) + BaseMessages.getString(PKG, "SelectDirectoryDialog.Dialog.PermissionDenied.Message2"));
                    mb.setText(BaseMessages.getString(PKG, "SelectDirectoryDialog.Dialog.PermissionDenied.Title"));
                    mb.open();
                }
            }
        });
        /*
       * RENAME directory
       */
        MenuItem miRen = new MenuItem(mTree, SWT.CASCADE);
        miRen.setText(BaseMessages.getString(PKG, "SelectDirectoryDialog.PopupMenu.Directory.Rename"));
        miRen.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                if (!readOnly) {
                    TreeItem ti = wTree.getSelection()[0];
                    String[] str = ConstUI.getTreeStrings(ti);
                    RepositoryDirectoryInterface dir = repositoryTree.findDirectory(str);
                    if (dir != null) {
                        // 
                        // What's the new name of the directory?
                        // 
                        String oldName = dir.getName();
                        EnterStringDialog etd = new EnterStringDialog(shell, oldName, BaseMessages.getString(PKG, "SelectDirectoryDialog.Dialog.EnterDirectoryNewName.Message"), BaseMessages.getString(PKG, "SelectDirectoryDialog.Dialog.EnterDirectoryNewName.Title"));
                        String newName = etd.open();
                        if (newName != null && !newName.equals(oldName)) {
                            dir.setName(newName);
                            try {
                                rep.renameRepositoryDirectory(dir.getObjectId(), dir.getParent(), newName);
                                ti.setText(newName);
                                wTree.setSelection(ti);
                            } catch (Exception exception) {
                                new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Directory.Rename.UnexpectedError.Message1") + oldName + "]" + Const.CR + BaseMessages.getString(PKG, "RepositoryExplorerDialog.Directory.Rename.UnexpectedError.Message2"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Directory.Rename.UnexpectedError.Title"), exception);
                            }
                        }
                    }
                }
            }
        });
        MenuItem miDel = new MenuItem(mTree, SWT.CASCADE);
        miDel.setText(BaseMessages.getString(PKG, "SelectDirectoryDialog.PopupMenu.Directory.Delete"));
        miDel.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                if (!readOnly) {
                    TreeItem ti = wTree.getSelection()[0];
                    String[] str = ConstUI.getTreeStrings(ti);
                    RepositoryDirectoryInterface dir = repositoryTree.findDirectory(str);
                    if (dir != null) {
                        try {
                            rep.deleteRepositoryDirectory(dir);
                            ti.dispose();
                        } catch (KettleException exception) {
                            new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Directory.Delete.ErrorRemoving.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Directory.Delete.ErrorRemoving.Message1"), exception);
                        }
                    }
                }
            }
        });
    }
    wTree.setMenu(mTree);
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) KettleException(org.pentaho.di.core.exception.KettleException) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) TreeItem(org.eclipse.swt.widgets.TreeItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) MenuItem(org.eclipse.swt.widgets.MenuItem) EnterStringDialog(org.pentaho.di.ui.core.dialog.EnterStringDialog) KettleException(org.pentaho.di.core.exception.KettleException) MessageBox(org.eclipse.swt.widgets.MessageBox) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu)

Aggregations

EnterStringDialog (org.pentaho.di.ui.core.dialog.EnterStringDialog)9 MessageBox (org.eclipse.swt.widgets.MessageBox)6 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)5 KettleException (org.pentaho.di.core.exception.KettleException)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 FileDialog (org.eclipse.swt.widgets.FileDialog)2 FileInputList (org.pentaho.di.core.fileinput.FileInputList)2 RepositoryDirectory (org.pentaho.di.repository.RepositoryDirectory)2 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)2 GetXMLDataMeta (org.pentaho.di.trans.steps.getxmldata.GetXMLDataMeta)2 EnterTextDialog (org.pentaho.di.ui.core.dialog.EnterTextDialog)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 CCombo (org.eclipse.swt.custom.CCombo)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 FocusAdapter (org.eclipse.swt.events.FocusAdapter)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1