Java Code Examples for org.eclipse.swt.graphics.Point#equals()

The following examples show how to use org.eclipse.swt.graphics.Point#equals() . 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: PipelineArgumentsTabTest.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
public void testScrollbar(PipelineArgumentsTab pipelineArgumentsTab) {
  Composite composite = pipelineArgumentsTab.internalComposite;
  assertNotNull(composite);
  Composite parent = pipelineArgumentsTab.internalComposite.getParent();
  if (parent instanceof ScrolledComposite) {
    pipelineArgumentsTab.handleLayoutChange();
    Point compositeSize = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    ScrolledComposite scrollComposite = (ScrolledComposite) parent;
    Point scrollSize = new Point(scrollComposite.getMinWidth(), scrollComposite.getMinHeight());
    if (compositeSize.equals(scrollSize)) {
      return;
    }
    fail("Scrollbar is not working");
  }
  fail("Did not find the Scroll composite");
}
 
Example 2
Source File: CellSelectionDragMode.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
public void mouseMove(NatTable natTable, MouseEvent event) {
	if (event.x > natTable.getWidth()) {
		return;
	}
	int selectedColumnPosition = natTable.getColumnPositionByX(event.x);
	int selectedRowPosition = natTable.getRowPositionByY(event.y);

	if (selectedColumnPosition > -1 && selectedRowPosition > -1) {
		Point dragInCellPosition = new Point(selectedColumnPosition, selectedRowPosition);
		if(lastDragInCellPosition == null || !dragInCellPosition.equals(lastDragInCellPosition)){
			lastDragInCellPosition = dragInCellPosition;

			fireSelectionCommand(natTable, selectedColumnPosition, selectedRowPosition, true, false);
		}
	}
}
 
Example 3
Source File: CellSelectionDragMode.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public void mouseMove(NatTable natTable, MouseEvent event) {
	if (event.x > natTable.getWidth()) {
		return;
	}
	int selectedColumnPosition = natTable.getColumnPositionByX(event.x);
	int selectedRowPosition = natTable.getRowPositionByY(event.y);

	if (selectedColumnPosition > -1 && selectedRowPosition > -1) {
		Point dragInCellPosition = new Point(selectedColumnPosition, selectedRowPosition);
		if(lastDragInCellPosition == null || !dragInCellPosition.equals(lastDragInCellPosition)){
			lastDragInCellPosition = dragInCellPosition;

			fireSelectionCommand(natTable, selectedColumnPosition, selectedRowPosition, true, false);
		}
	}
}
 
Example 4
Source File: ApplicationOverviewEditorPart.java    From codewind-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public void update(CodewindConnection conn, CodewindApplication app, boolean init) {
	if (form.isDisposed()) {
		return;
	}
	boolean changed = false;
	if (conn == null || !conn.isConnected() || app == null) {
		changed = !messageComp.getVisible();
		messageComp.setVisible(true);
		((GridData)messageComp.getLayoutData()).exclude = false;
		messageLabel.setText(conn == null || !conn.isConnected() ? Messages.AppOverviewEditorNoConnection : Messages.AppOverviewEditorNoApplication);
		sectionComp.setVisible(false);
		((GridData)sectionComp.getLayoutData()).exclude = true;
	} else {
		changed = messageComp.getVisible();
		messageComp.setVisible(false);
		((GridData)messageComp.getLayoutData()).exclude = true;
		sectionComp.setVisible(true);
		((GridData)sectionComp.getLayoutData()).exclude = false;
		projectInfoSection.update(app);
		projectStatusSection.update(app);
		projectLinkSection.update(app);
		appInfoSection.update(app);
	}

	Point currentSize = form.getBody().getSize();
	form.layout(true, true);
	Point newSize = form.getBody().computeSize(SWT.DEFAULT, SWT.DEFAULT);
	if (!newSize.equals(currentSize)) {
		changed = true;
	}
	
	if (init || changed) {
		form.reflow(true);
	}
}
 
Example 5
Source File: RenameRefactoringPopup.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected void updatePopupLocation() {
	packPopup();
	Point loc = computePopupLocation();

	if (loc != null && !loc.equals(popup.getLocation())) {
		popup.setLocation(loc);
	}
}
 
Example 6
Source File: RenameInformationPopup.java    From typescript.java with MIT License 5 votes vote down vote up
private void updatePopupLocation(boolean force) {
		if (! force && fSnapPosition == SNAP_POSITION_LOWER_RIGHT)
			return;

		packPopup();
		Point loc= computePopupLocation(fSnapPosition);
		if (loc != null && ! loc.equals(fPopup.getLocation())) {
			fPopup.setLocation(loc);
			// XXX workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=170774
//			fPopup.moveBelow(fEditor.getSite().getShell().getShells()[0]);
		}
	}
 
Example 7
Source File: SWTBotUtils.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Try to make the shell fully visible in the display. If the shell cannot
 * fit the display, it will be positioned so that top-left corner is at
 * <code>(0, 0)</code> in display-relative coordinates.
 *
 * @param shell
 *            the shell to make fully visible
 */
private static void makeShellFullyVisible(Shell shell) {
    Rectangle displayBounds = shell.getDisplay().getBounds();
    Point absCoord = shell.toDisplay(0, 0);
    Point shellSize = shell.getSize();

    Point newLocation = new Point(absCoord.x, absCoord.y);
    newLocation.x = Math.max(0, Math.min(absCoord.x, displayBounds.width - shellSize.x));
    newLocation.y = Math.max(0, Math.min(absCoord.y, displayBounds.height - shellSize.y));
    if (!newLocation.equals(absCoord)) {
        shell.setLocation(newLocation);
    }
}
 
Example 8
Source File: RenameInformationPopup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void updatePopupLocation(boolean force) {
		if (! force && fSnapPosition == SNAP_POSITION_LOWER_RIGHT)
			return;

		packPopup();
		Point loc= computePopupLocation(fSnapPosition);
		if (loc != null && ! loc.equals(fPopup.getLocation())) {
			fPopup.setLocation(loc);
			// XXX workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=170774
//			fPopup.moveBelow(fEditor.getSite().getShell().getShells()[0]);
		}
	}
 
Example 9
Source File: TextFieldNavigationHandler.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
void selectionChanged() {
	Point selection= getSelection();
	if (selection.equals(fLastSelection)) {
		// leave caret position
	} else if (selection.x == selection.y) { //empty range
		fCaretPosition= selection.x;
	} else if (fLastSelection.y == selection.y) {
		fCaretPosition= selection.x; //same end -> assume caret at start
	} else {
		fCaretPosition= selection.y;
	}
	fLastSelection= selection;
}
 
Example 10
Source File: SelectNextOccurrenceHandler.java    From eclipse-multicursor with Eclipse Public License 1.0 4 votes vote down vote up
private void startEditing(ISourceViewer viewer) throws ExecutionException {
	final Point selOffsetAndLen = viewer.getSelectedRange();
	final IDocument document = viewer.getDocument();

	try {
		final String searchText;
		final int candidateSearchOffset;
		final int selStart = CoordinatesUtil.fromOffsetAndLengthToStartAndEnd(selOffsetAndLen).x;
		if (selOffsetAndLen.y == 0) { // no characters selected
			final String documentText = document.get();
			final Point wordOffsetAndLen = TextUtil.findWordSurrounding(documentText, selStart);
			if (wordOffsetAndLen != null) {
				searchText = document.get(wordOffsetAndLen.x, wordOffsetAndLen.y);
				candidateSearchOffset = wordOffsetAndLen.x;
			} else {
				final IRegion selectedLine = document.getLineInformationOfOffset(selStart);
				searchText = document.get(selectedLine.getOffset(), selectedLine.getLength());
				candidateSearchOffset = selectedLine.getOffset();
			}
		} else {
			searchText = document.get(selOffsetAndLen.x, selOffsetAndLen.y);
			candidateSearchOffset = selOffsetAndLen.x;
		}

		final int searchOffset;
		final List<IRegion> selections;
		final Point startingSelection;

		final SelectInProgress currentState = getCurrentState();
		if (LinkedModeModel.getModel(document, 0) != null &&
				currentState != null
				&& selOffsetAndLen.equals(currentState.startingSelection)
				&& searchText.equals(currentState.searchText)) {
			startingSelection = currentState.startingSelection;
			selections = new ArrayList<IRegion>(currentState.existingSelections);
			searchOffset = currentState.nextOffset;
		} else {
			startingSelection = selOffsetAndLen;
			selections = new ArrayList<IRegion>();
			searchOffset = candidateSearchOffset;
		}

		final IRegion matchingRegion = new FindReplaceDocumentAdapter(document).find(searchOffset,
				searchText, true, true, false, false);
		if (matchingRegion != null) {
			selections.add(matchingRegion);

			if (selections.size() == 1) {
				// select the next occurrence too; only selecting the current cursor pos isn't useful
				final IRegion secondMatchingRegion = new FindReplaceDocumentAdapter(document).find(
						matchingRegion.getOffset() + matchingRegion.getLength(), searchText, true, true, false, false);
				if (secondMatchingRegion != null) {
					selections.add(secondMatchingRegion);
				}
			}

			if (selections.size() > 1) {
				final IRegion lastSelection = selections.get(selections.size() - 1);
				saveCurrentState(new SelectInProgress(startingSelection, searchText, selections,
						lastSelection.getOffset() + lastSelection.getLength()));

				startLinkedEdit(selections, viewer, selOffsetAndLen);
			}
		}
	} catch (BadLocationException e) {
		throw new ExecutionException("Editing failed", e);
	}
}