use of org.pentaho.ui.xul.dom.Document in project data-access by pentaho.
the class EmbeddedWizard method setUploadPath.
/**
* Upload path is by necessity relative. as such it will differ where the module is based.
*
* @param path
*/
public void setUploadPath(String path) {
Document rootDocument = mainWizardContainer.getDocumentRoot();
// $NON-NLS-1$
XulFileUpload upload = (XulFileUpload) rootDocument.getElementById("fileUpload");
upload.setAction(path);
}
use of org.pentaho.ui.xul.dom.Document in project pentaho-kettle by pentaho.
the class FragmentHandlerTest method testRefreshOptions.
@Test
public void testRefreshOptions() throws Exception {
XulListbox connectionBox = mock(XulListbox.class);
when(document.getElementById("connection-type-list")).thenReturn(connectionBox);
when(connectionBox.getSelectedItem()).thenReturn("myDb");
XulListbox accessBox = mock(XulListbox.class);
when(document.getElementById("access-type-list")).thenReturn(accessBox);
when(accessBox.getSelectedItem()).thenReturn("Native");
DataHandler dataHandler = mock(DataHandler.class);
when(xulDomContainer.getEventHandler("dataHandler")).thenReturn(dataHandler);
DatabaseInterface dbInterface = mock(DatabaseInterface.class);
when(dbInterface.getDefaultDatabasePort()).thenReturn(5309);
DataHandler.connectionMap.put("myDb", dbInterface);
XulComponent component = mock(XulComponent.class);
XulComponent parent = mock(XulComponent.class);
when(component.getParent()).thenReturn(parent);
when(document.getElementById("database-options-box")).thenReturn(component);
XulDomContainer fragmentContainer = mock(XulDomContainer.class);
Document mockDoc = mock(Document.class);
XulComponent firstChild = mock(XulComponent.class);
when(mockDoc.getFirstChild()).thenReturn(firstChild);
when(fragmentContainer.getDocumentRoot()).thenReturn(mockDoc);
when(xulDomContainer.loadFragment(anyString(), any(Object.class))).thenReturn(fragmentContainer);
XulTextbox portBox = mock(XulTextbox.class);
when(document.getElementById("port-number-text")).thenReturn(portBox);
fragmentHandler.refreshOptions();
// Iterate through the other database access types
when(accessBox.getSelectedItem()).thenReturn("JNDI");
fragmentHandler.refreshOptions();
when(accessBox.getSelectedItem()).thenReturn("ODBC");
fragmentHandler.refreshOptions();
when(accessBox.getSelectedItem()).thenReturn("OCI");
fragmentHandler.refreshOptions();
when(accessBox.getSelectedItem()).thenReturn("Plugin");
fragmentHandler.refreshOptions();
}
use of org.pentaho.ui.xul.dom.Document in project pentaho-kettle by pentaho.
the class BrowseControllerTest method setUp.
@Before
public void setUp() throws Exception {
DocumentFactory.registerElementClass(ElementDom4J.class);
controller = new BrowseController();
controller.setRepositoryDirectory(mock(UIRepositoryDirectory.class));
directoryMap = new HashMap<>(8);
controller.setDirMap(directoryMap);
document = mock(Document.class);
XulDomContainer xulDomContainer = mock(XulDomContainer.class);
when(xulDomContainer.getDocumentRoot()).thenReturn(document);
controller.setXulDomContainer(xulDomContainer);
UIRepositoryDirectory someDirectory = mock(UIRepositoryDirectory.class);
selectedFolder = mock(UIRepositoryDirectory.class);
when(selectedFolder.createFolder(FOLDER_NAME)).thenReturn(someDirectory);
XulTree folderTree = mock(XulTree.class);
when(folderTree.getSelectedItems()).thenReturn(Collections.<Object>singleton(selectedFolder));
controller.setFolderTree(folderTree);
directoryBinding = mock(Binding.class);
controller.setDirectoryBinding(directoryBinding);
selectedItemsBinding = mock(Binding.class);
controller.setSelectedItemsBinding(selectedItemsBinding);
}
use of org.pentaho.ui.xul.dom.Document 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.dom.Document in project pentaho-kettle by pentaho.
the class JobGraph method setMenu.
protected synchronized void setMenu(int x, int y) {
currentMouseX = x;
currentMouseY = y;
final JobEntryCopy jobEntry = jobMeta.getJobEntryCopy(x, y, iconsize);
setJobEntry(jobEntry);
Document doc = xulDomContainer.getDocumentRoot();
if (jobEntry != null) {
// We clicked on a Job Entry!
XulMenupopup menu = (XulMenupopup) doc.getElementById("job-graph-entry");
if (menu != null) {
List<JobEntryCopy> selection = jobMeta.getSelectedEntries();
doRightClickSelection(jobEntry, selection);
int sels = selection.size();
XulMenuitem item = (XulMenuitem) doc.getElementById("job-graph-entry-newhop");
item.setDisabled(sels < 2);
JfaceMenupopup launchMenu = (JfaceMenupopup) doc.getElementById("job-graph-entry-launch-popup");
String[] referencedObjects = jobEntry.getEntry().getReferencedObjectDescriptions();
boolean[] enabledObjects = jobEntry.getEntry().isReferencedObjectEnabled();
launchMenu.setDisabled(Utils.isEmpty(referencedObjects));
launchMenu.removeChildren();
if (!Utils.isEmpty(referencedObjects)) {
for (int i = 0; i < referencedObjects.length; i++) {
final int index = i;
String referencedObject = referencedObjects[i];
Action action = new Action(referencedObject, Action.AS_DROP_DOWN_MENU) {
public void run() {
loadReferencedObject(jobEntry, index);
}
};
JfaceMenuitem child = new JfaceMenuitem(null, launchMenu, xulDomContainer, referencedObject, i, action);
child.setLabel(referencedObject);
child.setDisabled(!enabledObjects[i]);
}
}
item = (XulMenuitem) doc.getElementById("job-graph-entry-align-snap");
item.setAcceltext("ALT-HOME");
item.setLabel(BaseMessages.getString(PKG, "JobGraph.PopupMenu.JobEntry.AllignDistribute.SnapToGrid"));
item.setAccesskey("alt-home");
XulMenu aMenu = (XulMenu) doc.getElementById("job-graph-entry-align");
if (aMenu != null) {
aMenu.setDisabled(sels < 1);
}
item = (XulMenuitem) doc.getElementById("job-graph-entry-detach");
if (item != null) {
item.setDisabled(!jobMeta.isEntryUsedInHops(jobEntry));
}
item = (XulMenuitem) doc.getElementById("job-graph-entry-hide");
if (item != null) {
item.setDisabled(!(jobEntry.isDrawn() && !jobMeta.isEntryUsedInHops(jobEntry)));
}
item = (XulMenuitem) doc.getElementById("job-graph-entry-delete");
if (item != null) {
item.setDisabled(!jobEntry.isDrawn());
}
item = (XulMenuitem) doc.getElementById("job-graph-entry-parallel");
if (item != null) {
item.setSelected(jobEntry.isLaunchingInParallel());
}
try {
JobGraphJobEntryMenuExtension extension = new JobGraphJobEntryMenuExtension(xulDomContainer, doc, jobMeta, jobEntry, this);
ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.JobGraphJobEntrySetMenu.id, extension);
} catch (Exception e) {
log.logError("Error handling menu right click on job entry through extension point", e);
}
ConstUI.displayMenu(menu, canvas);
}
} else {
// Clear the menu
final JobHopMeta hi = findJobHop(x, y);
setCurrentHop(hi);
if (hi != null) {
// We clicked on a HOP!
XulMenupopup menu = (XulMenupopup) doc.getElementById("job-graph-hop");
if (menu != null) {
XulMenuitem miPopEvalUncond = (XulMenuitem) doc.getElementById("job-graph-hop-evaluation-uncond");
XulMenuitem miPopEvalTrue = (XulMenuitem) doc.getElementById("job-graph-hop-evaluation-true");
XulMenuitem miPopEvalFalse = (XulMenuitem) doc.getElementById("job-graph-hop-evaluation-false");
XulMenuitem miDisHop = (XulMenuitem) doc.getElementById("job-graph-hop-enabled");
XulMenuitem miFlipHop = (XulMenuitem) doc.getElementById("job-graph-hop-flip");
//
if (miPopEvalUncond != null && miPopEvalTrue != null && miPopEvalFalse != null) {
if (hi.isUnconditional()) {
miPopEvalUncond.setSelected(true);
miPopEvalTrue.setSelected(false);
miPopEvalFalse.setSelected(false);
} else {
if (hi.getEvaluation()) {
miPopEvalUncond.setSelected(false);
miPopEvalTrue.setSelected(true);
miPopEvalFalse.setSelected(false);
} else {
miPopEvalUncond.setSelected(false);
miPopEvalTrue.setSelected(false);
miPopEvalFalse.setSelected(true);
}
}
if (!hi.getFromEntry().evaluates()) {
miPopEvalTrue.setDisabled(true);
miPopEvalFalse.setDisabled(true);
} else {
miPopEvalTrue.setDisabled(false);
miPopEvalFalse.setDisabled(false);
}
if (!hi.getFromEntry().isUnconditional()) {
miPopEvalUncond.setDisabled(true);
} else {
miPopEvalUncond.setDisabled(false);
}
if (hi.getFromEntry().isStart()) {
miFlipHop.setDisabled(true);
} else {
miFlipHop.setDisabled(false);
}
}
if (miDisHop != null) {
if (hi.isEnabled()) {
miDisHop.setLabel(BaseMessages.getString(PKG, "JobGraph.PopupMenu.Hop.Disable"));
} else {
miDisHop.setLabel(BaseMessages.getString(PKG, "JobGraph.PopupMenu.Hop.Enable"));
}
}
ConstUI.displayMenu(menu, canvas);
}
} else {
// Clicked on the background: maybe we hit a note?
final NotePadMeta ni = jobMeta.getNote(x, y);
setCurrentNote(ni);
if (ni != null) {
XulMenupopup menu = (XulMenupopup) doc.getElementById("job-graph-note");
if (menu != null) {
ConstUI.displayMenu(menu, canvas);
}
} else {
XulMenupopup menu = (XulMenupopup) doc.getElementById("job-graph-background");
if (menu != null) {
final String clipcontent = spoon.fromClipboard();
XulMenuitem item = (XulMenuitem) doc.getElementById("job-graph-note-paste");
if (item != null) {
item.setDisabled(clipcontent == null);
}
ConstUI.displayMenu(menu, canvas);
}
}
}
}
}
Aggregations