Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[gef-dev] Help! If drag and drop outside the pane, the scrollbar doesn't show up

Hello,

I run the following code in Editor (extends
MultiPageEditorPart), two rectangles and connection
can display correctly on the panel, but if drag and
drop any rectangle outside the pane, the scrollbar
doesn't show up. Any help?

Thanks in advance!

Michael 

 
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_composites[0] = new Composite(getContainer(),
SWT.NONE);
LightweightSystem lws = new LightweightSystem();

		FigureCanvas fc = new FigureCanvas(_composites[0],
lws);
		
		GridData gridData0 =
			new GridData(
				GridData.FILL_BOTH
					| GridData.GRAB_HORIZONTAL
					| GridData.GRAB_VERTICAL);
		gridData0.horizontalSpan =
GridData.HORIZONTAL_ALIGN_FILL;
		gridData0.verticalSpan = GridData.VERTICAL_ALIGN_FILL;
		fc.setLayoutData(gridData0);
		fc.setBackground(ColorConstants.listBackground);

		Figure panel = new Figure();
		fc.setContents(panel);

		ScrollPane scrollpane = new ScrollPane();
		scrollpane.setBounds(new Rectangle(0, 0, 500, 500));
		

		final Figure view = new Figure();
		view.setLayoutManager(new XYLayout());
		
		scrollpane.setScrollBarVisibility(ScrollPane.ALWAYS);
		scrollpane.setContents(view);
		ScrollBar sb = scrollpane.getVerticalScrollBar();
		
		RectangleFigure node1 = new RectangleFigure(),
		node2 = new RectangleFigure();
		node1.setBackgroundColor(ColorConstants.red);
		node2.setBackgroundColor(ColorConstants.blue);
		node2.setLocation(new Point(600, 600));
		PolylineConnection conn = new PolylineConnection();
		conn.setSourceAnchor(new ChopboxAnchor(node1));
		conn.setTargetAnchor(new ChopboxAnchor(node2));
		conn.setTargetDecoration(new PolygonDecoration());

		Label label = new Label("Midpoint");
		label.setOpaque(true);
		label.setBackgroundColor(ColorConstants.buttonLightest);
		label.setBorder(new LineBorder());
		conn.add(label, new MidpointLocator(conn, 0));
		new Dragger(node1);
		new Dragger(node2);
		view.add(node1);
		view.add(node2);
		view.add(conn);

		panel.add(scrollpane);
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
static class Dragger extends MouseMotionListener.Stub
implements MouseListener {
      public Dragger(IFigure figure){
            figure.addMouseMotionListener(this);
            figure.addMouseListener(this);
      }
      Point last;
      public void mouseReleased(MouseEvent e){}
      public void mouseClicked(MouseEvent e){}
      public void mouseDoubleClicked(MouseEvent e){}
      public void mousePressed(MouseEvent e){
            last = e.getLocation();
      }
      public void mouseDragged(MouseEvent e){
            Point p = e.getLocation();
            Dimension delta = p.getDifference(last);
            last = p;
            Figure f = ((Figure)e.getSource());
           
f.setBounds(f.getBounds().getTranslated(delta.width,
delta.height));
      }
};


Back to the top