org.eclipse.gef.editparts.LayerManager Java Examples

The following examples show how to use org.eclipse.gef.editparts.LayerManager. 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: TableViewGraphicalNodeEditPolicy.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
@Override
public void eraseTargetFeedback(final Request request) {
    final LayerManager manager = (LayerManager) getHost().getRoot();
    final IFigure layer = manager.getLayer(LayerConstants.PRIMARY_LAYER);
    getFeedbackLayer().setBounds(layer.getBounds());

    final List list = getFeedbackLayer().getChildren();

    for (final Iterator iter = list.iterator(); iter.hasNext();) {
        final Object obj = iter.next();
        if (obj instanceof Label) {
            iter.remove();
        }
    }
    getFeedbackLayer().repaint();

    super.eraseTargetFeedback(request);
}
 
Example #2
Source File: TableViewGraphicalNodeEditPolicy.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
@Override
public void eraseTargetFeedback(Request request) {
	LayerManager manager = (LayerManager) this.getHost().getRoot();
	IFigure layer = manager.getLayer(LayerConstants.PRIMARY_LAYER);
	this.getFeedbackLayer().setBounds(layer.getBounds());

	List list = this.getFeedbackLayer().getChildren();

	for (Iterator iter = list.iterator(); iter.hasNext();) {
		Object obj = iter.next();
		if (obj instanceof Label) {
			iter.remove();
		}
	}
	this.getFeedbackLayer().repaint();

	super.eraseTargetFeedback(request);
}
 
Example #3
Source File: DeferredGraphicalViewer.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @see GraphicalViewer#findHandleAt(org.eclipse.draw2d.geometry.Point)
 */
public Handle findHandleAt( Point p )
{
	LayerManager layermanager = (LayerManager) getEditPartRegistry( ).get( LayerManager.ID );
	if ( layermanager == null )
		return null;
	List list = new ArrayList( 3 );
	// list.add(layermanager.getLayer(LayerConstants.PRIMARY_LAYER));
	list.add( layermanager.getLayer( LayerConstants.CONNECTION_LAYER ) );
	list.add( layermanager.getLayer( LayerConstants.FEEDBACK_LAYER ) );
	IFigure handle = getLightweightSystem( ).getRootFigure( )
			.findFigureAtExcluding( p.x, p.y, list );
	if ( handle instanceof Handle )
		return (Handle) handle;
	return null;
}
 
Example #4
Source File: TableViewGraphicalNodeEditPolicy.java    From erflute with Apache License 2.0 6 votes vote down vote up
@Override
public void eraseTargetFeedback(Request request) {
    final LayerManager manager = (LayerManager) getHost().getRoot();
    final IFigure layer = manager.getLayer(LayerConstants.PRIMARY_LAYER);
    getFeedbackLayer().setBounds(layer.getBounds());

    final List<?> list = getFeedbackLayer().getChildren();

    for (final Iterator<?> iter = list.iterator(); iter.hasNext();) {
        final Object obj = iter.next();
        if (obj instanceof Label) {
            iter.remove();
        }
    }
    getFeedbackLayer().repaint();

    super.eraseTargetFeedback(request);
}
 
Example #5
Source File: ReportPrintGraphicalViewerOperation.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public ReportPrintGraphicalViewerOperation( GraphicalViewer g,
		Drawable drawable, Device device, Rectangle region )
{
	this.device = device;
	this.region = region;
	this.drawable = drawable;
	this.viewer = g;

	LayerManager lm = (LayerManager) viewer.getEditPartRegistry( )
			.get( LayerManager.ID );
	IFigure f = lm.getLayer( LayerConstants.PRINTABLE_LAYERS );

	this.printSource = f;
}
 
Example #6
Source File: DirectEditManagerEx.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Asks the source edit part to erase source feedback.
 */
protected void eraseFeedback() {
	if (showingFeedback) {
		LayerManager.Helper.find(getEditPart())
				.getLayer(LayerConstants.FEEDBACK_LAYER)
				.remove(getCellEditorFrame());
		cellEditorFrame = null;
		getEditPart().eraseSourceFeedback(getDirectEditRequest());
		showingFeedback = false;
	}
}
 
Example #7
Source File: EditorRulerEditPart.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public IFigure getGuideLayer( )
{
	LayerManager lm = (LayerManager) diagramViewer.getEditPartRegistry( )
			.get( LayerManager.ID );
	if ( lm != null )
		return lm.getLayer( LayerConstants.GUIDE_LAYER );
	return null;
}
 
Example #8
Source File: ReportElementEditPart.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private IFigure getHandleLayer( )
{
	super.getLayer( LayerConstants.HANDLE_LAYER );
	LayerManager manager = (LayerManager) getViewer( ).getEditPartRegistry( )
			.get( LayerManager.ID );
	return manager.getLayer( LayerConstants.HANDLE_LAYER );
}
 
Example #9
Source File: ShowDragInfomationProcessor.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void removeLabelFigue()
{
	if (labelFigure != null)
	{
		LayerManager lm = (LayerManager) editpart.getViewer( )
				.getEditPartRegistry().get(LayerManager.ID);
		if (lm == null)
			return;
		lm.getLayer(LayerConstants.FEEDBACK_LAYER).remove(  labelFigure );
		labelFigure = null;
	}
}
 
Example #10
Source File: ShowDragInfomationProcessor.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected void addFeedback(IFigure figure) {
	LayerManager lm = (LayerManager) editpart.getViewer( )
			.getEditPartRegistry().get(LayerManager.ID);
	if (lm == null)
		return;
	lm.getLayer(LayerConstants.FEEDBACK_LAYER).add(figure);
}
 
Example #11
Source File: BonitaUnspecifiedTypeCreationTool.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 
 */
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: ExportToHtmlAction.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
public static Map<TableView, Location> getTableLocationMap(
		GraphicalViewer viewer, ERDiagram diagram) {
	Map<TableView, Location> tableLocationMap = new HashMap<TableView, Location>();

	ScalableFreeformRootEditPart rootEditPart = (ScalableFreeformRootEditPart) viewer
			.getEditPartRegistry().get(LayerManager.ID);
	IFigure rootFigure = ((LayerManager) rootEditPart)
			.getLayer(LayerConstants.PRINTABLE_LAYERS);
	int translateX = ExportToImageAction
			.translateX(rootFigure.getBounds().x);
	int translateY = ExportToImageAction
			.translateY(rootFigure.getBounds().y);

	Category category = diagram.getCurrentCategory();

	for (Object child : rootEditPart.getContents().getChildren()) {
		NodeElementEditPart editPart = (NodeElementEditPart) child;
		NodeElement nodeElement = (NodeElement) editPart.getModel();
		if (!(nodeElement instanceof TableView)) {
			continue;
		}

		if (category == null || category.isVisible(nodeElement, diagram)) {
			IFigure figure = editPart.getFigure();
			Rectangle figureRectangle = figure.getBounds();

			Location location = new Location(
					figureRectangle.x + translateX, figureRectangle.y
							+ translateY, figureRectangle.width,
					figureRectangle.height);
			tableLocationMap.put((TableView) nodeElement, location);
		}
	}

	return tableLocationMap;
}
 
Example #13
Source File: RelationBendpointEditPolicy.java    From erflute with Apache License 2.0 4 votes vote down vote up
@Override
protected void showMoveBendpointFeedback(BendpointRequest bendpointrequest) {
    final Relationship relation = (Relationship) getHost().getModel();
    final RelationEditPart editPart = (RelationEditPart) getHost();

    if (relation.getSourceWalker() == relation.getTargetWalker()) {
        if (bendpointrequest.getIndex() != 1) {
            return;
        }
        final Point point = bendpointrequest.getLocation();
        getConnection().translateToRelative(point);
        final Bendpoint rate = getRate(point);
        rate.setRelative(true);

        final float rateX = (100f - (rate.getX() / 2)) / 100;
        final float rateY = (100f - (rate.getY() / 2)) / 100;

        final ERTableEditPart tableEditPart = (ERTableEditPart) editPart.getSource();
        final Rectangle bounds = tableEditPart.getFigure().getBounds();

        final Rectangle rect = new Rectangle();
        rect.x = (int) (bounds.x + (bounds.width * rateX));
        rect.y = (int) (bounds.y + (bounds.height * rateY));
        rect.width = (int) (bounds.width * rate.getX() / 100);
        rect.height = (int) (bounds.height * rate.getY() / 100);

        relation.setSourceLocationp(100, (int) (100 * rateY));

        relation.setTargetLocationp((int) (100 * rateX), 100);

        final LayerManager manager = (LayerManager) tableEditPart.getRoot();
        final IFigure layer = manager.getLayer(LayerConstants.PRIMARY_LAYER);
        getFeedbackLayer().setBounds(layer.getBounds());

        final List<?> children = getFeedbackLayer().getChildren();
        children.clear();
        getFeedbackLayer().repaint();

        final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager();
        final double zoom = zoomManager.getZoom();

        final Polyline feedbackFigure = new Polyline();
        feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) (rect.y * zoom)));
        feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) ((rect.y + rect.height) * zoom)));
        feedbackFigure.addPoint(new Point((int) ((rect.x + rect.width) * zoom), (int) ((rect.y + rect.height) * zoom)));
        feedbackFigure.addPoint(new Point((int) ((rect.x + rect.width) * zoom), (int) (rect.y * zoom)));
        feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) (rect.y * zoom)));

        feedbackFigure.setLineStyle(SWT.LINE_DASH);

        feedbackFigure.translateToRelative(feedbackFigure.getLocation());

        addFeedback(feedbackFigure);

    } else {
        super.showMoveBendpointFeedback(bendpointrequest);
    }
}
 
Example #14
Source File: DirectEditManagerEx.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
private void showCellEditorFrame() {
	LayerManager.Helper.find(getEditPart())
			.getLayer(LayerConstants.FEEDBACK_LAYER)
			.add(getCellEditorFrame());
	placeBorder();
}
 
Example #15
Source File: TableCellResizeEditPolicy.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @param handle_layer
 * @return
 */
private IFigure getTopLayer( String layer )
{
	return LayerManager.Helper.find( getHost( ) ).getLayer( layer );
}
 
Example #16
Source File: RelationBendpointEditPolicy.java    From ermaster-b with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void showMoveBendpointFeedback(BendpointRequest bendpointrequest) {
	Relation relation = (Relation) getHost().getModel();
	RelationEditPart editPart = (RelationEditPart) this.getHost();

	if (relation.getSource() == relation.getTarget()) {
		if (bendpointrequest.getIndex() != 1) {
			return;
		}
		Point point = bendpointrequest.getLocation();
		this.getConnection().translateToRelative(point);
		Bendpoint rate = this.getRate(point);
		rate.setRelative(true);

		float rateX = (100f - (rate.getX() / 2)) / 100;
		float rateY = (100f - (rate.getY() / 2)) / 100;

		ERTableEditPart tableEditPart = (ERTableEditPart) editPart
				.getSource();
		Rectangle bounds = tableEditPart.getFigure().getBounds();

		Rectangle rect = new Rectangle();
		rect.x = (int) (bounds.x + (bounds.width * rateX));
		rect.y = (int) (bounds.y + (bounds.height * rateY));
		rect.width = (int) (bounds.width * rate.getX() / 100);
		rect.height = (int) (bounds.height * rate.getY() / 100);

		relation.setSourceLocationp(100, (int) (100 * rateY));

		relation.setTargetLocationp((int) (100 * rateX), 100);

		LayerManager manager = (LayerManager) tableEditPart.getRoot();
		IFigure layer = manager.getLayer(LayerConstants.PRIMARY_LAYER);
		this.getFeedbackLayer().setBounds(layer.getBounds());

		List children = this.getFeedbackLayer().getChildren();
		children.clear();
		this.getFeedbackLayer().repaint();

		ZoomManager zoomManager = ((ScalableFreeformRootEditPart) this
				.getHost().getRoot()).getZoomManager();
		double zoom = zoomManager.getZoom();

		Polyline feedbackFigure = new Polyline();
		feedbackFigure.addPoint(new Point((int) (rect.x * zoom),
				(int) (rect.y * zoom)));
		feedbackFigure.addPoint(new Point((int) (rect.x * zoom),
				(int) ((rect.y + rect.height) * zoom)));
		feedbackFigure.addPoint(new Point(
				(int) ((rect.x + rect.width) * zoom),
				(int) ((rect.y + rect.height) * zoom)));
		feedbackFigure
				.addPoint(new Point((int) ((rect.x + rect.width) * zoom),
						(int) (rect.y * zoom)));
		feedbackFigure.addPoint(new Point((int) (rect.x * zoom),
				(int) (rect.y * zoom)));

		feedbackFigure.setLineStyle(SWT.LINE_DASH);

		feedbackFigure.translateToRelative(feedbackFigure.getLocation());

		this.addFeedback(feedbackFigure);

	} else {
		super.showMoveBendpointFeedback(bendpointrequest);
	}

}
 
Example #17
Source File: RelationBendpointEditPolicy.java    From ermasterr with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void showMoveBendpointFeedback(final BendpointRequest bendpointrequest) {
    final Relation relation = (Relation) getHost().getModel();
    final RelationEditPart editPart = (RelationEditPart) getHost();

    if (relation.getSource() == relation.getTarget()) {
        if (bendpointrequest.getIndex() != 1) {
            return;
        }
        final Point point = bendpointrequest.getLocation();
        getConnection().translateToRelative(point);
        final Bendpoint rate = getRate(point);
        rate.setRelative(true);

        final float rateX = (100f - (rate.getX() / 2)) / 100;
        final float rateY = (100f - (rate.getY() / 2)) / 100;

        final ERTableEditPart tableEditPart = (ERTableEditPart) editPart.getSource();
        final Rectangle bounds = tableEditPart.getFigure().getBounds();

        final Rectangle rect = new Rectangle();
        rect.x = (int) (bounds.x + (bounds.width * rateX));
        rect.y = (int) (bounds.y + (bounds.height * rateY));
        rect.width = bounds.width * rate.getX() / 100;
        rect.height = bounds.height * rate.getY() / 100;

        relation.setSourceLocationp(100, (int) (100 * rateY));

        relation.setTargetLocationp((int) (100 * rateX), 100);

        final LayerManager manager = (LayerManager) tableEditPart.getRoot();
        final IFigure layer = manager.getLayer(LayerConstants.PRIMARY_LAYER);
        getFeedbackLayer().setBounds(layer.getBounds());

        final List children = getFeedbackLayer().getChildren();
        children.clear();
        getFeedbackLayer().repaint();

        final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager();
        final double zoom = zoomManager.getZoom();

        final Polyline feedbackFigure = new Polyline();
        feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) (rect.y * zoom)));
        feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) ((rect.y + rect.height) * zoom)));
        feedbackFigure.addPoint(new Point((int) ((rect.x + rect.width) * zoom), (int) ((rect.y + rect.height) * zoom)));
        feedbackFigure.addPoint(new Point((int) ((rect.x + rect.width) * zoom), (int) (rect.y * zoom)));
        feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) (rect.y * zoom)));

        feedbackFigure.setLineStyle(SWT.LINE_DASH);

        feedbackFigure.translateToRelative(feedbackFigure.getLocation());

        addFeedback(feedbackFigure);

    } else {
        super.showMoveBendpointFeedback(bendpointrequest);
    }

}