本文整理汇总了Java中org.eclipse.gef.GraphicalEditPart类的典型用法代码示例。如果您正苦于以下问题:Java GraphicalEditPart类的具体用法?Java GraphicalEditPart怎么用?Java GraphicalEditPart使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GraphicalEditPart类属于org.eclipse.gef包,在下文中一共展示了GraphicalEditPart类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSelectionHandles
import org.eclipse.gef.GraphicalEditPart; //导入依赖的package包/类
/**
* Create selection handles in the style as predefined in DeltaEcore
* @see DEGraphicalEditorTheme
*/
@Override
protected List<Object> createSelectionHandles() {
List<Object> list = new ArrayList<Object>();
MoveHandle moveHandle = new MoveHandle((GraphicalEditPart) getHost());
moveHandle.setDragTracker(getDragTracker());
if (isDragAllowed()) {
moveHandle.setCursor(Cursors.SIZEALL);
} else {
moveHandle.setCursor(SharedCursors.ARROW);
}
// set line style to meet the predefined theme
DEGraphicalEditorTheme theme = DEGraphicalEditor.getTheme();
LineBorder border = new LineBorder();
border.setColor(theme.getSelectionSecondaryColor());
border.setWidth(theme.getLineWidth());
moveHandle.setBorder(border);
list.add(moveHandle);
return list;
}
示例2: getFigureConstraint
import org.eclipse.gef.GraphicalEditPart; //导入依赖的package包/类
protected Rectangle getFigureConstraint(){
GraphicalEditPart parent = (GraphicalEditPart)getParent();
Rectangle parentVisibleBounds = parent.getFigure().getClientArea().getCopy();
Rectangle bounds;
if(parentVisibleBounds.width < 0 || parentVisibleBounds.height < 0) {
bounds = new Rectangle(0, 0, 300, -1);
}else{
Date date = featureModel.getSelectedDate();
DwEnumContainerWrapped model = (DwEnumContainerWrapped)getModel();
DwTemporalPosition position = model.getPosition(date);
Point desiredDefaultPosition = new Point(editor.getEditorGraphicalDimension().width-20-320, 20);
if(position == null || !position.getPosition().equals(desiredDefaultPosition) && model.getAlignment() == EditorAlignment.RightTop){
model.addPosition(desiredDefaultPosition, date, false);
}
bounds = new Rectangle(model.getPosition(date).getPosition(), new Dimension(300, -1));
}
return bounds;
}
示例3: createCommand
import org.eclipse.gef.GraphicalEditPart; //导入依赖的package包/类
private Command createCommand(final List objects, final RGB rgb) {
if (objects.isEmpty()) {
return null;
}
if (!(objects.get(0) instanceof GraphicalEditPart)) {
return null;
}
final CompoundCommand command = new CompoundCommand();
for (int i = 0; i < objects.size(); i++) {
final GraphicalEditPart part = (GraphicalEditPart) objects.get(i);
final Object modelObject = part.getModel();
if (modelObject instanceof ViewableModel) {
command.add(new ChangeBackgroundColorCommand((ViewableModel) modelObject, rgb.red, rgb.green, rgb.blue));
} else if (modelObject instanceof ConnectionElement) {
command.add(new ChangeConnectionColorCommand((ConnectionElement) modelObject, rgb.red, rgb.green, rgb.blue));
}
}
return command;
}
示例4: addHandles
import org.eclipse.gef.GraphicalEditPart; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static void addHandles(final GraphicalEditPart part, final List handles) {
handles.add(new ERDiagramMoveHandle(part));
handles.add(createHandle(part, PositionConstants.EAST));
handles.add(createHandle(part, PositionConstants.SOUTH_EAST));
handles.add(createHandle(part, PositionConstants.SOUTH));
handles.add(createHandle(part, PositionConstants.SOUTH_WEST));
handles.add(createHandle(part, PositionConstants.WEST));
handles.add(createHandle(part, PositionConstants.NORTH_WEST));
handles.add(createHandle(part, PositionConstants.NORTH));
handles.add(createHandle(part, PositionConstants.NORTH_EAST));
}
示例5: calculateEnabled
import org.eclipse.gef.GraphicalEditPart; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected boolean calculateEnabled() {
List objects = this.getSelectedObjects();
if (objects.isEmpty()) {
return false;
}
if (!(objects.get(0) instanceof GraphicalEditPart)) {
return false;
}
return true;
}
示例6: refreshChildren
import org.eclipse.gef.GraphicalEditPart; //导入依赖的package包/类
@Override
protected void refreshChildren() {
super.refreshChildren();
List<?> children = getChildren();
for (int i = 0; i < children.size(); i++) {
EditPart editPart = (EditPart) children.get(i);
editPart.refresh();
}
if (getSelection() >= 0){
GraphicalEditPart colEP = (GraphicalEditPart) children.get(0);
Rectangle r1 = colEP.getFigure().getBounds();
int rowHeinght = getOneRowHeight();
getFigure().getSelection().setBounds(new Rectangle(
r1.x, r1.y + getSelection()*rowHeinght,
getExpandedBounds().width - r1.x*2, rowHeinght
));
} else {
getFigure().getSelection().setBounds(new Rectangle());
}
}
示例7: addChildVisual
import org.eclipse.gef.GraphicalEditPart; //导入依赖的package包/类
/**
* @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#addChildVisual(org.eclipse.gef.EditPart, int)
*/
@Override
protected void addChildVisual(EditPart childEditPart, int index) {
super.addChildVisual(childEditPart, index);
if (!isCreated()) {
if (((AbstractNode) childEditPart.getModel()).getUmlModel().equals(getAdded())) {
DirectEditorManager dem = new DirectEditorManager((GraphicalEditPart) childEditPart,
TextCellEditor.class,
new DirectEditCellEditorLocator(((GraphicalEditPart) childEditPart).getFigure()));
dem.show();
setCreated(true);
}
}
}
示例8: getChildFigure
import org.eclipse.gef.GraphicalEditPart; //导入依赖的package包/类
/**
*
* void
*/
private void getChildFigure(EditPart currentEditPart) {
List<EditPart> childrenEditPart = currentEditPart.getChildren();
for( EditPart child : childrenEditPart ) {
if( child instanceof NotationNameEditPart ) {
if( ((NotationNameEditPart)child).getFigure() instanceof org.eclipse.draw2d.Label ) {
GraphicalEditPart gEdit = (GraphicalEditPart) child;
setDirectManager(new DirectEditorManager((GraphicalEditPart) child,
TextCellEditor.class,
new DirectEditCellEditorLocator(gEdit.getFigure())));
directManager.show();
break;
} else {
getChildFigure(child);
}
}
}
}
示例9: handleKeyDown
import org.eclipse.gef.GraphicalEditPart; //导入依赖的package包/类
@Override
protected boolean handleKeyDown(KeyEvent e) {
if (isInState(STATE_INITIAL) && UIUtil.isArrowKey(e.keyCode)) {
EditPartViewer viewer = getCurrentViewer();
if (viewer instanceof GraphicalViewer) {
JSSCompoundCommand ccmd = new JSSCompoundCommand(null);
for(Object selectedEditPart : getCurrentViewer().getSelectedEditParts()) {
if (selectedEditPart instanceof GraphicalEditPart) {
Object modelObj = ((EditPart) selectedEditPart).getModel();
if(modelObj instanceof MGraphicElement) {
MGraphicElement node = (MGraphicElement) modelObj;
ccmd.add(getNewXYCommand(e.keyCode,node));
}
}
}
if(!ccmd.isEmpty()) {
getDomain().getCommandStack().execute(ccmd);
return true;
}
}
}
return super.handleKeyDown(e);
}
示例10: refreshVisuals
import org.eclipse.gef.GraphicalEditPart; //导入依赖的package包/类
/**
* @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals()
*/
@Override
protected void refreshVisuals() {
try {
super.refreshVisuals();
NotationNode notationNode = (NotationNode) getModel();
Polyline line = (Polyline) this.getFigure();
line.removeAllPoints();
line.addPoint(new Point(notationNode.getX(), notationNode.getY()));
line.addPoint(new Point(notationNode.getX(), notationNode.getY() + notationNode.getHeight()));
Rectangle bounds = new Rectangle(notationNode.getX(),
notationNode.getY(),
notationNode.getWidth(),
notationNode.getHeight());
((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), bounds);
} catch (Exception e) {
Log.error(UMLMessage.MESSAGE_INTERACTION_USE_EDIT_PART_REFRESH_VISUALS_ERROR + e);
}
}
示例11: refreshVisuals
import org.eclipse.gef.GraphicalEditPart; //导入依赖的package包/类
@Override
protected void refreshVisuals()
{
GridData gridData = new GridData();
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = SWT.FILL;
gridData.verticalAlignment = SWT.FILL;
GraphicalEditPart parent = (GraphicalEditPart) getParent();
parent.setLayoutConstraint(this, figure, gridData);
GridLayout layoutManager = (GridLayout) getFigure().getLayoutManager();
layoutManager.numColumns =
((ChartSet) parent.getModel()).getOrientation() == Orientation.HORIZONTAL
? getModelChildren().size() : 1;
layoutManager.invalidate();
}
示例12: createSelectionHandles
import org.eclipse.gef.GraphicalEditPart; //导入依赖的package包/类
@Override
protected List<AbstractHandle> createSelectionHandles() {
List<AbstractHandle> list = new ArrayList<AbstractHandle>();
MoveHandle handle = new MoveHandle((GraphicalEditPart) getHost());
handle.setBorder(new MarginBorder(5));
list.add(handle);
// BandButtonPadHandle buttonPadHandle=new BandButtonPadHandle((GraphicalEditPart)getHost());
// buttonPadHandle.setBorder(null);
// list.add(buttonPadHandle);
// NonResizableHandleKit.addMoveHandle((GraphicalEditPart) getHost(), list);
// list.add(new CellResizeHandle2((GraphicalEditPart) getHost(), PositionConstants.SOUTH));
// // if (hasNorth)
// list.add(new CellResizeHandle2((GraphicalEditPart) getHost(), PositionConstants.NORTH));
return list;
}
示例13: generateSnapPartsList
import org.eclipse.gef.GraphicalEditPart; //导入依赖的package包/类
/**
* The list of element is based on the father of first selected item
*/
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
protected List generateSnapPartsList(List exclusions) {
// Don't snap to any figure that is being dragged
List children = new ArrayList();
if (exclusions.size()>0){
EditPart selectedItem = (EditPart)exclusions.get(0);
children.addAll(selectedItem.getParent().getChildren());
children.removeAll(exclusions);
// Don't snap to hidden figures
List hiddenChildren = new ArrayList();
for (Iterator iter = children.iterator(); iter.hasNext();) {
GraphicalEditPart child = (GraphicalEditPart) iter.next();
if (!child.getFigure().isVisible())
hiddenChildren.add(child);
}
children.removeAll(hiddenChildren);
}
return children;
}
示例14: showCreateBendpointFeedback
import org.eclipse.gef.GraphicalEditPart; //导入依赖的package包/类
/**
* @see org.eclipse.gef.editpolicies.BendpointEditPolicy#showCreateBendpointFeedback(org.eclipse.gef.requests.BendpointRequest)
*/
@Override
protected void showCreateBendpointFeedback(BendpointRequest request) {
IFigure feedback = getDragSourceFeedbackFigure();
Rectangle bounds = new Rectangle(getInitialFeedbackBounds().getCopy());
PrecisionRectangle rect = new PrecisionRectangle(bounds);
getHostFigure().translateToAbsolute(rect);
Point movePoint = request.getLocation();
movePoint.x = ((GraphicalEditPart) getHost()).getFigure().getBounds().x;//movePoint.x - rect.getSize().width / 2;
rect.setLocation(movePoint);
feedback.translateToRelative(rect);
feedback.setBounds(rect);
}
示例15: refreshVisuals
import org.eclipse.gef.GraphicalEditPart; //导入依赖的package包/类
@Override
protected void refreshVisuals()
{
boolean horizontal = ((AxisLandingPad) getModel()).chart.getParent()
.getOrientation() == Orientation.HORIZONTAL;
nameLabel.setVertical(!horizontal);
if (horizontal)
{
((GraphicalEditPart) getParent()).setLayoutConstraint(this, figure,
new GridData(GridData.FILL, GridData.CENTER, true, false));
}
else
{
((GraphicalEditPart) getParent()).setLayoutConstraint(this, figure,
new GridData(GridData.CENTER, GridData.FILL, false, true));
}
figure.invalidate();
}