/** * This method is used to enable direct name editing in the feature */ @Override public void performRequest(Request req) { if(!editor.isLastDateSelected()) return; if(req.getType() == RequestConstants.REQ_DIRECT_EDIT) { } if(req.getType() == RequestConstants.REQ_OPEN){ DwFeatureWrapped feature = (DwFeatureWrapped)getModel(); Date date = editor.getCurrentSelectedDate(); if(feature.calculateVariationTypeCircleBounds(date).contains(((SelectionRequest)req).getLocation())){ HyFeatureType type = HyEvolutionUtil.getValidTemporalElement(feature.getWrappedModelElement().getTypes(), date); HyFeatureTypeEnum newType = type.getType() == HyFeatureTypeEnum.MANDATORY ? HyFeatureTypeEnum.OPTIONAL : HyFeatureTypeEnum.MANDATORY; DwFeatureChangeTypeCommand command = new DwFeatureChangeTypeCommand(feature.getWrappedModelElement(), newType, editor); editor.executeCommand(command); this.refreshVisuals(); }else{ performDirectEditing(); } } }
/** * Performs direct edit on double click */ @Override public DragTracker getDragTracker(final Request request) { if (request instanceof SelectionRequest && ((SelectionRequest) request).getLastButtonPressed() == 3) return null; IDoubleClickCallback callback = new IDoubleClickCallback() { @Override public void handleDoubleClick(int btn) { performDirectEditRequest(request); } }; return new DoubleClickDirectEditDragTracker(this, getTopGraphicEditPart(), callback); }
@Override public void showTargetFeedback(Request request) { if (request instanceof SelectionRequest) { Control parent = getViewer().getControl(); org.eclipse.swt.graphics.Point location = new org.eclipse.swt.graphics.Point(parent.getLocation().x, parent.getLocation().y); Display display = WidgetUtils.getDisplay(); location = display.map(parent, null, location); Point pt = ((SelectionRequest)request).getLocation().getCopy(); getHostFigure().translateToParent(pt); pt.x += location.x; pt.y += location.y; updateBrowserText(); tip.setBounds (pt.x, pt.y, 400, 120); tip.setVisible (true); } super.showTargetFeedback(request); }
/** * This method is used to enable direct name editing in the feature */ @Override public void performRequest(Request req) { if(!editor.isLastDateSelected()) return; if(req.getType() == RequestConstants.REQ_DIRECT_EDIT) { } if(req.getType() == RequestConstants.REQ_OPEN){ DwFeatureWrapped feature = (DwFeatureWrapped)getModel(); Date date = editor.getCurrentSelectedDate(); if(feature.calculateVariationTypeCircleBounds(date).contains(((SelectionRequest)req).getLocation())){ HyFeatureType type = HyEvolutionUtil.getValidTemporalElement(feature.getWrappedModelElement().getTypes(), date); type.setValidUntil(date); HyFeatureType newType = HyFeatureFactory.eINSTANCE.createHyFeatureType(); newType.setValidSince(date); if(type.getType() == HyFeatureTypeEnum.MANDATORY){ newType.setType(HyFeatureTypeEnum.OPTIONAL); }else{ newType.setType(HyFeatureTypeEnum.MANDATORY); } feature.getWrappedModelElement().getTypes().add(newType); this.refreshVisuals(); }else{ performDirectEditing(); } } }
/** * @see org.eclipse.gef.editpolicies.AbstractEditPolicy#getTargetEditPart(org.eclipse.gef.Request) */ @Override public EditPart getTargetEditPart(Request request) { // TODO Auto-generated method stub if (super.getTargetEditPart(request) != null) this.targetEditPart = super.getTargetEditPart(request); if (request instanceof SelectionRequest) this.request = (SelectionRequest) request; return super.getTargetEditPart(request); }
/** * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#getDragTracker(org.eclipse.gef.Request) */ @Override public DragTracker getDragTracker(Request request) { if (request instanceof SelectionRequest && ((SelectionRequest) request).getLastButtonPressed() == 3) return null; return new SequenceDelegatingDragEditPartsTracker(this, getParent()); }
@Override public DragTracker getDragTracker(final Request request) { if (request instanceof SelectionRequest && ((SelectionRequest) request).getLastButtonPressed() == 3) return null; IDoubleClickCallback callback = new IDoubleClickCallback() { public void handleDoubleClick(int btn) { performDirectEditRequest(request); } }; return new DoubleClickDirectEditDragTracker(this, getTopGraphicEditPart(), callback); }
/** * Handle the doubleclick on the resize bar, in this way is possible to resize the band to the minimum size to contains all * the element */ protected boolean handleDoubleClick(int button) { if (getSourceEditPart() != null) { if (button == 1) { SelectionRequest request = new SelectionRequest(); request.setLocation(getLocation()); request.setType(RequestConstants.REQ_OPEN); getSourceEditPart().performRequest(request); } } return true; }
@Override public void eraseTargetFeedback(Request request) { super.eraseTargetFeedback(request); if (request instanceof SelectionRequest) { tip.setVisible (false); } }
public DragTracker getDragTracker(Request request) { if (request.getType().equals(REQ_SELECTION) && ((SelectionRequest) request).getLastButtonPressed() != 1) { return null; } return new RulerDragTracker(this); }
/** * If there is a {@link Handle} under the mouse, this method sets the drag * tracker returned from the handle. If there's an {@link EditPart} under * the mouse, this method sets the drag tracker returned from the edit part. * * @see AbstractTool#handleButtonDown(int) */ protected boolean handleButtonDown(int button) { if (!stateTransition(STATE_INITIAL, STATE_DRAG)) { resetHover(); return true; } resetHover(); EditPartViewer viewer = getCurrentViewer(); Point p = getLocation(); if (getDragTracker() != null) getDragTracker().deactivate(); if (viewer instanceof GraphicalViewer) { Handle handle = ((GraphicalViewer) viewer).findHandleAt(p); if (handle != null) { setDragTracker(handle.getDragTracker()); return true; } } updateTargetRequest(); ((SelectionRequest) getTargetRequest()).setLastButtonPressed(button); updateTargetUnderMouse(); EditPart editpart = getTargetEditPart(); if (editpart != null) { setDragTracker(editpart.getDragTracker(getTargetRequest())); lockTargetEditPart(editpart); return true; } return false; }
/** * Resets this tool when the last button is released. * * @see AbstractTool#handleButtonUp(int) */ protected boolean handleButtonUp(int button) { if (getCurrentInput().isAnyButtonDown()) return false; ((SelectionRequest) getTargetRequest()).setLastButtonPressed(0); setDragTracker(null); setState(STATE_INITIAL); unlockTargetEditPart(); return true; }
/** * Sets the modifiers , type and location of the target request (which is a * {@link SelectionRequest}) and then calls {@link #updateHoverRequest()}. * * @see TargetingTool#updateTargetRequest() */ protected void updateTargetRequest() { SelectionRequest request = (SelectionRequest) getTargetRequest(); request.setModifiers(getCurrentInput().getModifiers()); request.setType(getCommandName()); request.setLocation(getLocation()); updateHoverRequest(); }
/** * Creates a {@link SelectionRequest} and sends it to the source edit part * via {@link EditPart#performRequest(Request)}. Possible uses are to open * the selected item in another editor or replace the current editor's * contents based on the selected item. */ protected void performOpen() { SelectionRequest request = new SelectionRequest(); request.setLocation(getLocation()); request.setModifiers(getCurrentInput().getModifiers()); request.setType(RequestConstants.REQ_OPEN); getSourceEditPart().performRequest(request); }
@Override public DragTracker getDragTracker(Request req) { if (req instanceof SelectionRequest && ((SelectionRequest)req).getLastButtonPressed() == 3) { return new DeselectAllTracker(this); } return new MarqueeDragTracker(); }
@Override public DragTracker getDragTracker(Request request) { if (request.getType().equals(REQ_SELECTION) && ((SelectionRequest)request).getLastButtonPressed() != 1) { return null; } return new InstallOptionsRulerDragTracker(this); }
protected boolean isFigureLeft( Request request ) { if ( !( request instanceof SelectionRequest ) ) { return true; } SelectionRequest selctionRequest = (SelectionRequest) request; Point p = selctionRequest.getLocation( ); // getFigure().translateToAbsolute(p); getFigure( ).translateToRelative( p ); Point center = getFigure( ).getBounds( ).getCenter( ); return center.x >= p.x; }
public DragTracker getDragTracker( Request req ) { if ( req instanceof SelectionRequest && ( (SelectionRequest) req ).getLastButtonPressed( ) == 3 ) return new DeselectAllTracker( this ); return new RootDragTracker( ); }
protected void performOpen( ) { SelectionRequest request = new SelectionRequest( ); request.setLocation( getLocation( ) ); request.setType( RequestConstants.REQ_OPEN ); request.getExtendedData( ).put( DesignerConstants.TABLE_ROW_NUMBER, Integer.valueOf( getNumber( ) ) ); if ( getSourceEditPart( ).understandsRequest( request ) ) { getSourceEditPart( ).performRequest( request ); } }
/** * When the label's model element definition changes, we must change our references. * */ public void notifyChanged(Notification notification) { int type = notification.getEventType(); int featureIdUrn = notification.getFeatureID(UrncorePackage.class); int featureIdUcm = notification.getFeatureID(MapPackage.class); int featureIdGrl = notification.getFeatureID(GrlPackage.class); // bug 523: feedback remains even when element is deleted. eraseTargetFeedback(new SelectionRequest()); if (type == Notification.SET) { // if changing component definitions if (featureIdUrn == UrncorePackage.IURN_CONTAINER_REF__CONT_DEF) { if (modelElement instanceof IURNContainerRef) { if (comp != null) comp.eAdapters().remove(this); comp = ((IURNContainerRef) modelElement).getContDef(); if (comp != null) comp.eAdapters().add(this); } } else if (featureIdUcm == MapPackage.RESP_REF__RESP_DEF) { // if changing responsibility definitions if (modelElement instanceof RespRef) { if (resp != null) resp.eAdapters().remove(this); resp = ((RespRef) modelElement).getRespDef(); if (resp != null) resp.eAdapters().add(this); } } // something changed; inform parent. not sure how useful this is anymore if (getParent() != null) { ((URNDiagramEditPart) getParent()).notifyChanged(notification); refreshVisuals(); } } else if (type == Notification.ADD || type == Notification.ADD_MANY || type == Notification.REMOVE || type == Notification.REMOVE_MANY) { refreshVisuals(); } }
public DragTracker getDragTracker(Request request) { if (request.getType().equals(REQ_SELECTION) && ((SelectionRequest) request).getLastButtonPressed() != 1) { return null; } return new JDRulerDragTracker(this); }
/** * Creates a {@link SelectionRequest} for the target request. * * @see TargetingTool#createTargetRequest() */ protected Request createTargetRequest() { SelectionRequest request = new SelectionRequest(); request.setType(getCommandName()); return request; }
public static void doubleClick(final EditPart theEditPart) { final SelectionRequest request = new SelectionRequest(); request.setType(RequestConstants.REQ_OPEN); theEditPart.performRequest(request); }