org.eclipse.gef.requests.CreateRequest Java Examples
The following examples show how to use
org.eclipse.gef.requests.CreateRequest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ERDiagramLayoutEditPolicy.java From ermaster-b with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override protected void showSizeOnDropFeedback(CreateRequest request) { Point p = new Point(request.getLocation().getCopy()); ZoomManager zoomManager = ((ScalableFreeformRootEditPart) this .getHost().getRoot()).getZoomManager(); double zoom = zoomManager.getZoom(); IFigure feedback = getSizeOnDropFeedback(request); Dimension size = request.getSize().getCopy(); feedback.translateToRelative(size); feedback.setBounds(new Rectangle((int) (p.x * zoom), (int) (p.y * zoom), size.width, size.height) .expand(getCreationFeedbackOffset(request))); }
Example #2
Source File: DraggableElementCreationTool.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private void redrawFeedback() { this.calculateCursor(); final Command command = getCommand(); if (command != null && command.canExecute()) { if (!draggableElement.getLayer().getChildren().contains(figure)) { draggableElement.getLayer().add(figure); } final IFigure parentFigure = draggableElement.getLayer(); final Point location = ((CreateRequest) getTargetRequest()).getLocation(); FiguresHelper.translateToAbsolute(parentFigure, location); showTargetCompartmentFeedback(); Point translated = getLocation().getTranslated(-figure.getSize().width / 2, -figure.getSize().height / 2); FiguresHelper.translateToAbsolute(figure, translated); figure.setLocation(translated); } else { if (draggableElement.getLayer().getChildren().contains(figure)) { draggableElement.getLayer().remove(figure); } } }
Example #3
Source File: BonitaUnspecifiedTypeCreationTool.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
protected void snapPoint(CreateRequest request) { Dimension delta =getDragMoveDelta(); Point moveDelta = new Point(delta.preciseWidth(),delta.preciseHeight()); if (helper != null && sourceRectangle != null && compoundSrcRect != null) { PrecisionRectangle baseRect = sourceRectangle.getPreciseCopy(); PrecisionRectangle jointRect = compoundSrcRect.getPreciseCopy(); baseRect.translate(moveDelta); jointRect.translate(moveDelta); PrecisionPoint preciseDelta = new PrecisionPoint(moveDelta); helper.snapPoint(request, PositionConstants.HORIZONTAL | PositionConstants.VERTICAL, new PrecisionRectangle[] { baseRect, jointRect }, preciseDelta); request.setLocation(preciseDelta); } }
Example #4
Source File: PaletteToolTransferDropTargetListenerWithSelection.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * Overridden to select the created object. * * @see org.eclipse.gef.dnd.AbstractTransferDropTargetListener#handleDrop() * /!\ don't call super, this method is copied from AbstractTransferDropTargetListener, * and added a method to select added object (method copied from CreationTool) * Please note that intermediate class are also trying to */ @Override protected void handleDrop() { final CreateRequest request = getCreateRequest(); final Point loc = super.getDropLocation().getCopy(); request.setLocation(loc); updateTargetEditPart(); if (getTargetEditPart() != null) { final Command command = getCommand(); if (command != null && command.canExecute()) { getViewer().getEditDomain().getCommandStack().execute(command); insertOnSequenceFlow(command, getTargetEditPart(), getViewer(), true); selectAddedObject(getViewer(), DiagramCommandStack.getReturnValues(command)); getViewer().getEditDomain().loadDefaultTool(); } else { getCurrentEvent().detail = DND.DROP_NONE; } } else { getCurrentEvent().detail = DND.DROP_NONE; } }
Example #5
Source File: BasePaletteFactory.java From birt with Eclipse Public License 1.0 | 6 votes |
public boolean preHandleMouseUp( ) { CreateRequest request = getRequest( ); if ( IReportElementConstants.REPORT_ELEMENT_LIST.equalsIgnoreCase( (String) request.getNewObjectType( ) ) ) { // ListHandle list = SessionHandleAdapter.getInstance( ) // .getReportDesignHandle( ) // .getElementFactory( ) // .newList( null ); ListHandle list = DesignElementFactory.getInstance( ) .newList( null ); setModel( list ); return super.preHandleMouseUp( ); } return false; }
Example #6
Source File: BasePaletteFactory.java From birt with Eclipse Public License 1.0 | 6 votes |
public boolean preHandleMouseUp( ) { CreateRequest request = getRequest( ); if ( IReportElementConstants.REPORT_ELEMENT_LABEL.equalsIgnoreCase( (String) request.getNewObjectType( ) ) ) { // LabelHandle labelItemHandle = // SessionHandleAdapter.getInstance( ) // .getReportDesignHandle( ) // .getElementFactory( ) // .newLabel( null ); LabelHandle labelItemHandle = DesignElementFactory.getInstance( ) .newLabel( null ); setModel( labelItemHandle ); return super.preHandleMouseUp( ); } return false; }
Example #7
Source File: BasePaletteFactory.java From birt with Eclipse Public License 1.0 | 6 votes |
public boolean preHandleMouseUp( ) { CreateRequest request = getRequest( ); if ( IReportElementConstants.REPORT_ELEMENT_DATA.equalsIgnoreCase( (String) request.getNewObjectType( ) ) ) { // DataItemHandle dataHandle = SessionHandleAdapter.getInstance( // ) // .getReportDesignHandle( ) // .getElementFactory( ) // .newDataItem( null ); DataItemHandle dataHandle = DesignElementFactory.getInstance( ) .newDataItem( null ); setModel( dataHandle ); // disable this dialog // dialog will pop-up after image is create // see ReportCreationTool.selectAddedObject() // BindingColumnDialog dialog = new BindingColumnDialog( true ); // dialog.setInput( dataHandle ); // if ( dialog.open( ) == Window.OK ) // { return super.preHandleMouseUp( ); // } } return false; }
Example #8
Source File: BasePaletteFactory.java From birt with Eclipse Public License 1.0 | 5 votes |
public boolean preHandleMouseUp( ) { CreateRequest request = getRequest( ); if ( IReportElementConstants.REPORT_ELEMENT_TEXTDATA.equalsIgnoreCase( (String) request.getNewObjectType( ) ) ) { // LabelHandle labelItemHandle = // SessionHandleAdapter.getInstance( ) // .getReportDesignHandle( ) // .getElementFactory( ) // .newLabel( null ); TextDataHandle textItemHandle = DesignElementFactory.getInstance( ) .newTextData( null ); try { textItemHandle.setContentType( DesignChoiceConstants.TEXT_CONTENT_TYPE_HTML ); } catch ( SemanticException e ) { ExceptionHandler.handle( e ); return false; } setModel( textItemHandle ); return super.preHandleMouseUp( ); } return false; }
Example #9
Source File: DraggableElementCreationTool.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected void snapPoint(CreateRequest request) { if (helper != null && figure != null) { final PrecisionRectangle baseRect = sourceRectangle.getPreciseCopy(); final PrecisionRectangle jointRect = compoundSrcRect.getPreciseCopy(); Point location = getLocation().getTranslated(-figure.getSize().width / 2, -figure.getSize().height / 2); final PrecisionPoint preciseDelta = new PrecisionPoint(location.preciseX(), location.preciseY()); baseRect.translate(preciseDelta); jointRect.translate(preciseDelta); helper.snapPoint(request, PositionConstants.HORIZONTAL | PositionConstants.VERTICAL, new PrecisionRectangle[] { baseRect, jointRect }, preciseDelta); request.setLocation(preciseDelta); } }
Example #10
Source File: DraggableElementCreationTool.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override protected void updateTargetRequest() { ((CreateRequest) getTargetRequest()).setLocation(getLocation()); final CreateRequest req = getCreateRequest(); req.getExtendedData().clear(); if (isInState(STATE_DRAG_IN_PROGRESS)) { snapPoint(req); } else { req.setLocation(getLocation()); req.setSize(null); } }
Example #11
Source File: BonitaUnspecifiedTypeCreationTool.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * */ protected void redrawFeedback() { if(!noRedraw){ calculateCursor(); if(getTargetEditPart() != null){ layer = LayerManager.Helper.find(getTargetEditPart()).getLayer(LayerConstants.HANDLE_LAYER); IFigure parentFigure = layer; Point location = ((CreateRequest)getTargetRequest()).getLocation(); FiguresHelper.translateToAbsolute(parentFigure, location); Command command = getCommand(); if(figure != null) { figure.setLocation(location); } if (command != null && command.canExecute()) { if (!layer.getChildren().contains(figure)) { if(figure != null) { layer.add(figure); } } showTargetCompartmentFeedback(); } else { if (layer.getChildren().contains(figure)) { layer.remove(figure); } } }else{ eraseTargetFeedback(); } } }
Example #12
Source File: ReportFlowLayoutEditPolicy.java From birt with Eclipse Public License 1.0 | 5 votes |
protected org.eclipse.gef.commands.Command getCreateCommand( CreateRequest request ) { EditPart after = getInsertionReference( request ); CreateCommand command = new CreateCommand( request.getExtendedData( ) ); Object model = this.getHost( ).getModel( ); // if ( model instanceof ReportElementModel ) // { // command.setParent( ( (ReportElementModel) model ).getSlotHandle( ) ); // }else if ( model instanceof SlotHandle ) { command.setParent( ( (SlotHandle) model ) ); } else if ( model instanceof ListBandProxy ) { command.setParent( ( (ListBandProxy) model ).getSlotHandle( ) ); } else { command.setParent( model ); } // No previous edit part if ( after != null ) { command.setAfter( after.getModel( ) ); } return command; }
Example #13
Source File: ERDiagramLayoutEditPolicy.java From ermasterr with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected void showSizeOnDropFeedback(final CreateRequest request) { final Point p = new Point(request.getLocation().getCopy()); final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager(); final double zoom = zoomManager.getZoom(); final IFigure feedback = getSizeOnDropFeedback(request); final Dimension size = request.getSize().getCopy(); feedback.translateToRelative(size); feedback.setBounds(new Rectangle((int) (p.x * zoom), (int) (p.y * zoom), size.width, size.height).expand(getCreationFeedbackOffset(request))); }
Example #14
Source File: BasePaletteFactory.java From birt with Eclipse Public License 1.0 | 5 votes |
public boolean preHandleMouseUp( ) { CreateRequest request = getRequest( ); if ( IReportElementConstants.AUTOTEXT_VARIABLE.equalsIgnoreCase( (String) request.getNewObjectType( ) ) ) { ModuleHandle reportHandle = SessionHandleAdapter.getInstance( ) .getReportDesignHandle( ); if ( reportHandle instanceof ReportDesignHandle ) { SelectVariableDialog dialog = new SelectVariableDialog( (ReportDesignHandle) SessionHandleAdapter.getInstance( ) .getReportDesignHandle( ) ); if ( dialog.open( ) == Dialog.OK ) { AutoTextHandle autoTextItemHandle = DesignElementFactory.getInstance( ) .newAutoText( null ); try { autoTextItemHandle.setPageVariable( (String) dialog.getResult( ) ); autoTextItemHandle.setAutoTextType( DesignChoiceConstants.AUTO_TEXT_PAGE_VARIABLE ); setModel( autoTextItemHandle ); } catch ( SemanticException e ) { ExceptionHandler.handle( e ); } return super.preHandleMouseUp( ); } } } return false; }
Example #15
Source File: BasePaletteFactory.java From birt with Eclipse Public License 1.0 | 5 votes |
public boolean preHandleMouseUp( ) { CreateRequest request = getRequest( ); AutoTextHandle autoTextItemHandle = DesignElementFactory.getInstance( ) .newAutoText( null ); try { if ( IReportElementConstants.AUTOTEXT_PAGE.equalsIgnoreCase( (String) request.getNewObjectType( ) ) ) { autoTextItemHandle.setAutoTextType( DesignChoiceConstants.AUTO_TEXT_PAGE_NUMBER ); } else if ( IReportElementConstants.AUTOTEXT_TOTAL_PAGE_COUNT.equalsIgnoreCase( (String) request.getNewObjectType( ) ) ) { autoTextItemHandle.setAutoTextType( DesignChoiceConstants.AUTO_TEXT_TOTAL_PAGE ); } } catch ( SemanticException e ) { // TODO Auto-generated catch block e.printStackTrace( ); } setModel( autoTextItemHandle ); return super.preHandleMouseUp( ); }
Example #16
Source File: RegionNameEditPart.java From statecharts with Eclipse Public License 1.0 | 5 votes |
@Override public EditPart getTargetEditPart(Request request) { // Delegate creation requests to the figure compartment edit part if (request instanceof CreateRequest) { for (Object object : getParent().getChildren()) { if (object instanceof RegionCompartmentEditPart) { return (EditPart) object; } } } return super.getTargetEditPart(request); }
Example #17
Source File: CrosstabCellFlowLayoutEditPolicy.java From birt with Eclipse Public License 1.0 | 5 votes |
private CrosstabCellCreateCommand getCrosstabCellCreateCommand(CreateRequest request, EditPart after) { CrosstabCellCreateCommand command = new CrosstabCellCreateCommand( request.getExtendedData( ) ); command.setParent( getHost( ).getModel( ) ); command.setAfter( after == null ? null : after.getModel( ) ); return command; }
Example #18
Source File: TreeLayoutEditPolicy.java From statecharts with Eclipse Public License 1.0 | 5 votes |
@Override protected Command getCreateCommand(CreateRequest request) { final CompoundCommand cmd = new CompoundCommand(); cmd.add(super.getCreateCommand(request)); if (request instanceof CreateViewAndElementRequest) { final CreateViewAndElementRequest req = (CreateViewAndElementRequest) request; if (shouldUpdateAnnotationsOnCreation(req)) { cmd.add(new ICommandProxy( new UpdateAnnotationsOnCreationCommand(getHost() .getEditingDomain(), req))); } } return cmd; }
Example #19
Source File: ERDiagramLayoutEditPolicy.java From erflute with Apache License 2.0 | 5 votes |
@Override protected void showSizeOnDropFeedback(CreateRequest request) { final Point p = new Point(request.getLocation().getCopy()); final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager(); final double zoom = zoomManager.getZoom(); final IFigure feedback = getSizeOnDropFeedback(request); final Dimension size = request.getSize().getCopy(); feedback.translateToRelative(size); feedback.setBounds(new Rectangle((int) (p.x * zoom), (int) (p.y * zoom), size.width, size.height) .expand(getCreationFeedbackOffset(request))); }
Example #20
Source File: AbstractToolHandleExtends.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * @param request * The request to set. */ public void setRequest( CreateRequest request ) { this.request = request; }
Example #21
Source File: LayoutPolicy.java From olca-app with Mozilla Public License 2.0 | 4 votes |
@Override protected Command getCreateCommand(final CreateRequest request) { return null; }
Example #22
Source File: LayoutPolicy.java From olca-app with Mozilla Public License 2.0 | 4 votes |
@Override protected Command getCreateCommand(CreateRequest request) { return null; }
Example #23
Source File: CompartmentLayoutEditPolicy.java From statecharts with Eclipse Public License 1.0 | 4 votes |
@SuppressWarnings("unchecked") @Override protected Command getCreateCommand(CreateRequest request) { if (request instanceof CreateViewAndElementRequest) { TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()) .getEditingDomain(); CompositeTransactionalCommand cc = new CompositeTransactionalCommand( editingDomain, DiagramUIMessages.AddCommand_Label); Iterator<?> descriptors = ((CreateViewRequest) request) .getViewDescriptors().iterator(); while (descriptors.hasNext()) { CreateViewRequest.ViewDescriptor descriptor = (CreateViewRequest.ViewDescriptor) descriptors .next(); int feedBackIndex = getFeedbackIndexFor(request); // obtain CreateElementRequest and add initial region feedback // index to request map. This index is needed to add the // semantic element at the correct listIndex CreateElementRequest createElementRequest = (CreateElementRequest) ((CreateViewAndElementRequest) request) .getViewAndElementDescriptor() .getCreateElementRequestAdapter() .getAdapter(CreateElementRequest.class); if (createElementRequest != null) { createElementRequest.getParameters().put( RequestParameterKeys.RegionFeedbackIndex, feedBackIndex); } CreateCommand createCommand = new CompartmentChildCreateCommand( editingDomain, descriptor, (View) (getHost().getModel()), feedBackIndex); cc.compose(createCommand); } return new ICommandProxy(cc.reduce()); } return null; }
Example #24
Source File: CompartmentEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
protected Command getCreateCommand(CreateRequest request) { return null; }
Example #25
Source File: CamelEditorDropTargetListener.java From tesb-studio-se with Apache License 2.0 | 4 votes |
@Override protected void handleDrop() { if (!checkSelectionSource()) { return; } updateTargetRequest(); updateTargetEditPart(); if (selectSourceList.get(0) instanceof PaletteEditPart && getTargetRequest() instanceof CreateRequest) { if (getTargetEditPart() instanceof ProcessPart) { Object newObject = ((CreateRequest) getTargetRequest()).getNewObject(); if (newObject != null) { Command command = getCommand(); if (command != null) { execCommandStack(command); } } } return; } if (isContextSource) { createContext(); } else { if (!(getTargetEditPart() instanceof NodeContainerPart)) { try { createNewComponent(getCurrentEvent()); } catch (OperationCanceledException e) { return; } } } // in case after drag/drop the editor is dirty but can not get focus if (editor.isDirty()) { editor.setFocus(); } this.eraseTargetFeedback(); }
Example #26
Source File: ParameterDropAdapter.java From birt with Eclipse Public License 1.0 | 4 votes |
public boolean performDrop( Object transfer, Object target, int operation, DNDLocation location ) { if ( target instanceof EditPart )// drop on layout { EditPart editPart = (EditPart) target; if ( editPart != null ) { CreateRequest request = new CreateRequest( ); if ( transfer instanceof Object[] ) { Object[] newObjs = (Object[]) transfer; transfer = UIUtil.getInsertPamaterElements( newObjs ); } try { if ( transfer instanceof ScalarParameterHandle ) { transfer = InsertInLayoutUtil.performInsertParameter( (ScalarParameterHandle) transfer ); } else if ( transfer instanceof Object[] ) { Object[] objs = (Object[])transfer; Object[] copys = new Object[objs.length]; for (int i=0; i<objs.length; i++) { if (objs[i] instanceof ScalarParameterHandle) { copys[i] = InsertInLayoutUtil.performInsertParameter( (ScalarParameterHandle) objs[i] ); } else { // Return now , don't support the other type return false; } } transfer = copys; } } catch ( SemanticException e ) { // do nothing return false; } request.getExtendedData( ) .put( DesignerConstants.KEY_NEWOBJECT, transfer ); request.setLocation( location.getPoint( ) ); Command command = editPart.getCommand( request ); if ( command != null && command.canExecute( ) ) { CommandStack stack = SessionHandleAdapter.getInstance( ) .getCommandStack( ); stack.startTrans( Messages.getString( "LevelHandleDropAdapter.ActionText" ) ); //$NON-NLS-1$ editPart.getViewer( ) .getEditDomain( ) .getCommandStack( ) .execute( command ); stack.commit( ); return true; } else return false; } } return false; }
Example #27
Source File: LevelAttributeHandleDropAdapter.java From birt with Eclipse Public License 1.0 | 4 votes |
public boolean performDrop( Object transfer, Object target, int operation, DNDLocation location ) { if (transfer instanceof IAdaptable) { if (((IAdaptable)transfer).getAdapter( StructureHandle.class ) instanceof LevelAttributeHandle) { transfer = ((IAdaptable)transfer).getAdapter( StructureHandle.class ); } } if ( target instanceof EditPart )// drop on layout { EditPart editPart = (EditPart) target; if ( editPart != null ) { CreateRequest request = new CreateRequest( ); request.getExtendedData( ) .put( DesignerConstants.KEY_NEWOBJECT, transfer ); request.setLocation( location.getPoint( ) ); Command command = editPart.getCommand( request ); if ( command != null && command.canExecute( ) ) { CommandStack stack = SessionHandleAdapter.getInstance( ) .getCommandStack( ); stack.startTrans( Messages.getString( "LevelHandleDropAdapter.ActionText" ) ); //$NON-NLS-1$ editPart.getViewer( ) .getEditDomain( ) .getCommandStack( ) .execute( command ); CrosstabReportItemHandle crosstab = getCrosstab( editPart ); if ( crosstab != null ) { AggregationCellProviderWrapper providerWrapper = new AggregationCellProviderWrapper( crosstab ); providerWrapper.updateAllAggregationCells( AggregationCellViewAdapter.SWITCH_VIEW_TYPE ); } stack.commit( ); return true; } else return false; } } return false; }
Example #28
Source File: JoinXYLayoutEditPolicy.java From birt with Eclipse Public License 1.0 | 4 votes |
protected Command getCreateCommand( CreateRequest request ) { return null; }
Example #29
Source File: AbstractToolHandleExtends.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * @return Returns the request. */ public CreateRequest getRequest( ) { return request; }
Example #30
Source File: ListLayoutEditPolicy.java From birt with Eclipse Public License 1.0 | 4 votes |
protected Command getCreateCommand( CreateRequest request ) { return null; }