use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class ExcelInputDialogTest method getFieldsTest.
@Test
public /**
* http://jira.pentaho.com/browse/PDI-13930
*/
void getFieldsTest() throws Exception {
ExcelInputDialog dialog = Mockito.mock(ExcelInputDialog.class);
RowMeta fields = new RowMeta();
ExcelInputMeta info = Mockito.mock(ExcelInputMeta.class);
Mockito.doReturn(true).when(info).readAllSheets();
int[] startColumn = { 0 };
Mockito.doReturn(startColumn).when(info).getStartColumn();
int[] startRow = { 0 };
Mockito.doReturn(startRow).when(info).getStartRow();
KWorkbook workbook = Mockito.mock(KWorkbook.class);
Mockito.doReturn(1).when(workbook).getNumberOfSheets();
KSheet sheet = Mockito.mock(KSheet.class);
Mockito.doReturn(sheet).when(workbook).getSheet(0);
KCell cell = Mockito.mock(KCell.class);
int fieldCount = 400;
for (int i = 0; i <= fieldCount - 1; i++) {
Mockito.doReturn(cell).when(sheet).getCell(i, 0);
Mockito.doReturn(cell).when(sheet).getCell(i, 1);
}
Mockito.doReturn("testValue").when(cell).getContents();
Mockito.doReturn(KCellType.NUMBER).when(cell).getType();
PluginRegistry pluginRegistry = Mockito.mock(PluginRegistry.class);
PluginInterface stringPlugin = Mockito.mock(PluginInterface.class);
Mockito.doReturn(stringPlugin).when(pluginRegistry).getPlugin(ValueMetaPluginType.class, "1");
Mockito.doReturn(Mockito.mock(ValueMetaInterface.class)).when(pluginRegistry).loadClass(stringPlugin, ValueMetaInterface.class);
ValueMetaFactory.pluginRegistry = pluginRegistry;
Method processingWorkbookMethod = ExcelInputDialog.class.getDeclaredMethod("processingWorkbook", RowMetaInterface.class, ExcelInputMeta.class, KWorkbook.class);
processingWorkbookMethod.setAccessible(true);
processingWorkbookMethod.invoke(dialog, fields, info, workbook);
Assert.assertEquals(fieldCount, fields.size());
}
use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class RepositoryConnectControllerTest method setUp.
@Before
public void setUp() {
controller = new RepositoryConnectController(pluginRegistry, () -> spoon, repositoriesMeta);
when(pluginInterface.getName()).thenReturn(PLUGIN_NAME);
when(pluginInterface.getIds()).thenReturn(new String[] { ID });
when(pluginInterface.getDescription()).thenReturn(PLUGIN_DESCRIPTION);
List<PluginInterface> plugins = new ArrayList<>();
plugins.add(pluginInterface);
when(pluginRegistry.getPlugins(RepositoryPluginType.class)).thenReturn(plugins);
when(repositoryMeta.getId()).thenReturn(ID);
when(repositoryMeta.getName()).thenReturn(PLUGIN_NAME);
when(repositoryMeta.getDescription()).thenReturn(PLUGIN_DESCRIPTION);
}
use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class JmsProducerDialog method getImage.
private Image getImage() {
PluginInterface plugin = PluginRegistry.getInstance().getPlugin(StepPluginType.class, stepMeta.getStepMetaInterface());
String id = plugin.getIds()[0];
if (id != null) {
return GUIResource.getInstance().getImagesSteps().get(id).getAsBitmapForSize(shell.getDisplay(), ConstUI.ICON_SIZE, ConstUI.ICON_SIZE);
}
return null;
}
use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class Spoon method refreshCoreObjects.
public void refreshCoreObjects() {
if (shell.isDisposed()) {
return;
}
if (!designSelected) {
return;
}
if (coreObjectsTree == null || coreObjectsTree.isDisposed()) {
addCoreObjectsTree();
}
showTrans = getActiveTransformation() != null;
showJob = getActiveJob() != null;
if (showTrans == previousShowTrans && showJob == previousShowJob) {
return;
}
// First remove all the entries that where present...
//
TreeItem[] expandItems = coreObjectsTree.getItems();
for (TreeItem item : expandItems) {
item.dispose();
}
if (showTrans) {
// Fill the base components...
//
// ////////////////////////////////////////////////////////////////////////////////////////////////
// TRANSFORMATIONS
// ////////////////////////////////////////////////////////////////////////////////////////////////
PluginRegistry registry = PluginRegistry.getInstance();
final List<PluginInterface> baseSteps = registry.getPlugins(StepPluginType.class);
final List<String> baseCategories = registry.getCategories(StepPluginType.class);
for (String baseCategory : baseCategories) {
TreeItem item = new TreeItem(coreObjectsTree, SWT.NONE);
item.setText(baseCategory);
item.setImage(GUIResource.getInstance().getImageFolder());
List<PluginInterface> sortedCat = baseSteps.stream().filter(baseStep -> baseStep.getCategory().equalsIgnoreCase(baseCategory)).sorted(Comparator.comparing(PluginInterface::getName)).collect(Collectors.toList());
for (PluginInterface p : sortedCat) {
final Image stepImage = GUIResource.getInstance().getImagesStepsSmall().get(p.getIds()[0]);
String pluginName = p.getName();
String pluginDescription = p.getDescription();
if (!filterMatch(pluginName) && !filterMatch(pluginDescription)) {
continue;
}
createTreeItem(item, pluginName, stepImage, p.getIds()[0]);
coreStepToolTipMap.put(pluginName, pluginDescription);
}
}
// Add History Items...
TreeItem item = new TreeItem(coreObjectsTree, SWT.NONE);
item.setText(BaseMessages.getString(PKG, "Spoon.History"));
item.setImage(GUIResource.getInstance().getImageFolder());
List<ObjectUsageCount> pluginHistory = props.getPluginHistory();
//
for (int i = 0; i < pluginHistory.size() && i < 10; i++) {
ObjectUsageCount usage = pluginHistory.get(i);
PluginInterface stepPlugin = PluginRegistry.getInstance().findPluginWithId(StepPluginType.class, usage.getObjectName());
if (stepPlugin != null) {
final Image stepImage = GUIResource.getInstance().getImagesSteps().get(stepPlugin.getIds()[0]).getAsBitmapForSize(display, ConstUI.MEDIUM_ICON_SIZE, ConstUI.MEDIUM_ICON_SIZE);
String pluginName = Const.NVL(stepPlugin.getName(), "");
String pluginDescription = Const.NVL(stepPlugin.getDescription(), "");
if (!filterMatch(pluginName) && !filterMatch(pluginDescription)) {
continue;
}
TreeItem stepItem = createTreeItem(item, pluginName, stepImage);
stepItem.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
System.out.println("Tree item Listener fired");
}
});
coreStepToolTipMap.put(stepPlugin.getDescription(), pluginDescription + " (" + usage.getNrUses() + ")");
}
}
}
if (showJob) {
// Fill the base components...
//
// ////////////////////////////////////////////////////////////////////////////////////////////////
// JOBS
// ////////////////////////////////////////////////////////////////////////////////////////////////
PluginRegistry registry = PluginRegistry.getInstance();
List<PluginInterface> baseJobEntries = registry.getPlugins(JobEntryPluginType.class);
List<String> baseCategories = registry.getCategories(JobEntryPluginType.class);
TreeItem generalItem = null;
for (String baseCategory : baseCategories) {
TreeItem item = new TreeItem(coreObjectsTree, SWT.NONE);
item.setText(baseCategory);
item.setImage(GUIResource.getInstance().getImageFolder());
if (baseCategory.equalsIgnoreCase(JobEntryPluginType.GENERAL_CATEGORY)) {
generalItem = item;
}
for (int j = 0; j < baseJobEntries.size(); j++) {
if (!baseJobEntries.get(j).getIds()[0].equals(JobMeta.STRING_SPECIAL)) {
if (baseJobEntries.get(j).getCategory().equalsIgnoreCase(baseCategory)) {
final Image jobEntryImage = GUIResource.getInstance().getImagesJobentriesSmall().get(baseJobEntries.get(j).getIds()[0]);
String pluginName = Const.NVL(baseJobEntries.get(j).getName(), "");
String pluginDescription = Const.NVL(baseJobEntries.get(j).getDescription(), "");
if (!filterMatch(pluginName) && !filterMatch(pluginDescription)) {
continue;
}
TreeItem stepItem = createTreeItem(item, pluginName, jobEntryImage);
stepItem.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event arg0) {
System.out.println("Tree item Listener fired");
}
});
// if (isPlugin)
// stepItem.setFont(GUIResource.getInstance().getFontBold());
coreJobToolTipMap.put(pluginName, pluginDescription);
}
}
}
}
// First add a few "Special entries: Start, Dummy, OK, ERROR
// We add these to the top of the base category, we don't care about
// the sort order here.
//
JobEntryCopy startEntry = JobMeta.createStartEntry();
JobEntryCopy dummyEntry = JobMeta.createDummyEntry();
String[] specialText = new String[] { startEntry.getName(), dummyEntry.getName() };
String[] specialTooltip = new String[] { startEntry.getDescription(), dummyEntry.getDescription() };
Image[] specialImage = new Image[] { GUIResource.getInstance().getImageStartMedium(), GUIResource.getInstance().getImageDummyMedium() };
int pos = 0;
for (int i = 0; i < specialText.length; i++) {
if (!filterMatch(specialText[i]) && !filterMatch(specialTooltip[i])) {
continue;
}
TreeItem specialItem = new TreeItem(generalItem, SWT.NONE, pos);
specialItem.setImage(specialImage[i]);
specialItem.setText(specialText[i]);
specialItem.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event arg0) {
System.out.println("Tree item Listener fired");
}
});
coreJobToolTipMap.put(specialText[i], specialTooltip[i]);
pos++;
}
}
variableComposite.layout(true, true);
previousShowTrans = showTrans;
previousShowJob = showJob;
}
use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class Spoon method helpStep.
public void helpStep() {
final StepMeta stepMeta = (StepMeta) selectionObject;
PluginInterface stepPlugin = PluginRegistry.getInstance().findPluginWithId(StepPluginType.class, stepMeta.getStepID());
HelpUtils.openHelpDialog(shell, stepPlugin);
}
Aggregations