use of org.talend.core.ui.ITestContainerProviderService in project tdi-studio-se by Talend.
the class AbstractTalendEditor method setFocus.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.ui.parts.GraphicalEditor#setFocus()
*/
@Override
public void setFocus() {
IComponentSettingsView viewer = (IComponentSettingsView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(IComponentSettingsView.ID);
if (viewer != null) {
IStructuredSelection selection = (IStructuredSelection) getViewer().getSelection();
if (selection.size() == 1 && (selection.getFirstElement() instanceof NodePart || selection.getFirstElement() instanceof ConnectionPart || selection.getFirstElement() instanceof SubjobContainerPart || selection.getFirstElement() instanceof ConnLabelEditPart)) {
viewer.setElement((Element) ((AbstractEditPart) selection.getFirstElement()).getModel());
} else {
viewer.cleanDisplay();
}
}
JobSettings.switchToCurJobSettingsView();
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
ITestContainerProviderService testContainerService = (ITestContainerProviderService) GlobalServiceRegister.getDefault().getService(ITestContainerProviderService.class);
if (testContainerService != null) {
testContainerService.switchToCurTestContainerView();
}
}
super.setFocus();
if (!readOnly) {
// When gain focus, check read-only to disable read-only mode if process has been restore while opened :
// 1. Enabled/disabled components :
// process.checkReadOnly();
// 2. Set backgroung color :
List children = getViewer().getRootEditPart().getChildren();
if (!children.isEmpty()) {
ProcessPart rep = (ProcessPart) children.get(0);
rep.ajustReadOnly();
}
}
}
use of org.talend.core.ui.ITestContainerProviderService in project tdi-studio-se by Talend.
the class DefaultRunProcessService method createJavaProcessor.
/**
* DOC xue Comment method "createJavaProcessor".
*
* @param process
* @param filenameFromLabel
* @return
*/
protected IProcessor createJavaProcessor(IProcess process, Property property, boolean filenameFromLabel) {
boolean isTestContainer = false;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
ITestContainerProviderService testContainerService = (ITestContainerProviderService) GlobalServiceRegister.getDefault().getService(ITestContainerProviderService.class);
if (testContainerService != null && property != null && property.getItem() != null) {
isTestContainer = testContainerService.isTestContainerItem(property.getItem());
}
}
if (isTestContainer) {
return new MavenJavaProcessor(process, property, filenameFromLabel);
}
// check for ESB Runtime
if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBRunContainerService.class)) {
IESBRunContainerService runContainerService = (IESBRunContainerService) GlobalServiceRegister.getDefault().getService(IESBRunContainerService.class);
if (runContainerService != null) {
IProcessor processor = runContainerService.createJavaProcessor(process, property, filenameFromLabel);
if (processor != null) {
return processor;
}
}
}
if (ComponentCategory.CATEGORY_4_MAPREDUCE.getName().equals(process.getComponentsType())) {
return new MapReduceJavaProcessor(process, property, filenameFromLabel);
} else if (ComponentCategory.CATEGORY_4_SPARK.getName().equals(process.getComponentsType())) {
return new SparkJavaProcessor(process, property, filenameFromLabel);
} else if (ComponentCategory.CATEGORY_4_STORM.getName().equals(process.getComponentsType())) {
return new StormJavaProcessor(process, property, filenameFromLabel);
} else if (ComponentCategory.CATEGORY_4_SPARKSTREAMING.getName().equals(process.getComponentsType())) {
return new SparkJavaProcessor(process, property, filenameFromLabel);
} else if (ComponentCategory.CATEGORY_4_CAMEL.getName().equals(process.getComponentsType())) {
Bundle bundle = Platform.getBundle(PluginChecker.EXPORT_ROUTE_PLUGIN_ID);
if (bundle != null) {
try {
Class camelJavaProcessor = bundle.loadClass("org.talend.resources.export.maven.runprocess.CamelJavaProcessor");
Constructor constructor = camelJavaProcessor.getConstructor(IProcess.class, Property.class, boolean.class);
return (MavenJavaProcessor) constructor.newInstance(process, property, filenameFromLabel);
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
return new MavenJavaProcessor(process, property, filenameFromLabel);
} else {
return new MavenJavaProcessor(process, property, filenameFromLabel);
}
}
use of org.talend.core.ui.ITestContainerProviderService in project tdi-studio-se by Talend.
the class NodePart method performRequest.
@Override
public void performRequest(Request req) {
Node node = (Node) getModel();
IExternalData oldExternalData = node.getExternalData();
if (req.getType().equals(RequestConstants.REQ_OPEN)) {
IExternalNode externalNode = null;
if (node.isExternalNode()) {
IElementParameter externalParam = node.getElementParameterFromField(EParameterFieldType.EXTERNAL);
if (externalParam != null && externalParam.isShow(node.getElementParameters())) {
externalNode = ExternalUtilities.getExternalNodeReadyToOpen(node);
}
}
IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (externalNode != null && (part instanceof AbstractMultiPageTalendEditor)) {
boolean isOriginalNode = false;
ITestContainerProviderService testContainerService = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
testContainerService = (ITestContainerProviderService) GlobalServiceRegister.getDefault().getService(ITestContainerProviderService.class);
if (testContainerService != null) {
isOriginalNode = testContainerService.isOriginalNode(node);
if (isOriginalNode) {
testContainerService.renameConnection(node, true);
}
}
}
int returnValue = externalNode.open(getViewer().getControl().getShell());
if (!node.isReadOnly()) {
if (returnValue == SWT.OK) {
Command cmd = new ExternalNodeChangeCommand(node, externalNode, oldExternalData);
CommandStack cmdStack = (CommandStack) part.getAdapter(CommandStack.class);
cmdStack.execute(cmd);
} else {
externalNode.setExternalData(oldExternalData);
}
}
if (isOriginalNode && (testContainerService != null)) {
testContainerService.renameConnection(node, false);
}
} else {
// add for feature 13361
boolean isJoblet = false;
if (PluginChecker.isJobLetPluginLoaded()) {
AbstractProcessProvider jobletProcessProvider = AbstractProcessProvider.findProcessProviderFromPID(IComponent.JOBLET_PID);
final IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
boolean isAvoidShowJobletAfterDoubleClick = false;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IComponentsLocalProviderService.class)) {
IComponentsLocalProviderService componentService = (IComponentsLocalProviderService) GlobalServiceRegister.getDefault().getService(IComponentsLocalProviderService.class);
if (componentService != null) {
isAvoidShowJobletAfterDoubleClick = componentService.isAvoidToShowJobletAfterDoubleClick();
}
}
if (service != null && service.isJobletComponent(node) && !isAvoidShowJobletAfterDoubleClick) {
isJoblet = true;
String version = (String) node.getPropertyValue(EParameterName.PROCESS_TYPE_VERSION.getName());
final Item jobletItem = jobletProcessProvider.getJobletItem(node, version);
RepositoryWorkUnit<Object> repositoryWorkUnit = new RepositoryWorkUnit<Object>("", this) {
@Override
protected void run() throws LoginException, PersistenceException {
if (jobletItem != null) {
service.openJobletItem((JobletProcessItem) jobletItem);
}
}
};
repositoryWorkUnit.setAvoidUnloadResources(true);
CoreRuntimePlugin.getInstance().getProxyRepositoryFactory().executeRepositoryWorkUnit(repositoryWorkUnit);
}
}
if (!isJoblet) {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
String processName = (String) node.getPropertyValue(EParameterName.PROCESS_TYPE_PROCESS.getName());
String version = (String) node.getPropertyValue(EParameterName.PROCESS_TYPE_VERSION.getName());
boolean isAvoidShowJobAfterDoubleClick = false;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IComponentsLocalProviderService.class)) {
IComponentsLocalProviderService service = (IComponentsLocalProviderService) GlobalServiceRegister.getDefault().getService(IComponentsLocalProviderService.class);
if (service != null) {
isAvoidShowJobAfterDoubleClick = service.isAvoidToShowJobAfterDoubleClick();
}
}
// bug 20796
boolean isSelectUseDynamic = false;
Object useDynamicJobValue = node.getPropertyValue(EParameterName.USE_DYNAMIC_JOB.getName());
if (useDynamicJobValue != null && useDynamicJobValue instanceof Boolean) {
isSelectUseDynamic = (Boolean) useDynamicJobValue;
}
if (processName != null && !"".equals(processName) && !isAvoidShowJobAfterDoubleClick && !isSelectUseDynamic) {
//$NON-NLS-1$
ItemCacheManager.clearCache();
ProcessItem processItem = ItemCacheManager.getProcessItem(processName, version);
if (processItem == null) {
return;
}
Property updatedProperty = null;
try {
updatedProperty = ProxyRepositoryFactory.getInstance().getLastVersion(new Project(ProjectManager.getInstance().getProject(processItem)), processName).getProperty();
} catch (PersistenceException e) {
CommonExceptionHandler.process(e);
}
// update the property of the node repository object
// node.getObject().setProperty(updatedProperty);
processItem = (ProcessItem) updatedProperty.getItem();
final ProcessItem item = processItem;
RepositoryWorkUnit<Object> repositoryWorkUnit = new RepositoryWorkUnit<Object>("", this) {
@Override
protected void run() throws LoginException, PersistenceException {
try {
if (item != null) {
ERepositoryObjectType repObjType = ERepositoryObjectType.getItemType(item);
IJobEditorHandler editorInputFactory = JobEditorHandlerManager.getInstance().extractEditorInputFactory(repObjType.getType());
editorInputFactory.openJobEditor(editorInputFactory.createJobEditorInput(item, true));
}
} catch (PartInitException e) {
MessageBoxExceptionHandler.process(e);
}
}
};
repositoryWorkUnit.setAvoidUnloadResources(true);
CoreRuntimePlugin.getInstance().getProxyRepositoryFactory().executeRepositoryWorkUnit(repositoryWorkUnit);
} else {
try {
// modified for feature 2454.
page.showView(ComponentSettingsView.ID);
} catch (PartInitException e) {
CommonExceptionHandler.process(e);
}
}
}
}
}
super.performRequest(req);
}
use of org.talend.core.ui.ITestContainerProviderService in project tdi-studio-se by Talend.
the class PaletteSettingPage method getComponentsUsedInProject.
public Set<IComponent> getComponentsUsedInProject(Project project) {
if (componentsUsed != null) {
return componentsUsed;
}
componentsUsed = new HashSet<IComponent>();
IProxyRepositoryFactory repositoryFactory = CoreUIPlugin.getDefault().getProxyRepositoryFactory();
try {
ERepositoryObjectType jobType = ERepositoryObjectType.PROCESS;
if (jobType != null) {
List<IRepositoryViewObject> allProcess = repositoryFactory.getAll(project, jobType, true);
addUsedComponents(componentsUsed, allProcess, ComponentCategory.CATEGORY_4_DI);
}
ERepositoryObjectType jobletType = ERepositoryObjectType.JOBLET;
if (jobletType != null) {
List<IRepositoryViewObject> allJoblet = repositoryFactory.getAll(project, jobletType, true);
addUsedComponents(componentsUsed, allJoblet, ComponentCategory.CATEGORY_4_DI);
}
ERepositoryObjectType routeType = ERepositoryObjectType.PROCESS_ROUTE;
if (routeType != null) {
List<IRepositoryViewObject> allRoutes = repositoryFactory.getAll(project, routeType, true);
addUsedComponents(componentsUsed, allRoutes, ComponentCategory.CATEGORY_4_CAMEL);
}
//$NON-NLS-1$
ERepositoryObjectType mrType = ERepositoryObjectType.valueOf("PROCESS_MR");
if (mrType != null) {
List<IRepositoryViewObject> allMr = repositoryFactory.getAll(project, mrType, true);
addUsedComponents(componentsUsed, allMr, ComponentCategory.CATEGORY_4_MAPREDUCE);
addUsedComponents(componentsUsed, allMr, ComponentCategory.CATEGORY_4_SPARK);
}
//$NON-NLS-1$
ERepositoryObjectType stormType = ERepositoryObjectType.valueOf("PROCESS_STORM");
if (stormType != null) {
List<IRepositoryViewObject> allStorm = repositoryFactory.getAll(project, stormType, true);
addUsedComponents(componentsUsed, allStorm, ComponentCategory.CATEGORY_4_STORM);
addUsedComponents(componentsUsed, allStorm, ComponentCategory.CATEGORY_4_SPARKSTREAMING);
}
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
ITestContainerProviderService testContainerService = (ITestContainerProviderService) GlobalServiceRegister.getDefault().getService(ITestContainerProviderService.class);
if (testContainerService != null) {
ERepositoryObjectType testCaseType = testContainerService.getTestCaseObjectType();
if (testCaseType != null) {
List<IRepositoryViewObject> allTestCase = repositoryFactory.getAll(project, testCaseType, true);
addUsedComponents(componentsUsed, allTestCase, ComponentCategory.CATEGORY_4_SPARK);
addUsedComponents(componentsUsed, allTestCase, ComponentCategory.CATEGORY_4_DI);
}
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
return componentsUsed;
}
use of org.talend.core.ui.ITestContainerProviderService in project tdi-studio-se by Talend.
the class ComponentChooseDialog method createNewComponent.
public void createNewComponent(DropTargetEvent event1) {
boolean quickCreateInput = event1.detail == DND.DROP_LINK;
boolean quickCreateOutput = event1.detail == DND.DROP_COPY;
Iterator iterator = getSelection().iterator();
List<TempStore> list = new ArrayList<TempStore>();
List<IComponent> components = new ArrayList<IComponent>();
while (iterator.hasNext()) {
Object obj = iterator.next();
if (obj instanceof RepositoryNode) {
RepositoryNode sourceNode = (RepositoryNode) obj;
if (equalsJobInCurrentEditor(sourceNode)) {
continue;
}
Item item = sourceNode.getObject().getProperty().getItem();
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
ITestContainerProviderService testContainerService = (ITestContainerProviderService) GlobalServiceRegister.getDefault().getService(ITestContainerProviderService.class);
if (testContainerService != null && testContainerService.isTestContainerItem(item)) {
continue;
}
}
ERepositoryObjectType type = sourceNode.getObjectType();
if (!(item instanceof ConnectionItem) && !(item instanceof ProcessItem) && !(item instanceof JobletProcessItem) && !(item instanceof RulesItem) && !(item instanceof LinkRulesItem)) {
// RulesItem
return;
}
{
/**
* Remove this limitation for feature: TDI-32362, I think it should be ok, don't know why adding
* this limitation to forbid to d&d salseforce connection, I keep those code in case this behavior
* will cause some bugs when d&d salseforce connection, then maybe need to review
*/
// if (item instanceof SalesforceSchemaConnectionItem && type ==
// ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA) {
// return;
// }
}
TempStore store = new TempStore();
store.seletetedNode = sourceNode;
getAppropriateComponent(item, quickCreateInput, quickCreateOutput, store, type);
if (store.component != null) {
list.add(store);
} else {
MessageDialog.openInformation(editor.getEditorSite().getShell(), //$NON-NLS-1$
Messages.getString("TalendEditorDropTargetListener.dngsupportdialog.title"), //$NON-NLS-1$
Messages.getString("TalendEditorDropTargetListener.dngsupportdialog.content"));
}
}
org.eclipse.swt.graphics.Point swtLocation = new org.eclipse.swt.graphics.Point(event1.x, event1.y);
Canvas canvas = (Canvas) editor.getViewer().getControl();
/*
* translate to Canvas coordinate
*/
swtLocation = canvas.toControl(swtLocation);
org.eclipse.swt.graphics.Point size = canvas.getSize();
/*
* translate to Viewport coordinate with zoom
*/
org.eclipse.draw2d.geometry.Point draw2dPosition = new org.eclipse.draw2d.geometry.Point(swtLocation.x, swtLocation.y);
/*
* calcule the view port position. Take into acounte the scroll position
*/
ProcessPart part = (ProcessPart) editor.getViewer().getRootEditPart().getRoot().getChildren().get(0);
IFigure targetFigure = part.getFigure();
translateAbsolateToRelative(targetFigure, draw2dPosition);
//$NON-NLS-1$
String lastUniqname = "";
// creates every node
for (TempStore store : list) {
RepositoryNode selectedNode = store.seletetedNode;
IComponent element = store.component;
if (!components.contains(element)) {
components.add(element);
}
Node node = new Node(element);
// for bug4564(metadata label format)
// IPreferenceStore preferenceStore = DesignerPlugin.getDefault().getPreferenceStore();
// if (preferenceStore.getBoolean(TalendDesignerPrefConstants.USE_REPOSITORY_NAME)) {
// node.setPropertyValue(EParameterName.LABEL.getName(), selectedNode.getObject().getLabel());
// }
IPreferenceStore preferenceStore = DesignerPlugin.getDefault().getPreferenceStore();
if (preferenceStore.getBoolean(TalendDesignerPrefConstants.USE_REPOSITORY_NAME)) {
String LabelValue = null;
RepositoryNode repositoryNode = null;
repositoryNode = (RepositoryNode) getSelection().getFirstElement();
// dnd a table
IElementParameter dbTableParam = node.getElementParameterFromField(EParameterFieldType.DBTABLE);
boolean hasDbTableField = dbTableParam != null;
if (repositoryNode.getObjectType() == ERepositoryObjectType.METADATA_CON_TABLE && repositoryNode.getObject() != null && repositoryNode.getObject().getProperty().getItem() instanceof DatabaseConnectionItem && hasDbTableField) {
LabelValue = DesignerUtilities.getParameterVar(dbTableParam.getName());
} else if (repositoryNode.getObjectType() == ERepositoryObjectType.PROCESS || repositoryNode.getObjectType() == ERepositoryObjectType.PROCESS_MR || repositoryNode.getObjectType() == ERepositoryObjectType.PROCESS_STORM) {
// dnd a job
LabelValue = DesignerUtilities.getParameterVar(EParameterName.PROCESS);
} else if (repositoryNode.getObjectType() == ERepositoryObjectType.JOBLET || repositoryNode.getObjectType() == ERepositoryObjectType.SPARK_JOBLET || repositoryNode.getObjectType() == ERepositoryObjectType.SPARK_STREAMING_JOBLET) {
LabelValue = element.getName();
} else if (CorePlugin.getDefault().getDesignerCoreService().getPreferenceStore(TalendDesignerPrefConstants.DEFAULT_LABEL).equals(node.getPropertyValue(EParameterName.LABEL.getName()))) {
// dnd a default
LabelValue = selectedNode.getObject().getLabel();
}
if (LabelValue != null) {
node.setPropertyValue(EParameterName.LABEL.getName(), LabelValue);
}
}
processSpecificDBTypeIfSameProduct(store.componentName, node);
NodeContainer nc = ((Process) node.getProcess()).loadNodeContainer(node, false);
;
// create component on link
boolean executed = false;
if (getSelection().size() == 1 && getTargetEditPart() instanceof SubjobContainerPart) {
executed = createComponentOnLink(node, draw2dPosition);
}
if (!executed) {
// create the node on the design sheet
execCommandStack(new CreateNodeContainerCommand((Process) editor.getProcess(), nc, draw2dPosition));
}
// initialize the propertiesView
CompoundCommand cc = new CompoundCommand();
createRefreshingPropertiesCommand(cc, selectedNode, node);
execCommandStack(cc);
// for (Command command : commands) {
// }
propaHadoopCfgChanges(selectedNode);
draw2dPosition = draw2dPosition.getCopy();
draw2dPosition.x += TalendEditor.GRID_SIZE;
draw2dPosition.y += TalendEditor.GRID_SIZE;
node.checkNode();
lastUniqname = node.getUniqueName();
}
// setselecte(part, lastUniqname);
}
// Shell shell = Display.getCurrent().getActiveShell();
// ModulesInstallerUtil.installModules(new Shell(shell), components);
}
Aggregations