Search in sources :

Example 1 with SelectDirectoryDialog

use of org.pentaho.di.ui.repository.dialog.SelectDirectoryDialog in project pentaho-kettle by pentaho.

the class RepositoryDirectoryUI method chooseDirectory.

public static RepositoryDirectoryInterface chooseDirectory(Shell shell, Repository rep, RepositoryDirectoryInterface directoryFrom) {
    if (rep == null) {
        return null;
    }
    if (directoryFrom == null) {
        try {
            directoryFrom = rep.getUserHomeDirectory();
        } catch (KettleException ex) {
            directoryFrom = new RepositoryDirectory();
        }
    }
    ObjectId idDirectoryFrom = directoryFrom.getObjectId();
    SelectDirectoryDialog sdd = new SelectDirectoryDialog(shell, SWT.NONE, rep);
    // PDI-13867: root dir and its direct subdirectories are restricted.
    HashSet<String> restrictedPaths = new HashSet<String>();
    restrictedPaths.add(directoryFrom.findRoot().getPath());
    restrictedPaths.add("/home");
    sdd.setRestrictedPaths(restrictedPaths);
    // TODO: expand and select directoryFrom in the dialog.
    RepositoryDirectoryInterface rd = sdd.open();
    if (rd == null || idDirectoryFrom == rd.getObjectId()) {
        return null;
    }
    return rd;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) ObjectId(org.pentaho.di.repository.ObjectId) SelectDirectoryDialog(org.pentaho.di.ui.repository.dialog.SelectDirectoryDialog) HashSet(java.util.HashSet)

Example 2 with SelectDirectoryDialog

use of org.pentaho.di.ui.repository.dialog.SelectDirectoryDialog in project pentaho-kettle by pentaho.

the class GetRepositoryNamesDialog method displaydirectoryList.

private void displaydirectoryList() {
    try {
        if (repository == null) {
            throw new KettleException(BaseMessages.getString(PKG, "GetRepositoryNames.Exception.NotConnectedToRepository"));
        }
        SelectDirectoryDialog sdd = new SelectDirectoryDialog(shell, SWT.NONE, repository);
        RepositoryDirectoryInterface rd = sdd.open();
        if (rd != null) {
            wDirectory.setText(rd.getPath());
        }
    } catch (Exception e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "GetRepositoryNames.ErrorGettingFolderds.DialogMessage"), e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) SelectDirectoryDialog(org.pentaho.di.ui.repository.dialog.SelectDirectoryDialog) KettleException(org.pentaho.di.core.exception.KettleException)

Example 3 with SelectDirectoryDialog

use of org.pentaho.di.ui.repository.dialog.SelectDirectoryDialog in project pentaho-kettle by pentaho.

the class Spoon method importDirectoryToRepository.

public void importDirectoryToRepository() {
    FileDialog dialog = new FileDialog(shell, SWT.OPEN | SWT.MULTI);
    dialog.setText(BaseMessages.getString(PKG, "Spoon.SelectAnXMLFileToImportFrom.Message"));
    if (dialog.open() == null) {
        return;
    }
    // Ask for a set of import rules
    // 
    MessageBox box = new MessageBox(shell, SWT.ICON_QUESTION | SWT.APPLICATION_MODAL | SWT.SHEET | SWT.YES | SWT.NO | SWT.CANCEL);
    box.setText(BaseMessages.getString(PKG, "Spoon.QuestionApplyImportRules.Title"));
    box.setMessage(BaseMessages.getString(PKG, "Spoon.QuestionApplyImportRules.Message"));
    int answer = box.open();
    if (answer == SWT.CANCEL) {
        return;
    }
    // Get the import rules
    // 
    ImportRules importRules = new ImportRules();
    if (answer == SWT.YES) {
        ImportRulesDialog importRulesDialog = new ImportRulesDialog(shell, importRules);
        if (!importRulesDialog.open()) {
            return;
        }
    }
    // Ask for a destination in the repository...
    // 
    SelectDirectoryDialog sdd = new SelectDirectoryDialog(shell, SWT.NONE, rep);
    RepositoryDirectoryInterface baseDirectory = sdd.open();
    if (baseDirectory == null) {
        return;
    }
    // Finally before importing, ask for a version comment (if applicable)
    // 
    String fullPath = baseDirectory.getPath() + "/foo.ktr";
    String versionComment = null;
    boolean versionOk = false;
    while (!versionOk) {
        versionComment = RepositorySecurityUI.getVersionComment(shell, rep, "Import of files into [" + baseDirectory.getPath() + "]", fullPath, true);
        // if the version comment is null, the user hit cancel, exit.
        if (versionComment == null) {
            return;
        }
        if (Utils.isEmpty(versionComment) && rep.getSecurityProvider().isVersionCommentMandatory()) {
            if (!RepositorySecurityUI.showVersionCommentMandatoryDialog(shell)) {
                versionOk = true;
            }
        } else {
            versionOk = true;
        }
    }
    String[] filenames = dialog.getFileNames();
    if (filenames.length > 0) {
        RepositoryImportProgressDialog ripd = new RepositoryImportProgressDialog(shell, SWT.NONE, rep, dialog.getFilterPath(), filenames, baseDirectory, versionComment, importRules);
        ripd.open();
        refreshTree();
    }
}
Also used : ImportRules(org.pentaho.di.imp.ImportRules) RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) ImportRulesDialog(org.pentaho.di.ui.imp.ImportRulesDialog) RepositoryImportProgressDialog(org.pentaho.di.ui.repository.dialog.RepositoryImportProgressDialog) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) KettlePropertiesFileDialog(org.pentaho.di.ui.core.dialog.KettlePropertiesFileDialog) FileDialog(org.eclipse.swt.widgets.FileDialog) SelectDirectoryDialog(org.pentaho.di.ui.repository.dialog.SelectDirectoryDialog) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 4 with SelectDirectoryDialog

use of org.pentaho.di.ui.repository.dialog.SelectDirectoryDialog in project pentaho-kettle by pentaho.

the class CopyTableWizardPage3 method createControl.

public void createControl(Composite parent) {
    shell = parent.getShell();
    int margin = Const.MARGIN;
    int middle = props.getMiddlePct();
    ModifyListener lsMod = new ModifyListener() {

        public void modifyText(ModifyEvent arg0) {
            setPageComplete(canFlipToNextPage());
        }
    };
    // create the composite to hold the widgets
    Composite composite = new Composite(parent, SWT.NONE);
    props.setLook(composite);
    FormLayout compLayout = new FormLayout();
    compLayout.marginHeight = Const.FORM_MARGIN;
    compLayout.marginWidth = Const.FORM_MARGIN;
    composite.setLayout(compLayout);
    // Job name:
    wlTransname = new Label(composite, SWT.RIGHT);
    wlTransname.setText(BaseMessages.getString(PKG, "CopyTableWizardPage3.Dialog.JobName.Label"));
    props.setLook(wlTransname);
    fdlTransname = new FormData();
    fdlTransname.left = new FormAttachment(0, 0);
    fdlTransname.right = new FormAttachment(middle, -margin);
    fdlTransname.top = new FormAttachment(0, margin);
    wlTransname.setLayoutData(fdlTransname);
    wTransname = new Text(composite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wTransname);
    wTransname.addModifyListener(lsMod);
    fdTransname = new FormData();
    fdTransname.left = new FormAttachment(middle, 0);
    fdTransname.top = new FormAttachment(0, margin);
    fdTransname.right = new FormAttachment(100, 0);
    wTransname.setLayoutData(fdTransname);
    // Directory:
    wlDirectory = new Label(composite, SWT.RIGHT);
    wlDirectory.setText(BaseMessages.getString(PKG, "CopyTableWizardPage3.Dialog.Directory.Label"));
    props.setLook(wlDirectory);
    fdlDirectory = new FormData();
    fdlDirectory.left = new FormAttachment(0, 0);
    fdlDirectory.right = new FormAttachment(middle, -margin);
    fdlDirectory.top = new FormAttachment(wTransname, margin);
    wlDirectory.setLayoutData(fdlDirectory);
    wbDirectory = new Button(composite, SWT.PUSH);
    wbDirectory.setText(BaseMessages.getString(PKG, "CopyTableWizardPage3.Dialog.DirectoryButton.Label"));
    props.setLook(wbDirectory);
    fdbDirectory = new FormData();
    fdbDirectory.right = new FormAttachment(100, 0);
    fdbDirectory.top = new FormAttachment(wTransname, margin);
    wbDirectory.setLayoutData(fdbDirectory);
    wbDirectory.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            SelectDirectoryDialog sdd = new SelectDirectoryDialog(shell, SWT.NONE, rep);
            directory = sdd.open();
            if (directory != null) {
                wDirectory.setText(directory.getPath());
                setPageComplete(canFlipToNextPage());
            }
        }
    });
    wDirectory = new Text(composite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wDirectory);
    wDirectory.setEditable(false);
    fdDirectory = new FormData();
    fdDirectory.left = new FormAttachment(middle, 0);
    fdDirectory.top = new FormAttachment(wTransname, margin);
    fdDirectory.right = new FormAttachment(wbDirectory, 0);
    wDirectory.setLayoutData(fdDirectory);
    // set the composite as the control for this page
    setControl(composite);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ModifyListener(org.eclipse.swt.events.ModifyListener) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) SelectDirectoryDialog(org.pentaho.di.ui.repository.dialog.SelectDirectoryDialog) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 5 with SelectDirectoryDialog

use of org.pentaho.di.ui.repository.dialog.SelectDirectoryDialog in project pentaho-kettle by pentaho.

the class RipDatabaseWizardPage3 method createControl.

public void createControl(Composite parent) {
    shell = parent.getShell();
    int margin = Const.MARGIN;
    int middle = props.getMiddlePct();
    ModifyListener lsMod = new ModifyListener() {

        public void modifyText(ModifyEvent arg0) {
            setPageComplete(canFlipToNextPage());
        }
    };
    // create the composite to hold the widgets
    Composite composite = new Composite(parent, SWT.NONE);
    props.setLook(composite);
    FormLayout compLayout = new FormLayout();
    compLayout.marginHeight = Const.FORM_MARGIN;
    compLayout.marginWidth = Const.FORM_MARGIN;
    composite.setLayout(compLayout);
    // Job name:
    wlJobname = new Label(composite, SWT.RIGHT);
    wlJobname.setText("Job name :");
    props.setLook(wlJobname);
    fdlJobname = new FormData();
    fdlJobname.left = new FormAttachment(0, 0);
    fdlJobname.right = new FormAttachment(middle, -margin);
    fdlJobname.top = new FormAttachment(0, margin);
    wlJobname.setLayoutData(fdlJobname);
    wJobname = new Text(composite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wJobname);
    wJobname.addModifyListener(lsMod);
    fdJobname = new FormData();
    fdJobname.left = new FormAttachment(middle, 0);
    fdJobname.top = new FormAttachment(0, margin);
    fdJobname.right = new FormAttachment(100, 0);
    wJobname.setLayoutData(fdJobname);
    // Directory:
    wlDirectory = new Label(composite, SWT.RIGHT);
    wlDirectory.setText("Directory :");
    props.setLook(wlDirectory);
    fdlDirectory = new FormData();
    fdlDirectory.left = new FormAttachment(0, 0);
    fdlDirectory.right = new FormAttachment(middle, -margin);
    fdlDirectory.top = new FormAttachment(wJobname, margin);
    wlDirectory.setLayoutData(fdlDirectory);
    wbDirectory = new Button(composite, SWT.PUSH);
    wbDirectory.setText("...");
    props.setLook(wbDirectory);
    fdbDirectory = new FormData();
    fdbDirectory.right = new FormAttachment(100, 0);
    fdbDirectory.top = new FormAttachment(wJobname, margin);
    wbDirectory.setLayoutData(fdbDirectory);
    wbDirectory.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            if (rep != null) {
                SelectDirectoryDialog sdd = new SelectDirectoryDialog(shell, SWT.NONE, rep);
                repositoryDirectory = sdd.open();
                if (repositoryDirectory != null) {
                    wDirectory.setText(repositoryDirectory.getPath());
                    setPageComplete(canFlipToNextPage());
                }
            } else {
                DirectoryDialog directoryDialog = new DirectoryDialog(shell, SWT.NONE);
                directoryDialog.setFilterPath(wDirectory.getText());
                directoryDialog.setText("Select a target directory");
                directoryDialog.setMessage("Select the target directory of the job and transformations:");
                String target = directoryDialog.open();
                if (target != null) {
                    wDirectory.setText(target);
                    directory = target;
                    setPageComplete(canFlipToNextPage());
                }
            }
        }
    });
    wDirectory = new Text(composite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wDirectory);
    wDirectory.setEditable(false);
    fdDirectory = new FormData();
    fdDirectory.left = new FormAttachment(middle, 0);
    fdDirectory.top = new FormAttachment(wJobname, margin);
    fdDirectory.right = new FormAttachment(wbDirectory, 0);
    wDirectory.setLayoutData(fdDirectory);
    // set the composite as the control for this page
    setControl(composite);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ModifyListener(org.eclipse.swt.events.ModifyListener) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) SelectDirectoryDialog(org.pentaho.di.ui.repository.dialog.SelectDirectoryDialog) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) SelectDirectoryDialog(org.pentaho.di.ui.repository.dialog.SelectDirectoryDialog) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Aggregations

SelectDirectoryDialog (org.pentaho.di.ui.repository.dialog.SelectDirectoryDialog)5 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)3 ModifyEvent (org.eclipse.swt.events.ModifyEvent)2 ModifyListener (org.eclipse.swt.events.ModifyListener)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 FormAttachment (org.eclipse.swt.layout.FormAttachment)2 FormData (org.eclipse.swt.layout.FormData)2 FormLayout (org.eclipse.swt.layout.FormLayout)2 Button (org.eclipse.swt.widgets.Button)2 Composite (org.eclipse.swt.widgets.Composite)2 Label (org.eclipse.swt.widgets.Label)2 Text (org.eclipse.swt.widgets.Text)2 KettleException (org.pentaho.di.core.exception.KettleException)2 HashSet (java.util.HashSet)1 DirectoryDialog (org.eclipse.swt.widgets.DirectoryDialog)1 FileDialog (org.eclipse.swt.widgets.FileDialog)1 MessageBox (org.eclipse.swt.widgets.MessageBox)1 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)1 Point (org.pentaho.di.core.gui.Point)1