org.eclipse.swt.events.MouseEvent Java Examples

The following examples show how to use org.eclipse.swt.events.MouseEvent. 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: MovablePanningSelectionTool.java    From erflute with Apache License 2.0 6 votes vote down vote up
@Override
public void mouseDown(MouseEvent e, EditPartViewer viewer) {
    if (viewer.getContents() instanceof AbstractModelEditPart) {
        // マウスポインタがクリックされた位置を記録する。コピーしたオブジェクトの貼り付け位置として使う、等。
        final AbstractModelEditPart editPart = (AbstractModelEditPart) viewer.getContents();
        final IERDiagram diagram = (IERDiagram) editPart.getModel();
        diagram.setMousePoint(new Point(e.x, e.y));
        editPart.getFigure().translateToRelative(diagram.getMousePoint());

        final ERFluteMultiPageEditor multiPageEditor = diagram.getEditor();
        final int QUICK_OUTLINE_OPEN_BUTTON = 2;
        if (e.button == QUICK_OUTLINE_OPEN_BUTTON && multiPageEditor != null) {
            final MainDiagramEditor mainDiagramEditor = (MainDiagramEditor) multiPageEditor.getActiveEditor();
            mainDiagramEditor.runERDiagramQuickOutlineAction();
        }
    }

    super.mouseDown(e, viewer);
}
 
Example #2
Source File: MouseEventMatcher.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public boolean matches(NatTable natTable, MouseEvent event, LabelStack regionLabels) {
	if (regionLabels == null) {
		return false;
	}

	boolean stateMaskMatches;
	if (stateMask != 0) {
		stateMaskMatches = (event.stateMask == stateMask) ? true : false;
	} else {
		stateMaskMatches = event.stateMask == 0;
	}

	boolean eventRegionMatches;
	if (this.regionName != null) {
		eventRegionMatches = regionLabels.hasLabel(regionName);
	} else {
		eventRegionMatches = true;
	}

	boolean buttonMatches = button == event.button;

	return stateMaskMatches && eventRegionMatches && buttonMatches;
}
 
Example #3
Source File: ERDiagramMultiPageEditor.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
private void addMouseListenerToTabFolder() {
    final CTabFolder tabFolder = (CTabFolder) getContainer();

    tabFolder.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(final MouseEvent mouseevent) {

            final Category category = getPageCategory(getActivePage());

            if (category != null) {
                final CategoryNameChangeDialog dialog = new CategoryNameChangeDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), category);

                if (dialog.open() == IDialogConstants.OK_ID) {
                    final ChangeCategoryNameCommand command = new ChangeCategoryNameCommand(diagram, category, dialog.getCategoryName());
                    execute(command);
                }
            }

            super.mouseDoubleClick(mouseevent);
        }
    });
}
 
Example #4
Source File: GeoMapViewer.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void mouseUp(MouseEvent e) {
	if (isSelecting()) {
		PointD lonLat = getLocationProvider().getLonLat(selection);
		int zoom = geoMap.getZoom();
		Point position = GeoMapUtil.computePosition(lonLat, zoom);
		Point newPosition = new Point(position.x + selectionOffset.x,
				position.y + selectionOffset.y);
		lonLat = GeoMapUtil.getLongitudeLatitude(newPosition, zoom);
		getLocationProvider().setLonLat(selection, lonLat.x, lonLat.y);
		reveal(selection, checkButtons(e, getPanCenterButtons()));
		selectionStart = null;
		selectionOffset = null;
	} else {
		super.mouseUp(e);
	}
}
 
Example #5
Source File: BookmarkRulerColumn.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Called on drag selection.
 *
 * @param event the mouse event caught by the mouse move listener
 * @return <code>true</code> if scrolling happened, <code>false</code> otherwise
 */
private boolean autoScroll(MouseEvent event) {
    Rectangle area= fCanvas.getClientArea();

    if (event.y > area.height) {
        autoScroll(SWT.DOWN);
        return true;
    }

    if (event.y < 0) {
        autoScroll(SWT.UP);
        return true;
    }

    stopAutoScroll();
    return false;
}
 
Example #6
Source File: ChartComposite.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns a string for the tooltip.
 *
 * @param e  the mouse event.
 *
 * @return A tool tip or <code>null</code> if no tooltip is available.
 */
public String getToolTipText(org.eclipse.swt.events.MouseEvent e) {
    String result = null;
    if (this.info != null) {
        EntityCollection entities = this.info.getEntityCollection();
        if (entities != null) {
            Rectangle insets = getClientArea();
            ChartEntity entity = entities.getEntity(
                    (int) ((e.x - insets.x) / this.scaleX),
                    (int) ((e.y - insets.y) / this.scaleY));
            if (entity != null) {
                result = entity.getToolTipText();
            }
        }
    }
    return result;

}
 
Example #7
Source File: CommonLineNumberRulerColumn.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Called on drag selection.
 *
 * @param event the mouse event caught by the mouse move listener
 * @return <code>true</code> if scrolling happened, <code>false</code> otherwise
 */
private boolean autoScroll(MouseEvent event) {
	Rectangle area= fCanvas.getClientArea();

	if (event.y > area.height) {
		autoScroll(SWT.DOWN);
		return true;
	}

	if (event.y < 0) {
		autoScroll(SWT.UP);
		return true;
	}

	stopAutoScroll();
	return false;
}
 
Example #8
Source File: GenerericTreeViewer.java    From offspring with MIT License 6 votes vote down vote up
@Override
public void mouseDown(final MouseEvent event) {
  doubleClick = false;
  Display.getDefault().timerExec(Display.getDefault().getDoubleClickTime(),
      new Runnable() {

        @Override
        public void run() {
          if (!doubleClick) {
            Point pt = new Point(event.x, event.y);
            ViewerCell cell = getCell(pt);
            if (cell != null) {
              IGenericTableColumn column = getGenericTable().getColumns()[cell
                  .getColumnIndex()];
              if (column.getCellActivateHandler() != null) {
                column.getCellActivateHandler().activate(cell.getElement());
              }
            }
          }
        }
      });
}
 
Example #9
Source File: ComponentHierarchyMenu.java    From arx with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new instance
 * 
 * @param hierarchy
 * @param controller
 */
public ComponentHierarchyMenu(ComponentHierarchy hierarchy,
                              Controller controller) {
    
    // Init
    this.hierarchy = hierarchy;
    this.controller = controller;
    this.controller.addListener(ModelPart.MODEL, this);
    this.createMenu();

    // Listen
    this.hierarchy.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDown(final MouseEvent e) {
            if (e.button == 3) {
                onMouseDown(ComponentHierarchyMenu.this.hierarchy.getControl().toDisplay(e.x, e.y));
            }
        }
    });
}
 
Example #10
Source File: TmfEventsTable.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void mouseDoubleClick(final MouseEvent event) {
    if (event.button != 1) {
        return;
    }
    // Identify the selected row
    final Point point = new Point(event.x, event.y);
    final TableItem item = fTable.getItem(point);
    if (item != null) {
        final Rectangle imageBounds = item.getImageBounds(0);
        imageBounds.width = BOOKMARK_IMAGE.getBounds().width;
        if (imageBounds.contains(point)) {
            final Long rank = (Long) item.getData(Key.RANK);
            if (rank != null) {
                toggleBookmark(rank);
            }
        }
    }
}
 
Example #11
Source File: TimeRangeHistogram.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void mouseDown(MouseEvent event) {
    final long endTime = fDataModel.getEndTime();
    final long startTime = fDataModel.getStartTime();
    if (fScaledData != null && fDragState == DRAG_NONE && startTime < endTime) {
        if (event.button == 2 || (event.button == 1 && (event.stateMask & SWT.MODIFIER_MASK) == SWT.CTRL)) {
            fDragState = DRAG_RANGE;
            fDragButton = event.button;
            fStartPosition = event.x;
            long maxOffset = (long) ((startTime - fFullRangeStartTime) / fScaledData.fBucketDuration);
            long minOffset = (long) ((endTime - fFullRangeEndTime) / fScaledData.fBucketDuration);
            fMaxOffset = (int) Math.max(Integer.MIN_VALUE, Math.min(Integer.MAX_VALUE, maxOffset));
            fMinOffset = (int) Math.max(Integer.MIN_VALUE, Math.min(Integer.MAX_VALUE, minOffset));
            return;
        } else if (event.button == 3) {
            fDragState = DRAG_ZOOM;
            fDragButton = event.button;
            fRangeStartTime = getTimestamp(event.x);
            fRangeDuration = 0;
            fCanvas.redraw();
            return;
        }
    }
    super.mouseDown(event);
}
 
Example #12
Source File: CellSelectionDragMode.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public void mouseDown(NatTable natTable, MouseEvent event) {
	natTable.forceFocus();

	shiftMask = ((event.stateMask & SWT.SHIFT) == SWT.SHIFT);
	controlMask = ((event.stateMask & SWT.CONTROL) == SWT.CONTROL);

	fireSelectionCommand(natTable, natTable.getColumnPositionByX(event.x), natTable.getRowPositionByY(event.y), shiftMask, controlMask);
}
 
Example #13
Source File: DetailsView.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
private void setLink(CLabel label, IEventInvoker<IDetailsViewEventListener> invoker) {
	label.setCursor(SWTResourceManager.getCursor(SWT.CURSOR_HAND));
	label.addMouseListener(new MouseAdapter() {

		@Override
		public void mouseUp(MouseEvent e) {
			eventManager.invoke(invoker);
		}
		
	});
}
 
Example #14
Source File: LegendPageBar.java    From slr-toolkit with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void mouseUp(MouseEvent e) {
	
	if(e.getSource() == labelColorShow) {
		RGB rgb = PageSupport.openAndGetColor(this.getParent(), labelColorShow);
	}
	
}
 
Example #15
Source File: TimeGraphViewTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static void resetMousePosition(SWTBotTimeGraph timegraph, boolean inNs, MouseEvent mouseEvent) {
    Rectangle rect = timegraph.widget.getBounds();
    if (!inNs) {
        mouseEvent.x = rect.width - 1;
    } else {
        mouseEvent.x = 1;
    }
    mouseEvent.y = rect.height / 2 + rect.y;
    timegraph.widget.mouseMove(mouseEvent);
}
 
Example #16
Source File: ExpressionCollectionViewer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void createTableViewerComposite(final Composite parent,
        final TabbedPropertySheetWidgetFactory widgetFactory) {
    viewer = new TableViewer(parent, SWT.BORDER | SWT.FULL_SELECTION);
    viewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 70).create());
    viewer.getTable().setLinesVisible(true);
    viewer.getTable().setHeaderVisible(captions != null && !captions.isEmpty());

    provider = new ExpressionCollectionContentProvider();
    viewer.setContentProvider(provider);

    for (int i = 0; i < Math.max(minNbCol, getNbCols()); i++) {
        addColumnToViewer(i);
    }
    viewer.getTable().addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(final MouseEvent e) {
            if (minNbRow == 0 || getNbRows() < minNbRow) {
                final Point point = new Point(e.x, e.y);
                final TableItem item = viewer.getTable().getItem(point);
                int currentWidth = 0;
                int colIndex = 0;
                for (int i = 0; i < viewer.getTable().getColumns().length; i++) {
                    final TableColumn c = viewer.getTable().getColumns()[i];
                    if (point.x >= currentWidth && point.x < currentWidth + c.getWidth()) {
                        colIndex = i;
                        break;
                    }
                    currentWidth = currentWidth + c.getWidth();
                }
                if (item == null && fixedRow) { //When fixedRow is true, no add button is present so we need to keep this behavior
                    addRow(colIndex);
                }
            }
        }
    });

}
 
Example #17
Source File: TmfMouseDragProvider.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void mouseDown(MouseEvent e) {
    if ((getChartViewer().getWindowDuration() != 0) && ((e.button == 2) || (e.button == 1 && (e.stateMask & SWT.CTRL) != 0))) {
        fStartPosition = e.x;
        fIsUpdate = true;
    }
}
 
Example #18
Source File: TimeGraphMarkerAxis.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private String getHiddenCategoryForEvent(MouseEvent e, Rectangle bounds) {
    List<String> categories = getVisibleCategories();
    Rectangle rect = HIDE.getBounds();
    rect.x += bounds.x + EXPANDED.getBounds().width + HIDE_BORDER;
    rect.y += bounds.y + TOP_MARGIN + HIDE_BORDER;
    rect.width -= 2 * HIDE_BORDER;
    rect.height -= 2 * HIDE_BORDER;
    for (int i = 0; i < categories.size(); i++) {
        if (rect.contains(e.x, e.y)) {
            return categories.get(i);
        }
        rect.y += HEIGHT;
    }
    return null;
}
 
Example #19
Source File: CheckBoxCellEditor.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * As soon as the editor is activated, flip the current data value and commit it.<br/>
 * The repaint will pick up the new value and flip the image.
 */
@Override
protected Control activateCell(Composite parent, Object originalCanonicalValue, Character initialEditValue) {
	setCanonicalValue(originalCanonicalValue);

	checked = !checked;

	canvas = new Canvas(parent, SWT.NONE);

	canvas.addPaintListener(new PaintListener() {
		public void paintControl(PaintEvent paintEvent) {
			Rectangle bounds = canvas.getBounds();
			Rectangle rect = new Rectangle(0, 0, bounds.width, bounds.height);
			checkBoxCellPainter.paintIconImage(paintEvent.gc, rect, bounds.height / 2 - checkBoxCellPainter.getPreferredHeight(checked) / 2, checked);
		}

	});

	canvas.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseUp(MouseEvent e) {
			checked = !checked;
			canvas.redraw();
		}

	});

	commit(MoveDirectionEnum.NONE, false);

	return canvas;
}
 
Example #20
Source File: CameraHelper.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void mouseMove(final MouseEvent e) {
	if (camera != null) {
		camera.mouseMove(e);
	}

}
 
Example #21
Source File: TextFileImportWizardPage1.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void createControl( Composite parent ) {
  // create the composite to hold the widgets
  Composite composite = new Composite( parent, SWT.NONE );
  props.setLook( composite );

  FormLayout compLayout = new FormLayout();
  compLayout.marginHeight = Const.FORM_MARGIN;
  compLayout.marginWidth = Const.FORM_MARGIN;
  composite.setLayout( compLayout );

  MouseAdapter lsMouse = new MouseAdapter() {
    public void mouseDown( MouseEvent e ) {
      int s = getSize();
      // System.out.println("size = "+s);
      setPageComplete( s > 0 );
    }
  };

  wTable = new TableDraw( composite, props, this, fields );
  wTable.setRows( rows );
  props.setLook( wTable );
  wTable.setFields( fields );
  fdTable = new FormData();
  fdTable.left = new FormAttachment( 0, 0 );
  fdTable.right = new FormAttachment( 100, 0 );
  fdTable.top = new FormAttachment( 0, 0 );
  fdTable.bottom = new FormAttachment( 100, 0 );
  wTable.setLayoutData( fdTable );
  wTable.addMouseListener( lsMouse );

  // set the composite as the control for this page
  setControl( composite );
}
 
Example #22
Source File: UiBindingRegistry.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public IDragMode getDragMode(MouseEvent event) {
	LabelStack regionLabels = natTable.getRegionLabelsByXY(event.x, event.y);
	
    for (DragBinding dragBinding : dragBindings) {
        if (dragBinding.getMouseEventMatcher().matches(natTable, event, regionLabels)) {
            return dragBinding.getDragMode();
        }
    }
    
	return null;
}
 
Example #23
Source File: MovablePanningSelectionTool.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
@Override
public void mouseDown(MouseEvent e, EditPartViewer viewer) {
	if (viewer.getContents() instanceof ERDiagramEditPart) {
		ERDiagramEditPart editPart = (ERDiagramEditPart) viewer
				.getContents();
		ERDiagram diagram = (ERDiagram) editPart.getModel();

		diagram.mousePoint = new Point(e.x, e.y);

		editPart.getFigure().translateToRelative(diagram.mousePoint);
	}

	super.mouseDown(e, viewer);
}
 
Example #24
Source File: CustomPreviewTable.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void mouseDown( MouseEvent e )
{
	if ( e.button == 1 )
	{
		if ( e.widget instanceof Label )
		{
			bDragging = true;
			iDragStartXLocation = cnvCells.getDisplay( )
					.getCursorLocation( ).x;
			iResizingColumnIndex = ( (Integer) ( e.widget                                     ).getData( ) ).intValue( );
		}
	}
}
 
Example #25
Source File: SelectionDialog.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
private ItemPkg getCell(MouseEvent event, Table table) {
	ItemPkg result = null;
	TableItem item = table.getItem(new Point(event.x,event.y));

	if (item != null) {
		for (int i = 0; i < table.getColumnCount(); i++) {
			if (item.getBounds(i).contains(event.x, event.y)) {
				result = new ItemPkg(item,i);
				break;
			}
		}
	}
	return result;
}
 
Example #26
Source File: ControlListItem.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
private MouseAdapter doCreateMouseListener() {
	return new MouseAdapter() {
		@Override
		public void mouseDown(MouseEvent e) {
			if (indexListener != null) {
				if (e.count == 2) {
					indexListener.open();
				} else {
					indexListener.select();
				}
			}
		}
	};
}
 
Example #27
Source File: CellLabelMouseEventMatcher.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean matches(NatTable natTable, MouseEvent event, LabelStack regionLabels) {
	NatEventData eventData = NatEventData.createInstanceFromEvent(event);
	LabelStack customLabels = natTable.getConfigLabelsByPosition(eventData.getColumnPosition(), eventData.getRowPosition());

	return super.matches(natTable, event, regionLabels)	&& customLabels.getLabels().contains(labelToMatch);
}
 
Example #28
Source File: ColumnReorderDragMode.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public void mouseUp(NatTable natTable, MouseEvent event) {
	natTable.removeOverlayPainter(overlayPainter);
	if (dragFromGridColumnPosition >= 0 && dragToGridColumnPosition >= 0 && isValidCoordinate) {

		fireMoveCommand(natTable);

		if(CellEdgeEnum.RIGHT == moveDirection) {
			selectDragFocusColumn(natTable, event, dragToGridColumnPosition - 1);
		} else {
			selectDragFocusColumn(natTable, event, dragToGridColumnPosition);
		}
	}
}
 
Example #29
Source File: SwtEventHandler.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void mouseUp( MouseEvent e )
{
	// FILTER OUT ALL TRIGGERS FOR MOUSE UP/CLICK ONLY
	TriggerCondition[] tgArray = isLeftButton( e ) ? new TriggerCondition[]{
			TriggerCondition.ONMOUSEUP_LITERAL,
			TriggerCondition.ONCLICK_LITERAL,
			TriggerCondition.MOUSE_CLICK_LITERAL,
	}
			: new TriggerCondition[]{
				TriggerCondition.ONRIGHTCLICK_LITERAL
			};

	handleAction( tgArray, e );
}
 
Example #30
Source File: TimeGraphScale.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void mouseDoubleClick(MouseEvent e) {
    if (e.button == 1 && null != fTimeProvider && fTimeProvider.getTime0() != fTimeProvider.getTime1() && (e.stateMask & SWT.BUTTON_MASK) == 0) {
        fTimeProvider.resetStartFinishTime();
        fTime0bak = fTimeProvider.getTime0();
        fTime1bak = fTimeProvider.getTime1();
    }
}