use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class AbstractMultiPageTalendEditor method selectNode.
/**
* DOC bqian Comment method "selectNode".
*
* @param node
*/
public void selectNode(INode node) {
GraphicalViewer viewer = designerEditor.getViewer();
Object object = viewer.getRootEditPart().getChildren().get(0);
if (object instanceof ProcessPart) {
for (EditPart editPart : (List<EditPart>) ((ProcessPart) object).getChildren()) {
if (editPart instanceof NodePart) {
if (((NodePart) editPart).getModel().equals(node)) {
viewer.select(editPart);
}
}
}
}
}
use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class TalendPaletteViewer method addFavoritesComponent.
public void addFavoritesComponent(CombinedTemplateCreationEntry component) {
if (favoritesEditPart != null) {
List children = favoritesEditPart.getChildren();
int insertIndex = 0;
boolean alreadyExist = false;
if (children != null) {
for (; insertIndex < children.size(); insertIndex++) {
TalendEntryEditPart entryEditPart = (TalendEntryEditPart) children.get(insertIndex);
CombinedTemplateCreationEntry entryModule = (CombinedTemplateCreationEntry) entryEditPart.getModel();
int compareResult = entryModule.getLabel().toLowerCase().compareTo(component.getLabel().toLowerCase());
if (0 == compareResult) {
alreadyExist = true;
break;
}
if (0 < compareResult) {
break;
}
}
}
if (!alreadyExist) {
TalendEditorPaletteFactory.addNewFavoriteIntoPreference(component.getLabel());
CombinedTemplateCreationEntry newFavorite = TalendEditorPaletteFactory.createEntryFrom(component);
newFavorite.setParent(favoritesEditPart.getDrawer());
EditPart child = favoritesEditPart.createChild(newFavorite);
PaletteDrawer paletteDrawer = favoritesEditPart.getDrawer();
if (paletteDrawer != null) {
paletteDrawer.add(insertIndex, newFavorite);
}
// needn't use this, or will cause problem
// favoritesEditPart.addChild(child, insertIndex);
}
}
}
use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class NodePart method refreshTargetConnections.
@Override
protected void refreshTargetConnections() {
int i;
ConnectionEditPart editPart;
Object model;
Map mapModelToEditPart = new HashMap();
List connections = getTargetConnections();
for (i = 0; i < connections.size(); i++) {
editPart = (ConnectionEditPart) connections.get(i);
mapModelToEditPart.put(editPart.getModel(), editPart);
}
List modelObjects = getModelTargetConnections();
if (modelObjects == null) {
modelObjects = new ArrayList();
}
for (i = 0; i < modelObjects.size(); i++) {
model = modelObjects.get(i);
if (model instanceof IConnection) {
INode sourcenode = ((IConnection) model).getSource();
INode targetnode = ((IConnection) model).getSource();
String connectorName = ((IConnection) model).getConnectorName();
if (sourcenode.getConnectorFromName(connectorName) == null && targetnode.getConnectorFromName(connectorName) == null) {
return;
}
}
if (i < connections.size() && ((EditPart) connections.get(i)).getModel() == model) {
continue;
}
editPart = (ConnectionEditPart) mapModelToEditPart.get(model);
if (editPart != null) {
reorderTargetConnection(editPart, i);
} else {
editPart = createOrFindConnection(model);
addTargetConnection(editPart, i);
}
}
// Remove the remaining Connection EditParts
List trash = new ArrayList();
for (; i < connections.size(); i++) {
trash.add(connections.get(i));
}
for (i = 0; i < trash.size(); i++) {
removeTargetConnection((ConnectionEditPart) trash.get(i));
}
}
use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class NodePart method propertyChange.
// ------------------------------------------------------------------------
// Abstract methods from PropertyChangeListener
/*
* (non-Javadoc)
*
* @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
*/
@Override
public void propertyChange(final PropertyChangeEvent changeEvent) {
boolean needUpdateSubjob = false;
if (!this.isActive()) {
return;
}
if (changeEvent.getPropertyName().equals(Node.LOCATION)) {
refreshVisuals();
needUpdateSubjob = true;
} else if (changeEvent.getPropertyName().equals(Node.PERFORMANCE_DATA)) {
refreshVisuals();
getParent().refresh();
needUpdateSubjob = true;
} else if (changeEvent.getPropertyName().equals(Node.INPUTS)) {
refreshTargetConnections();
needUpdateSubjob = true;
} else if (changeEvent.getPropertyName().equals(Node.OUTPUTS)) {
refreshSourceConnections();
refreshTargetConnections();
needUpdateSubjob = true;
} else if (changeEvent.getPropertyName().equals(Node.SIZE)) {
refreshVisuals();
getParent().refresh();
needUpdateSubjob = true;
} else if (changeEvent.getPropertyName().equals(Node.ICON_CHANGE)) {
changeIcon((Node) changeEvent.getSource());
refreshVisuals();
} else if (changeEvent.getPropertyName().equals(EParameterName.ACTIVATE.getName())) {
if (((INode) getModel()).isActivate()) {
((NodeFigure) figure).setDummy(((Node) getModel()).isDummy());
((NodeFigure) figure).setAlpha(-1);
((NodeFigure) figure).repaint();
refreshVisuals();
} else {
((NodeFigure) figure).setDummy(((Node) getModel()).isDummy());
((NodeFigure) figure).setAlpha(Node.ALPHA_VALUE);
((NodeFigure) figure).repaint();
refreshVisuals();
}
} else if (changeEvent.getPropertyName().equals(EParameterName.DUMMY.getName())) {
if (((INode) getModel()).isActivate()) {
((NodeFigure) figure).setDummy(((Node) getModel()).isDummy());
((NodeFigure) figure).setAlpha(-1);
} else {
((NodeFigure) figure).setDummy(((Node) getModel()).isDummy());
((NodeFigure) figure).setAlpha(Node.ALPHA_VALUE);
}
((NodeFigure) figure).repaint();
refreshVisuals();
} else if (changeEvent.getPropertyName().equals(EParameterName.START.getName())) {
if (((INode) getModel()).isStart()) {
((NodeFigure) figure).setStart(true);
((NodeFigure) figure).repaint();
refreshVisuals();
} else {
((NodeFigure) figure).setStart(false);
((NodeFigure) figure).repaint();
refreshVisuals();
}
} else if (changeEvent.getPropertyName().equals(EParameterName.HINT.getName())) {
if (((Node) getModel()).isSetShowHint()) {
((NodeFigure) figure).setHint(((Node) getModel()).getShowHintText());
} else {
//$NON-NLS-1$
((NodeFigure) figure).setHint("");
}
needUpdateSubjob = true;
} else if (changeEvent.getPropertyName().equals(EParameterName.CONNECTION_FORMAT.getName())) {
Node node = (Node) getModel();
for (IConnection conn : ((Node) getModel()).getOutgoingConnections()) {
String connIdName = null;
String oldName = conn.getUniqueName();
if (conn instanceof Connection && conn.getLineStyle().hasConnectionCategory(IConnectionCategory.FLOW)) {
node.getProcess().removeUniqueConnectionName(oldName);
if (node.getProcess().checkValidConnectionName(node.getConnectionName(), false)) {
connIdName = node.getProcess().generateUniqueConnectionName(node.getConnectionName());
} else {
//$NON-NLS-1$
connIdName = node.getProcess().generateUniqueConnectionName("row");
}
if (node.getProcess().checkValidConnectionName(connIdName)) {
((Connection) conn).setUniqueName(connIdName);
node.getProcess().addUniqueConnectionName(connIdName);
((Connection) conn).setName(connIdName);
} else {
node.getProcess().addUniqueConnectionName(oldName);
}
}
}
} else if (changeEvent.getPropertyName().equals(EParameterName.REPAINT.getName())) {
((NodeFigure) figure).repaint();
refreshVisuals();
EditPart parentPart = getParent();
if (parentPart != null) {
parentPart.refresh();
}
needUpdateSubjob = true;
}
if (needUpdateSubjob) {
EditPart editPart = getParent();
if (editPart != null) {
while ((!(editPart instanceof ProcessPart)) && (!(editPart instanceof SubjobContainerPart))) {
editPart = editPart.getParent();
}
if (editPart instanceof SubjobContainerPart) {
editPart.refresh();
}
}
}
}
use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class ProcessTreeEditPart method refreshChildren.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.editparts.AbstractEditPart#refreshChildren()
*/
@SuppressWarnings("unchecked")
@Override
protected void refreshChildren() {
Map modelToEditPart = new HashMap();
List children = getChildren();
int i;
for (i = 0; i < children.size(); i++) {
EditPart editPart = (EditPart) children.get(i);
modelToEditPart.put(editPart.getModel(), editPart);
}
List modelObjects = getModelChildren();
// sort model for Outline
Collections.sort(modelObjects, new Comparator<Node>() {
@Override
public int compare(Node o1, Node o2) {
return StringUtils.compareStringDigit(o1.getUniqueName(), o2.getUniqueName());
}
});
for (i = 0; i < modelObjects.size(); i++) {
Object model = modelObjects.get(i);
if (i >= children.size() || ((EditPart) children.get(i)).getModel() != model) {
EditPart editPart = (EditPart) modelToEditPart.get(model);
if (editPart != null) {
reorderChild(editPart, i);
} else {
editPart = createChild(model);
addChild(editPart, i);
}
}
}
List trash = new ArrayList();
for (; i < children.size(); i++) {
trash.add(children.get(i));
}
for (i = 0; i < trash.size(); i++) {
EditPart ep = (EditPart) trash.get(i);
removeChild(ep);
}
}
Aggregations