use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class Spoon method editPartitioning.
public void editPartitioning(TransMeta transMeta, StepMeta stepMeta) {
String[] schemaNames;
try {
schemaNames = pickupPartitionSchemaNames(transMeta);
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.ErrorDialog.Title"), BaseMessages.getString(PKG, "Spoon.ErrorDialog.ErrorFetchingFromRepo.PartitioningSchemas"), e);
return;
}
try {
/*Check if Partition schema has already defined*/
if (isDefinedSchemaExist(schemaNames)) {
/*Prepare settings for Method selection*/
PluginRegistry registry = PluginRegistry.getInstance();
List<PluginInterface> plugins = registry.getPlugins(PartitionerPluginType.class);
int exactSize = StepPartitioningMeta.methodDescriptions.length + plugins.size();
PartitionSettings settings = new PartitionSettings(exactSize, transMeta, stepMeta, this);
settings.fillOptionsAndCodesByPlugins(plugins);
/*Method selection*/
PartitionMethodSelector methodSelector = new PartitionMethodSelector();
String partitionMethodDescription = methodSelector.askForPartitionMethod(shell, settings);
if (!StringUtil.isEmpty(partitionMethodDescription)) {
String method = settings.getMethodByMethodDescription(partitionMethodDescription);
int methodType = StepPartitioningMeta.getMethodType(method);
settings.updateMethodType(methodType);
settings.updateMethod(method);
/*Schema selection*/
MethodProcessor methodProcessor = MethodProcessorFactory.create(methodType);
methodProcessor.schemaSelection(settings, shell, delegates);
}
addUndoChange(settings.getTransMeta(), new StepMeta[] { settings.getBefore() }, new StepMeta[] { settings.getAfter() }, new int[] { settings.getTransMeta().indexOfStep(settings.getStepMeta()) });
refreshGraph();
}
} catch (Exception e) {
new ErrorDialog(shell, "Error", "There was an unexpected error while editing the partitioning method specifics:", e);
}
}
use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class SpoonUiExtenderPluginType method getRelevantExtenders.
public List<SpoonUiExtenderPluginInterface> getRelevantExtenders(Class<?> clazz, String uiEvent) {
PluginRegistry instance = PluginRegistry.getInstance();
List<PluginInterface> pluginInterfaces = instance.getPlugins(SpoonUiExtenderPluginType.class);
List<SpoonUiExtenderPluginInterface> relevantPluginInterfaces = new ArrayList<SpoonUiExtenderPluginInterface>();
if (pluginInterfaces != null) {
for (PluginInterface pluginInterface : pluginInterfaces) {
try {
Object loadClass = instance.loadClass(pluginInterface);
SpoonUiExtenderPluginInterface spoonUiExtenderPluginInterface = (SpoonUiExtenderPluginInterface) loadClass;
Set<String> events = spoonUiExtenderPluginInterface.respondsTo().get(clazz);
if (events != null && events.contains(uiEvent)) {
relevantPluginInterfaces.add(spoonUiExtenderPluginInterface);
}
} catch (KettlePluginException e) {
e.printStackTrace();
}
}
}
return relevantPluginInterfaces;
}
use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class TransDialog method open.
public TransMeta open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
props.setLook(shell);
shell.setImage(GUIResource.getInstance().getImageTransGraph());
lsMod = new ModifyListener() {
public void modifyText(ModifyEvent e) {
changed = true;
}
};
lsModSel = new SelectionAdapter() {
public void widgetSelected(SelectionEvent 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, "TransDialog.Shell.Title"));
middle = props.getMiddlePct();
margin = Const.MARGIN;
wTabFolder = new CTabFolder(shell, SWT.BORDER);
props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
wTabFolder.setSimple(false);
addTransTab();
addParamTab();
addLogTab();
addDateTab();
addDepTab();
addMiscTab();
addMonitoringTab();
// See if there are any other tabs to be added...
extraTabs = new ArrayList<TransDialogPluginInterface>();
java.util.List<PluginInterface> transDialogPlugins = PluginRegistry.getInstance().getPlugins(TransDialogPluginType.class);
for (PluginInterface transDialogPlugin : transDialogPlugins) {
try {
TransDialogPluginInterface extraTab = (TransDialogPluginInterface) PluginRegistry.getInstance().loadClass(transDialogPlugin);
extraTab.addTab(transMeta, parent, wTabFolder);
extraTabs.add(extraTab);
} catch (Exception e) {
KettleRepositoryLostException krle = KettleRepositoryLostException.lookupStackStrace(e);
if (krle != null) {
throw krle;
}
new ErrorDialog(shell, "Error", "Error loading transformation dialog plugin with id " + transDialogPlugin.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"));
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 }, Const.MARGIN, null);
// Add listeners
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
lsGet = new Listener() {
public void handleEvent(Event e) {
get();
}
};
lsSQL = new Listener() {
public void handleEvent(Event e) {
sql();
}
};
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
wOK.addListener(SWT.Selection, lsOK);
wGet.addListener(SWT.Selection, lsGet);
wSQL.addListener(SWT.Selection, lsSQL);
wCancel.addListener(SWT.Selection, lsCancel);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wTransname.addSelectionListener(lsDef);
wTransdescription.addSelectionListener(lsDef);
wTransversion.addSelectionListener(lsDef);
wMaxdatetable.addSelectionListener(lsDef);
wMaxdatefield.addSelectionListener(lsDef);
wMaxdateoffset.addSelectionListener(lsDef);
wMaxdatediff.addSelectionListener(lsDef);
wSizeRowset.addSelectionListener(lsDef);
wUniqueConnections.addSelectionListener(lsDef);
wFeedbackSize.addSelectionListener(lsDef);
wStepPerfInterval.addSelectionListener(lsDef);
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
if (currentTab != null) {
setCurrentTab(currentTab);
} else {
wTabFolder.setSelection(0);
}
getData();
BaseStepDialog.setSize(shell);
changed = false;
sharedObjectsFileChanged = false;
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return transMeta;
}
use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class BaseStepDialog method setShellImage.
private void setShellImage(Shell shell) {
if (stepMeta != null) {
PluginInterface plugin = PluginRegistry.getInstance().getPlugin(StepPluginType.class, stepMeta.getStepMetaInterface());
createHelpButton(shell, stepMeta, plugin);
String id = plugin.getIds()[0];
if (id != null) {
shell.setImage(GUIResource.getInstance().getImagesSteps().get(id).getAsBitmapForSize(shell.getDisplay(), ConstUI.ICON_SIZE, ConstUI.ICON_SIZE));
}
}
}
use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class SpoonStepsDelegate method getStepDialog.
public StepDialogInterface getStepDialog(StepMetaInterface stepMeta, TransMeta transMeta, String stepName) throws KettleException {
Class<?>[] paramClasses = new Class<?>[] { Shell.class, Object.class, TransMeta.class, String.class };
Object[] paramArgs = new Object[] { spoon.getShell(), stepMeta, transMeta, stepName };
PluginRegistry registry = PluginRegistry.getInstance();
PluginInterface plugin = registry.getPlugin(StepPluginType.class, stepMeta);
String dialogClassName = plugin.getClassMap().get(StepDialogInterface.class);
if (dialogClassName == null) {
// try the deprecated way
log.logDebug("Use of StepMetaInterface#getDialogClassName is deprecated, use PluginDialog annotation instead.");
dialogClassName = stepMeta.getDialogClassName();
}
try {
Class<StepDialogInterface> dialogClass = registry.getClass(plugin, dialogClassName);
Constructor<StepDialogInterface> dialogConstructor = dialogClass.getConstructor(paramClasses);
return dialogConstructor.newInstance(paramArgs);
} catch (Exception e) {
// try the old way for compatibility
try {
Class<?>[] sig = new Class<?>[] { Shell.class, StepMetaInterface.class, TransMeta.class, String.class };
Method method = stepMeta.getClass().getDeclaredMethod("getDialog", sig);
if (method != null) {
log.logDebug("Use of StepMetaInterface#getDialog is deprecated, use PluginDialog annotation instead.");
return (StepDialogInterface) method.invoke(stepMeta, paramArgs);
}
} catch (Throwable ignored) {
}
String errorTitle = BaseMessages.getString(PKG, "Spoon.Dialog.ErrorCreatingStepDialog.Title");
String errorMsg = BaseMessages.getString(PKG, "Spoon.Dialog.ErrorCreatingStepDialog.Message", dialogClassName);
new ErrorDialog(spoon.getShell(), errorTitle, errorMsg, e);
throw new KettleException(e);
}
}
Aggregations