use of org.pentaho.di.core.ObjectUsageCount in project pentaho-kettle by pentaho.
the class PropsUI method init.
@SuppressWarnings("unchecked")
protected synchronized void init() {
super.createLogChannel();
properties = new Properties();
pluginHistory = new ArrayList<ObjectUsageCount>();
setDefault();
loadProps();
addDefaultEntries();
loadPluginHistory();
loadScreens();
loadLastUsedFiles();
loadLastUsedRepoFiles();
loadOpenTabFiles();
resetRecentSearches();
PluginRegistry registry = PluginRegistry.getInstance();
List<PluginInterface> plugins = registry.getPlugins(LifecyclePluginType.class);
List<GUIOption<Object>> leditables = new ArrayList<GUIOption<Object>>();
for (PluginInterface plugin : plugins) {
if (!plugin.getClassMap().keySet().contains(GUIOption.class)) {
continue;
}
try {
GUIOption<Object> loaded = registry.loadClass(plugin, GUIOption.class);
if (loaded != null) {
leditables.add(loaded);
}
} catch (ClassCastException cce) {
// Not all Lifecycle plugins implement GUIOption, keep calm and carry on
LogChannel.GENERAL.logDebug("Plugin " + plugin.getIds()[0] + " does not implement GUIOption, it will not be editable");
} catch (Exception e) {
LogChannel.GENERAL.logError("Unexpected error loading class for plugin " + plugin.getName(), e);
}
}
editables = Collections.unmodifiableList(leditables);
}
use of org.pentaho.di.core.ObjectUsageCount 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;
}
Aggregations