use of org.talend.repository.model.IRepositoryNode in project tdi-studio-se by Talend.
the class EditProcess method getSelectedObject.
private IRepositoryNode getSelectedObject() {
if (params == null) {
ISelection selection = getSelection();
if (selection != null) {
return (IRepositoryNode) ((IStructuredSelection) selection).getFirstElement();
}
} else {
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (null == workbenchWindow) {
return null;
}
IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
if (null == workbenchPage) {
return null;
}
IPerspectiveDescriptor currentPerspective = workbenchPage.getPerspective();
if (!getPerspectiveId().equals(currentPerspective.getId())) {
// show di perspective
try {
workbenchWindow.getWorkbench().showPerspective(getPerspectiveId(), workbenchWindow);
workbenchPage = workbenchWindow.getActivePage();
} catch (WorkbenchException e) {
ExceptionHandler.process(e);
return null;
}
}
IRepositoryNode repositoryNode = RepositorySeekerManager.getInstance().searchRepoViewNode(params.getProperty("nodeId"), false);
IRepositoryView viewPart = getViewPart();
if (repositoryNode != null && viewPart != null) {
RepositoryNodeUtilities.expandParentNode(viewPart, repositoryNode);
return repositoryNode;
}
}
return null;
}
use of org.talend.repository.model.IRepositoryNode in project tdi-studio-se by Talend.
the class SaveAsProcessAction method run.
@Override
public void run() {
SaveAsProcessWizard processWizard = new SaveAsProcessWizard(editorPart);
WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), processWizard);
if (dlg.open() == Window.OK) {
try {
// Set readonly to false since created job will always be editable.
JobEditorInput newJobEditorInput = new ProcessEditorInput(processWizard.getProcess(), true, true, false);
IWorkbenchPage page = getActivePage();
IRepositoryNode repositoryNode = RepositoryNodeUtilities.getRepositoryNode(newJobEditorInput.getItem().getProperty().getId(), false);
newJobEditorInput.setRepositoryNode(repositoryNode);
// close the old editor
page.closeEditor(((AbstractTalendEditor) this.editorPart).getParent(), false);
// open the new editor, because at the same time, there will update the jobSetting/componentSetting view
page.openEditor(newJobEditorInput, MultiPageTalendEditor.ID, true);
} catch (Exception e) {
MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", "Job could not be saved" + " : " + e.getMessage());
ExceptionHandler.process(e);
}
}
}
use of org.talend.repository.model.IRepositoryNode in project tdi-studio-se by Talend.
the class ComponentChooseDialog method getChangeMetadataCommand.
/**
* DOC bqian Comment method "getChangeMetadataCommand".
*
* @param selectedNode
* @param node
* @param list
* @param connectionItem
*/
private void getChangeMetadataCommand(CompoundCommand cc, RepositoryNode selectedNode, Node node, ConnectionItem connectionItem) {
if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_CON_COLUMN) {
RepositoryNode columnParentNode = selectedNode.getParent().getParent();
if (columnParentNode != null) {
selectedNode = columnParentNode;
}
}
if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_CON_TABLE || selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_SAP_FUNCTION || selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_SALESFORCE_MODULE) {
String etlSchema = null;
if (connectionItem.getConnection() instanceof DatabaseConnection) {
DatabaseConnection connection = (DatabaseConnection) connectionItem.getConnection();
if (connection instanceof DatabaseConnection) {
etlSchema = connection.getUiSchema();
}
if (!"".equals(etlSchema)) {
//$NON-NLS-1$
//$NON-NLS-1$
IElementParameter e = node.getElementParameter("ELT_SCHEMA_NAME");
if (e != null) {
if (connection.isContextMode() && ContextParameterUtils.isContainContextParam(etlSchema)) {
e.setValue(etlSchema);
} else {
e.setValue(TalendTextUtils.addQuotes(etlSchema));
}
}
// node.getElementParameter("ELT_SCHEMA_NAME").setValue("\"" + etlSchema + "\"");
}
}
IRepositoryViewObject object = selectedNode.getObject();
MetadataTable table = null;
if (object instanceof MetadataTableRepositoryObject) {
table = ((MetadataTableRepositoryObject) object).getTable();
} else if (object instanceof SalesforceModuleRepositoryObject) {
table = ((SalesforceModuleRepositoryObject) object).getDefaultTable();
IRepositoryViewObject obj = null;
if (selectedNode.getChildren() != null) {
for (IRepositoryNode repositoryNode : selectedNode.getChildren()) {
obj = repositoryNode.getObject();
if (obj instanceof MetadataTableRepositoryObject) {
table = ((MetadataTableRepositoryObject) obj).getTable();
break;
}
}
}
}
// for SAP
if (PluginChecker.isSAPWizardPluginLoaded() && connectionItem instanceof SAPConnectionItem) {
getSAPCommand(cc, object, connectionItem, table, node);
return;
}
if (table != null) {
//$NON-NLS-1$
String value = connectionItem.getProperty().getId() + " - " + table.getLabel();
IElementParameter schemaParam = node.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE);
if (schemaParam == null) {
schemaParam = node.getElementParameterFromField(EParameterFieldType.SCHEMA_REFERENCE);
}
IElementParameter queryParam = node.getElementParameterFromField(EParameterFieldType.QUERYSTORE_TYPE);
if (queryParam != null) {
queryParam = queryParam.getChildParameters().get(EParameterName.QUERYSTORE_TYPE.getName());
if (queryParam != null) {
queryParam.setValue(EmfComponent.BUILTIN);
}
}
// }
if (PluginChecker.isHL7PluginLoaded() && connectionItem instanceof HL7ConnectionItem) {
Command hl7Cmd = new RepositoryChangeMetadataForHL7Command(node, IEbcdicConstant.TABLE_SCHEMAS, table.getLabel(), ConvertionHelper.convert(table));
cc.add(hl7Cmd);
return;
}
if (schemaParam == null) {
return;
}
if (node.isELTComponent()) {
//$NON-NLS-1$
node.setPropertyValue(EParameterName.LABEL.getName(), "__ELT_TABLE_NAME__");
}
schemaParam.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
RepositoryChangeMetadataCommand command2 = new RepositoryChangeMetadataCommand(node, //$NON-NLS-1$
schemaParam.getName() + ":" + EParameterName.REPOSITORY_SCHEMA_TYPE.getName(), value, ConvertionHelper.convert(table), null, connectionItem.getConnection());
cc.add(command2);
return;
}
}
}
use of org.talend.repository.model.IRepositoryNode in project tdi-studio-se by Talend.
the class ComponentChooseDialog method handleDrop.
// private void checkRequiredModules() {
// Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
// if (newObject instanceof Node) {
// IComponent component = ((Node) newObject).getComponent();
// Shell shell = Display.getCurrent().getActiveShell();
// ModulesInstallerUtil.installModules(new Shell(shell), component);
// }
// }
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.dnd.TemplateTransferDropTargetListener#handleDrop()
*/
@Override
protected void handleDrop() {
updateTargetRequest();
updateTargetEditPart();
// checkRequiredModules();
if (fromPalette && getTargetRequest() instanceof CreateRequest) {
if (selectedConnectionPart != null) {
CreateRequest req = ((CreateRequest) getTargetRequest());
Object o = req.getNewObject();
Point location = req.getLocation();
if (o instanceof Node) {
createComponentOnLink((Node) o, location);
}
// checkRequiredModules();
return;
} else if (getTargetEditPart() instanceof ProcessPart) {
// for palette dnd, feature 6457
Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
if (newObject != null) {
Command command = getCommand();
if (command != null) {
execCommandStack(command);
}
}
// checkRequiredModules();
return;
} else if (getTargetEditPart() instanceof SubjobContainerPart) {
// TDI-24985:for palette dnd.
Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
if (newObject != null) {
Command command = getCommand();
if (command != null) {
execCommandStack(command);
}
}
return;
} else if (getTargetEditPart() instanceof JobletContainerPart) {
JobletContainerPart jobletPart = (JobletContainerPart) getTargetEditPart();
if (isLock(jobletPart)) {
Shell shell = Display.getCurrent().getActiveShell();
ChooseJobletDialog dialog = new ChooseJobletDialog(new Shell(shell), getDropLocation());
if (dialog.open() == dialog.OK) {
EditPart part = getTargetEditPart();
if (dialog.addToJoblet()) {
AbstractMultiPageTalendEditor openEditor = getJobletPart((JobletContainerPart) part);
part = openEditor.getDesignerEditor().getProcessPart();
// editor = openEditor.getTalendEditor();
setTargetEditPart(part);
Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
if (newObject != null) {
Command command = getCommand();
if (command != null) {
CommandStack commandStack = (CommandStack) openEditor.getAdapter(CommandStack.class);
if (commandStack != null) {
commandStack.execute(command);
} else {
command.execute();
}
}
}
// checkRequiredModules();
return;
} else {
part = getParentPart(part);
setTargetEditPart(part);
Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
if (newObject != null) {
Command command = getCommand();
if (command != null) {
execCommandStack(command);
}
}
// checkRequiredModules();
return;
}
}
}
}
}
List<Object> sources = getSelectSource();
if (containsContextSource(sources)) {
createContext(sources);
} else {
if (!(getTargetEditPart() instanceof NodeContainerPart)) {
try {
createNewComponent(getCurrentEvent());
} catch (OperationCanceledException e) {
return;
}
} else {
if (containsSQLPatternSource(sources)) {
createSQLPattern(sources);
} else {
Object obj = getSelection().getFirstElement();
createSchema(obj, getTargetEditPart());
createQuery(obj, getTargetEditPart());
createProperty(obj, getTargetEditPart());
createChildJob(obj, getTargetEditPart());
createValidationRule(obj, getTargetEditPart());
if (obj instanceof IRepositoryNode) {
propaHadoopCfgChanges((IRepositoryNode) obj);
}
for (IExtendedNodeHandler hander : ExtendedNodeManager.getExtendedNodeHandler()) {
boolean updated = hander.updateComponent(obj, getTargetEditPart(), editor.getCommandStack());
if (updated) {
break;
}
}
}
}
}
// in case after drag/drop the editor is dirty but can not get focus
if (editor.isDirty()) {
editor.setFocus();
}
this.eraseTargetFeedback();
}
use of org.talend.repository.model.IRepositoryNode in project tdi-studio-se by Talend.
the class StatusManagerSettingPage method processItems.
private void processItems(List<RepositoryObject> objects, IRepositoryNode node) {
if (node == null) {
return;
}
// if the root node of type is not init, force init.
IProjectRepositoryNode root = node.getRoot();
if (root instanceof ProjectRepositoryNode) {
((ProjectRepositoryNode) root).initNode(node);
}
if (node.getType() == ENodeType.REPOSITORY_ELEMENT) {
if (node.getObject() != null) {
Property property = node.getObject().getProperty();
Item item = property.getItem();
if (item != null && filterRepositoryNode((RepositoryNode) node)) {
// must be item
RepositoryObject object = new RepositoryObject(node.getObject().getProperty());
object.setRepositoryNode(node);
// ItemVersionObject object = new ItemVersionObject(node, property.getVersion());
objects.add(object);
}
}
} else {
IContentProvider contentProvider = treeViewer.getContentProvider();
if (contentProvider instanceof NavigatorContentServiceContentProvider) {
NavigatorContentServiceContentProvider navigatorProvider = (NavigatorContentServiceContentProvider) contentProvider;
Object[] children = navigatorProvider.getChildren(node);
for (Object child : children) {
if (child instanceof RepositoryNode) {
processItems(objects, (RepositoryNode) child);
}
}
} else {
for (IRepositoryNode child : node.getChildren()) {
processItems(objects, child);
}
}
}
}
Aggregations