use of org.pentaho.di.ui.spoon.TreeSelection in project pentaho-kettle by pentaho.
the class ConnectionPopupMenuExtension method callExtensionPoint.
@Override
public void callExtensionPoint(LogChannelInterface logChannelInterface, Object extension) throws KettleException {
Menu popupMenu = null;
Tree selectionTree = (Tree) extension;
TreeSelection[] objects = spoonSupplier.get().getTreeObjects(selectionTree);
TreeSelection object = objects[0];
Object selection = object.getSelection();
if (selection == VFSConnectionDetails.class) {
popupMenu = createRootPopupMenu(selectionTree);
} else if (selection instanceof ConnectionTreeItem) {
vfsConnectionTreeItem = (ConnectionTreeItem) selection;
popupMenu = createItemPopupMenu(selectionTree);
}
if (popupMenu != null) {
ConstUI.displayMenu(popupMenu, selectionTree);
} else {
selectionTree.setMenu(null);
}
}
use of org.pentaho.di.ui.spoon.TreeSelection in project pentaho-kettle by pentaho.
the class RunConfigurationPopupMenuExtension method callExtensionPoint.
@Override
public void callExtensionPoint(LogChannelInterface logChannelInterface, Object extension) throws KettleException {
Menu popupMenu = null;
Tree selectionTree = (Tree) extension;
TreeSelection[] objects = spoonSupplier.get().getTreeObjects(selectionTree);
TreeSelection object = objects[0];
Object selection = object.getSelection();
if (selection == RunConfiguration.class) {
popupMenu = createRootPopupMenu(selectionTree);
} else if (selection instanceof String) {
runConfiguration = (String) selection;
if (runConfiguration.equalsIgnoreCase(DefaultRunConfigurationProvider.DEFAULT_CONFIG_NAME)) {
return;
}
popupMenu = createItemPopupMenu(selectionTree);
}
if (popupMenu != null) {
ConstUI.displayMenu(popupMenu, selectionTree);
} else {
selectionTree.setMenu(null);
}
}
use of org.pentaho.di.ui.spoon.TreeSelection in project pentaho-kettle by pentaho.
the class SpoonTreeDelegate method addDragSourceToTree.
public void addDragSourceToTree(final Tree tree, final Tree selectionTree, final Tree coreObjectsTree) {
// Drag & Drop for steps
Transfer[] ttypes = new Transfer[] { XMLTransfer.getInstance() };
DragSource ddSource = new DragSource(tree, DND.DROP_MOVE);
ddSource.setTransfer(ttypes);
ddSource.addDragListener(new DragSourceListener() {
public void dragStart(DragSourceEvent event) {
TreeSelection[] treeObjects = getTreeObjects(tree, selectionTree, coreObjectsTree);
if (treeObjects.length == 0) {
event.doit = false;
return;
}
spoon.hideToolTips();
TreeSelection treeObject = treeObjects[0];
Object object = treeObject.getSelection();
TransMeta transMeta = spoon.getActiveTransformation();
if (object instanceof StepMeta || object instanceof PluginInterface || (object instanceof DatabaseMeta && transMeta != null) || object instanceof TransHopMeta || object instanceof JobEntryCopy) {
event.doit = true;
} else {
event.doit = false;
}
}
public void dragSetData(DragSourceEvent event) {
TreeSelection[] treeObjects = getTreeObjects(tree, selectionTree, coreObjectsTree);
if (treeObjects.length == 0) {
event.doit = false;
return;
}
int type = 0;
String id = null;
String data = null;
TreeSelection treeObject = treeObjects[0];
Object object = treeObject.getSelection();
if (object instanceof StepMeta) {
StepMeta stepMeta = (StepMeta) object;
type = DragAndDropContainer.TYPE_STEP;
// name of the step.
data = stepMeta.getName();
} else if (object instanceof PluginInterface) {
PluginInterface plugin = (PluginInterface) object;
Class<? extends PluginTypeInterface> pluginType = plugin.getPluginType();
if (Const.classIsOrExtends(pluginType, StepPluginType.class)) {
type = DragAndDropContainer.TYPE_BASE_STEP_TYPE;
id = plugin.getIds()[0];
// Step type name
data = plugin.getName();
} else {
type = DragAndDropContainer.TYPE_BASE_JOB_ENTRY;
// job entry type name
data = plugin.getName();
if (treeObject.getItemText().equals(JobMeta.createStartEntry().getName())) {
data = treeObject.getItemText();
} else if (treeObject.getItemText().equals(JobMeta.createDummyEntry().getName())) {
data = treeObject.getItemText();
}
}
} else if (object instanceof DatabaseMeta) {
DatabaseMeta databaseMeta = (DatabaseMeta) object;
type = DragAndDropContainer.TYPE_DATABASE_CONNECTION;
data = databaseMeta.getName();
} else if (object instanceof TransHopMeta) {
TransHopMeta hop = (TransHopMeta) object;
type = DragAndDropContainer.TYPE_TRANS_HOP;
// nothing for really ;-)
data = hop.toString();
} else if (object instanceof JobEntryCopy) {
JobEntryCopy jobEntryCopy = (JobEntryCopy) object;
type = DragAndDropContainer.TYPE_JOB_ENTRY;
// name of the job entry.
data = jobEntryCopy.getName();
} else {
event.doit = false;
// ignore anything else you drag.
return;
}
event.data = new DragAndDropContainer(type, data, id);
}
public void dragFinished(DragSourceEvent event) {
}
});
}
use of org.pentaho.di.ui.spoon.TreeSelection in project pentaho-kettle by pentaho.
the class SpoonTreeDelegateTest method getTreeObjects_getStepById.
@Test
public void getTreeObjects_getStepById() {
SpoonTreeDelegate std = spy(new SpoonTreeDelegate(spoon));
Tree selection = mock(Tree.class);
Tree core = mock(Tree.class);
TreeItem item = mock(TreeItem.class);
PluginInterface step = mock(PluginInterface.class);
PluginRegistry registry = mock(PluginRegistry.class);
TreeItem[] items = new TreeItem[] { item };
when(ConstUI.getTreeStrings(item)).thenReturn(new String[] { "Output", "Avro Output" });
when(PluginRegistry.getInstance()).thenReturn(registry);
doReturn(items).when(core).getSelection();
doReturn("AvroOutputPlugin").when(item).getData(anyString());
doReturn(step).when(registry).findPluginWithId(StepPluginType.class, "AvroOutputPlugin");
spoon.showJob = false;
spoon.showTrans = true;
TreeSelection[] ts = std.getTreeObjects(core, selection, core);
assertEquals(1, ts.length);
assertEquals(step, ts[0].getSelection());
}
use of org.pentaho.di.ui.spoon.TreeSelection in project pdi-dataservice-server-plugin by pentaho.
the class DataServicePopupMenuExtension method callExtensionPoint.
@Override
public void callExtensionPoint(LogChannelInterface log, Object extension) throws KettleException {
Menu popupMenu = null;
Tree selectionTree = (Tree) extension;
TreeSelection[] objects = delegate.getSpoon().getTreeObjects(selectionTree);
TreeSelection object = objects[0];
Object selection = object.getSelection();
if (selection == DataServiceMeta.class) {
popupMenu = uiFactory.getMenu(selectionTree);
createRootPopupMenu(popupMenu);
} else if (selection instanceof DataServiceMeta) {
selectedDataService = (DataServiceMeta) selection;
popupMenu = uiFactory.getMenu(selectionTree);
createItemPopupMenu(popupMenu);
}
if (popupMenu != null) {
ConstUI.displayMenu(popupMenu, selectionTree);
} else {
selectionTree.setMenu(null);
}
}
Aggregations