use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class RepositoryExplorerDialog method renameUser.
public boolean renameUser(String name, String newname) {
boolean retval = false;
try {
if (Utils.isEmpty(newname)) {
throw new KettleException(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Exception.NameCanNotBeEmpty"));
}
if (!name.equals(newname)) {
ObjectId id = securityManager.getUserID(name);
if (id != null) {
// System.out.println("Renaming user ["+name+"] with ID = "+id);
securityManager.renameUser(id, newname);
retval = true;
} else {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.User.Rename.ErrorFinding.Message1") + name + "]" + Const.CR + BaseMessages.getString(PKG, "RepositoryExplorerDialog.User.Rename.ErrorFinding.Message2"));
mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.User.Rename.ErrorFinding.Title"));
mb.open();
}
}
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.User.Rename.UnexpectedError.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.User.Rename.UnexpectedError.Message") + name + "]", e);
}
return retval;
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class SelectDirectoryDialog method open.
@SuppressWarnings("deprecation")
public RepositoryDirectoryInterface open() {
dircolor = GUIResource.getInstance().getColorDirectory();
Shell parent = getParent();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
props.setLook(shell);
shell.setImage(GUIResource.getInstance().getImageSpoon());
shell.setText(BaseMessages.getString(PKG, "SelectDirectoryDialog.Dialog.Main.Title"));
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
// Tree
wTree = new Tree(shell, SWT.SINGLE | SWT.BORDER);
props.setLook(wTree);
try {
if (rep instanceof RepositoryExtended) {
RepositoryExtended repositoryExtended = (RepositoryExtended) this.rep;
repositoryTree = repositoryExtended.loadRepositoryDirectoryTree("/", null, -1, BooleanUtils.isTrue(repositoryExtended.getUserInfo().isAdmin()), true, false);
} else {
repositoryTree = this.rep.loadRepositoryDirectoryTree();
}
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "SelectDirectoryDialog.Dialog.ErrorRefreshingDirectoryTree.Title"), BaseMessages.getString(PKG, "SelectDirectoryDialog.Dialog.ErrorRefreshingDirectoryTree.Message"), e);
return null;
}
if (!getData()) {
return null;
}
// Buttons
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wRefresh = new Button(shell, SWT.PUSH);
wRefresh.setText(BaseMessages.getString(PKG, "System.Button.Refresh"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
FormData fdTree = new FormData();
FormData fdOK = new FormData();
FormData fdRefresh = new FormData();
FormData fdCancel = new FormData();
int margin = 10;
// To the right of the label
fdTree.left = new FormAttachment(0, 0);
fdTree.top = new FormAttachment(0, 0);
fdTree.right = new FormAttachment(100, 0);
fdTree.bottom = new FormAttachment(100, -50);
wTree.setLayoutData(fdTree);
fdOK.left = new FormAttachment(wTree, 0, SWT.CENTER);
fdOK.bottom = new FormAttachment(100, -margin);
wOK.setLayoutData(fdOK);
fdRefresh.left = new FormAttachment(wOK, 10);
fdRefresh.bottom = new FormAttachment(100, -margin);
wRefresh.setLayoutData(fdRefresh);
fdCancel.left = new FormAttachment(wRefresh, 10);
fdCancel.bottom = new FormAttachment(100, -margin);
wCancel.setLayoutData(fdCancel);
// Add listeners
wCancel.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
dispose();
}
});
// Add listeners
wOK.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
handleOK();
}
});
wTree.addSelectionListener(new SelectionAdapter() {
private String getSelectedPath(SelectionEvent selectionEvent) {
TreeItem treeItem = (TreeItem) selectionEvent.item;
String path;
if (treeItem.getParentItem() == null) {
path = treeItem.getText();
} else {
path = ConstUI.getTreePath(treeItem, 0);
}
return path;
}
private boolean isSelectedPathRestricted(SelectionEvent selectionEvent) {
String path = getSelectedPath(selectionEvent);
boolean isRestricted = isRestrictedPath(path);
return isRestricted;
}
public void widgetDefaultSelected(SelectionEvent selectionEvent) {
if (isSelectedPathRestricted(selectionEvent)) {
return;
}
handleOK();
}
public void widgetSelected(SelectionEvent selectionEvent) {
boolean restricted = isSelectedPathRestricted(selectionEvent);
wOK.setEnabled(!restricted);
}
});
wRefresh.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
getData();
}
});
wTree.addMenuDetectListener(new MenuDetectListener() {
public void menuDetected(MenuDetectEvent e) {
setTreeMenu();
}
});
BaseStepDialog.setSize(shell);
shell.open();
Display display = parent.getDisplay();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return selection;
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class JobEntryTransDialog method getByReferenceData.
private void getByReferenceData(ObjectId transObjectId) {
try {
RepositoryObject transInf = rep.getObjectInformation(transObjectId, RepositoryObjectType.TRANSFORMATION);
String path = DialogUtils.getPath(jobMeta.getRepositoryDirectory().getPath(), transInf.getRepositoryDirectory().getPath());
String fullPath = Const.NVL(path, "") + "/" + Const.NVL(transInf.getName(), "");
wPath.setText(fullPath);
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "JobEntryTransDialog.Exception.UnableToReferenceObjectId.Title"), BaseMessages.getString(PKG, "JobEntryTransDialog.Exception.UnableToReferenceObjectId.Message"), e);
}
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class RepositoryExplorerDialog method editSlaveServer.
public void editSlaveServer(String slaveName) {
try {
ObjectId id = rep.getSlaveID(slaveName);
// Load the last version
SlaveServer slaveServer = rep.loadSlaveServer(id, null);
SlaveServerDialog dd = new SlaveServerDialog(shell, slaveServer);
if (dd.open()) {
rep.insertLogEntry("Updating slave server '" + slaveServer.getName() + "'");
rep.save(slaveServer, Const.VERSION_COMMENT_EDIT_VERSION, null);
if (!slaveName.equalsIgnoreCase(slaveServer.getName())) {
refreshTree();
}
}
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.Edit.UnexpectedError.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.Edit.UnexpectedError.Message") + slaveName + "]", e);
}
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class RepositoryExplorerDialog method renameJob.
public boolean renameJob(String name, RepositoryDirectoryInterface repdir, String newname) {
boolean retval = false;
try {
if (Utils.isEmpty(newname)) {
throw new KettleException(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Exception.NameCanNotBeEmpty"));
}
if (!name.equals(newname)) {
ObjectId id = rep.getJobId(name, repdir);
if (id != null) {
// System.out.println("Renaming transformation ["+name+"] with ID = "+id);
String comment = BaseMessages.getString(REPOSITORY_PKG, "Repository.Rename", name, newname);
rep.renameJob(id, comment, repdir, newname);
retval = true;
} else {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Job.Rename.ErrorFinding.Message1") + name + "]" + Const.CR + BaseMessages.getString(PKG, "RepositoryExplorerDialog.Job.Rename.ErrorFinding.Message2"));
mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Job.Rename.ErrorFinding.Title"));
mb.open();
}
}
} catch (KettleException dbe) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Job.Rename.UnexpectedError.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Job.Rename.UnexpectedError.Message") + name + "]", dbe);
}
return retval;
}
Aggregations