use of org.pentaho.ui.xul.XulComponent in project pentaho-kettle by pentaho.
the class SpoonPerspectiveManager method removePerspective.
public void removePerspective(SpoonPerspective per) {
perspectives.remove(per);
orderedPerspectives.remove(per);
Document document = domContainer.getDocumentRoot();
XulComponent comp = document.getElementById("perspective-" + per.getId());
comp.getParent().removeChild(comp);
comp = document.getElementById("perspective-btn-" + per.getId());
comp.getParent().removeChild(comp);
XulToolbar mainToolbar = (XulToolbar) domContainer.getDocumentRoot().getElementById("main-toolbar");
((Composite) mainToolbar.getManagedObject()).layout(true, true);
deck.setSelectedIndex(0);
}
use of org.pentaho.ui.xul.XulComponent in project pentaho-kettle by pentaho.
the class SpoonLockController method lockContent.
public void lockContent() throws Exception {
try {
if (workingMeta != null && workingMeta.getObjectId() != null && supportsLocking(Spoon.getInstance().getRepository())) {
// Look in the SpoonTransformationDelegate for details on the TabItem creation
if (!tabBound) {
bindingFactory.createBinding(this, "activeMetaUnlocked", Spoon.getInstance().delegates.tabs.findTabMapEntry(workingMeta).getTabItem(), "image", new // $NON-NLS-1$ //$NON-NLS-2$
BindingConvertor<Boolean, Image>() {
@Override
public Image sourceToTarget(Boolean activeMetaUnlocked) {
if (activeMetaUnlocked) {
if (workingMeta instanceof TransMeta) {
return GUIResource.getInstance().getImageTransGraph();
} else if (workingMeta instanceof JobMeta) {
return GUIResource.getInstance().getImageJobGraph();
}
} else {
return GUIResource.getInstance().getImageLocked();
}
return null;
}
@Override
public Boolean targetToSource(Image arg0) {
return false;
}
});
tabBound = true;
}
// Decide whether to lock or unlock the object
if (fetchRepositoryLock(workingMeta) == null) {
// Lock the object (it currently is NOT locked)
XulPromptBox lockNotePrompt = promptLockMessage(document, messages, null);
lockNotePrompt.addDialogCallback(new XulDialogCallback<String>() {
public void onClose(XulComponent component, Status status, String value) {
if (!status.equals(Status.CANCEL)) {
try {
if (workingMeta instanceof TransMeta) {
getService(Spoon.getInstance().getRepository()).lockTransformation(workingMeta.getObjectId(), value);
} else if (workingMeta instanceof JobMeta) {
getService(Spoon.getInstance().getRepository()).lockJob(workingMeta.getObjectId(), value);
}
// Execute binding. Notify listeners that the object is now locked
// $NON-NLS-1$ //$NON-NLS-2$
firePropertyChange("activeMetaUnlocked", true, false);
// this keeps the menu item and the state in sync
// could a binding be used instead?
XulDomContainer container = getXulDomContainer();
XulMenuitem lockMenuItem = // $NON-NLS-1$
(XulMenuitem) container.getDocumentRoot().getElementById("lock-context-lock");
lockMenuItem.setSelected(true);
} catch (Exception e) {
// convert to runtime exception so it bubbles up through the UI
throw new RuntimeException(e);
}
} else {
// this keeps the menu item and the state in sync
// could a binding be used instead?
XulDomContainer container = getXulDomContainer();
XulMenuitem lockMenuItem = // $NON-NLS-1$
(XulMenuitem) container.getDocumentRoot().getElementById("lock-context-lock");
lockMenuItem.setSelected(false);
}
}
public void onError(XulComponent component, Throwable err) {
throw new RuntimeException(err);
}
});
lockNotePrompt.open();
} else {
// Unlock the object (it currently IS locked)
if (workingMeta instanceof TransMeta) {
getService(Spoon.getInstance().getRepository()).unlockTransformation(workingMeta.getObjectId());
} else if (workingMeta instanceof JobMeta) {
getService(Spoon.getInstance().getRepository()).unlockJob(workingMeta.getObjectId());
}
// Execute binding. Notify listeners that the object is now unlocked
// $NON-NLS-1$ //$NON-NLS-2$
firePropertyChange("activeMetaUnlocked", false, true);
}
} else if (workingMeta != null && workingMeta.getObjectId() == null && supportsLocking(Spoon.getInstance().getRepository())) {
XulDomContainer container = getXulDomContainer();
// $NON-NLS-1$
XulMenuitem lockMenuItem = (XulMenuitem) container.getDocumentRoot().getElementById("lock-context-lock");
lockMenuItem.setSelected(false);
// $NON-NLS-1$
XulMessageBox msgBox = (XulMessageBox) document.createElement("messagebox");
// $NON-NLS-1$
msgBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
// $NON-NLS-1$
msgBox.setMessage(BaseMessages.getString(PKG, "LockController.SaveBeforeLock"));
msgBox.setModalParent(shell);
msgBox.open();
} else {
XulDomContainer container = getXulDomContainer();
// $NON-NLS-1$
XulMenuitem lockMenuItem = (XulMenuitem) container.getDocumentRoot().getElementById("lock-context-lock");
lockMenuItem.setSelected(false);
// $NON-NLS-1$
XulMessageBox msgBox = (XulMessageBox) document.createElement("messagebox");
// $NON-NLS-1$
msgBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
// $NON-NLS-1$
msgBox.setMessage(BaseMessages.getString(PKG, "LockController.NoLockingSupport"));
msgBox.setModalParent(shell);
msgBox.open();
}
} catch (Throwable th) {
// $NON-NLS-1$
log.error(BaseMessages.getString(PKG, "LockController.NoLockingSupport"), th);
new ErrorDialog(((Spoon) SpoonFactory.getInstance()).getShell(), BaseMessages.getString(PKG, "Dialog.Error"), BaseMessages.getString(PKG, "LockController.NoLockingSupport"), // $NON-NLS-1$ //$NON-NLS-2$
th);
}
}
use of org.pentaho.ui.xul.XulComponent in project pentaho-kettle by pentaho.
the class AbstractPermissionsController method init.
protected void init(Repository rep) throws Exception {
if (rep != null && rep.hasService(RepositorySecurityProvider.class)) {
service = (RepositorySecurityProvider) rep.getService(RepositorySecurityProvider.class);
} else {
throw new ControllerInitializationException(BaseMessages.getString(PKG, "PermissionsController.ERROR_0001_UNABLE_TO_INITIAL_REPOSITORY_SERVICE", // $NON-NLS-1$
RepositorySecurityManager.class));
}
// $NON-NLS-1$
messageBox = (XulMessageBox) document.createElement("messagebox");
viewAclsModel = new UIRepositoryObjectAcls();
manageAclsModel = new UIRepositoryObjectAclModel(viewAclsModel);
bf = new DefaultBindingFactory();
bf.setDocument(this.getXulDomContainer().getDocumentRoot());
mainController = (MainController) this.getXulDomContainer().getEventHandler("mainController");
// $NON-NLS-1$
confirmBox = (XulConfirmBox) document.createElement("confirmbox");
// $NON-NLS-1$
confirmBox.setTitle(BaseMessages.getString(PKG, "PermissionsController.RemoveAclWarning"));
// $NON-NLS-1$
confirmBox.setMessage(BaseMessages.getString(PKG, "PermissionsController.RemoveAclWarningText"));
// $NON-NLS-1$
confirmBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
// $NON-NLS-1$
confirmBox.setCancelLabel(BaseMessages.getString(PKG, "Dialog.Cancel"));
confirmBox.addDialogCallback(new XulDialogCallback<Object>() {
public void onClose(XulComponent sender, Status returnCode, Object retVal) {
if (returnCode == Status.ACCEPT) {
viewAclsModel.removeSelectedAcls();
}
}
public void onError(XulComponent sender, Throwable t) {
}
});
}
use of org.pentaho.ui.xul.XulComponent in project pentaho-kettle by pentaho.
the class EESecurityController method removeRole.
/**
* removeRole method is called when user has click on a remove button in a role deck. It first displays a confirmation
* message to the user and once the user selects ok, it remove the role
*
* @throws Exception
*/
public void removeRole() throws Exception {
// $NON-NLS-1$
XulConfirmBox confirmBox = (XulConfirmBox) document.createElement("confirmbox");
// $NON-NLS-1$
confirmBox.setTitle(BaseMessages.getString(PKG, "ConfirmDialog.Title"));
// $NON-NLS-1$
confirmBox.setMessage(BaseMessages.getString(PKG, "RemoveRoleConfirmDialog.Message"));
// $NON-NLS-1$
confirmBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
// $NON-NLS-1$
confirmBox.setCancelLabel(BaseMessages.getString(PKG, "Dialog.Cancel"));
confirmBox.addDialogCallback(new XulDialogCallback<Object>() {
public void onClose(XulComponent sender, Status returnCode, Object retVal) {
if (returnCode == Status.ACCEPT) {
if (service != null) {
if (eeSecurity != null && eeSecurity.getSelectedRole() != null) {
try {
((IRoleSupportSecurityManager) service).deleteRole(eeSecurity.getSelectedRole().getName());
eeSecurity.removeRole(eeSecurity.getSelectedRole().getName());
} catch (Throwable th) {
// $NON-NLS-1$
messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
// $NON-NLS-1$
messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
messageBox.setMessage(BaseMessages.getString(PKG, "RemoveRole.UnableToRemoveRole", // $NON-NLS-1$
th.getLocalizedMessage()));
messageBox.open();
}
} else {
// $NON-NLS-1$
messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
// $NON-NLS-1$
messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
// $NON-NLS-1$
messageBox.setMessage(BaseMessages.getString(PKG, "RemoveRole.NoRoleSelected"));
messageBox.open();
}
}
}
}
public void onError(XulComponent sender, Throwable t) {
if (mainController == null || !mainController.handleLostRepository(t)) {
// $NON-NLS-1$
messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
// $NON-NLS-1$
messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
messageBox.setMessage(// $NON-NLS-1$
BaseMessages.getString(PKG, "RemoveRole.UnableToRemoveRole", t.getLocalizedMessage()));
messageBox.open();
}
}
});
confirmBox.open();
}
use of org.pentaho.ui.xul.XulComponent in project pentaho-kettle by pentaho.
the class RevisionController method restoreRevision.
public void restoreRevision() {
try {
final Collection<UIRepositoryContent> content = fileTable.getSelectedItems();
final UIRepositoryContent contentToRestore = content.iterator().next();
Collection<UIRepositoryObjectRevision> versions = revisionTable.getSelectedItems();
final UIRepositoryObjectRevision versionToRestore = versions.iterator().next();
SwtConfirmBox confirmbox = promptCommitComment(document);
if (contentToRestore instanceof ILockObject && ((ILockObject) contentToRestore).isLocked()) {
// Cannot restore revision of locked content
// $NON-NLS-1$
messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
// $NON-NLS-1$
messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
// $NON-NLS-1$
messageBox.setMessage(BaseMessages.getString(PKG, "RevisionsController.RestoreLockedFileNotAllowed"));
messageBox.open();
return;
}
confirmbox.addDialogCallback(new XulDialogCallback<String>() {
public void onClose(XulComponent component, Status status, String value) {
if (!status.equals(Status.CANCEL)) {
try {
if (contentToRestore instanceof IRevisionObject) {
((IRevisionObject) contentToRestore).restoreRevision(versionToRestore, value);
List<UIRepositoryObject> objects = new ArrayList<UIRepositoryObject>();
objects.add(contentToRestore);
browseController.setRepositoryObjects(objects);
} else {
throw new IllegalStateException(BaseMessages.getString(PKG, // $NON-NLS-1$
"RevisionsController.RevisionsNotSupported"));
}
} catch (Exception e) {
if (mainController == null || !mainController.handleLostRepository(e)) {
// convert to runtime exception so it bubbles up through the UI
throw new RuntimeException(e);
}
}
}
}
public void onError(XulComponent component, Throwable err) {
if (mainController == null || !mainController.handleLostRepository(err)) {
throw new RuntimeException(err);
}
}
});
confirmbox.open();
} catch (Exception e) {
if (mainController == null || !mainController.handleLostRepository(e)) {
throw new RuntimeException(new KettleException(e));
}
}
}
Aggregations