use of org.eclipse.gef.EditPart in project cubrid-manager by CUBRID.
the class HostMonitorEditPolicy method createDeleteCommand.
/**
* create a command of delete figure
*
* @param deleteRequest to delete figure
* @return command of delete figure
*/
protected Command createDeleteCommand(GroupRequest deleteRequest) {
DeleteHostMonitorCommand deleteCommand = new DeleteHostMonitorCommand();
EditPart host = getHost();
deleteCommand.setNodeToDelete((HostNode) host.getModel());
deleteCommand.setDashboard((Dashboard) host.getParent().getModel());
return deleteCommand;
}
use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class TalendPaletteViewer method addRecentlyUsedComponent.
public void addRecentlyUsedComponent(IComponent component) {
EComponentType componentType = component.getComponentType();
if (componentType == EComponentType.JOBLET_INPUT_OUTPUT || componentType == EComponentType.JOBLET_TRIGGER) {
return;
}
if (recentlyUsedEditPart != null) {
List children = recentlyUsedEditPart.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().compareTo(component.getName());
if (0 == compareResult) {
alreadyExist = true;
break;
}
// if (0 < compareResult) {
// break;
// }
}
}
// if already exist, remove first
if (alreadyExist) {
if (0 == insertIndex) {
return;
}
TalendEntryEditPart entryEditPart = (TalendEntryEditPart) children.get(insertIndex);
CombinedTemplateCreationEntry entryModule = (CombinedTemplateCreationEntry) entryEditPart.getModel();
removeRecentlyUsedComponent(entryModule);
}
// if (!alreadyExist) {
TalendCombinedTemplateCreationEntry newRecently = TalendEditorPaletteFactory.createEntryFrom(component);
newRecently.setTimestemp(new Date());
newRecently.setParent(recentlyUsedEditPart.getDrawer());
EditPart child = recentlyUsedEditPart.createChild(newRecently);
PaletteDrawer paletteDrawer = recentlyUsedEditPart.getDrawer();
if (paletteDrawer != null) {
// paletteDrawer.add(insertIndex, newRecently);
paletteDrawer.add(0, newRecently);
}
// reobtain
children = recentlyUsedEditPart.getChildren();
if (children != null) {
int size = children.size();
final int recentlyUsedSize = PaletteSettingsPreferencePage.getPaletteRencentlyUsedListSize();
if (recentlyUsedSize < size) {
TalendEntryEditPart entryEditPart = (TalendEntryEditPart) children.get(recentlyUsedSize);
CombinedTemplateCreationEntry entryModule = (CombinedTemplateCreationEntry) entryEditPart.getModel();
removeRecentlyUsedComponent(entryModule);
}
}
// needn't use this, or will cause problem
// recentlyUsedEditPart.addChild(child, insertIndex);
// }
refreshRecentlyUsedComponentToReference();
}
}
use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class FindAssignmentAction method zoomFitSelection.
// PTODO mhelleboid bug for org.eclipse.gmf.runtime.diagram.ui.internal.actions.ZoomContributionItem
private void zoomFitSelection(ZoomManager zoomManager, List editParts, DiagramEditPart diagramEditPart, boolean zoomOutOnly) {
Rectangle rectangle = null;
for (Iterator iter = editParts.iterator(); iter.hasNext(); ) {
EditPart editPart = (EditPart) iter.next();
IFigure f = ((GraphicalEditPart) editPart).getFigure();
rectangle = rectangle == null ? f.getBounds().getCopy() : rectangle.getUnion(f.getBounds());
}
// IF nothing to Zoom...
if (rectangle == null) {
// do nothing
return;
}
// Translate the region into pixels
MapModeUtil.getMapMode(diagramEditPart.getFigure()).LPtoDP(rectangle);
Viewport viewport = zoomManager.getViewport();
float xratio = viewport.getHorizontalRangeModel().getExtent() / (float) rectangle.width;
float yratio = viewport.getVerticalRangeModel().getExtent() / (float) rectangle.height;
double zoom = 1.0;
zoom = (yratio < xratio) ? Math.floor(yratio * 100) : Math.floor(xratio * 100);
if (zoomOutOnly && zoom >= 100) {
// we should always continue in order to set the viewport
// location
zoom = 100;
}
// apply thresholds
zoom = Math.min((int) (zoomManager.getMaxZoom() * 100), Math.max((int) (zoomManager.getMinZoom() * 100), zoom));
int viewX = Math.round(rectangle.getTopLeft().x * (float) zoom / 100.0f);
int viewY = Math.round(rectangle.getTopLeft().y * (float) zoom / 100.0f);
zoomManager.setZoom(zoom / 100);
viewport.setHorizontalLocation(viewX);
viewport.setVerticalLocation(viewY);
}
use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class TalendConnectionCreationTool method handleCreateConnection.
/*
* override this method for issue 1253.
*
* @see org.eclipse.gef.tools.AbstractConnectionCreationTool#handleCreateConnection()
*/
@Override
protected boolean handleCreateConnection() {
Command endCommand = getCommand();
if (endCommand != null) {
return super.handleCreateConnection();
}
if (getTargetEditPart() == null) {
EditPart processPart = getProcessPart(this.sourcePart);
if (processPart != null) {
this.setTargetEditPart(getProcessPart(this.sourcePart));
this.getTargetRequest().setType(RequestConstants.REQ_CONNECTION_END);
}
return handleConnection();
}
if (isInState(STATE_TERMINAL)) {
// Fake a drag to cause feedback to be displayed immediately on mouse down.
setState(STATE_CONNECTION_STARTED);
handleDrag();
}
return true;
}
use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class SubjobContainerPart method propertyChange.
/*
* (non-Javadoc)
*
* @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
*/
@Override
public void propertyChange(PropertyChangeEvent evt) {
String prop = evt.getPropertyName();
if (SubjobContainer.UPDATE_SUBJOB_CONTENT.equals(prop)) {
refresh();
List<AbstractGraphicalEditPart> childrens = getChildren();
for (AbstractGraphicalEditPart part : childrens) {
part.refresh();
}
} else if (SubjobContainer.UPDATE_SUBJOB_CONNECTIONS.equals(prop)) {
refreshSourceConnections();
} else if (SubjobContainer.UPDATE_SUBJOB_TITLE_COLOR.equals(prop)) {
if (getFigure() instanceof SubjobContainerFigure) {
((SubjobContainerFigure) getFigure()).updateSubJobTitleColor();
refreshVisuals();
}
} else if (SubjobContainer.UPDATE_SUBJOB_DISPLAY.equals(prop)) {
List<NodeContainer> tmpList = new ArrayList<NodeContainer>(((SubjobContainer) getModel()).getNodeContainers());
((SubjobContainer) getModel()).getNodeContainers().clear();
refreshChildren();
List elems = ((Process) getParent().getModel()).getElements();
elems.remove(getModel());
EditPart parent = getParent();
parent.refresh();
((SubjobContainer) getModel()).getNodeContainers().addAll(tmpList);
elems.add(getModel());
parent.refresh();
} else if ("UPDATE_SPARKSTREAMING_STATUS".equals(prop)) {
if (getFigure() instanceof SparkStreamingSubjobContainerFigure) {
((SparkStreamingSubjobContainerFigure) getFigure()).updateData();
refreshVisuals();
}
} else {
// can only be UPDATE_SUBJOB_DATA, need to modify if some others are added
if (getFigure() instanceof SubjobContainerFigure) {
((SubjobContainerFigure) getFigure()).updateData();
refreshVisuals();
}
}
}
Aggregations