Package org.eclipse.swt.widgets

Examples of org.eclipse.swt.widgets.Tracker


        CTabItem dragItem = folder.getItem(folder.toControl(display.getCursorLocation()));
        if (dragItem == null)
          return;

        // open a tracker with current item's bounds
        t = new Tracker(folder, SWT.NONE);

        Rectangle[] rects = { dragItem.getBounds() };
        t.setRectangles(rects);

        t.addListener(SWT.Move, new Listener() {
View Full Code Here


    Shell shell = getShell();
    if (shell == null || shell.isDisposed()) {
      return;
    }

    Tracker tracker = new Tracker(shell.getDisplay(), style);
    tracker.setStippled(true);
    Rectangle[] r = new Rectangle[] { shell.getBounds() };
    tracker.setRectangles(r);

    // Ignore any deactivate events caused by opening the tracker.
    // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=120656
    boolean oldListenToDeactivate = listenToDeactivate;
    listenToDeactivate = false;
    if (tracker.open()) {
      if (!shell.isDisposed()) {
        shell.setBounds(tracker.getRectangles()[0]);
      }
    }
    tracker.dispose();
    listenToDeactivate = oldListenToDeactivate;
  }
View Full Code Here

          }
      });

    _drawArea.addMouseListener(new MouseListener()
      {
        Tracker tracker = new Tracker(_drawArea, SWT.RESIZE);

        @Override
        public void mouseDoubleClick(MouseEvent e)
          {
          // Change Selection and open the selected object.
          _lstCell.clearSelection();

          // Retrieve CanvasCell in absolute coordinates
          CanvasCell cc = _lstCell.find(e.x - _origin.x, e.y - _origin.y);

          if (cc != null)
            {
            cc.isSelected = true;
            _drawArea.redraw();

            openIconAction.run();
            }

          _drawArea.redraw();
          }

        @Override
        public void mouseDown(MouseEvent e)
          {
          switch (e.button)
            {
            case 1:
              if ((e.stateMask & (SWT.SHIFT | SWT.CTRL)) == 0)
                {
                _lstCell.clearSelection();
                _drawArea.redraw();
                }

              tracker.setRectangles(new Rectangle[]
                {
                  new Rectangle(e.x, e.y, 16, 16),
                });

              boolean rb = tracker.open();

              if (rb)
                {
                Rectangle[] tabrect = tracker.getRectangles();

                Rectangle rSelect = tabrect[0];

                // Retrieve absolute coordinates
                rSelect.x -= _origin.x;
View Full Code Here

          }
      });

    _drawArea.addMouseListener(new MouseListener()
      {
        Tracker tracker = new Tracker(_drawArea, SWT.RESIZE);

        @Override
        public void mouseDoubleClick(MouseEvent e)
          {
          // Change Selection and open the selected object.
          _lstCell.clearSelection();

          // Retrieve CanvasCell in absolute coordinates
          CanvasCell cc = _lstCell.find(e.x - _origin.x, e.y - _origin.y);

          if (cc != null)
            {
            cc.isSelected = true;
            _drawArea.redraw();

            openIconAction.run();
            }

          _drawArea.redraw();
          }

        @Override
        public void mouseDown(MouseEvent e)
          {
          switch (e.button)
            {
            case 1:
              if ((e.stateMask & (SWT.SHIFT | SWT.CTRL)) == 0)
                {
                _lstCell.clearSelection();
                _drawArea.redraw();
                }

              tracker.setRectangles(new Rectangle[]
                {
                  new Rectangle(e.x, e.y, 16, 16),
                });

              boolean rb = tracker.open();

              if (rb)
                {
                Rectangle[] tabrect = tracker.getRectangles();

                Rectangle rSelect = tabrect[0];

                // Retrieve absolute coordinates
                rSelect.x -= _origin.x;
View Full Code Here

          }
      });

    _drawArea.addMouseListener(new MouseListener()
      {
        Tracker tracker = new Tracker(_drawArea, SWT.RESIZE);

        @Override
        public void mouseDoubleClick(MouseEvent e)
          {
          // Change Selection and open the selected object.
          _lstCell.clearSelection();

          // Retrieve CanvasCell in absolute coordinates
          CanvasCell cc = _lstCell.find(e.x - _origin.x, e.y - _origin.y);

          if (cc != null)
            {
            cc.isSelected = true;
            _drawArea.redraw();

            openIconAction.run();
            }

          _drawArea.redraw();
          }

        @Override
        public void mouseDown(MouseEvent e)
          {
          switch (e.button)
            {
            case 1:
              if ((e.stateMask & (SWT.SHIFT | SWT.CTRL)) == 0)
                {
                _lstCell.clearSelection();
                _drawArea.redraw();
                }

              tracker.setRectangles(new Rectangle[]
                {
                  new Rectangle(e.x, e.y, 16, 16),
                });

              boolean rb = tracker.open();

              if (rb)
                {
                Rectangle[] tabrect = tracker.getRectangles();

                Rectangle rSelect = tabrect[0];

                // Retrieve absolute coordinates
                rSelect.x -= _origin.x;
View Full Code Here

                break;
              default:
                break;
            }
           
            tracker = new Tracker(border.getDisplay(), style);
            tracker.setStippled(true);
            tracker.setRectangles(new Rectangle[] { shell.getBounds() });
            tracker.addDisposeListener(this);
            tracker.open();
            tracker.dispose();
View Full Code Here

                    sourceBounds);
        }

        // Create a tracker.  This is just an XOR rect on the screen.
        // As it moves we notify the drag listeners.
        final Tracker tracker = new Tracker(display, SWT.NULL);
        tracker.setStippled(true);

        tracker.addListener(SWT.Move, new Listener() {
            public void handleEvent(final Event event) {
                display.syncExec(new Runnable() {
                    public void run() {
                      // Get the curslor location as a point
                        Point location = new Point(event.x, event.y);

                        // Select a drop target; use the global one by default
                      IDropTarget target = null;
                       
                        Control targetControl = display.getCursorControl();

                        // Get the drop target for this location
                        target = getDropTarget(targetControl,
                                draggedItem, location,
                                tracker.getRectangles()[0]);

                      // Set up the tracker feedback based on the target
                        Rectangle snapTarget = null;
                        if (target != null) {
                            snapTarget = target.getSnapRectangle();

                            tracker.setCursor(target.getCursor());
                        } else {
                            tracker.setCursor(DragCursors
                                    .getCursor(DragCursors.INVALID));
                        }

                        // If snapping then reset the tracker's rectangle based on the current drop target
                        if (allowSnapping) {
                            if (snapTarget == null) {
                                snapTarget = new Rectangle(sourceBounds.x
                                        + location.x - initialLocation.x,
                                        sourceBounds.y + location.y
                                                - initialLocation.y,
                                        sourceBounds.width, sourceBounds.height);
                            }

                            // Try to prevent flicker: don't change the rectangles if they're already in
                            // the right location
                            Rectangle[] currentRectangles = tracker.getRectangles();

                            if (!(currentRectangles.length == 1 && currentRectangles[0]
                                    .equals(snapTarget))) {
                                tracker.setRectangles(new Rectangle[] { snapTarget });
                            }
                        }
                    }
                });
            }
        });

        // Setup...when the drag starts we might already be over a valid target, check this...
        // If there is a 'global' target then skip the check
        IDropTarget target = null;
        Control startControl = display.getCursorControl();
       
        if (startControl != null && allowSnapping) {
            target = getDropTarget(startControl,
                draggedItem, initialLocation,
                sourceBounds);
        }

        // Set up an initial tracker rectangle
        Rectangle startRect = sourceBounds;
        if (target != null) {
            Rectangle rect = target.getSnapRectangle();
           
            if (rect != null) {
                startRect = rect;
            }

            tracker.setCursor(target.getCursor());
        }
       
        if (startRect != null) {
            tracker.setRectangles(new Rectangle[] { Geometry.copy(startRect)});
        }

        // Tracking Loop...tracking is preformed on the 'SWT.Move' listener registered
        // against the tracker.
       
        // HACK:
        // Some control needs to capture the mouse during the drag or other
        // controls will interfere with the cursor
        Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
        if (shell != null) {
            shell.setCapture(true);
        }

        // Run tracker until mouse up occurs or escape key pressed.
        boolean trackingOk = tracker.open();

        // HACK:
        // Release the mouse now
        if (shell != null) {
            shell.setCapture(false);
        }

        // Done tracking...
       
        // Get the current drop target
        IDropTarget dropTarget = null;
        Point finalLocation = display.getCursorLocation();
        Control targetControl = display.getCursorControl();
        dropTarget = getDropTarget(targetControl, draggedItem,
                finalLocation, tracker.getRectangles()[0]);

        // Cleanup...
        tracker.dispose();
       
        // if we're going to perform a 'drop' then delay the issuing of the 'finished'
        // callback until after it's done...
        if (trackingOk) {
          return dropTarget;
View Full Code Here

    @Override
    public void handleEvent(Event event)
    {
        if (event.button == 1 && event.stateMask == SWT.MOD1)
        {
            Tracker tracker = new Tracker(chart.getPlotArea(), SWT.RESIZE);
            tracker.setRectangles(new Rectangle[] { new Rectangle(event.x, event.y, 0, 0) });
            if (tracker.open())
            {
                Rectangle rectangle = tracker.getRectangles()[0];

                try
                {
                    for (IAxis axis : chart.getAxisSet().getXAxes())
                    {
                        Range range = new Range(axis.getDataCoordinate(rectangle.x), axis.getDataCoordinate(rectangle.x
                                        + rectangle.width));
                        axis.setRange(range);
                    }

                    for (IAxis axis : chart.getAxisSet().getYAxes())
                    {
                        Range range = new Range(axis.getDataCoordinate(rectangle.y), axis.getDataCoordinate(rectangle.y
                                        + rectangle.height));
                        axis.setRange(range);
                    }
                }
                catch (IllegalArgumentException ignore)
                {
                    PortfolioPlugin.log(ignore);
                }
                chart.redraw();
            }
            tracker.dispose();
        }
    }
View Full Code Here

    Shell shell = getShell();
    if (shell == null || shell.isDisposed()) {
      return;
    }

    Tracker tracker = new Tracker(shell.getDisplay(), style);
    tracker.setStippled(true);
    Rectangle[] r = new Rectangle[] { shell.getBounds() };
    tracker.setRectangles(r);

    // Ignore any deactivate events caused by opening the tracker.
    // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=120656
    boolean oldListenToDeactivate = listenToDeactivate;
    listenToDeactivate = false;
    if (tracker.open()) {
      if (shell != null && !shell.isDisposed()) {
        shell.setBounds(tracker.getRectangles()[0]);
      }
    }
    listenToDeactivate = oldListenToDeactivate;
  }
View Full Code Here

   * Perform the requested tracker action (resize or move).
   *
   * @param style The track style (resize or move).
   */
  private void performTrackerAction(int style) {
    Tracker tracker = new Tracker(dialogShell.getDisplay(), style);
    tracker.setStippled(true);
    Rectangle[] r = new Rectangle[] { dialogShell.getBounds() };
    tracker.setRectangles(r);
    isDeactivateListenerActive = false;
    if (tracker.open()) {
      dialogShell.setBounds(tracker.getRectangles()[0]);
      isDeactivateListenerActive = true;
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.swt.widgets.Tracker

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.