use of org.talend.designer.business.diagram.custom.figures.BusinessItemShapeFigure 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);
}
}
use of org.talend.designer.business.diagram.custom.figures.BusinessItemShapeFigure in project tdi-studio-se by Talend.
the class BusinessItemShapeEditPart method unregisterVisuals.
@Override
protected void unregisterVisuals() {
IFigure figure2 = getFigure();
if (figure2 instanceof BusinessItemShapeFigure) {
((BusinessItemShapeFigure) figure2).disposeColors();
}
super.unregisterVisuals();
}
use of org.talend.designer.business.diagram.custom.figures.BusinessItemShapeFigure in project tdi-studio-se by Talend.
the class BusinessItemShapeEditPart method refreshVisuals.
@Override
public void refreshVisuals() {
super.refreshVisuals();
NodeFigure nodeFigure = getNodeFigure();
for (Object obj : nodeFigure.getChildren()) {
if (obj instanceof BusinessItemShapeFigure) {
BusinessItemShapeFigure shapFigure = (BusinessItemShapeFigure) obj;
for (Object figure : shapFigure.getChildren()) {
if (figure instanceof BusinessItemNameFigure) {
BusinessItemNameFigure nameFigure = (BusinessItemNameFigure) figure;
nameFigure.addMouseMotionListener(new MouseMotionListener() {
@Override
public void mouseMoved(MouseEvent me) {
// TODO Auto-generated method stub
}
@Override
public void mouseHover(MouseEvent me) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent me) {
// TODO Auto-generated method stub
}
@Override
public void mouseEntered(MouseEvent me) {
elementHelper.updateTooltipFigure(getNodeFigure(), tooltipFigure, editPart);
}
@Override
public void mouseDragged(MouseEvent me) {
// TODO Auto-generated method stub
}
});
EObject object = ((Node) getModel()).getElement();
if (object instanceof BusinessItem) {
BusinessItem item = (BusinessItem) object;
String hAlignment = item.getHAlignment();
if (hAlignment == null) {
hAlignment = BusinessAlignment.LEFT.toString();
}
String vAlignment = item.getVAlignment();
if (vAlignment == null) {
vAlignment = BusinessAlignment.TOP.toString();
}
if (BusinessAlignment.HCENTRE.toString().equals(hAlignment)) {
if (BusinessAlignment.TOP.toString().equals(vAlignment)) {
nameFigure.setAlignment(PositionConstants.TOP);
} else if (BusinessAlignment.BOTTOM.toString().equals(vAlignment)) {
nameFigure.setAlignment(PositionConstants.BOTTOM);
} else {
nameFigure.setAlignment(PositionConstants.CENTER);
}
} else if (BusinessAlignment.VCENTRE.toString().equals(vAlignment)) {
if (BusinessAlignment.LEFT.toString().equals(hAlignment)) {
nameFigure.setAlignment(PositionConstants.LEFT);
} else if (BusinessAlignment.RIGHT.toString().equals(hAlignment)) {
nameFigure.setAlignment(PositionConstants.RIGHT);
} else {
nameFigure.setAlignment(PositionConstants.CENTER);
}
} else {
nameFigure.setAlignment(getPosition(hAlignment, BusinessAlignment.HORIZONTAL, item) | getPosition(vAlignment, BusinessAlignment.VERTICAL, item));
}
}
}
}
}
}
elementHelper.updateTooltipFigure(getNodeFigure(), tooltipFigure, this);
}
use of org.talend.designer.business.diagram.custom.figures.BusinessItemShapeFigure in project tdi-studio-se by Talend.
the class BusinessDiagramEditor method selectionChanged.
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
super.selectionChanged(part, selection);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
JobSettingsView view = (JobSettingsView) page.findView(JobSettingsView.ID);
getDiagramEditorInput().getItem().getProperty().eAdapters().remove(dirtyListener);
if (view == null) {
return;
}
if (!(selection instanceof IStructuredSelection)) {
return;
}
Object firstElement = ((IStructuredSelection) selection).getFirstElement();
if (!(selection instanceof IStructuredSelection)) {
return;
} else if (firstElement instanceof RepositoryNode) {
return;
}
// for Find Assignment
if (((IStructuredSelection) selection).size() > 0) {
DiagramEditPart diagramEditPart = getDiagramEditPart();
if (diagramEditPart instanceof BusinessProcessEditPart) {
BusinessProcessEditPart processPart = (BusinessProcessEditPart) diagramEditPart;
for (Object object : processPart.getChildren()) {
if (object instanceof BusinessItemShapeEditPart) {
BusinessItemShapeEditPart shapEditPart = (BusinessItemShapeEditPart) object;
IFigure figure = shapEditPart.getFigure();
for (Object child : figure.getChildren()) {
if (child instanceof BusinessItemShapeFigure) {
BusinessItemShapeFigure shapFigure = (BusinessItemShapeFigure) child;
Border border = shapFigure.getBorder();
if (border != null) {
shapFigure.setDrawFrame(false);
shapFigure.revalidate();
shapFigure.repaint();
}
}
}
}
}
}
}
// to refresh the jobsettings view
if (((IStructuredSelection) selection).size() > 1) {
view.cleanDisplay();
} else {
if (firstElement instanceof BusinessItemShapeEditPart || firstElement instanceof BaseBusinessItemRelationShipEditPart || firstElement instanceof NoteEditPart || firstElement instanceof NoteAttachmentEditPart) {
view.refresh(false, firstElement);
} else if (firstElement instanceof BusinessProcessEditPart || firstElement instanceof CompartmentEditPart) {
view.refresh(true, this);
}
}
getDiagramEditorInput().getItem().getProperty().eAdapters().add(dirtyListener);
}
Aggregations