use of org.talend.repository.model.IRepositoryNode in project tdi-studio-se by Talend.
the class SaveAsBusinessModelAction method run.
@Override
public void run() {
SaveAsBusinessModelWizard businessModelWizard = new SaveAsBusinessModelWizard(editorPart);
WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), businessModelWizard);
if (dlg.open() == Window.OK) {
try {
BusinessProcessItem businessProcessItem = businessModelWizard.getBusinessProcessItem();
IRepositoryNode repositoryNode = RepositoryNodeUtilities.getRepositoryNode(businessProcessItem.getProperty().getId(), false);
// because step1, the fresh will unload the resource(EMF), so, assign a new one...
businessProcessItem = (BusinessProcessItem) repositoryNode.getObject().getProperty().getItem();
IWorkbenchPage page = getActivePage();
DiagramResourceManager diagramResourceManager = new DiagramResourceManager(page, new NullProgressMonitor());
IFile file = businessModelWizard.getTempFile();
// Set readonly to false since created job will always be editable.
RepositoryEditorInput newBusinessModelEditorInput = new RepositoryEditorInput(file, businessProcessItem);
newBusinessModelEditorInput.setRepositoryNode(repositoryNode);
// here really do the normal save as function
IDocumentProvider provider = ((BusinessDiagramEditor) this.editorPart).getDocumentProvider();
provider.aboutToChange(newBusinessModelEditorInput);
provider.saveDocument(null, newBusinessModelEditorInput, provider.getDocument(this.editorPart.getEditorInput()), true);
provider.changed(newBusinessModelEditorInput);
// copy back from the *.business_diagram file to *.item file.
// @see:BusinessDiagramEditor.doSave(IProgressMonitor progressMonitor)
diagramResourceManager.updateFromResource(businessProcessItem, newBusinessModelEditorInput.getFile());
// notice: here, must save it, save the item to disk, otherwise close the editor
// without any modification, there won't save the
// model again, so, will lost the graphic when reopen it.
ProxyRepositoryFactory.getInstance().save(businessProcessItem);
// close the old editor
page.closeEditor(this.editorPart, false);
// open the new editor, because at the same time, there will update the jobSetting/componentSetting view
IEditorPart openEditor = page.openEditor(newBusinessModelEditorInput, BusinessDiagramEditor.ID, true);
} catch (Exception e) {
MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", "Business model 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 BusinessAssignmentComposite method createSelectionListener.
private void createSelectionListener() {
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
BusinessAssignment businessAssignment = getBusinessAssignment(event.getSelection());
if (businessAssignment != null) {
final IRepositoryView repositoryView = getRepositoryView();
if (repositoryView != null) {
IProjectRepositoryNode rootRepositoryNode = repositoryView.getRoot();
TalendItem item = businessAssignment.getTalendItem();
//
if (item instanceof Routine && rootRepositoryNode instanceof ProjectRepositoryNode) {
RepositoryNodeUtilities.expandParentNode(getRepositoryView(), ((ProjectRepositoryNode) rootRepositoryNode).getRootRepositoryNode(ERepositoryObjectType.CODE));
}
selectChild(item, (IRepositoryNode) rootRepositoryNode);
}
}
}
private void selectChild(TalendItem item, IRepositoryNode rootRepositoryNode) {
try {
RepositoryNode curNode = null;
JobSettingsView viewer = (JobSettingsView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(JobSettingsView.ID);
IRepositoryViewObject lastVersion = ProxyRepositoryFactory.getInstance().getLastVersion(item.getId());
if (lastVersion != null) {
curNode = RepositoryNodeUtilities.getRepositoryNode(lastVersion);
select(viewer, curNode);
} else if (item instanceof TableMetadata) {
MetadataTable table = MetadataToolHelper.getMetadataTableFromRepository(item.getId());
if (table != null) {
//$NON-NLS-1$
String id = item.getId().split(" - ")[0];
RepositoryNode node = RepositoryNodeUtilities.getMetadataTableFromConnection(item.getId());
IRepositoryView view = getRepositoryView();
if (view != null) {
RepositoryNodeUtilities.expandParentNode(view, node);
select(viewer, node);
}
}
} else if (item instanceof Query) {
org.talend.core.model.metadata.builder.connection.Query query = MetadataToolHelper.getQueryFromRepository(item.getId());
if (query != null) {
//$NON-NLS-1$
String id = item.getId().split(" - ")[0];
IRepositoryView view = getRepositoryView();
RepositoryNode node = RepositoryNodeUtilities.getQueryFromConnection(item.getId());
RepositoryNodeUtilities.expandParentNode(view, node);
select(viewer, node);
}
} else if (item instanceof SAPFunction) {
SAPFunctionUnit function = MetadataToolHelper.getSAPFunctionFromRepository(item.getId());
if (function != null) {
IRepositoryView view = getRepositoryView();
RepositoryNode node = RepositoryNodeUtilities.getSAPFunctionFromConnection(item.getId());
RepositoryNodeUtilities.expandParentNode(view, node);
select(viewer, node);
}
} else {
for (IRepositoryNode node : rootRepositoryNode.getChildren()) {
RepositoryNode rNode = (RepositoryNode) node;
if (item instanceof SQLPattern && rNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.SQLPATTERNS) {
if (rNode.getType() == ENodeType.REPOSITORY_ELEMENT) {
SQLPatternItem sqlItem = (SQLPatternItem) rNode.getObject().getProperty().getItem();
if (sqlItem.isSystem() && item.getLabel().equals(rNode.getObject().getLabel())) {
select(viewer, rNode);
}
} else {
selectChild(item, rNode);
}
} else if (item instanceof Routine && rNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.ROUTINES) {
if (rNode.getType() == ENodeType.REPOSITORY_ELEMENT) {
RoutineItem sqlItem = (RoutineItem) rNode.getObject().getProperty().getItem();
if (sqlItem.isBuiltIn() && item.getLabel().equals(rNode.getObject().getLabel())) {
select(viewer, rNode);
}
} else {
selectChild(item, rNode);
}
}
}
}
} catch (PersistenceException e) {
// TODO Auto-generated catch block
// e.printStackTrace();
ExceptionHandler.process(e);
}
}
private void select(JobSettingsView viewer, RepositoryNode repositoryNode) {
if (viewer == null) {
return;
}
if (repositoryNode == null) {
return;
}
CorePlugin.getDefault().getRepositoryService().removeRepositoryTreeViewListener(viewer);
final IRepositoryView repositoryView = getRepositoryView();
if (repositoryView != null) {
repositoryView.getViewer().setSelection(new StructuredSelection(repositoryNode));
}
CorePlugin.getDefault().getRepositoryService().addRepositoryTreeViewListener(viewer);
}
});
}
use of org.talend.repository.model.IRepositoryNode in project tdi-studio-se by Talend.
the class JSONRepositoryContentHandler method hideAction.
@Override
public boolean hideAction(IRepositoryNode node, Class actionType) {
boolean canHandle = false;
ERepositoryObjectType nodeType = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
if (JSONRepositoryNodeType.JSON.equals(nodeType)) {
canHandle = true;
}
if (!canHandle) {
if (ERepositoryObjectType.METADATA_CON_TABLE.equals(nodeType) || ERepositoryObjectType.METADATA_CON_COLUMN.equals(nodeType)) {
RepositoryNode parentNode = node.getParent();
if (parentNode != null && JSONRepositoryNodeType.JSON.equals(parentNode.getProperties(EProperties.CONTENT_TYPE))) {
canHandle = true;
}
}
}
if (canHandle) {
if (actionType == CreateTableAction.class) {
return true;
}
}
return false;
}
use of org.talend.repository.model.IRepositoryNode in project tdi-studio-se by Talend.
the class UseDynamicJobSelectionDialog method setCheckingNodes.
private void setCheckingNodes() {
final IContentProvider contentProvider = getItemsTreeViewer().getContentProvider();
final Object input = getItemsTreeViewer().getInput();
if (contentProvider instanceof ITreeContentProvider && input instanceof ProjectRepositoryNode && getNeedCheckedjobs() != null && getNeedCheckedjobs().length > 0) {
ITreeContentProvider cnfContentProvider = (ITreeContentProvider) contentProvider;
List<IRepositoryNode> checkingNodes = new ArrayList<IRepositoryNode>();
List<String> needCheckedJobIds = new ArrayList(Arrays.asList(getNeedCheckedjobs()));
final ProjectRepositoryNode root = (ProjectRepositoryNode) input;
final RepositoryNode rootRepositoryNode = root.getRootRepositoryNode(getSupportType());
if (rootRepositoryNode == null) {
return;
}
withReferenceProjects(cnfContentProvider, rootRepositoryNode, needCheckedJobIds, checkingNodes);
// set check for node
getItemsTreeViewer().setCheckedElements(checkingNodes.toArray());
// select and will expand the selected node auto
getItemsTreeViewer().setSelection(new StructuredSelection(checkingNodes), true);
// let scroll bar on top
getItemsTreeViewer().setSelection(new StructuredSelection(rootRepositoryNode));
getItemsTreeViewer().setSelection(StructuredSelection.EMPTY);
}
}
use of org.talend.repository.model.IRepositoryNode in project tdi-studio-se by Talend.
the class UseDynamicJobSelectionDialog method withReferenceProjects.
private void withReferenceProjects(final ITreeContentProvider cnfContentProvider, RepositoryNode rootRepositoryNode, final List<String> needCheckedJobIds, List<IRepositoryNode> checkingNodes) {
if (rootRepositoryNode == null) {
return;
}
setCheckingNodes(cnfContentProvider, rootRepositoryNode, needCheckedJobIds, checkingNodes, true);
if (needCheckedJobIds.isEmpty()) {
return;
}
// ref
final IRepositoryNode refRoot = rootRepositoryNode.getRoot().getRootRepositoryNode(ERepositoryObjectType.REFERENCED_PROJECTS);
if (refRoot != null) {
final Object[] children = cnfContentProvider.getChildren(refRoot);
for (Object c : children) {
if (c instanceof ProjectRepositoryNode) {
withReferenceProjects(cnfContentProvider, ((ProjectRepositoryNode) c).getRootRepositoryNode(getSupportType()), needCheckedJobIds, checkingNodes);
}
}
}
}
Aggregations