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;
}
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);
}
}
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();
}
}
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);
}
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);
}
Aggregations