use of org.pentaho.di.core.plugins.PluginInterface 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.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class CreateDatabaseWizardPage1 method createControl.
public void createControl(Composite parent) {
int margin = Const.MARGIN;
int middle = props.getMiddlePct();
// create the composite to hold the widgets
Composite composite = new Composite(parent, SWT.NONE);
props.setLook(composite);
FormLayout compLayout = new FormLayout();
compLayout.marginHeight = Const.FORM_MARGIN;
compLayout.marginWidth = Const.FORM_MARGIN;
composite.setLayout(compLayout);
wlName = new Label(composite, SWT.RIGHT);
wlName.setText(BaseMessages.getString(PKG, "CreateDatabaseWizardPage1.DBName.Label"));
props.setLook(wlName);
fdlName = new FormData();
fdlName.left = new FormAttachment(0, 0);
fdlName.top = new FormAttachment(0, 0);
fdlName.right = new FormAttachment(middle, 0);
wlName.setLayoutData(fdlName);
wName = new Text(composite, SWT.SINGLE | SWT.BORDER);
props.setLook(wName);
fdName = new FormData();
fdName.left = new FormAttachment(middle, margin);
fdName.right = new FormAttachment(100, 0);
wName.setLayoutData(fdName);
wName.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
setPageComplete(false);
}
});
wlDBType = new Label(composite, SWT.RIGHT);
wlDBType.setText(BaseMessages.getString(PKG, "CreateDatabaseWizardPage1.DBType.Label"));
props.setLook(wlDBType);
fdlDBType = new FormData();
fdlDBType.left = new FormAttachment(0, 0);
fdlDBType.top = new FormAttachment(wName, margin);
fdlDBType.right = new FormAttachment(middle, 0);
wlDBType.setLayoutData(fdlDBType);
wDBType = new List(composite, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
props.setLook(wDBType);
PluginRegistry registry = PluginRegistry.getInstance();
java.util.List<PluginInterface> plugins = registry.getPlugins(DatabasePluginType.class);
Collections.sort(plugins, new Comparator<PluginInterface>() {
@Override
public int compare(PluginInterface o1, PluginInterface o2) {
return o1.getName().toUpperCase().compareTo(o2.getName().toUpperCase());
}
});
for (PluginInterface plugin : plugins) {
try {
wDBType.add(plugin.getName());
wDBIDtoNameMap.put(plugin.getIds()[0], plugin.getName());
} catch (Exception e) {
throw new RuntimeException("Error creating class for: " + plugin, e);
}
}
// Select a default: the first
/*
* if (databaseMeta.getDatabaseType() <= 0) { wDBType.select(0); } else {
*/
int idx = wDBType.indexOf(wDBIDtoNameMap.get(databaseMeta.getPluginId()));
if (idx >= 0) {
wDBType.select(idx);
} else {
wDBType.select(0);
}
// }
fdDBType = new FormData();
fdDBType.top = new FormAttachment(wName, margin);
fdDBType.left = new FormAttachment(middle, margin);
fdDBType.bottom = new FormAttachment(80, 0);
fdDBType.right = new FormAttachment(100, 0);
wDBType.setLayoutData(fdDBType);
wDBType.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
setAccessTypes();
setPageComplete(false);
}
});
wlAccType = new Label(composite, SWT.RIGHT);
wlAccType.setText(BaseMessages.getString(PKG, "CreateDatabaseWizardPage1.DBAccessType.Label"));
props.setLook(wlAccType);
fdlAccType = new FormData();
fdlAccType.left = new FormAttachment(0, 0);
fdlAccType.top = new FormAttachment(wDBType, margin);
fdlAccType.right = new FormAttachment(middle, 0);
wlAccType.setLayoutData(fdlAccType);
wAccType = new List(composite, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
props.setLook(wAccType);
fdAccType = new FormData();
fdAccType.top = new FormAttachment(wDBType, margin);
fdAccType.left = new FormAttachment(middle, margin);
fdAccType.bottom = new FormAttachment(100, 0);
fdAccType.right = new FormAttachment(100, 0);
wAccType.setLayoutData(fdAccType);
wAccType.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
setPageComplete(false);
}
});
setAccessTypes();
// set the composite as the control for this page
setControl(composite);
}
use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class GUIResource method loadJobEntryImages.
/**
* Load all step images from files.
*/
private void loadJobEntryImages() {
imagesJobentries = new Hashtable<String, SwtUniversalImage>();
imagesJobentriesSmall = new Hashtable<String, Image>();
// //
// // JOB ENTRY IMAGES TO LOAD
// //
PluginRegistry registry = PluginRegistry.getInstance();
List<PluginInterface> plugins = registry.getPlugins(JobEntryPluginType.class);
for (int i = 0; i < plugins.size(); i++) {
PluginInterface plugin = plugins.get(i);
if ("SPECIAL".equals(plugin.getIds()[0])) {
continue;
}
SwtUniversalImage image = null;
Image small_image = null;
String filename = plugin.getImageFile();
try {
ClassLoader classLoader = registry.getClassLoader(plugin);
image = SwtSvgImageUtil.getUniversalImage(display, classLoader, filename);
} catch (Throwable t) {
log.logError("Error occurred loading image [" + filename + "] for plugin " + plugin.getIds()[0], t);
} finally {
if (image == null) {
log.logError("Unable to load image [" + filename + "] for plugin " + plugin.getIds()[0]);
image = SwtSvgImageUtil.getMissingImage(display);
}
}
//
if (image != null) {
small_image = image.getAsBitmapForSize(display, ConstUI.MEDIUM_ICON_SIZE, ConstUI.MEDIUM_ICON_SIZE);
}
imagesJobentries.put(plugin.getIds()[0], image);
imagesJobentriesSmall.put(plugin.getIds()[0], small_image);
}
}
use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class GUIResource method loadStepImages.
/**
* Load all step images from files.
*/
private void loadStepImages() {
// imagesSteps.clear();
// imagesStepsSmall.clear();
//
// STEP IMAGES TO LOAD
//
PluginRegistry registry = PluginRegistry.getInstance();
List<PluginInterface> steps = registry.getPlugins(StepPluginType.class);
for (PluginInterface step : steps) {
if (imagesSteps.get(step.getIds()[0]) != null) {
continue;
}
SwtUniversalImage image = null;
Image small_image = null;
String filename = step.getImageFile();
try {
ClassLoader classLoader = registry.getClassLoader(step);
image = SwtSvgImageUtil.getUniversalImage(display, classLoader, filename);
} catch (Throwable t) {
log.logError("Error occurred loading image [" + filename + "] for plugin " + step, t);
} finally {
if (image == null) {
log.logError("Unable to load image file [" + filename + "] for plugin " + step);
image = SwtSvgImageUtil.getMissingImage(display);
}
}
// Calculate the smaller version of the image @ 16x16...
// Perhaps we should make this configurable?
//
small_image = image.getAsBitmapForSize(display, ConstUI.MEDIUM_ICON_SIZE, ConstUI.MEDIUM_ICON_SIZE);
imagesSteps.put(step.getIds()[0], image);
imagesStepsSmall.put(step.getIds()[0], small_image);
}
}
use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class ImportRulesDialog method getCompositesData.
protected void getCompositesData() {
for (TableItem item : table.getItems()) {
item.dispose();
}
table.clearAll();
// Fill the table items in the table with data from importRules:
//
compositesList = new ArrayList<ImportRuleCompositeInterface>();
for (ImportRuleInterface rule : importRules.getRules()) {
try {
TableItem item = new TableItem(table, SWT.NONE);
item.setChecked(rule.isEnabled());
PluginRegistry registry = PluginRegistry.getInstance();
PluginInterface plugin = registry.getPlugin(ImportRulePluginType.class, rule);
item.setText(1, Const.NVL(plugin.getName(), rule.getClass().getName()));
// Put a composite in the 3rd column...
//
// First get the composite generating class...
//
ImportRuleCompositeInterface importRuleComposite = getImportRuleComposite(rule);
compositesList.add(importRuleComposite);
final Composite composite = importRuleComposite.getComposite(table, rule);
composite.layout(true, true);
final TableEditor editor = new TableEditor(table);
editor.grabHorizontal = true;
editor.grabVertical = true;
editor.setEditor(composite, item, 2);
// Put actual data onto the composite
//
importRuleComposite.setCompositeData(rule);
item.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent event) {
composite.dispose();
}
});
} catch (Exception e) {
new ErrorDialog(shell, "Error", "Error displaying rule options for rule: " + rule.toString(), e);
compositesList.add(null);
}
}
}
Aggregations