use of org.pentaho.di.ui.repository.dialog.RepositoryImportProgressDialog 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();
}
}
Aggregations