use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class RepositoryExplorerDialog method restoreSelectedObjects.
public boolean restoreSelectedObjects() {
TreeItem[] items = wTree.getSelection();
boolean error = false;
for (int i = 0; i < items.length; i++) {
final RepositoryElementMetaInterface repositoryObject = objectMap.get(ConstUI.getTreePath(items[i], 0));
if (repositoryObject != null) {
try {
rep.undeleteObject(repositoryObject);
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Trans.Delete.ErrorRestoring.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Trans.Delete.ErrorRestoring.Message"), e);
error = true;
}
}
}
refreshTree();
return !error;
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class RepositoryExplorerDialog method moveJob.
public boolean moveJob(String xml, RepositoryDirectoryInterface repdir) {
debug = "Move Job";
boolean retval = false;
try {
debug = "parse xml";
Document doc = XMLHandler.loadXMLString(xml);
String dirname = XMLHandler.getTagValue(doc, "dragdrop", "directory");
String jobname = XMLHandler.getTagValue(doc, "dragdrop", "job");
if (dirname != null && jobname != null) {
debug = "dirname=" + dirname + ", jobname=" + jobname;
// OK, find this transformation...
RepositoryDirectoryInterface fromdir = directoryTree.findDirectory(dirname);
if (fromdir != null) {
debug = "fromdir found: move job!";
ObjectId existingjobID = rep.getJobId(jobname, repdir);
if (existingjobID == null) {
ObjectId id = rep.getJobId(jobname, fromdir);
rep.renameJob(id, repdir, jobname);
retval = true;
} else {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Job.Move.ErrorDuplicate.Message", jobname) + Const.CR);
mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Job.Move.ErrorDuplicate.Title"));
mb.open();
}
} else {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Job.Move.ErrorMoving.Message") + dirname + "]" + Const.CR);
mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Job.Move.ErrorMoving.Title"));
mb.open();
}
}
} catch (Exception dbe) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Job.Move.UnexpectedError.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Trans.Move.UnexpectedError.Message"), dbe);
}
return retval;
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class RepositoryExplorerDialog method exportTransformations.
public void exportTransformations(RepositoryDirectoryInterface root) {
try {
DirectoryDialog dialog = new DirectoryDialog(shell, SWT.OPEN);
if (dialog.open() != null) {
String directory = dialog.getFilterPath();
ObjectId[] dirids = ((root == null) ? directoryTree : root).getDirectoryIDs();
for (int d = 0; d < dirids.length; d++) {
RepositoryDirectoryInterface repdir = directoryTree.findDirectory(dirids[d]);
String[] trans = rep.getTransformationNames(dirids[d], false);
// See if the directory exists...
File dir = new File(directory + repdir.getPath());
if (!dir.exists()) {
dir.mkdir();
log.logBasic("Exporting transformation", "Created directory [" + dir.getName() + "]");
}
for (int i = 0; i < trans.length; i++) {
// reads last version
TransMeta ti = rep.loadTransformation(trans[i], repdir, null, true, null);
if (log.isBasic()) {
log.logBasic("Exporting transformation", "[" + trans[i] + "] in directory [" + repdir.getPath() + "]");
}
String xml = XMLHandler.getXMLHeader() + ti.getXML();
String filename = directory + repdir.getPath() + Const.FILE_SEPARATOR + fixFileName(trans[i]) + ".ktr";
File f = new File(filename);
try {
FileOutputStream fos = new FileOutputStream(f);
fos.write(xml.getBytes(Const.XML_ENCODING));
fos.close();
} catch (IOException e) {
throw new RuntimeException("Exporting transformation: Couldn't create file [" + filename + "]", e);
}
}
}
}
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.ExportTrans.UnexpectedError.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.ExportTrans.UnexpectedError.Message"), e);
}
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class RepositoryExplorerDialog method delSelectedObjects.
public boolean delSelectedObjects() {
TreeItem[] items = wTree.getSelection();
boolean error = false;
MessageBox mb = new MessageBox(shell, SWT.ICON_WARNING | SWT.YES | SWT.NO);
mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Trans.Delete.Confirm.Message1") + (items.length > 1 ? BaseMessages.getString(PKG, "RepositoryExplorerDialog.Trans.Delete.Confirm.Message2") + items.length + BaseMessages.getString(PKG, "RepositoryExplorerDialog.Trans.Delete.Confirm.Message3") : BaseMessages.getString(PKG, "RepositoryExplorerDialog.Trans.Delete.Confirm.Message4")));
mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Trans.Delete.Confirm.Title"));
int answer = mb.open();
if (answer != SWT.YES) {
return false;
}
for (int i = 0; i < items.length; i++) {
final RepositoryElementMetaInterface repositoryObject = objectMap.get(ConstUI.getTreePath(items[i], 0));
if (repositoryObject != null) {
try {
switch(repositoryObject.getObjectType()) {
case TRANSFORMATION:
rep.deleteTransformation(repositoryObject.getObjectId());
break;
case JOB:
rep.deleteJob(repositoryObject.getObjectId());
break;
default:
break;
}
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Trans.Delete.ErrorRemoving.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Trans.Delete.ErrorRemoving.Message") + repositoryObject.getName() + "]", e);
error = true;
}
}
}
refreshTree();
return !error;
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class RepositoryExplorerDialog method delDatabase.
public void delDatabase(String databasename) {
try {
rep.deleteDatabaseMeta(databasename);
refreshTree();
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Delete.UnexpectedError.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Delete.UnexpectedError.Message"), e);
}
}
Aggregations