use of org.talend.repository.model.RepositoryNode in project tdi-studio-se by Talend.
the class OpenDiagramAction method init.
/*
* (non-Javadoc)
*
* @see org.talend.repository.ui.actions.ITreeContextualAction#init(org.eclipse.jface.viewers.TreeViewer,
* org.eclipse.jface.viewers.IStructuredSelection)
*/
public void init(TreeViewer viewer, IStructuredSelection selection) {
boolean enabled = false;
if (!selection.isEmpty() && selection.size() == 1) {
Object object = selection.getFirstElement();
if (object instanceof RepositoryNode) {
RepositoryNode repositoryNode = (RepositoryNode) object;
ERepositoryObjectType nodeType = (ERepositoryObjectType) repositoryNode.getProperties(EProperties.CONTENT_TYPE);
if (repositoryNode.getType() == RepositoryNode.ENodeType.REPOSITORY_ELEMENT) {
if (nodeType == ERepositoryObjectType.BUSINESS_PROCESS) {
enabled = true;
}
}
if (enabled && (ProxyRepositoryFactory.getInstance().isUserReadOnlyOnCurrentProject() || !ProjectManager.getInstance().isInCurrentMainProject(repositoryNode) || !isLastVersion(repositoryNode))) {
enabled = false;
}
RepositoryNode parent = repositoryNode.getParent();
if (enabled && parent != null && parent.isBin()) {
enabled = false;
}
}
}
setEnabled(enabled);
}
use of org.talend.repository.model.RepositoryNode in project tdi-studio-se by Talend.
the class OpenDiagramAction method doRun.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
protected void doRun() {
ISelection selection = getSelectedObject();
if (selection == null) {
return;
}
Object obj = ((IStructuredSelection) selection).getFirstElement();
if (obj instanceof RepositoryNode) {
RepositoryNode repositoryNode = (RepositoryNode) obj;
IRepositoryViewObject repositoryObject = repositoryNode.getObject();
Property updatedProperty = null;
if (repositoryObject instanceof RepositoryObject) {
RepositoryViewObject abstractRepositoryObject = new RepositoryViewObject(repositoryObject.getProperty());
updatedProperty = abstractRepositoryObject.getProperty();
} else if (repositoryObject instanceof RepositoryViewObject) {
updatedProperty = repositoryObject.getProperty();
}
if (updatedProperty != null) {
BusinessProcessItem businessProcessItem = (BusinessProcessItem) updatedProperty.getItem();
DiagramResourceManager diagramResourceManager = new DiagramResourceManager(getActivePage(), new NullProgressMonitor());
IFile file = diagramResourceManager.createDiagramFile();
diagramResourceManager.updateResource(businessProcessItem, file);
IEditorPart part = diagramResourceManager.openEditor(businessProcessItem, file, false);
if (part instanceof BusinessDiagramEditor) {
((BusinessDiagramEditor) part).setLastVersion(true);
}
// TDI-21143 : Studio repository view : remove all refresh call to repo view
// IRepositoryView view = getViewPart();
// if (view != null) {
// view.refresh(repositoryNode);
// }
}
}
}
use of org.talend.repository.model.RepositoryNode in project tdi-studio-se by Talend.
the class ReadDiagramAction method doRun.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
protected void doRun() {
if (repositoryNode == null && getSelection() != null) {
Object firstElement = ((IStructuredSelection) getSelection()).getFirstElement();
if (firstElement instanceof RepositoryNode) {
repositoryNode = (RepositoryNode) firstElement;
}
}
RepositoryNode node = repositoryNode;
if (node != null) {
IRepositoryViewObject repositoryObject = node.getObject();
Property updatedProperty = repositoryObject.getProperty();
if (updatedProperty != null) {
BusinessProcessItem businessProcessItem = (BusinessProcessItem) updatedProperty.getItem();
DiagramResourceManager diagramResourceManager = new DiagramResourceManager(getActivePage(), new NullProgressMonitor());
IFile file = diagramResourceManager.createDiagramFile();
diagramResourceManager.updateResource(businessProcessItem, file);
IEditorPart part = diagramResourceManager.openEditor(businessProcessItem, file, true);
if (part instanceof BusinessDiagramEditor) {
((BusinessDiagramEditor) part).setLastVersion(true);
}
}
}
}
use of org.talend.repository.model.RepositoryNode in project tdi-studio-se by Talend.
the class GmfPastCommand method cloneAssignmentForModel.
private void cloneAssignmentForModel(List<BusinessItem> nodes, List pChildren) {
if (nodes == null || pChildren == null) {
return;
}
int i = nodes.size();
for (BusinessItem businessItem : getSortedBusinessItems(nodes)) {
BusinessItem newItem = (BusinessItem) getEObject(businessItem);
if (!addNew) {
newItem.setBusinessProcess(businessItem.getBusinessProcess());
}
newItem.setHAlignment(businessItem.getHAlignment());
newItem.setName(businessItem.getName());
newItem.setVAlignment(businessItem.getVAlignment());
List assignments = new ArrayList();
boolean execute = false;
int n = 0;
for (Object object : businessItem.getAssignments()) {
BusinessAssignment older = (BusinessAssignment) object;
BusinessAssignment newAssignment = (BusinessAssignment) getEObject(older);
newAssignment.setBusinessItem(newItem);
newAssignment.setComment(older.getComment());
if (!addNew) {
newAssignment.setTalendItem(older.getTalendItem());
} else {
TalendItem item = older.getTalendItem();
String talendId = null;
if (item != null) {
talendId = item.getId();
} else {
List idList = (List) itemIds.get(businessItem);
if (n < idList.size()) {
talendId = (String) idList.get(n);
}
n++;
}
RepositoryNode node = null;
if (talendId.split(" - ").length == 1) {
//$NON-NLS-1$
node = RepositoryNodeUtilities.getRepositoryNode(talendId);
} else {
node = RepositoryNodeUtilities.getMetadataTableFromConnection(talendId);
if (node == null) {
node = RepositoryNodeUtilities.getQueryFromConnection(talendId);
}
}
RepositoryHelper repositoryHelper = new RepositoryHelper();
Repository repository = process.getLocalRepositoryCopy();
if (repository == null) {
repository = repositoryHelper.createLocalRepositoryCopy(process);
}
TalendItem talendItem = repositoryHelper.createTalendItem(repository, node);
newAssignment.setTalendItem(talendItem);
}
assignments.add(newAssignment);
}
if (assignments.size() > 0) {
newItem.getAssignments().addAll(assignments);
}
if (i <= pChildren.size()) {
View node = (View) pChildren.get(pChildren.size() - i);
node.setElement(newItem);
i--;
}
if (addNew) {
this.process.getBusinessItems().add(newItem);
}
}
}
use of org.talend.repository.model.RepositoryNode in project tdi-studio-se by Talend.
the class FindAssignmentAction method doRun.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
protected void doRun() {
RepositoryNode repositoryNode = (RepositoryNode) getFirstSelectedObject();
IEditorPart activeEditor = getActiveEditor();
// remove frames draw last time
for (BusinessItemShapeFigure shapFigure : repaintedFigures) {
shapFigure.setDrawFrame(false);
shapFigure.revalidate();
shapFigure.repaint();
}
if (activeEditor instanceof BusinessDiagramEditor) {
BusinessDiagramEditor businessDiagramEditor = (BusinessDiagramEditor) activeEditor;
Diagram diagram = (Diagram) businessDiagramEditor.getDiagramEditPart().getModel();
BusinessProcess businessProcess = (BusinessProcess) diagram.getElement();
// PTODO mhelleboid use OCL or using a visitor
List list = new ArrayList();
for (Iterator iter = businessProcess.getBusinessItems().iterator(); iter.hasNext(); ) {
BusinessItem businessItem = (BusinessItem) iter.next();
for (Iterator iterator = businessItem.getAssignments().iterator(); iterator.hasNext(); ) {
BusinessAssignment businessAssignment = (BusinessAssignment) iterator.next();
TalendItem talendItem = businessAssignment.getTalendItem();
IRepositoryViewObject obj = repositoryNode.getObject();
if (talendItem.getId().equals(repositoryNode.getId())) {
list.add(businessItem);
} else if (talendItem instanceof SQLPattern || talendItem instanceof Routine || talendItem instanceof TableMetadata || talendItem instanceof Query || talendItem instanceof SapFunctionMetadata) {
if (talendItem.getLabel().equals(repositoryNode.getProperties(EProperties.LABEL))) {
list.add(businessItem);
}
}
}
}
IDiagramGraphicalViewer diagramGraphicalViewer = businessDiagramEditor.getDiagramGraphicalViewer();
List editParts = new ArrayList();
for (Iterator iter = list.iterator(); iter.hasNext(); ) {
BusinessItem businessItem = (BusinessItem) iter.next();
editParts.addAll(diagramGraphicalViewer.findEditPartsForElement(EMFCoreUtil.getProxyID(businessItem), BaseBusinessItemRelationShipEditPart.class));
editParts.addAll(diagramGraphicalViewer.findEditPartsForElement(EMFCoreUtil.getProxyID(businessItem), BusinessItemShapeEditPart.class));
}
diagramGraphicalViewer.deselectAll();
// add a frame when use findAassignment
for (Iterator iter = editParts.iterator(); iter.hasNext(); ) {
EditPart editPart = (EditPart) iter.next();
if (editPart instanceof BusinessItemShapeEditPart) {
BusinessItemShapeEditPart shapEditPart = (BusinessItemShapeEditPart) editPart;
IFigure figure = shapEditPart.getFigure();
for (Object child : figure.getChildren()) {
if (child instanceof BusinessItemShapeFigure) {
BusinessItemShapeFigure shapFigure = (BusinessItemShapeFigure) child;
shapFigure.setDrawFrame(true);
shapFigure.revalidate();
shapFigure.repaint();
repaintedFigures.add(shapFigure);
}
}
}
diagramGraphicalViewer.getSelectionManager().appendSelection(editPart);
}
ZoomManager zoomManager = (ZoomManager) businessDiagramEditor.getAdapter(ZoomManager.class);
zoomFitSelection(zoomManager, editParts, businessDiagramEditor.getDiagramEditPart(), true);
}
}
Aggregations