List of usage examples for org.eclipse.jface.util Util isWindows
public static boolean isWindows()
From source file:au.gov.ga.earthsci.common.ui.util.URLDropAdapter.java
License:Apache License
/** * Determine whether the drop target data is valid. On some platforms this * cannot be detected, in which which case we return true. * //from w ww.j av a2s . c o m * @param event * the drop target event * @return <code>true</code> if data is valid, (or can not be determined), * <code>false</code> otherwise. */ protected boolean dropTargetDataIsValid(DropTargetEvent event) { if (Util.isWindows()) { return URLTransfer.getInstance().nativeToJava(event.currentDataType) != null; } return true; }
From source file:com.google.dart.tools.deploy.DartIDEApplication.java
License:Open Source License
private void setWorkspaceLocation() { Location workspaceLocation = Platform.getInstanceLocation(); File userHomeDir = new File(System.getProperty("user.home")); URL workspaceUrl;/*w ww .j a v a 2s . com*/ try { if (Util.isMac()) { workspaceUrl = new URL("file", null, System.getProperty("user.home") + "/Library/Application Support/DartEditor"); } else if (Util.isWindows()) { File workspaceDir = new File(userHomeDir, "DartEditor"); workspaceUrl = workspaceDir.toURI().toURL(); } else { File workspaceDir = new File(userHomeDir, ".dartEditor"); workspaceUrl = workspaceDir.toURI().toURL(); } workspaceLocation.set(workspaceUrl, true); } catch (IllegalStateException e) { // This generally happens in a runtime workbench, when the application has not been launched // with -data @noDefault. workspaceLocation.set() cannot be called twice. //Activator.logError(e); } catch (IOException e) { Activator.logError(e); } }
From source file:com.google.dart.tools.ui.omni.OmniBoxPopup.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); boolean isWin32 = Util.isWindows(); GridLayoutFactory.fillDefaults().extendedMargins(isWin32 ? 0 : 3, 3, 2, 2).applyTo(composite); Composite tableComposite = new Composite(composite, SWT.NONE); GridDataFactory.fillDefaults().grab(true, true).applyTo(tableComposite); TableColumnLayout tableColumnLayout = new TableColumnLayout(); tableComposite.setLayout(tableColumnLayout); table = new Table(tableComposite, SWT.SINGLE | SWT.FULL_SELECTION); textLayout = new TextLayout(table.getDisplay()); textLayout.setOrientation(getDefaultOrientation()); Font boldFont = resourceManager .createFont(FontDescriptor.createFrom(JFaceResources.getDialogFont()).setStyle(SWT.BOLD)); textLayout.setFont(table.getFont()); textLayout.setText(OmniBoxMessages.OmniBox_Providers); int maxProviderWidth = (int) (textLayout.getBounds().width * 1.1); textLayout.setFont(boldFont);//from ww w .ja v a 2 s. c o m for (int i = 0; i < providers.length; i++) { OmniProposalProvider provider = providers[i]; textLayout.setText(provider.getName()); int width = (int) (textLayout.getBounds().width * 1.1); if (width > maxProviderWidth) { maxProviderWidth = width; } } //TODO (pquitslund): just a placeholder column for now tableColumnLayout.setColumnData(new TableColumn(table, SWT.NONE), new ColumnWeightData(0, 3 /* maxProviderWidth) */)); tableColumnLayout.setColumnData(new TableColumn(table, SWT.NONE), new ColumnWeightData(100, 100)); //TODO (pquitslund): and with this goes the ability to resize... // table.getShell().addControlListener(new ControlAdapter() { // @Override // public void controlResized(ControlEvent e) { // if (!showAllMatches) { // if (!resized) { // resized = true; // e.display.timerExec(100, new Runnable() { // @Override // public void run() { // if (getShell() != null && !getShell().isDisposed()) { // refresh(getFilterText()); // } // resized = false; // } // // }); // } // } // } // }); /* * Since the control is unfocused, we need to hijack paint events and draw our own selections. */ final Color selectionColor = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION); table.addListener(SWT.EraseItem, new Listener() { @Override public void handleEvent(Event event) { event.detail &= ~SWT.HOT; if ((event.detail & SWT.SELECTED) == 0) { return; /* item not selected */ } Widget item = event.item; if (item instanceof TableItem) { Object data = ((TableItem) item).getData(); if (data instanceof OmniEntry) { if (((OmniEntry) data).element instanceof HeaderElement) { event.detail &= ~SWT.SELECTED; return; } } } int clientWidth = table.getClientArea().width; GC gc = event.gc; Color oldBackground = gc.getBackground(); gc.setBackground(selectionColor); gc.fillRectangle(new Rectangle(0, event.y, clientWidth, event.height)); gc.setBackground(oldBackground); event.detail &= ~SWT.SELECTED; } }); table.addKeyListener(getKeyAdapter()); table.addKeyListener(new KeyListener() { @Override public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.ARROW_UP && table.getSelectionIndex() == 0) { setFilterFocus(); } else if (e.character == SWT.ESC) { close(); } } @Override public void keyReleased(KeyEvent e) { // do nothing } }); table.addMouseListener(new MouseAdapter() { @Override public void mouseUp(MouseEvent e) { if (table.getSelectionCount() < 1) { return; } if (e.button != 1) { return; } if (table.equals(e.getSource())) { Object o = table.getItem(new Point(e.x, e.y)); TableItem selection = table.getSelection()[0]; if (selection.equals(o)) { handleSelection(); } } } }); table.addMouseMoveListener(new MouseMoveListener() { TableItem lastItem = null; @Override public void mouseMove(MouseEvent e) { if (table.equals(e.getSource())) { Object o = table.getItem(new Point(e.x, e.y)); if (lastItem == null ^ o == null) { table.setCursor(o == null ? null : table.getDisplay().getSystemCursor(SWT.CURSOR_HAND)); } if (o instanceof TableItem) { if (!o.equals(lastItem)) { lastItem = (TableItem) o; table.setSelection(new TableItem[] { lastItem }); } } else if (o == null) { lastItem = null; } } } }); table.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { handleSelection(); } @Override public void widgetSelected(SelectionEvent e) { if (Util.isMac()) { handleSelection(); } } }); final TextStyle boldStyle; if (PlatformUI.getPreferenceStore().getBoolean(IWorkbenchPreferenceConstants.USE_COLORED_LABELS)) { boldStyle = new TextStyle(boldFont, null, null); // italicsFont = resourceManager.createFont(FontDescriptor.createFrom( // table.getFont()).setStyle(SWT.ITALIC)); } else { boldStyle = null; } final TextStyle grayStyle = new TextStyle(table.getFont(), OmniBoxColors.SEARCH_ENTRY_ITEM_TEXT, null); Listener listener = new Listener() { @Override public void handleEvent(Event event) { OmniEntry entry = (OmniEntry) event.item.getData(); if (entry != null) { switch (event.type) { case SWT.MeasureItem: entry.measure(event, textLayout, resourceManager, boldStyle); break; case SWT.PaintItem: entry.paint(event, textLayout, resourceManager, boldStyle, grayStyle); break; case SWT.EraseItem: entry.erase(event); break; } } } }; table.addListener(SWT.MeasureItem, listener); table.addListener(SWT.EraseItem, listener); table.addListener(SWT.PaintItem, listener); //In GTK linux, the table is hungry for focus and steals it on updates //When the table has focus it grabs key events that are intended for the //search entry box; to make things right, we need to punt focus back //to the search box if (Util.isLinux()) { table.addFocusListener(new FocusListener() { @Override public void focusGained(FocusEvent e) { Display.getDefault().syncExec(new Runnable() { @Override public void run() { //punt focus back to the text box getFocusControl().setFocus(); } }); } @Override public void focusLost(FocusEvent e) { } }); } return composite; }
From source file:com.google.dart.tools.update.core.internal.UpdateUtils.java
License:Open Source License
@SuppressWarnings("static-access") private static OS getOS() { if (Util.isMac()) { return OS.OSX; }//ww w .j ava 2 s . co m if (Util.isLinux()) { return OS.LINUX; } if (Util.isWindows()) { return OS.WIN; } return OS.UNKNOWN; }
From source file:com.googlecode.goclipse.core.launch.GoLaunchConfigurationDelegate.java
License:Open Source License
protected IPath concertSourcePathToExecutablePath(ILaunchConfiguration configuration, IPath programRelativePath) throws CoreException { IProject prj = getProject(configuration); if (Environment.INSTANCE.isCmdFile(programRelativePath)) { IPath binRel = Environment.INSTANCE.getBinOutputFolder(prj); IPath exeBase = binRel;//from w w w .j a va 2s .co m String cmdName = LaunchUtil.getCmdName(programRelativePath); IPath executablePath = LaunchUtil.getExecutablePath(cmdName, prj); String executableName = executablePath.lastSegment(); //BM: I don't know what difference it makes these two alternatives: if (!Util.isWindows()) { executablePath = Path.fromOSString(".").append(executableName); } else { executablePath = Path.fromOSString(executableName); } programRelativePath = exeBase.append(executablePath); } return programRelativePath; }
From source file:com.mobilesorcery.sdk.internal.OSTester.java
License:Open Source License
@Override public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { try {/*w ww . j a v a 2 s .com*/ String os = System.getProperty("os.name"); String arg = (String) args[0]; if (OS_REGEXP_PROP.equals(property)) { Pattern p = Pattern.compile(arg); return p.matcher(os).matches(); } else if (OS_FAMILY_PROP.equals(property)) { if (WIN.equals(arg)) { return Util.isWindows(); } else if (MAC.equals(arg)) { return Util.isMac(); } else if (LINUX.equals(arg)) { return Util.isLinux(); } } } catch (Exception e) { CoreMoSyncPlugin.getDefault().log(e); } return false; }
From source file:com.rcpcompany.uibindings.extests.uiAttributes.UIAttributeImageDecorationTest.java
License:Open Source License
@Parameters public static Collection<Object[]> data() { final List<Object[]> filtered = new ArrayList<Object[]>(); final List<Object[]> c = Arrays.asList(new Object[][] { /*// ww w.ja v a 2 s . c o m * widgetClass, sizes (Point), outside, xLeft, xRight, yTop, yCenter, yBottom, * borderWidth, isEnabled */ // Text { Text.class, null, false, 0, 0, 0, 0, 0, 0, true }, { Text.class, null, true, 0, 0, 0, 0, 0, 0, Util.isMac() }, { Text.class, null, true, 6, -6, 1, 0, -1, 0, Util.isWindows() }, // Combo /* * INNER on Windows: does not seem to work! */ { Combo.class, null, false, 1, -21, 2, -1, -5, 0, Util.isMac() }, { Combo.class, null, true, 0, 0, 2, -1, -5, 0, Util.isMac() }, { Combo.class, null, true, 0, 0, 0, 0, 0, 0, Util.isWindows() }, // CCombo /* * INNER NOT POSSIBLE due to the way the inner controls are protected, so we cannot * add a paint listener */ // { CCombo.class, null, false, 0, 0, 0, 0, 0, 0, true }, { CCombo.class, null, true, 0, 0, 0, -1, -2, 0, Util.isMac() }, { CCombo.class, null, true, 2, 2, 1, 0, -2, 0, Util.isWindows() }, // StyledText { StyledText.class, null, false, 0, -3, 0, -1, -2, 0, Util.isMac() }, { StyledText.class, null, false, 0, 0, 0, 0, 0, 0, Util.isWindows() }, { StyledText.class, null, true, 0, 0, 0, -1, -2, 0, Util.isMac() }, { StyledText.class, null, true, 2, -2, 1, 0, -1, 0, Util.isWindows() }, // Button { Button.class, null, false, 14, -14, 5, -2, -9, 0, Util.isMac() }, { Button.class, null, false, 4, -4, 2, -1, -5, 0, Util.isWindows() }, { Button.class, null, true, 5, -5, 5, -2, -9, 0, Util.isMac() }, { Button.class, null, true, 0, 0, 3, -1, -6, 0, Util.isWindows() }, // Composite (small) { Composite.class, new Point(100, 30), false, 0, 0, 0, 0, 0, 0, Util.isMac() }, { Composite.class, new Point(100, 30), false, 0, -1, 0, 0, 0, 0, Util.isWindows() }, { Composite.class, new Point(100, 30), true, 0, 4, 0, 1, 2, 0, Util.isMac() }, { Composite.class, new Point(100, 30), true, 2, 10, 1, 3, 5, 0, Util.isWindows() }, // Composite (big) { Composite.class, new Point(100, 50), false, 0, 0, 0, -15, -30, 0, Util.isMac() }, { Composite.class, new Point(100, 50), false, 0, -1, 0, -15, -30, 0, Util.isWindows() }, { Composite.class, new Point(100, 50), true, 0, 4, 0, -14, -28, 0, Util.isMac() }, { Composite.class, new Point(100, 50), true, 2, 10, 1, -12, -25, 0, Util.isWindows() }, // Table /* * INSIDE: does not make sense */ { Table.class, new Point(100, 50), true, 0, 19, 0, -17, -33, 0, Util.isMac() }, { Table.class, new Point(100, 50), true, 2, 27, 1, -12, -25, 0, Util.isWindows() }, // Tree /* * INSIDE: does not make sense */ { Tree.class, new Point(100, 50), true, 0, 19, 0, -17, -33, 0, Util.isMac() }, { Tree.class, new Point(100, 50), true, 2, 27, -21, -34, -47, 0, Util.isWindows() }, }); for (final Object[] e : c) { if (e[9] == Boolean.FALSE) { continue; } final Class<?> widgetClass = (Class<?>) e[0]; final Point sizes = (Point) e[1]; final boolean outside = (Boolean) e[2]; final int xLeft = (Integer) e[3]; final int xRight = (Integer) e[4]; final int yTop = (Integer) e[5]; final int yCenter = (Integer) e[6]; final int yBottom = (Integer) e[7]; final int borderWidth = (Integer) e[8]; if (sizes == null) { if (!outside) { filtered.add(new Object[] { widgetClass, sizes, DecorationPosition.TOP_LEFT, outside, xLeft - 0, yTop, 0.0f, 0.0f, borderWidth, true }); filtered.add(new Object[] { widgetClass, sizes, DecorationPosition.TOP_RIGHT, outside, -SQUARE_SIZE + xRight + 0, yTop, 1.0f, 0.0f, borderWidth, true }); filtered.add(new Object[] { widgetClass, sizes, DecorationPosition.CENTER_LEFT, outside, xLeft - 0, -SQUARE_SIZE / 2 + yCenter, 0.0f, 0.5f, borderWidth, true }); filtered.add(new Object[] { widgetClass, sizes, DecorationPosition.CENTER_RIGHT, outside, -SQUARE_SIZE + xRight + 0, -SQUARE_SIZE / 2 + yCenter, 1.0f, 0.5f, borderWidth, true }); filtered.add(new Object[] { widgetClass, sizes, DecorationPosition.BOTTOM_LEFT, outside, xLeft - 0, -SQUARE_SIZE + yBottom, 0.0f, 1.0f, borderWidth, true }); filtered.add(new Object[] { widgetClass, sizes, DecorationPosition.BOTTOM_RIGHT, outside, -SQUARE_SIZE + xRight + 0, -SQUARE_SIZE + yBottom, 1.0f, 1.0f, borderWidth, true }); } else { filtered.add(new Object[] { widgetClass, sizes, DecorationPosition.TOP_LEFT, outside, xLeft - SQUARE_SIZE - IUIAttributeImageDecoration.OUTER_MARGIN_WIDTH, yTop, 0.0f, 0.0f, borderWidth, true }); filtered.add(new Object[] { widgetClass, sizes, DecorationPosition.TOP_RIGHT, outside, xRight + IUIAttributeImageDecoration.OUTER_MARGIN_WIDTH, yTop, 1.0f, 0.0f, borderWidth, true }); filtered.add(new Object[] { widgetClass, sizes, DecorationPosition.CENTER_LEFT, outside, xLeft - SQUARE_SIZE - IUIAttributeImageDecoration.OUTER_MARGIN_WIDTH, -SQUARE_SIZE / 2 + yCenter, 0.0f, 0.5f, borderWidth, true }); filtered.add(new Object[] { widgetClass, sizes, DecorationPosition.CENTER_RIGHT, outside, xRight + IUIAttributeImageDecoration.OUTER_MARGIN_WIDTH, -SQUARE_SIZE / 2 + yCenter, 1.0f, 0.5f, borderWidth, true }); filtered.add(new Object[] { widgetClass, sizes, DecorationPosition.BOTTOM_LEFT, outside, xLeft - SQUARE_SIZE - IUIAttributeImageDecoration.OUTER_MARGIN_WIDTH, -SQUARE_SIZE + yBottom, 0.0f, 1.0f, borderWidth, true }); filtered.add(new Object[] { widgetClass, sizes, DecorationPosition.BOTTOM_RIGHT, outside, xRight + IUIAttributeImageDecoration.OUTER_MARGIN_WIDTH, -SQUARE_SIZE + yBottom, 1.0f, 1.0f, borderWidth, true }); } } else { if (!outside) { filtered.add(new Object[] { widgetClass, sizes, DecorationPosition.TOP_LEFT, outside, xLeft - 0, yTop, 0.0f, 0.0f, borderWidth, true }); filtered.add(new Object[] { widgetClass, sizes, DecorationPosition.TOP_RIGHT, outside, -SQUARE_SIZE + xRight + 0 + sizes.x, yTop, 0.0f, 0.0f, borderWidth, true }); filtered.add(new Object[] { widgetClass, sizes, DecorationPosition.CENTER_LEFT, outside, xLeft - 0, -SQUARE_SIZE / 2 + yCenter + sizes.y / 2, 0.0f, 0.0f, borderWidth, true }); filtered.add(new Object[] { widgetClass, sizes, DecorationPosition.CENTER_RIGHT, outside, -SQUARE_SIZE + xRight + 0 + sizes.x, -SQUARE_SIZE / 2 + yCenter + sizes.y / 2, 0.0f, 0.0f, borderWidth, true }); filtered.add(new Object[] { widgetClass, sizes, DecorationPosition.BOTTOM_LEFT, outside, xLeft - 0, -SQUARE_SIZE + yBottom + sizes.y, 0.0f, 0.0f, borderWidth, true }); filtered.add(new Object[] { widgetClass, sizes, DecorationPosition.BOTTOM_RIGHT, outside, -SQUARE_SIZE + xRight + 0 + sizes.x, -SQUARE_SIZE + yBottom + sizes.y, 0.0f, 0.0f, borderWidth, true }); } else { filtered.add(new Object[] { widgetClass, sizes, DecorationPosition.TOP_LEFT, outside, xLeft - SQUARE_SIZE - IUIAttributeImageDecoration.OUTER_MARGIN_WIDTH, yTop, 0.0f, 0.0f, borderWidth, true }); filtered.add(new Object[] { widgetClass, sizes, DecorationPosition.TOP_RIGHT, outside, xRight + IUIAttributeImageDecoration.OUTER_MARGIN_WIDTH + sizes.x, yTop, 0.0f, 0.0f, borderWidth, true }); filtered.add(new Object[] { widgetClass, sizes, DecorationPosition.CENTER_LEFT, outside, xLeft - SQUARE_SIZE - IUIAttributeImageDecoration.OUTER_MARGIN_WIDTH, -SQUARE_SIZE / 2 + yCenter + sizes.y / 2, 0.0f, 0.0f, borderWidth, true }); filtered.add(new Object[] { widgetClass, sizes, DecorationPosition.CENTER_RIGHT, outside, xRight + IUIAttributeImageDecoration.OUTER_MARGIN_WIDTH + sizes.x, -SQUARE_SIZE / 2 + yCenter + sizes.y / 2, 0.0f, 0.0f, borderWidth, true }); filtered.add(new Object[] { widgetClass, sizes, DecorationPosition.BOTTOM_LEFT, outside, xLeft - SQUARE_SIZE - IUIAttributeImageDecoration.OUTER_MARGIN_WIDTH, -SQUARE_SIZE + yBottom + sizes.y, 0.0f, 0.0f, borderWidth, true }); filtered.add(new Object[] { widgetClass, sizes, DecorationPosition.BOTTOM_RIGHT, outside, xRight + IUIAttributeImageDecoration.OUTER_MARGIN_WIDTH + sizes.x, -SQUARE_SIZE + yBottom + sizes.y, 0.0f, 0.0f, borderWidth, true }); } } } final List<Object[]> l = Arrays.asList(new Object[][] { /* * widgetClass (Class<T>), sizes (Point), position, outside, x, y, addWidthFactor, * addHeightFactor, borderWidth, isEnabled */ }); for (final Object[] e : l) { if (e[8] == Boolean.FALSE) { continue; } filtered.add(e); } return filtered; }
From source file:com.rcpcompany.uibindings.uiAttributes.SimpleUIAttribute.java
License:Open Source License
/** * Calculates the inner and out bounds of the control of this attribute and updates the * decorations.// w ww . j a v a 2s . c om */ private void updateImageDecorations() { if (!(getWidget() instanceof Control)) return; final Control c = (Control) getWidget(); final Point size = c.getSize(); int bw = c.getBorderWidth(); if (bw == 0) { bw = 1; } final Rectangle innerBounds = new Rectangle(0, 0, size.x, size.y); /* * Special cases... and plenty of them! */ if (c instanceof Text) { if (Util.isWindows()) { innerBounds.width -= 4; innerBounds.height -= 4; if (bw == 1) { bw = 2; } } } else if (c instanceof CCombo) { if (Util.isMac()) { innerBounds.height -= 2; innerBounds.width -= 18; } else if (Util.isWindows()) { innerBounds.height -= 5; innerBounds.width -= 9; } } else if (c instanceof Combo) { if (Util.isMac()) { innerBounds.x += 1; innerBounds.y += 2; innerBounds.width -= 1 + 21; innerBounds.height -= 2 + 5; } else if (Util.isWindows()) { // innerBounds.x += 1 + 5; // innerBounds.y += 1 + 5; // innerBounds.width -= 16 + 2 + 10; // innerBounds.height -= 2 + 10; } } else if (c instanceof StyledText) { if (Util.isMac()) { innerBounds.width -= 3; innerBounds.height -= 2; } else if (Util.isWindows()) { innerBounds.height -= 4; innerBounds.width -= 4; } } else if (c instanceof Button) { if (Util.isMac()) { innerBounds.x += 14; innerBounds.y += 5; innerBounds.width -= 14 + 14; innerBounds.height -= 5 + 9; } else if (Util.isWindows()) { innerBounds.x += 4; innerBounds.y += 2; innerBounds.width -= 4 + 8; innerBounds.height -= 2 + 9; } } else if (c instanceof Table) { innerBounds.height = ((Table) c).getHeaderHeight(); if (innerBounds.height == 0) { innerBounds.height = ((Table) c).getItemHeight(); } final Rectangle r = ((Table) c).computeTrim(0, 0, innerBounds.width, innerBounds.height); innerBounds.y += r.y; if (Util.isMac()) { innerBounds.width -= 2; innerBounds.height -= 2; } else if (Util.isWindows()) { innerBounds.width -= 5; innerBounds.height -= 4; } } else if (c instanceof Tree) { innerBounds.height = ((Tree) c).getHeaderHeight(); if (innerBounds.height == 0) { innerBounds.height = ((Tree) c).getItemHeight(); } if (Util.isMac()) { final Rectangle r = ((Tree) c).computeTrim(0, 0, innerBounds.width, innerBounds.height); innerBounds.y += r.y; innerBounds.width -= 2; innerBounds.height -= 2; } else if (Util.isWindows()) { innerBounds.y = -innerBounds.height; innerBounds.width -= 5; innerBounds.height -= 4; } } else if (c instanceof Composite) { if (Util.isMac()) { innerBounds.width -= 2; innerBounds.height -= 2; } else if (Util.isWindows()) { innerBounds.width -= 5; innerBounds.height -= 4; } if (innerBounds.height > 40) { innerBounds.height = 20; } } final Rectangle outerBounds; if (c instanceof Table) { outerBounds = new Rectangle(0 - bw, innerBounds.y - bw, size.x + 2 * bw, innerBounds.height + 2 * bw); } else if (c instanceof Tree) { outerBounds = new Rectangle(0 - bw, innerBounds.y - bw, size.x + 2 * bw, innerBounds.height + 2 * bw); } else if (c instanceof Scrollable) { final Rectangle trim = ((Scrollable) c).computeTrim(0, innerBounds.y, size.x, innerBounds.height); outerBounds = new Rectangle(trim.x, innerBounds.y - bw, trim.width, innerBounds.height + 2 * bw); } else { outerBounds = new Rectangle(0 - bw, innerBounds.y - bw, size.x + 2 * bw, innerBounds.height + 2 * bw); } /* * Special cases... */ if (c instanceof Text) { if (Util.isWindows()) { outerBounds.x = -bw; outerBounds.width = innerBounds.width + 2 * bw; } } else if (c instanceof Button) { if (Util.isMac()) { outerBounds.x += 6; outerBounds.width -= 6 + 6; } else if (Util.isWindows()) { outerBounds.width -= 4; } } else if (c instanceof StyledText) { if (Util.isWindows()) { outerBounds.width -= 4; } } // IPaintDecoration.Factory.paintRectangle((Control) myWidget, innerBounds, // c.getDisplay().getSystemColor(SWT.COLOR_GREEN)); // IPaintDecoration.Factory.paintRectangle((Control) myWidget, outerBounds, // c.getDisplay().getSystemColor(SWT.COLOR_CYAN)); updateImageDecorations(c, innerBounds, outerBounds); }
From source file:de.jcup.egradle.eclipse.ui.AbstractFilterableTreeQuickDialog.java
License:Apache License
@Override protected final Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); boolean isWin32 = Util.isWindows(); GridLayoutFactory.fillDefaults().extendedMargins(isWin32 ? 0 : 3, 3, 2, 2).applyTo(composite); IBaseLabelProvider labelProvider = createLabelProvider(); if (labelProvider == null) { labelProvider = new LabelProvider(); }// ww w .j a v a2 s . c om int style = SWT.NONE; Tree tree = new Tree(composite, SWT.SINGLE | (style & ~SWT.MULTI)); GridData gridData = new GridData(GridData.FILL_BOTH); gridData.heightHint = tree.getItemHeight() * 12; gridData.verticalAlignment = SWT.TOP; gridData.grabExcessVerticalSpace = true; gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.FILL; tree.setLayoutData(gridData); treeViewer = new TreeViewer(tree); treeViewer.setContentProvider(contentProvider); /* filter */ textFilter = createFilter(); matcher = createItemMatcher(); textFilter.setMatcher(matcher); treeViewer.setFilters(textFilter); tree.setLayoutData(gridData); treeViewer.setContentProvider(contentProvider); treeViewer.addDoubleClickListener(this); treeViewer.setLabelProvider(labelProvider); return composite; }
From source file:de.jcup.egradle.eclipse.ui.QuickLaunchDialog.java
License:Apache License
@Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); boolean isWin32 = Util.isWindows(); GridLayoutFactory.fillDefaults().extendedMargins(isWin32 ? 0 : 3, 3, 2, 2).applyTo(composite); Text text = new Text(composite, SWT.NONE); Font terminalFont = JFaceResources.getTextFont(); text.setFont(terminalFont);/* w ww. j a va 2 s .c o m*/ GridData textLayoutData = new GridData(); textLayoutData.horizontalAlignment = GridData.FILL; textLayoutData.verticalAlignment = GridData.FILL; textLayoutData.grabExcessHorizontalSpace = true; textLayoutData.grabExcessVerticalSpace = false; textLayoutData.horizontalSpan = 2; text.setLayoutData(textLayoutData); text.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent event) { if (event.character == '\r') { inputText = text.getText(); close(); } } }); return composite; }