use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class JobDialog method open.
public JobMeta open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN | SWT.APPLICATION_MODAL);
props.setLook(shell);
shell.setImage(GUIResource.getInstance().getImageJobGraph());
lsMod = new ModifyListener() {
public void modifyText(ModifyEvent e) {
changed = true;
}
};
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "JobDialog.JobProperties.ShellText"));
middle = props.getMiddlePct();
margin = Const.MARGIN;
wTabFolder = new CTabFolder(shell, SWT.BORDER);
props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
//
for (LogTableInterface logTable : logTables) {
// can be null
logTableUserInterfaces.add(getLogTableUserInterface(logTable, jobMeta, lsMod));
}
addJobTab();
addParamTab();
addSettingsTab();
addLogTab();
// See if there are any other tabs to be added...
extraTabs = new ArrayList<JobDialogPluginInterface>();
java.util.List<PluginInterface> jobDialogPlugins = PluginRegistry.getInstance().getPlugins(JobDialogPluginType.class);
for (PluginInterface jobDialogPlugin : jobDialogPlugins) {
try {
JobDialogPluginInterface extraTab = (JobDialogPluginInterface) PluginRegistry.getInstance().loadClass(jobDialogPlugin);
extraTab.addTab(jobMeta, parent, wTabFolder);
extraTabs.add(extraTab);
} catch (Exception e) {
KettleRepositoryLostException krle = KettleRepositoryLostException.lookupStackStrace(e);
if (krle != null) {
throw krle;
}
new ErrorDialog(shell, "Error", "Error loading job dialog plugin with id " + jobDialogPlugin.getIds()[0], e);
}
}
fdTabFolder = new FormData();
fdTabFolder.left = new FormAttachment(0, 0);
fdTabFolder.top = new FormAttachment(0, 0);
fdTabFolder.right = new FormAttachment(100, 0);
fdTabFolder.bottom = new FormAttachment(100, -50);
wTabFolder.setLayoutData(fdTabFolder);
// THE BUTTONS
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wSQL = new Button(shell, SWT.PUSH);
wSQL.setText(BaseMessages.getString(PKG, "System.Button.SQL"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
// BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wSQL, wCancel }, margin, wSharedObjectsFile);
BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wSQL, wCancel }, Const.MARGIN, null);
// Add listeners
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
lsSQL = new Listener() {
public void handleEvent(Event e) {
sql();
}
};
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
wOK.addListener(SWT.Selection, lsOK);
wSQL.addListener(SWT.Selection, lsSQL);
wCancel.addListener(SWT.Selection, lsCancel);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wJobname.addSelectionListener(lsDef);
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
wTabFolder.setSelection(0);
getData();
BaseStepDialog.setSize(shell);
changed = false;
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return jobMeta;
}
use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class DataHandlerTest method testDatabaseTypeListener.
@Test
public void testDatabaseTypeListener() throws Exception {
DataHandler.DatabaseTypeListener listener = spy(new DataHandler.DatabaseTypeListener(PluginRegistry.getInstance()) {
@Override
public void databaseTypeAdded(String pluginName, DatabaseInterface databaseInterface) {
}
@Override
public void databaseTypeRemoved(String pluginName) {
}
});
assertNotNull(listener);
PluginInterface pluginInterface = mock(PluginInterface.class);
when(pluginInterface.getName()).thenReturn("Oracle");
doReturn(DatabaseInterface.class).when(pluginInterface).getMainType();
when(pluginInterface.getIds()).thenReturn(new String[] { "oracle" });
doReturn(DatabasePluginType.class).when(pluginInterface).getPluginType();
listener.pluginAdded(pluginInterface);
// The test can't load the plugin, so databaseTypeAdded never gets called. Perhaps register a mock plugin
verify(listener, never()).databaseTypeAdded(eq("Oracle"), any(DatabaseInterface.class));
listener.pluginRemoved(pluginInterface);
verify(listener, times(1)).databaseTypeRemoved("Oracle");
// Changed calls removed then added
listener.pluginChanged(pluginInterface);
verify(listener, times(2)).databaseTypeRemoved("Oracle");
verify(listener, never()).databaseTypeAdded(eq("Oracle"), any(DatabaseInterface.class));
}
use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class ImportRules method getXML.
public String getXML() {
StringBuilder xml = new StringBuilder();
xml.append(XMLHandler.openTag(XML_TAG)).append(Const.CR).append(Const.CR);
for (ImportRuleInterface rule : getRules()) {
PluginInterface plugin = PluginRegistry.getInstance().getPlugin(ImportRulePluginType.class, rule.getId());
xml.append("<!-- ").append(plugin.getName()).append(" : ").append(plugin.getDescription()).append(Const.CR).append(" -->").append(Const.CR);
xml.append(rule.getXML());
xml.append(Const.CR).append(Const.CR);
}
xml.append(XMLHandler.closeTag(XML_TAG));
return xml.toString();
}
use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class BaseImportRule method toString.
@Override
public String toString() {
// The rule name with an indication of whether or not this rule is enabled should do for now.
//
String pluginId = PluginRegistry.getInstance().getPluginId(this);
PluginInterface plugin = PluginRegistry.getInstance().findPluginWithId(ImportRulePluginType.class, pluginId);
return plugin.getName() + " (" + (enabled ? "enabled" : "disabled") + ").";
}
use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class ValueMetaFactory method getAllValueMetaNames.
public static String[] getAllValueMetaNames() {
List<String> strings = new ArrayList<String>();
List<PluginInterface> plugins = pluginRegistry.getPlugins(ValueMetaPluginType.class);
for (PluginInterface plugin : plugins) {
String id = plugin.getIds()[0];
if (!("0".equals(id))) {
strings.add(plugin.getName());
}
}
return strings.toArray(new String[strings.size()]);
}
Aggregations