use of org.pentaho.ui.xul.containers.XulMenupopup in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceStepMenuExtension method callExtensionPoint.
@Override
public void callExtensionPoint(LogChannelInterface log, Object object) throws KettleException {
StepMenuExtension extension = (StepMenuExtension) object;
TransMeta transMeta = extension.getTransGraph().getTransMeta();
StepMeta stepMeta = extension.getTransGraph().getCurrentStep();
XulMenupopup menu = extension.getMenu();
DataServiceMeta dataService = metaStoreUtil.getDataServiceByStepName(transMeta, stepMeta.getName());
Boolean hasDataService = dataService != null && dataService.isUserDefined();
menu.getElementById("dataservices-new").setDisabled(hasDataService);
menu.getElementById("dataservices-edit").setDisabled(!hasDataService);
menu.getElementById("dataservices-delete").setDisabled(!hasDataService);
menu.getElementById("dataservices-test").setDisabled(!hasDataService);
}
use of org.pentaho.ui.xul.containers.XulMenupopup in project pentaho-kettle by pentaho.
the class SparkTuningPopupMenuExtensionPoint method callExtensionPoint.
@Override
public void callExtensionPoint(LogChannelInterface log, Object object) throws KettleException {
StepMenuExtension extension = (StepMenuExtension) object;
StepMeta stepMeta = extension.getTransGraph().getCurrentStep();
XulMenupopup menu = extension.getMenu();
List<String> tunableProperties = SparkTunableProperties.getProperties(stepMeta.getStepID());
menu.getElementById("trans-graph-entry-spark-tuning").setDisabled(tunableProperties.isEmpty());
}
use of org.pentaho.ui.xul.containers.XulMenupopup in project pentaho-kettle by pentaho.
the class Spoon method setMenu.
private synchronized void setMenu(Tree tree) {
TreeSelection[] objects = getTreeObjects(tree);
if (objects.length != 1) {
// not yet supported, we can do this later when the OSX bug
return;
// goes away
}
TreeSelection object = objects[0];
selectionObject = object.getSelection();
Object selection = selectionObject;
selectionObjectParent = object.getParent();
// Not clicked on a real object: returns a class
XulMenupopup spoonMenu = null;
if (selection instanceof Class<?>) {
if (selection.equals(TransMeta.class)) {
// New
spoonMenu = (XulMenupopup) menuMap.get("trans-class");
} else if (selection.equals(JobMeta.class)) {
// New
spoonMenu = (XulMenupopup) menuMap.get("job-class");
} else if (selection.equals(TransHopMeta.class)) {
// New
spoonMenu = (XulMenupopup) menuMap.get("trans-hop-class");
} else if (selection.equals(DatabaseMeta.class)) {
spoonMenu = (XulMenupopup) menuMap.get("database-class");
} else if (selection.equals(PartitionSchema.class)) {
// New
spoonMenu = (XulMenupopup) menuMap.get("partition-schema-class");
} else if (selection.equals(ClusterSchema.class)) {
spoonMenu = (XulMenupopup) menuMap.get("cluster-schema-class");
} else if (selection.equals(SlaveServer.class)) {
spoonMenu = (XulMenupopup) menuMap.get("slave-cluster-class");
} else {
spoonMenu = null;
}
} else {
if (selection instanceof TransMeta) {
spoonMenu = (XulMenupopup) menuMap.get("trans-inst");
} else if (selection instanceof JobMeta) {
spoonMenu = (XulMenupopup) menuMap.get("job-inst");
} else if (selection instanceof PluginInterface) {
spoonMenu = (XulMenupopup) menuMap.get("step-plugin");
} else if (selection instanceof DatabaseMeta) {
spoonMenu = (XulMenupopup) menuMap.get("database-inst");
// disable for now if the connection is an SAP ERP type of database...
//
XulMenuitem item = (XulMenuitem) mainSpoonContainer.getDocumentRoot().getElementById("database-inst-explore");
if (item != null) {
final DatabaseMeta databaseMeta = (DatabaseMeta) selection;
item.setDisabled(!databaseMeta.isExplorable());
}
item = (XulMenuitem) mainSpoonContainer.getDocumentRoot().getElementById("database-inst-clear-cache");
if (item != null) {
final DatabaseMeta databaseMeta = (DatabaseMeta) selectionObject;
item.setLabel(BaseMessages.getString(PKG, "Spoon.Menu.Popup.CONNECTIONS.ClearDBCache") + // Clear
databaseMeta.getName());
}
item = (XulMenuitem) mainSpoonContainer.getDocumentRoot().getElementById("database-inst-share");
if (item != null) {
final DatabaseMeta databaseMeta = (DatabaseMeta) selection;
if (databaseMeta.isShared()) {
item.setLabel(BaseMessages.getString(PKG, "Spoon.Menu.Popup.CONNECTIONS.UnShare"));
} else {
item.setLabel(BaseMessages.getString(PKG, "Spoon.Menu.Popup.CONNECTIONS.Share"));
}
}
} else if (selection instanceof StepMeta) {
spoonMenu = (XulMenupopup) menuMap.get("step-inst");
} else if (selection instanceof JobEntryCopy) {
spoonMenu = (XulMenupopup) menuMap.get("job-entry-copy-inst");
} else if (selection instanceof TransHopMeta) {
spoonMenu = (XulMenupopup) menuMap.get("trans-hop-inst");
} else if (selection instanceof PartitionSchema) {
spoonMenu = (XulMenupopup) menuMap.get("partition-schema-inst");
} else if (selection instanceof ClusterSchema) {
spoonMenu = (XulMenupopup) menuMap.get("cluster-schema-inst");
} else if (selection instanceof SlaveServer) {
spoonMenu = (XulMenupopup) menuMap.get("slave-server-inst");
}
}
if (spoonMenu != null) {
ConstUI.displayMenu(spoonMenu, tree);
} else {
tree.setMenu(null);
}
createPopUpMenuExtension();
}
use of org.pentaho.ui.xul.containers.XulMenupopup in project pentaho-kettle by pentaho.
the class TransGraph method setMenu.
/**
* This sets the popup-menu on the background of the canvas based on the xy coordinate of the mouse. This method is
* called after a mouse-click.
*
* @param x X-coordinate on screen
* @param y Y-coordinate on screen
*/
private synchronized void setMenu(int x, int y) {
try {
currentMouseX = x;
currentMouseY = y;
final StepMeta stepMeta = transMeta.getStep(x, y, iconsize);
if (stepMeta != null) {
// We clicked on a Step!
setCurrentStep(stepMeta);
XulMenupopup menu = menuMap.get("trans-graph-entry");
try {
ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.TransStepRightClick.id, new StepMenuExtension(this, menu));
} catch (Exception ex) {
LogChannel.GENERAL.logError("Error calling TransStepRightClick extension point", ex);
}
if (menu != null) {
List<StepMeta> selection = transMeta.getSelectedSteps();
doRightClickSelection(stepMeta, selection);
int sels = selection.size();
Document doc = getXulDomContainer().getDocumentRoot();
// TODO: cache the next line (seems fast enough)?
//
List<PluginInterface> rowDistributionPlugins = PluginRegistry.getInstance().getPlugins(RowDistributionPluginType.class);
JfaceMenupopup customRowDistMenu = (JfaceMenupopup) doc.getElementById("trans-graph-entry-data-movement-popup");
customRowDistMenu.setDisabled(false);
customRowDistMenu.removeChildren();
// Add the default round robin plugin...
//
Action action = new Action("RoundRobinRowDistribution", Action.AS_CHECK_BOX) {
@Override
public void run() {
// default
stepMeta.setRowDistribution(null);
stepMeta.setDistributes(true);
}
};
boolean selected = stepMeta.isDistributes() && stepMeta.getRowDistribution() == null;
action.setChecked(selected);
JfaceMenuitem child = new JfaceMenuitem(null, customRowDistMenu, xulDomContainer, "Round Robin row distribution", 0, action);
child.setLabel(BaseMessages.getString(PKG, "TransGraph.PopupMenu.RoundRobin"));
child.setDisabled(false);
child.setSelected(selected);
for (int p = 0; p < rowDistributionPlugins.size(); p++) {
final PluginInterface rowDistributionPlugin = rowDistributionPlugins.get(p);
selected = stepMeta.isDistributes() && stepMeta.getRowDistribution() != null && stepMeta.getRowDistribution().getCode().equals(rowDistributionPlugin.getIds()[0]);
action = new Action(rowDistributionPlugin.getIds()[0], Action.AS_CHECK_BOX) {
@Override
public void run() {
try {
stepMeta.setRowDistribution((RowDistributionInterface) PluginRegistry.getInstance().loadClass(rowDistributionPlugin));
} catch (Exception e) {
LogChannel.GENERAL.logError("Error loading row distribution plugin class: ", e);
}
}
};
action.setChecked(selected);
child = new JfaceMenuitem(null, customRowDistMenu, xulDomContainer, rowDistributionPlugin.getName(), p + 1, action);
child.setLabel(rowDistributionPlugin.getName());
child.setDisabled(false);
child.setSelected(selected);
}
// Add the default copy rows plugin...
//
action = new Action("CopyRowsDistribution", Action.AS_CHECK_BOX) {
@Override
public void run() {
stepMeta.setDistributes(false);
}
};
selected = !stepMeta.isDistributes();
action.setChecked(selected);
child = new JfaceMenuitem(null, customRowDistMenu, xulDomContainer, "Copy rows distribution", 0, action);
child.setLabel(BaseMessages.getString(PKG, "TransGraph.PopupMenu.CopyData"));
child.setDisabled(false);
child.setSelected(selected);
JfaceMenupopup launchMenu = (JfaceMenupopup) doc.getElementById("trans-graph-entry-launch-popup");
String[] referencedObjects = stepMeta.getStepMetaInterface().getReferencedObjectDescriptions();
boolean[] enabledObjects = stepMeta.getStepMetaInterface().isReferencedObjectEnabled();
launchMenu.setDisabled(Utils.isEmpty(referencedObjects));
launchMenu.removeChildren();
int childIndex = 0;
// First see if we need to add a special "active" entry (running transformation)
//
StepMetaInterface stepMetaInterface = stepMeta.getStepMetaInterface();
String activeReferencedObjectDescription = stepMetaInterface.getActiveReferencedObjectDescription();
if (getActiveSubtransformation(this, stepMeta) != null && activeReferencedObjectDescription != null) {
action = new Action(activeReferencedObjectDescription, Action.AS_PUSH_BUTTON) {
@Override
public void run() {
// negative by convention
openMapping(stepMeta, -1);
}
};
child = new JfaceMenuitem(null, launchMenu, xulDomContainer, activeReferencedObjectDescription, childIndex++, action);
child.setLabel(activeReferencedObjectDescription);
child.setDisabled(false);
}
if (!Utils.isEmpty(referencedObjects)) {
for (int i = 0; i < referencedObjects.length; i++) {
final int index = i;
String referencedObject = referencedObjects[i];
action = new Action(referencedObject, Action.AS_PUSH_BUTTON) {
@Override
public void run() {
openMapping(stepMeta, index);
}
};
child = new JfaceMenuitem(null, launchMenu, xulDomContainer, referencedObject, childIndex++, action);
child.setLabel(referencedObject);
child.setDisabled(!enabledObjects[i]);
}
}
initializeXulMenu(doc, selection, stepMeta);
ConstUI.displayMenu(menu, canvas);
}
} else {
final TransHopMeta hi = findHop(x, y);
if (hi != null) {
// We clicked on a HOP!
XulMenupopup menu = menuMap.get("trans-graph-hop");
if (menu != null) {
setCurrentHop(hi);
XulMenuitem item = (XulMenuitem) getXulDomContainer().getDocumentRoot().getElementById("trans-graph-hop-enabled");
if (item != null) {
if (hi.isEnabled()) {
item.setLabel(BaseMessages.getString(PKG, "TransGraph.PopupMenu.DisableHop"));
} else {
item.setLabel(BaseMessages.getString(PKG, "TransGraph.PopupMenu.EnableHop"));
}
}
ConstUI.displayMenu(menu, canvas);
}
} else {
// Clicked on the background: maybe we hit a note?
final NotePadMeta ni = transMeta.getNote(x, y);
setCurrentNote(ni);
if (ni != null) {
XulMenupopup menu = menuMap.get("trans-graph-note");
if (menu != null) {
ConstUI.displayMenu(menu, canvas);
}
} else {
XulMenupopup menu = menuMap.get("trans-graph-background");
if (menu != null) {
final String clipcontent = spoon.fromClipboard();
XulMenuitem item = (XulMenuitem) getXulDomContainer().getDocumentRoot().getElementById("trans-graph-background-paste");
if (item != null) {
item.setDisabled(clipcontent == null);
}
ConstUI.displayMenu(menu, canvas);
}
}
}
}
} catch (Throwable t) {
// TODO: fix this: log somehow, is IGNORED for now.
t.printStackTrace();
}
}
use of org.pentaho.ui.xul.containers.XulMenupopup 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_PUSH_BUTTON) {
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