Java Code Examples for org.eclipse.swt.graphics.Point

The following are top voted examples for showing how to use org.eclipse.swt.graphics.Point. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: applecommander   File: TextFilterAdapter.java   Source Code and License 6 votes vote down vote up
protected void createTextWidget(String textContents) {
	StyledText styledText = new StyledText(getComposite(), SWT.NONE);
	styledText.setText(textContents);
	styledText.setFont(getCourierFont());
	styledText.setEditable(false);
	//styledText.setWordWrap(true);		// seems to throw size out-of-whack
	Point size = styledText.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
	getComposite().setContent(styledText);
	getComposite().setExpandHorizontal(true);
	getComposite().setExpandVertical(true);
	getComposite().setMinWidth(size.x);
	getComposite().setMinHeight(size.y);
	getComposite().getContent().addListener(SWT.KeyUp, getToolbarCommandHandler());

	getToolItem().setSelection(true);		
	setContentTypeAdapter(new StyledTextAdapter(styledText, getFileEntry().getFilename()));
}
 
Example 2
Project: xcalendar   File: XCalendarTimeWidget.java   Source Code and License 6 votes vote down vote up
/**
 * 
 */
@Override
public void render(XCalendarFrame frame) {
	// Background
	final GC gc = frame.getGc();
	final boolean hovered = mouse.isEntered();
	final XCalendarModel model = popup.getModel();
	final XCalendarTheme theme = model.getTheme();
	final XVirtualCalendar calendar = model.getCalendar();
	int x = bounds.x, y = bounds.y, w = bounds.width, h = bounds.height;
	gc.setBackground(theme.getBackground(true, false, false, hovered));
	gc.fillRoundRectangle(x, y, w, h, theme.getArc(), theme.getArc());

	// Foreground
	String t1 = this.type.text(theme, calendar);
	gc.setForeground(theme.getForeground(true, false, true));
	gc.setFont(theme.getBold()); final Point s1 = extent(gc, t1);
	gc.drawText(t1, x + 1 + ((w - s1.x) >> 1), y + 1 + ((h - s1.y) >> 1));
	
	if(this.type == XCalendarTime.HOUR || this.type == XCalendarTime.MINUTE) {
		String t2 = ":"; Point s2 = extent(gc, t2);
		gc.setBackground(theme.getBackground(true, false, false, false));
		gc.drawText(t2, x + 1 + w + (getMargin().x >> 2), y + 1 + ((h - s2.y) >> 1));
	}
}
 
Example 3
Project: eclipse-batch-editor   File: AbstractFilterableTreeQuickDialog.java   Source Code and License 6 votes vote down vote up
@Override
protected Point getInitialSize() {
	IDialogSettings dialogSettings = getDialogSettings();
	if (dialogSettings == null) {
		/* no dialog settings available, so fall back to min settings */
		return new Point(minWidth, minHeight);
	}
	Point point = super.getInitialSize();
	if (point.x < minWidth) {
		point.x = minWidth;
	}
	if (point.y < minHeight) {
		point.y = minHeight;
	}
	return point;
}
 
Example 4
Project: tap17-muggl-javaee   File: ArrayEntriesWindow.java   Source Code and License 6 votes vote down vote up
/**
 * Create the Shell, setting up any elements that are not set up by the main Composite.
 * @param arrayModificationHandler The ArrayModificationHandler the holds the represented array.
 * @param myDimension The dimension of a probably multidimensional array this Window represents.
 * @param dimensionsIndexes Dimension indexes of the higher-level dimensions the array represented might be a part of.
 */
private void createShell(ArrayModificationHandler arrayModificationHandler, int myDimension, int[] dimensionsIndexes) {
	this.shell = new Shell(this.display, SWT.BORDER | SWT.CLOSE | SWT.TITLE | SWT.MIN);
	this.shell.setText(Globals.WINDOWS_TITLE + Globals.WINDOWS_TITLE_CONNECTOR + "Array Entries");
	this.shell.setLayout(new FillLayout(SWT.VERTICAL));

	// Initialize the composite.
	new ArrayEntriesComposite(this, this.shell, this.display, SWT.NONE, arrayModificationHandler, myDimension, dimensionsIndexes);

	// Compute the needed size.
	Point point = this.shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
	point.x += 2;
	point.y += 2;
	int[] posXY = StaticGuiSupport.getCenteredPosition(point.x, point.y, this.parent.getShell());
	this.shell.setBounds(posXY[0], posXY[1], point.x, point.y);
}
 
Example 5
Project: neoscada   File: TitleRenderer.java   Source Code and License 6 votes vote down vote up
@Override
public void render ( final Graphics g, final Rectangle clientRectangle )
{
    if ( this.title == null || this.title.isEmpty () )
    {
        return;
    }

    g.setClipping ( this.rect );

    g.setFont ( createFont ( g.getResourceManager () ) );

    final Point size = g.textExtent ( this.title );

    final int x = this.rect.width / 2 - size.x / 2;
    final int y = this.padding;
    g.drawText ( this.title, this.rect.x + x, this.rect.y + y, null );

    g.setClipping ( clientRectangle );
}
 
Example 6
Project: tap17-muggl-javaee   File: ClassInspectionWindow.java   Source Code and License 6 votes vote down vote up
/**
 * Create the Shell, setting up any elements that are not set up by the main Composite.
 * @param parentShell The parent windows' Shell.
 * @param className The name of the class to inspect.
 * @param classFile The ClassFile to inspect.
 */
private void createShell(Shell parentShell, String className, ClassFile classFile) {
	this.shell = new Shell(this.display, SWT.BORDER | SWT.CLOSE | SWT.TITLE | SWT.MIN);
	this.shell.setText(Globals.WINDOWS_TITLE + Globals.WINDOWS_TITLE_CONNECTOR + "Class File Inspection");
	this.shell.setLayout(new FillLayout(SWT.VERTICAL));

	// No need to read it later, so it is not assigned to a variable.
	new ClassInspectionComposite(this, this.shell, this.display, SWT.NONE, className, classFile);

	// Compute the needed size.
	Point point = this.shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
	point.x += 2;
	point.y += 2;
	int[] posXY = StaticGuiSupport.getCenteredPosition(point.x, point.y, parentShell);
	this.shell.setBounds(posXY[0], posXY[1], point.x, point.y);
}
 
Example 7
Project: SWET   File: BreadcrumbItem.java   Source Code and License 6 votes vote down vote up
private Point computeSizeOfTextAndImages() {
	int width = 0, height = 0;
	final boolean textISNotEmpty = getText() != null && !getText().equals("");

	if (textISNotEmpty) {
		final GC gc = new GC(this.parentBreadcrumb);
		gc.setFont(this.parentBreadcrumb.getFont());
		final Point extent = gc.stringExtent(getText());
		gc.dispose();
		width += extent.x;
		height = extent.y;
	}

	final Point imageSize = computeMaxWidthAndHeightForImages(getImage(),
			this.selectionImage, this.disabledImage);

	if (imageSize.x != -1) {
		width += imageSize.x;
		height = Math.max(imageSize.y, height);
		if (textISNotEmpty) {
			width += MARGIN * 2;
		}
	}
	width += MARGIN;
	return new Point(width, height);
}
 
Example 8
Project: xcalendar   File: XCalendarClearWidget.java   Source Code and License 6 votes vote down vote up
/**
 * Render
 */
@Override
public void render(XCalendarFrame frame) {
	// Background
	final GC gc = frame.getGc();
	final XCalendarModel model = popup.getModel();
	final XCalendarTheme theme = model.getTheme();
	final boolean hovered = this.mouse.isEntered();
	int x = bounds.x, y = bounds.y, w = bounds.width, h = bounds.height;
	gc.setBackground(theme.getBackground(true, false, false, hovered));
	gc.fillRoundRectangle(x, y, w, h, theme.getArc(), theme.getArc());

	// Foreground
	String text = trash_o;
	gc.setForeground(theme.getToolBarBackground(false));
	gc.setFont(Fonts.getAwesomeFont()); final Point size = extent(gc, text);
	gc.drawText(text, x + 1 + ((w - size.x) >> 1), y + 1 + ((h - size.y) >> 1));
}
 
Example 9
Project: tap17-muggl-javaee   File: OptionsWindow.java   Source Code and License 6 votes vote down vote up
/**
 * Create the Shell, setting up any elements that are not set up by the main Composite.
 * @param parentShell The parent windows' Shell.
 * @param classLoader The system MugglClassLoader.
 */
private void createShell(Shell parentShell, MugglClassLoader classLoader) {
	this.shell = new Shell(this.display, SWT.BORDER | SWT.CLOSE | SWT.TITLE | SWT.MIN);
	this.shell.setText(Globals.WINDOWS_TITLE + Globals.WINDOWS_TITLE_CONNECTOR + "Options");
	this.shell.setLayout(new FillLayout(SWT.VERTICAL));
	
	final Image small = new Image(shell.getDisplay(),
	        OptionsWindow.class.getResourceAsStream("/images/tray_small.png"));
	final Image large = new Image(shell.getDisplay(),
			OptionsWindow.class.getResourceAsStream("/images/tray_large.png"));
	this.shell.setImages(new Image[] { small, large });
	
	// No need to read it later, so it is not assigned to a variable.
	new OptionsComposite(this, this.shell, SWT.NONE, classLoader);

	// Compute the needed size.
	Point point = this.shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
	point.x += 2;
	point.y += 2;
	int[] posXY = StaticGuiSupport.getCenteredPosition(point.x, point.y, parentShell);
	this.shell.setBounds(posXY[0], posXY[1], point.x, point.y);
}
 
Example 10
Project: AppleCommander   File: DiskMapTab.java   Source Code and License 6 votes vote down vote up
/**
 * Handle paint requests for vertical ruler.
 */
protected void paintVerticalRuler(PaintEvent event) {
	// FIXME - not i18n safe!!
	String label = (disk.getBitmapLabels()[0] + "s").toUpperCase(); //$NON-NLS-1$
	if (disk.getBitmapLabels().length == 2) {
		label = (disk.getBitmapLabels()[1] + "s").toUpperCase(); //$NON-NLS-1$
	}
	StringBuffer buf = new StringBuffer();
	for (int i=0; i<label.length(); i++) {
		if (i>0) buf.append("\n"); //$NON-NLS-1$
		buf.append(label.charAt(i));
	}
	label = buf.toString();
	Canvas canvas = (Canvas) event.widget;
	Rectangle area = canvas.getClientArea();
	event.gc.drawLine(area.x + area.width/2, area.y, area.x + area.width/2, area.y + area.height);
	Point size = event.gc.textExtent(label);
	event.gc.drawText(label, area.x + area.width/2 - size.x/2, area.y + area.height/2 - size.y/2);
}
 
Example 11
Project: Hydrograph   File: DebugDataViewer.java   Source Code and License 6 votes vote down vote up
private MouseWheelListener createMouseWheelScroller(final ScrolledComposite scrollable) {
	return new MouseWheelListener() {

		@Override
		public void mouseScrolled(MouseEvent e) {
			Point currentScroll = scrollable.getOrigin();
			scrollable.setOrigin(currentScroll.x, currentScroll.y - (e.count * 5));
		}
	};
}
 
Example 12
Project: BiglyBT   File: TabbedEntry.java   Source Code and License 5 votes vote down vote up
@Override
public Image obfuscatedImage(Image image) {
	Rectangle bounds = swtItem == null ? null : swtItem.getBounds();
	if ( bounds != null ){

		boolean isActive = swtItem.getParent().getSelection() == swtItem;
		boolean isHeaderVisible = swtItem.isShowing();

		Point location = Utils.getLocationRelativeToShell(swtItem.getParent());

		bounds.x += location.x;
		bounds.y += location.y;

		Map<String, Object> map = new HashMap<>();
		map.put("image", image);
		map.put("obfuscateTitle", false);
		if (isActive) {
			triggerEvent(UISWTViewEvent.TYPE_OBFUSCATE, map);

			if (viewTitleInfo instanceof ObfuscateImage) {
				((ObfuscateImage) viewTitleInfo).obfuscatedImage(image);
			}
		}

		if (isHeaderVisible) {
 			if (viewTitleInfo instanceof ObfuscateTab) {
 				String header = ((ObfuscateTab) viewTitleInfo).getObfuscatedHeader();
 				if (header != null) {
 					UIDebugGenerator.obfuscateArea(image, bounds, header);
 				}
 			}

 			if (MapUtils.getMapBoolean(map, "obfuscateTitle", false)) {
 				UIDebugGenerator.obfuscateArea(image, bounds);
 			}
		}
	}

	return image;
}
 
Example 13
Project: Hydrograph   File: PaletteToolTip.java   Source Code and License 5 votes vote down vote up
/**
 * 
 * Returns tooltip bounds
 * 
 * @return org.eclipse.swt.graphics.Rectangle
 */
public Rectangle getToolTipBounds(){
	Point tooltipSize = getToolTipWidthHeight();
	Rectangle bounds = new Rectangle(0, 0, tooltipSize.x, tooltipSize.y);
	logger.debug("tooltip bounds=" + bounds);
	return bounds;
}
 
Example 14
Project: time4sys   File: SrmEditor.java   Source Code and License 5 votes vote down vote up
/**
 * If there is just one page in the multi-page editor part,
 * this hides the single tab at the bottom.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void hideTabs() {
	if (getPageCount() <= 1) {
		setPageText(0, "");
		if (getContainer() instanceof CTabFolder) {
			((CTabFolder)getContainer()).setTabHeight(1);
			Point point = getContainer().getSize();
			getContainer().setSize(point.x, point.y + 6);
		}
	}
}
 
Example 15
Project: eclipse-bash-editor   File: BashBracketsSupport.java   Source Code and License 5 votes vote down vote up
protected final IRegion getSignedSelection(ISourceViewer sourceViewer) {
	Point viewerSelection = sourceViewer.getSelectedRange();

	StyledText text = sourceViewer.getTextWidget();
	Point selection = text.getSelectionRange();
	if (text.getCaretOffset() == selection.x) {
		viewerSelection.x = viewerSelection.x + viewerSelection.y;
		viewerSelection.y = -viewerSelection.y;
	}

	return new Region(viewerSelection.x, viewerSelection.y);
}
 
Example 16
Project: BiglyBT   File: ShellFactory.java   Source Code and License 5 votes vote down vote up
@Override
public Point computeSize(int wHint, int hHint) {
	if (!inSetSize && wHint > 0 && hHint == SWT.DEFAULT) {
		inSetSize = true;
		return super.computeSize(Utils.adjustPXForDPI(wHint), hHint);
	}
	return super.computeSize(wHint, hHint);
}
 
Example 17
Project: time4sys   File: NfpEditor.java   Source Code and License 5 votes vote down vote up
/**
 * If there is more than one page in the multi-page editor part,
 * this shows the tabs at the bottom.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void showTabs() {
	if (getPageCount() > 1) {
		setPageText(0, getString("_UI_SelectionPage_label"));
		if (getContainer() instanceof CTabFolder) {
			((CTabFolder)getContainer()).setTabHeight(SWT.DEFAULT);
			Point point = getContainer().getSize();
			getContainer().setSize(point.x, point.y - 6);
		}
	}
}
 
Example 18
Project: xcalendar   File: XCalendarMonthWidget.java   Source Code and License 5 votes vote down vote up
/**
 * 
 */
@Override
public void render(XCalendarFrame frame) {
	// Background
	final GC gc = frame.getGc();
	final boolean hovered = mouse.isEntered();
	final XCalendarModel model = popup.getModel();
	final XCalendarTheme theme = model.getTheme();
	final XVirtualCalendar calendar = model.getCalendar();
	
	ZoneId zoneId = model.getZoneId();
	final int year = calendar.getYear();
	final int month = query(calendar, zoneId, col, row);
	final ZonedDateTime d2 = calendar.getTravelDateTime();
	final ZonedDateTime d1 = calendar.getCalendarDateTime();
	boolean selected = isSameYear(d1, d2) && month == d1.getMonthValue();
	this.enabled = isValidYearMonth(year, month, zoneId, calendar::isValid);
	int x = bounds.x, y = bounds.y, w = bounds.width, h = bounds.height;
	gc.setBackground(theme.getBackground(enabled, selected, false, hovered));
	gc.fillRoundRectangle(x, y, w, h, theme.getArc(), theme.getArc());
	
	// Foreground
	String text = theme.getMonthTheme()[row][col];
	gc.setForeground(theme.getForeground(enabled, selected, true));
	gc.setFont(theme.getFont()); final Point size = extent(gc, text);
	gc.drawText(text, x + 1 + ((w - size.x) >> 1), y + 1 + ((h - size.y) >> 1));
}
 
Example 19
Project: OCCI-Studio   File: PlatformEditor.java   Source Code and License 5 votes vote down vote up
/**
 * If there is just one page in the multi-page editor part,
 * this hides the single tab at the bottom.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void hideTabs() {
	if (getPageCount() <= 1) {
		setPageText(0, "");
		if (getContainer() instanceof CTabFolder) {
			((CTabFolder)getContainer()).setTabHeight(1);
			Point point = getContainer().getSize();
			getContainer().setSize(point.x, point.y + 6);
		}
	}
}
 
Example 20
Project: n4js   File: ShowHistoryAction.java   Source Code and License 5 votes vote down vote up
@Override
public void runWithEvent(Event event) {
	if (event.widget instanceof ToolItem) {
		final ToolItem toolItem = (ToolItem) event.widget;
		final Control control = toolItem.getParent();
		final Menu menu = getMenuCreator().getMenu(control);

		final Rectangle bounds = toolItem.getBounds();
		final Point topLeft = new Point(bounds.x, bounds.y + bounds.height);
		menu.setLocation(control.toDisplay(topLeft));
		menu.setVisible(true);
	}
}
 
Example 21
Project: n4js   File: N4JSApplicationWorkbenchWindowAdvisor.java   Source Code and License 5 votes vote down vote up
@Override
public void preWindowOpen() {
	super.preWindowOpen();
	final IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
	configurer.setInitialSize(new Point(1024, 768));
	configurer.setShowCoolBar(true);
	configurer.setShowStatusLine(true);
	configurer.setShowProgressIndicator(true);
	configurer.setShowPerspectiveBar(true);
	initN4Context();
	updateDefaultEditorMappingIfAbsent();
	reviewDisabledCategoriesFromAppModel();

}
 
Example 22
Project: gemoc-studio   File: FsmEditor.java   Source Code and License 5 votes vote down vote up
/**
 * If there is just one page in the multi-page editor part,
 * this hides the single tab at the bottom.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void hideTabs() {
	if (getPageCount() <= 1) {
		setPageText(0, "");
		if (getContainer() instanceof CTabFolder) {
			((CTabFolder)getContainer()).setTabHeight(1);
			Point point = getContainer().getSize();
			getContainer().setSize(point.x, point.y + 6);
		}
	}
}
 
Example 23
Project: convertigo-eclipse   File: KTable.java   Source Code and License 5 votes vote down vote up
/**
 * Returns true, if the given cell is selected. Works also in Row Selection
 * Mode.
 * 
 * @param col
 * @param row
 * @return boolean
 */
public boolean isCellSelected(int col, int row) {
  if (!m_MultiSelectMode) {
    if (m_RowSelectionMode)
      return (row == m_FocusRow);
    return (col == m_FocusCol && row == m_FocusRow);
  }

  if (m_RowSelectionMode)
    return (m_Selection.get(new Integer(row)) != null);
  else
    return (m_Selection.get(new Point(col, row)) != null);
}
 
Example 24
Project: convertigo-eclipse   File: SequenceComposite.java   Source Code and License 5 votes vote down vote up
protected void initialize() {
	GridData gridData = new org.eclipse.swt.layout.GridData();
	gridData.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
	gridData.grabExcessHorizontalSpace = true;
	gridData.grabExcessVerticalSpace = true;
	gridData.verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
	httpData = new Text(this, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
	httpData.setLayoutData(gridData);
	httpData.setText("");
	this.setLayout(new GridLayout());
	setSize(new Point(300, 200));
}
 
Example 25
Project: SWET   File: PopupDialog.java   Source Code and License 5 votes vote down vote up
/**
 * Saves the bounds of the shell in the appropriate dialog settings. The
 * bounds are recorded relative to the parent shell, if there is one, or
 * display coordinates if there is no parent shell. Subclasses typically
 * need not override this method, but may extend it (calling
 * <code>super.saveDialogBounds</code> if additional bounds information
 * should be stored. Clients may also call this method to persist the bounds
 * at times other than closing the dialog.
 * 
 * @param shell
 *            The shell whose bounds are to be stored
 */
protected void saveDialogBounds(Shell shell) {
	IDialogSettings settings = getDialogSettings();
	if (settings != null) {
		Point shellLocation = shell.getLocation();
		Point shellSize = shell.getSize();
		Shell parent = getParentShell();
		if (parent != null) {
			Point parentLocation = parent.getLocation();
			shellLocation.x -= parentLocation.x;
			shellLocation.y -= parentLocation.y;
		}
		String prefix = getClass().getName();
		if (persistSize) {
			settings.put(prefix + DIALOG_WIDTH, shellSize.x);
			settings.put(prefix + DIALOG_HEIGHT, shellSize.y);
		}
		if (persistLocation) {
			settings.put(prefix + DIALOG_ORIGIN_X, shellLocation.x);
			settings.put(prefix + DIALOG_ORIGIN_Y, shellLocation.y);
		}
		if (showPersistActions && showDialogMenu) {
			settings.put(getClass().getName() + DIALOG_USE_PERSISTED_SIZE,
					persistSize);
			settings.put(getClass().getName() + DIALOG_USE_PERSISTED_LOCATION,
					persistLocation);

		}
	}
}
 
Example 26
Project: Hydrograph   File: ComponentSearchUtility.java   Source Code and License 5 votes vote down vote up
/**
 * Calculate the cursor position on current editor
 * @return cursorRelativePosition
 */
private Point calculatePosition() {

	Point cursorAbsLocation = graphicControl.getDisplay().getCursorLocation();
	Point cursorRelativePosition = graphicControl.getDisplay().map(null, graphicControl, cursorAbsLocation);
	if (!isInsideGraphic(cursorRelativePosition, graphicControl.getSize())) {
		return null;
	}
	return cursorRelativePosition;
}
 
Example 27
Project: iTrace-Archive   File: ITrace.java   Source Code and License 5 votes vote down vote up
/**
 * Finds the control under the specified screen coordinates and calls its
 * gaze handler on the localized point. Returns the gaze response or null if
 * the gaze is not handled.
 */
private IGazeResponse handleGaze(int screenX, int screenY, Gaze gaze){
	Queue<Control[]> childrenQueue = new LinkedList<Control[]>();
	childrenQueue.add(rootShell.getChildren());
	Rectangle monitorBounds = rootShell.getMonitor().getBounds();
    while (!childrenQueue.isEmpty()) {
        for (Control child : childrenQueue.remove()) {
            Rectangle childScreenBounds = child.getBounds();
            Point screenPos = child.toDisplay(0, 0);
            childScreenBounds.x = screenPos.x - monitorBounds.x;
            childScreenBounds.y = screenPos.y - monitorBounds.y;
            if (childScreenBounds.contains(screenX, screenY)) {
                if (child instanceof Composite) {
                    Control[] nextChildren =
                            ((Composite) child).getChildren();
                    if (nextChildren.length > 0 && nextChildren[0] != null) {
                        childrenQueue.add(nextChildren);
                    }
                }
                IGazeHandler handler =
                        (IGazeHandler) child
                                .getData(HandlerBindManager.KEY_HANDLER);
                if (child.isVisible() && handler != null) {
                    return handler.handleGaze(screenX, screenY,
                            screenX - childScreenBounds.x, screenY
                                    - childScreenBounds.y, gaze);
                }
            }
        }
    }
    return null;
}
 
Example 28
Project: gemoc-studio-modeldebugging   File: DecoratingColumLabelProvider.java   Source Code and License 5 votes vote down vote up
@Override
public Point getToolTipShift(Object element) {
	final Point res;

	if (cellLabelProvider == null) {
		res = null;
	} else {
		res = cellLabelProvider.getToolTipShift(element);
	}

	return res;
}
 
Example 29
Project: gemoc-studio-modeldebugging   File: TracingannotationsEditor.java   Source Code and License 5 votes vote down vote up
/**
 * If there is just one page in the multi-page editor part,
 * this hides the single tab at the bottom.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void hideTabs() {
	if (getPageCount() <= 1) {
		setPageText(0, "");
		if (getContainer() instanceof CTabFolder) {
			((CTabFolder)getContainer()).setTabHeight(1);
			Point point = getContainer().getSize();
			getContainer().setSize(point.x, point.y + 6);
		}
	}
}
 
Example 30
Project: BiglyBT   File: SideBarToolTips.java   Source Code and License 5 votes vote down vote up
/**
 * @return
 *
 * @since 3.1.1.1
 */
private String getToolTip(Point mousePos_RelativeToItem) {
	MdiEntryVitalityImage[] vitalityImages = mdiEntry.getVitalityImages();
	for (int i = 0; i < vitalityImages.length; i++) {
		SideBarVitalityImageSWT vitalityImage = (SideBarVitalityImageSWT) vitalityImages[i];
		if (vitalityImage == null) {
			continue;
		}
		String indicatorToolTip = vitalityImage.getToolTip();
		if (indicatorToolTip == null || !vitalityImage.isVisible()) {
			continue;
		}
		Rectangle hitArea = vitalityImage.getHitArea();
		if (hitArea == null) {
			continue;
		}
		if (hitArea.contains(mousePos_RelativeToItem)) {
			return indicatorToolTip;
		}
	}

	if (mdiEntry.getViewTitleInfo() != null) {
		String tt = (String) mdiEntry.getViewTitleInfo().getTitleInfoProperty(ViewTitleInfo.TITLE_INDICATOR_TEXT_TOOLTIP);
		return tt;
	}

	return null;
}
 
Example 31
Project: Hydrograph   File: ComponentSearchUtility.java   Source Code and License 5 votes vote down vote up
private void createAssitTextBox(Point cursorRelativePosition) {
	assistText = new Text((Composite) graphicControl, SWT.BORDER);
	assistText.setLocation(cursorRelativePosition.x, cursorRelativePosition.y - assistText.getLineHeight());
	assistText.setSize(200, assistText.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
	assistText.setTextLimit(51);
	assistText.setFocus();
}
 
Example 32
Project: xcalendar   File: XCalendarMonthWidget.java   Source Code and License 5 votes vote down vote up
/**
 * 
 */
@Override
public Pair<Point> locate(int x, int y, int w, int m) {
	int unit = w / 4;
	if(col == 3) { x = m; y += unit; } else { x += unit; }
	return new Pair<>(new Point(unit, unit), new Point(x, y));
}
 
Example 33
Project: Hydrograph   File: CommentBoxFigure.java   Source Code and License 5 votes vote down vote up
/**
 * 
 * Computes location of comment box figure relative to workbench
 * 
 * @param figureMouseLocation
 * @return
 */
private Point getFigureLocationOnWorkbench(Point figureMouseLocation) {

	int subtractFromMouseX, addToMouseY;
	java.awt.Point workbenchAWTMouseLocation = MouseInfo.getPointerInfo().getLocation();
	Point workbenchMouseLocation = new Point(workbenchAWTMouseLocation.x, workbenchAWTMouseLocation.y);

	subtractFromMouseX = figureMouseLocation.x - getBounds().x;
	addToMouseY = getBounds().y - figureMouseLocation.y;

	return new org.eclipse.swt.graphics.Point((workbenchMouseLocation.x - subtractFromMouseX),
			(workbenchMouseLocation.y + addToMouseY));
}
 
Example 34
Project: time4sys   File: TraceEditor.java   Source Code and License 5 votes vote down vote up
/**
 * If there is just one page in the multi-page editor part,
 * this hides the single tab at the bottom.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void hideTabs() {
	if (getPageCount() <= 1) {
		setPageText(0, "");
		if (getContainer() instanceof CTabFolder) {
			((CTabFolder)getContainer()).setTabHeight(1);
			Point point = getContainer().getSize();
			getContainer().setSize(point.x, point.y + 6);
		}
	}
}
 
Example 35
Project: pmTrans   File: FindReplaceDialog.java   Source Code and License 5 votes vote down vote up
private boolean replace() {
	Point x = text.getSelection();
	if (!text.getSelectionText().isEmpty()) {
		text.replaceTextRange(text.getSelection().x, text.getSelection().y - text.getSelection().x,
				replaceText.getText());
		text.setSelection(x.x + replaceText.getText().length());
		return true;
	}
	return false;
}
 
Example 36
Project: time4sys   File: GrmEditor.java   Source Code and License 5 votes vote down vote up
/**
 * If there is just one page in the multi-page editor part,
 * this hides the single tab at the bottom.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void hideTabs() {
	if (getPageCount() <= 1) {
		setPageText(0, "");
		if (getContainer() instanceof CTabFolder) {
			((CTabFolder)getContainer()).setTabHeight(1);
			Point point = getContainer().getSize();
			getContainer().setSize(point.x, point.y + 6);
		}
	}
}
 
Example 37
Project: time4sys   File: DesignEditor.java   Source Code and License 5 votes vote down vote up
/**
 * If there is just one page in the multi-page editor part,
 * this hides the single tab at the bottom.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void hideTabs() {
	if (getPageCount() <= 1) {
		setPageText(0, "");
		if (getContainer() instanceof CTabFolder) {
			((CTabFolder)getContainer()).setTabHeight(1);
			Point point = getContainer().getSize();
			getContainer().setSize(point.x, point.y + 6);
		}
	}
}
 
Example 38
Project: gemoc-studio   File: GexpressionsEditor.java   Source Code and License 5 votes vote down vote up
/**
 * If there is more than one page in the multi-page editor part,
 * this shows the tabs at the bottom.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void showTabs() {
	if (getPageCount() > 1) {
		setPageText(0, getString("_UI_SelectionPage_label"));
		if (getContainer() instanceof CTabFolder) {
			((CTabFolder)getContainer()).setTabHeight(SWT.DEFAULT);
			Point point = getContainer().getSize();
			getContainer().setSize(point.x, point.y - 6);
		}
	}
}
 
Example 39
Project: iTrace-Archive   File: TokenHighlighter.java   Source Code and License 5 votes vote down vote up
public TokenHighlighter(StyledText styledText, boolean show, ProjectionViewer projviewer){
	this.styledText = styledText;
	this.projviewer = projviewer;
	this.styledText.addPaintListener(this);
	this.show = show;
	this.numberOfPoints = 1;
	this.points = new Point[numberOfPoints];
	this.pointIndex = 0;
	this.nulls = 0;
	this.eventBroker = PlatformUI.getWorkbench().getService(IEventBroker.class);
	this.eventBroker.subscribe("iTrace/newstresponse", this);
	//this.gazeQueue = Activator.getDefault().gazeTransport.createClient();
	//System.out.println("gazeQueue");
}
 
Example 40
Project: neoscada   File: DetailViewEditor.java   Source Code and License 5 votes vote down vote up
/**
 * If there is just one page in the multi-page editor part,
 * this hides the single tab at the bottom.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void hideTabs ()
{
    if ( getPageCount () <= 1 )
    {
        setPageText ( 0, "" ); //$NON-NLS-1$
        if ( getContainer () instanceof CTabFolder )
        {
            ( (CTabFolder)getContainer () ).setTabHeight ( 1 );
            Point point = getContainer ().getSize ();
            getContainer ().setSize ( point.x, point.y + 6 );
        }
    }
}
 
Example 41
Project: time4sys   File: LibraryEditor.java   Source Code and License 5 votes vote down vote up
/**
 * If there is more than one page in the multi-page editor part,
 * this shows the tabs at the bottom.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void showTabs() {
	if (getPageCount() > 1) {
		setPageText(0, getString("_UI_SelectionPage_label"));
		if (getContainer() instanceof CTabFolder) {
			((CTabFolder)getContainer()).setTabHeight(SWT.DEFAULT);
			Point point = getContainer().getSize();
			getContainer().setSize(point.x, point.y - 6);
		}
	}
}
 
Example 42
Project: Hydrograph   File: DebugDataViewer.java   Source Code and License 5 votes vote down vote up
private Point getCellId(Point mouseLocation,TableViewer tableViewer){
	ViewerCell cell = tableViewer.getCell(mouseLocation);
	if(cell==null){
		return null;
	}
	int columnIndex = cell.getColumnIndex();				
	int rowIndex = tableViewer.getTable().indexOf((TableItem)cell.getItem())  ;
	return new Point(rowIndex, columnIndex);
}
 
Example 43
Project: xcalendar   File: XCalendarSelectTimeWidget.java   Source Code and License 5 votes vote down vote up
/**
 * 
 */
@Override
public Pair<Point> locate(int x, int y, int w, int m) {
	XCalendarModel model = popup.getModel();
	boolean time = model.isDateTime(), nullable = model.isNullable();
	int u = w / 7; int c = 1 + (time ? 1 : 0) + (nullable ? 1 : 0);
	if (!nullable) {
		return new Pair<>(new Point(w / c, u), new Point(m, y + u));
	} else {
		return new Pair<>(new Point(w / c, u), new Point(x + w / c, y));
	}
}
 
Example 44
Project: xcalendar   File: XCalendarDecrWidget.java   Source Code and License 5 votes vote down vote up
/**
 * 
 */
@Override
public Pair<Point> locate(int x, int y, int w, int m) {
	int unit = w / 3;
	if(type == SECOND) { x = m; y += unit; } else x += unit;
	return new Pair<>(new Point(unit, unit), new Point(x, y));
}
 
Example 45
Project: tap17-muggl-javaee   File: StepByStepExecutionWindow.java   Source Code and License 5 votes vote down vote up
/**
 * Create the Shell, setting up any elements that are not set up by the main Composite.
 * @param parentShell The parent windows' Shell.
 * @param classLoader The system MugglClassLoader.
 * @param classFile The classFile the initial Method belongs to.
 * @param method The initial Method.
 * @return true, if the shell could be setup properly, false otherwise.
 */
private boolean createShell(Shell parentShell, MugglClassLoader classLoader, ClassFile classFile, Method method) {
	this.shell = new Shell(this.display, SWT.BORDER | SWT.CLOSE | SWT.TITLE | SWT.MIN);
	this.shell.setText(Globals.WINDOWS_TITLE + Globals.WINDOWS_TITLE_CONNECTOR + "Step by Step Execution");
	this.shell.setLayout(new FillLayout(SWT.VERTICAL));
	try {
		// Compute and set the needed size. As there might be a MessageBox displayed, this has to be done now!
		Point point = this.shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
		point.x += 2;
		point.y += 2;
		int[] posXY = StaticGuiSupport.getCenteredPosition(point.x, point.y, parentShell);
		this.shell.setBounds(posXY[0], posXY[1], point.x, point.y);

		// Show the composite.
		this.stepByStepExecutionComposite = new StepByStepExecutionComposite(this, this.shell, this.display, SWT.NONE, classLoader, classFile, method);

		// Compute and set the needed size.
		point = this.shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
		point.x += 2;
		point.y += 2;
		posXY = StaticGuiSupport.getCenteredPosition(point.x, point.y, parentShell);
		this.shell.setBounds(posXY[0], posXY[1], point.x, point.y);
		return true;
	} catch (GUIException e) {
		// Only one (user-caused) exception will not be displayed for the user. In all other cases generate a message box to inform him what has happened.
		if (!e.getMessage().contains("Do not show this window!")) {
			StaticGuiSupport.showMessageBox(parentShell, "Error", "The step by step execution window could not be loaded.\n\nThe root cause is:\n" + e.getMessage(), SWT.OK | SWT.ICON_ERROR);
		}
		doExit();
		return false;
	}
}
 
Example 46
Project: neoscada   File: OsgiEditor.java   Source Code and License 5 votes vote down vote up
/**
 * If there is more than one page in the multi-page editor part,
 * this shows the tabs at the bottom.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void showTabs ()
{
    if ( getPageCount () > 1 )
    {
        setPageText ( 0, getString ( "_UI_SelectionPage_label" ) ); //$NON-NLS-1$
        if ( getContainer () instanceof CTabFolder )
        {
            ( (CTabFolder)getContainer () ).setTabHeight ( SWT.DEFAULT );
            Point point = getContainer ().getSize ();
            getContainer ().setSize ( point.x, point.y - 6 );
        }
    }
}
 
Example 47
Project: neoscada   File: WorldEditor.java   Source Code and License 5 votes vote down vote up
/**
 * If there is just one page in the multi-page editor part,
 * this hides the single tab at the bottom.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void hideTabs ()
{
    if ( getPageCount () <= 1 )
    {
        setPageText ( 0, "" ); //$NON-NLS-1$
        if ( getContainer () instanceof CTabFolder )
        {
            ( (CTabFolder)getContainer () ).setTabHeight ( 1 );
            Point point = getContainer ().getSize ();
            getContainer ().setSize ( point.x, point.y + 6 );
        }
    }
}
 
Example 48
Project: SWET   File: BreadcrumbItem.java   Source Code and License 5 votes vote down vote up
private Point computeMaxWidthAndHeightForImages(final Image... images) {
	final Point imageSize = new Point(-1, -1);
	for (final Image image : images) {
		if (image == null) {
			continue;
		}
		final Rectangle imageBounds = image.getBounds();
		imageSize.x = Math.max(imageBounds.width, imageSize.x);
		imageSize.y = Math.max(imageBounds.height, imageSize.y);
	}
	return imageSize;
}
 
Example 49
Project: neoscada   File: RecipeEditor.java   Source Code and License 5 votes vote down vote up
/**
 * If there is just one page in the multi-page editor part,
 * this hides the single tab at the bottom.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void hideTabs ()
{
    if ( getPageCount () <= 1 )
    {
        setPageText ( 0, "" ); //$NON-NLS-1$
        if ( getContainer () instanceof CTabFolder )
        {
            ( (CTabFolder)getContainer () ).setTabHeight ( 1 );
            Point point = getContainer ().getSize ();
            getContainer ().setSize ( point.x, point.y + 6 );
        }
    }
}
 
Example 50
Project: neoscada   File: InfrastructureEditor.java   Source Code and License 5 votes vote down vote up
/**
 * If there is more than one page in the multi-page editor part,
 * this shows the tabs at the bottom.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void showTabs ()
{
    if ( getPageCount () > 1 )
    {
        setPageText ( 0, getString ( "_UI_SelectionPage_label" ) ); //$NON-NLS-1$
        if ( getContainer () instanceof CTabFolder )
        {
            ( (CTabFolder)getContainer () ).setTabHeight ( SWT.DEFAULT );
            Point point = getContainer ().getSize ();
            getContainer ().setSize ( point.x, point.y - 6 );
        }
    }
}
 
Example 51
Project: convertigo-eclipse   File: CouchVariablesDialog.java   Source Code and License 5 votes vote down vote up
@Override
public void configureShell(Shell newShell) {
	super.configureShell(newShell);
	newShell.setText("Parameters availables");
	newShell.setSize(nWidth, nHeight);

	int nLeft = 0;
	int nTop = 0;

	Display display = newShell.getDisplay();

	Point pt = display.getCursorLocation();
	Monitor[] monitors = display.getMonitors();

	for (int i = 0; i < monitors.length; i++) {
		if (monitors[i].getBounds().contains(pt)) {
			Rectangle rect = monitors[i].getClientArea();

			if (rect.x < 0)
				nLeft = ((rect.width - nWidth) / 2) + rect.x;
			else
				nLeft = (rect.width - nWidth) / 2;

			if (rect.y < 0)
				nTop = ((rect.height - nHeight) / 2) + rect.y;
			else
				nTop = (rect.height - nHeight) / 2;

			break;
		}
	}

	newShell.setBounds(nLeft, nTop, nWidth, nHeight);
}
 
Example 52
Project: neoscada   File: SecurityEditor.java   Source Code and License 5 votes vote down vote up
/**
 * If there is more than one page in the multi-page editor part,
 * this shows the tabs at the bottom.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void showTabs ()
{
    if ( getPageCount () > 1 )
    {
        setPageText ( 0, getString ( "_UI_SelectionPage_label" ) ); //$NON-NLS-1$
        if ( getContainer () instanceof CTabFolder )
        {
            ( (CTabFolder)getContainer () ).setTabHeight ( SWT.DEFAULT );
            Point point = getContainer ().getSize ();
            getContainer ().setSize ( point.x, point.y - 6 );
        }
    }
}
 
Example 53
Project: xcalendar   File: XCalendarMinuteWidget.java   Source Code and License 5 votes vote down vote up
/**
 * 
 */
@Override
public Pair<Point> locate(int x, int y, int w, int m) {
	int unit = w / 4; int height = unit + unit / 10;
	if(col == 3) { x = m; y += height; } else { x += unit; }
	return new Pair<>(new Point(unit, height), new Point(x, y));
}
 
Example 54
Project: Hydrograph   File: HydrographInstallationDialog.java   Source Code and License 5 votes vote down vote up
protected void setButtonLayoutData(FontMetrics metrics, Control button,
		boolean visible) {
	GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
	int widthHint = Dialog.convertHorizontalDLUsToPixels(metrics,
			IDialogConstants.BUTTON_WIDTH);
	Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
	data.widthHint = Math.max(widthHint, minSize.x);
	data.exclude = !visible;
	button.setLayoutData(data);
}
 
Example 55
Project: neoscada   File: ItemEditor.java   Source Code and License 5 votes vote down vote up
/**
 * If there is more than one page in the multi-page editor part,
 * this shows the tabs at the bottom.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void showTabs ()
{
    if ( getPageCount () > 1 )
    {
        setPageText ( 0, getString ( "_UI_SelectionPage_label" ) ); //$NON-NLS-1$
        if ( getContainer () instanceof CTabFolder )
        {
            ( (CTabFolder)getContainer () ).setTabHeight ( SWT.DEFAULT );
            Point point = getContainer ().getSize ();
            getContainer ().setSize ( point.x, point.y - 6 );
        }
    }
}
 
Example 56
Project: neoscada   File: ConfigurationEditor.java   Source Code and License 5 votes vote down vote up
/**
 * If there is just one page in the multi-page editor part,
 * this hides the single tab at the bottom.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void hideTabs ()
{
    if ( getPageCount () <= 1 )
    {
        setPageText ( 0, "" ); //$NON-NLS-1$
        if ( getContainer () instanceof CTabFolder )
        {
            ( (CTabFolder)getContainer () ).setTabHeight ( 1 );
            Point point = getContainer ().getSize ();
            getContainer ().setSize ( point.x, point.y + 6 );
        }
    }
}
 
Example 57
Project: time4sys   File: MappingEditor.java   Source Code and License 5 votes vote down vote up
/**
 * If there is more than one page in the multi-page editor part,
 * this shows the tabs at the bottom.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void showTabs() {
	if (getPageCount() > 1) {
		setPageText(0, getString("_UI_SelectionPage_label"));
		if (getContainer() instanceof CTabFolder) {
			((CTabFolder)getContainer()).setTabHeight(SWT.DEFAULT);
			Point point = getContainer().getSize();
			getContainer().setSize(point.x, point.y - 6);
		}
	}
}
 
Example 58
Project: convertigo-eclipse   File: ArrayOrNullEditor.java   Source Code and License 5 votes vote down vote up
public void layout(Composite editor, boolean force) {
	Rectangle bounds = editor.getClientArea();
	Point buttonOpenSize = buttonOpenCtrl.computeSize(SWT.DEFAULT, SWT.DEFAULT, force);
       Point buttonNullSize = buttonNullCtrl.computeSize(SWT.DEFAULT, SWT.DEFAULT, force);
       if (labelCtrl != null) {
       	labelCtrl.setBounds(0, 0, bounds.width - (buttonOpenSize.x + buttonNullSize.x), bounds.height);
       }
       buttonOpenCtrl.setBounds(bounds.width - (buttonOpenSize.x + buttonNullSize.x), 0, buttonOpenSize.x, bounds.height);
       buttonNullCtrl.setBounds(bounds.width - buttonNullSize.x, 0, buttonNullSize.x, bounds.height);
}
 
Example 59
Project: JavaFX-FrameRateMeter   File: OldFXCanvas.java   Source Code and License 5 votes vote down vote up
private void sendMoveEventToFX() {
    if ((stagePeer == null) /*|| !isShowing()*/) {
        return;
    }
    Rectangle rect = getClientArea();
    Point los = toDisplay(rect.x, rect.y);
    stagePeer.setLocation(los.x, los.y);
}
 
Example 60
Project: xcalendar   File: AbstractXCalendarWidget.java   Source Code and License 5 votes vote down vote up
/**
 * 
 */
public AbstractXCalendarWidget(XCalendar popup) {
	this.popup = popup;
	this.disposed = false;
	this.margin = new Point(1, 1);
	this.bounds = new Rectangle(0, 0, 0, 0);
	this.mouse = new XCalendarMouseTracker();
}