Java Code Examples for org.eclipse.swt.SWT#DEFAULT

The following examples show how to use org.eclipse.swt.SWT#DEFAULT . These examples are extracted from open source projects. 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 Project: RepDev   File: Style.java    License: GNU General Public License v3.0 6 votes vote down vote up
public int getStyle(String item){
int swtStyle = SWT.DEFAULT;
String styleText = "";
for( int i=0; i<style.getChildNodes().getLength(); i++ ) {
    Node cur = style.getChildNodes().item(i);
    if( cur.getNodeName().equals(item) ) {
	for( int j=0; j<cur.getAttributes().getLength(); j++ ) {
	    if( cur.getAttributes().item(j).getNodeName().equals("style") ) {
		styleText = cur.getAttributes().item(j).getNodeValue();
	    }	    
	}
    }
}
if( styleText.equalsIgnoreCase("bold") ) swtStyle = SWT.BOLD;
if( styleText.equalsIgnoreCase("italic") ) swtStyle = SWT.ITALIC;
return swtStyle;

   }
 
Example 2
/**
 * Test method addZoomedEvent with duplicates.
 */
@Test
public void testaddZoomedEventDuplicate() {
    TimeGraphEntry entry = new TimeGraphEntry(NAME, SWT.DEFAULT, SWT.DEFAULT);
    ITimeEvent event1 = new TimeEvent(entry, 0, 10, 1);
    ITimeEvent event2 = new TimeEvent(entry, 10, 10, 2);
    ITimeEvent event3 = new TimeEvent(entry, 20, 10, 3);
    entry.addZoomedEvent(event1);
    entry.addZoomedEvent(event2);
    // duplicate events are not added twice
    entry.addZoomedEvent(event1);
    entry.addZoomedEvent(event2);
    entry.addZoomedEvent(event3);
    assertEquals(0, entry.getStartTime());
    assertEquals(30, entry.getEndTime());
    assertIteratorsEqual(Iterators.forArray(event1, event2, event3), entry.getTimeEventsIterator());
}
 
Example 3
Source Project: tlaplus   File: UIHelper.java    License: MIT License 6 votes vote down vote up
/**
 * This appropriately scales the non-zero spatial values contained in the
 * <code>TableWrapData</code> instance to observe display scaling.
 * 
 * @param tableWrapData the <code>TableWrapData</code> which should be altered
 */
public static void appropriatelyScaleTableWrapData(final TableWrapData tableWrapData) {
	// Windows and Mac appear to do the correct thing
	if (Platform.getOS().equals(Platform.OS_LINUX)) {
		final double scale = getDisplayScaleFactor();
		
		tableWrapData.indent = (int)((double)tableWrapData.indent * scale);
		
		if (tableWrapData.maxWidth != SWT.DEFAULT) {
			tableWrapData.maxWidth = (int)((double)tableWrapData.maxWidth * scale);
		}
		if (tableWrapData.maxHeight != SWT.DEFAULT) {
			tableWrapData.maxHeight = (int)((double)tableWrapData.maxHeight * scale);
		}
		if (tableWrapData.heightHint != SWT.DEFAULT) {
			tableWrapData.heightHint = (int)((double)tableWrapData.heightHint * scale);
		}
	}
}
 
Example 4
private void updateEntryBounds(ITimeEvent event) {
    if (event instanceof NullTimeEvent) {
        /* A NullTimeEvent should not affect the entry bounds */
        return;
    }
    long start = event.getTime();
    long newStart = getStartTime() == SWT.DEFAULT ? start : Long.min(start, getStartTime());

    long end = start + event.getDuration();
    long newEnd = getEndTime() == SWT.DEFAULT ? end : Long.max(end, getEndTime());

    /*
     * Model is immutable, this is the only way to do this, consider not updating
     * bounds in the future?
     */
    fStartTime = newStart;
    fEndTime = newEnd;
}
 
Example 5
Source Project: nebula   File: Oscilloscope.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Override
public Point computeSize(int wHint, int hHint, boolean changed) {
	checkWidget();

	int width;
	int height;

	if (wHint != SWT.DEFAULT) {
		width = wHint;
	} else {
		width = DEFAULT_WIDTH;
	}

	if (hHint != SWT.DEFAULT) {
		height = hHint;
	} else {
		height = DEFAULT_HEIGHT;
	}

	return new Point(width + 2, height + 2);
}
 
Example 6
public Point computeSize( Composite editor, int wHint, int hHint,
		boolean force )
{
	if ( wHint != SWT.DEFAULT && hHint != SWT.DEFAULT )
		return new Point( wHint, hHint );
	Point contentsSize = expressionText.computeSize( SWT.DEFAULT,
			SWT.DEFAULT,
			force );
	Point buttonSize = btnPopup.computeSize( SWT.DEFAULT,
			SWT.DEFAULT,
			force );
	// Just return the button width to ensure the button is not clipped
	// if the label is long.
	// The label will just use whatever extra width there is
	Point result = new Point( buttonSize.x, Math.max( contentsSize.y,
			buttonSize.y ) );
	return result;
}
 
Example 7
public Point computeSize( Composite editor, int wHint, int hHint,
		boolean force )
{
	if ( wHint != SWT.DEFAULT && hHint != SWT.DEFAULT )
		return new Point( wHint, hHint );
	Point contentsSize = expressionText.computeSize( SWT.DEFAULT,
			SWT.DEFAULT,
			force );
	Point buttonSize = btnPopup.computeSize( SWT.DEFAULT,
			SWT.DEFAULT,
			force );
	// Just return the button width to ensure the button is not clipped
	// if the label is long.
	// The label will just use whatever extra width there is
	Point result = new Point( buttonSize.x, Math.max( contentsSize.y,
			buttonSize.y ) );
	return result;
}
 
Example 8
Source Project: nebula   File: LED.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @see org.eclipse.swt.widgets.Control#computeSize(int, int, boolean)
 */
@Override
public Point computeSize(int wHint, int hHint, boolean changed) {
	int x = (wHint == SWT.DEFAULT) ? DEFAULT_WIDTH : wHint;
	if (hasDot) {
		x += (int) (1.5f * DOT_DIAMETER);
	}
	int y = (hHint == SWT.DEFAULT) ? DEFAULT_HEIGHT : hHint;
	return new Point(x, y);
}
 
Example 9
Source Project: eclipse   File: WorkspaceWizardPage.java    License: Apache License 2.0 5 votes vote down vote up
private Button createButton(String text, Consumer<SelectionEvent> handler) {
  Button result = new Button(container, SWT.DEFAULT);
  result.setText(text);
  result.addSelectionListener(createSelectionListener(handler));
  result.setEnabled(false);
  return result;
}
 
Example 10
Source Project: nebula   File: LEDSeparator.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @see org.eclipse.swt.widgets.Control#computeSize(int, int, boolean)
 */
@Override
public Point computeSize(int wHint, int hHint, boolean changed) {
	int x = (wHint == SWT.DEFAULT) ? BaseLED.THIN_DEFAULT_WIDTH : wHint;
	int y = (hHint == SWT.DEFAULT) ? BaseLED.DEFAULT_HEIGHT : hHint;
	return new Point(x, y);
}
 
Example 11
Source Project: n4js   File: TestProgressBar.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Point computeSize(int wHint, int hHint, boolean changed) {
	if (hHint == SWT.DEFAULT) {
		return super.computeSize(wHint, preferredHeight, changed);
	}
	return super.computeSize(wHint, hHint, changed);
}
 
Example 12
Source Project: birt   File: LineCanvas.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public Point computeSize( int wHint, int hHint, boolean changed )
{
	Point size = new Point( 100, 20 );
	if ( wHint != SWT.DEFAULT )
		size.x = wHint;
	if ( hHint != SWT.DEFAULT )
		size.y = hHint;
	Rectangle trim = computeTrim( 0, 0, size.x, size.y );
	return new Point( trim.width, trim.height );
}
 
Example 13
/**
 * Test method addChild to same parent.
 */
@Test
public void testAddChildSameParent() {
    TimeGraphEntry parent = new TimeGraphEntry("parent", SWT.DEFAULT, SWT.DEFAULT);
    TimeGraphEntry child = new TimeGraphEntry("child", SWT.DEFAULT, SWT.DEFAULT);
    parent.addChild(child);
    parent.addChild(child);
    assertEquals(null, parent.getParent());
    assertEquals(Arrays.asList(child), parent.getChildren());
    assertEquals(parent, child.getParent());
    assertEquals(Arrays.asList(), child.getChildren());
}
 
Example 14
/**
 * Test method removeChild.
 */
@Test
public void testRemoveChild() {
    TimeGraphEntry parent = new TimeGraphEntry("parent", SWT.DEFAULT, SWT.DEFAULT);
    TimeGraphEntry child = new TimeGraphEntry("child", SWT.DEFAULT, SWT.DEFAULT);
    parent.addChild(child);
    parent.removeChild(child);
    assertEquals(null, parent.getParent());
    assertEquals(Arrays.asList(), parent.getChildren());
    assertEquals(null, child.getParent());
    assertEquals(Arrays.asList(), child.getChildren());
}
 
Example 15
Source Project: nebula   File: AlignPrint.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private static int checkHAlign(int hAlign) {
	if (hAlign == SWT.LEFT || hAlign == SWT.CENTER || hAlign == SWT.RIGHT)
		return hAlign;
	if (hAlign == SWT.DEFAULT)
		return DEFAULT_HORIZONTAL_ALIGN;
	PaperClips.error(SWT.ERROR_INVALID_ARGUMENT,
			"hAlign must be one of SWT.LEFT, SWT.CENTER or SWT.RIGHT"); //$NON-NLS-1$
	return hAlign;
}
 
Example 16
private IAction createShowColumnAction(final TableColumn column) {
    final IAction columnMenuAction = new Action(column.getText(), IAction.AS_CHECK_BOX) {
        @Override
        public void run() {
            boolean isChecked = isChecked();
            int index = (int) column.getData(Key.INDEX);
            if (isChecked) {
                int width = (int) column.getData(Key.WIDTH);
                column.setResizable(true);
                if (width <= 0) {
                    fPacking = true;
                    column.pack();
                    fPacking = false;
                    column.setData(Key.WIDTH, SWT.DEFAULT);
                    fColumnSize[index] = SWT.DEFAULT;
                } else {
                    column.setWidth(width);
                }
            } else {
                column.setResizable(false);
                column.setWidth(0);
            }
            fColumnResizable[index] = isChecked;
            fTable.refresh();
        }
    };
    columnMenuAction.setChecked(column.getResizable());
    return columnMenuAction;
}
 
Example 17
Source Project: nebula   File: RoundedCheckbox.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @see org.eclipse.swt.widgets.Control#computeSize(int, int, boolean)
 */
@Override
public Point computeSize(int wHint, int hHint, boolean changed) {
	wHint = wHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(wHint) : wHint;
	hHint = hHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(hHint) : hHint;
	return DPIUtil.autoScaleDown(computeSizePixels(wHint, hHint, changed));
}
 
Example 18
@Override
public Rectangle getClientArea() {
  Rectangle clientArea = super.getClientArea();

  int extraLeftMargin = getExtraLeftMargin();

  /*
   * Check whether preferred client size fits into the available size; if
   * not re-compute client size with available size.
   */
  Point newClientSize = this.computeSize(SWT.DEFAULT, SWT.DEFAULT);

  int wHint = SWT.DEFAULT, hHint = SWT.DEFAULT;
  if (newClientSize.x > clientArea.width) {
    /*
     * Because newClientSize contains the trim, we have to subtract the
     * trim for wHint.
     */
    wHint = Math.max(clientArea.width - extraLeftMargin, getMinWidth());
  }
  if (newClientSize.y > clientArea.height) {
    /*
     * Because newClientSize contains the trim, we have to subtract the
     * trim for hHint.
     */
    hHint = Math.max(clientArea.height, getMinHeight());
  }
  newClientSize = this.computeSizeTrimless(wHint, hHint);

  /*
   * Center the unit of image and child composites.
   */
  clientArea.x += extraLeftMargin;
  clientArea.y += Math.max((clientArea.height - newClientSize.y) / 2, 0);

  clientArea.width = newClientSize.x;
  clientArea.height = newClientSize.y;
  this.cachedClientArea = clientArea;

  return clientArea;
}
 
Example 19
/**
 * Check if the user wishes to overwrite the supplied resource or all
 * resources.
 *
 * @param source
 *            the source resource
 * @param destination
 *            the resource to be overwritten
 * @return one of IDialogConstants.YES_ID, IDialogConstants.YES_TO_ALL_ID,
 *         IDialogConstants.NO_ID, IDialogConstants.CANCEL_ID indicating
 *         whether the current resource or all resources can be overwritten,
 *         or if the operation should be canceled.
 */
private int checkOverwrite(final IResource source, final IResource destination) {
    final int[] result = new int[1];

    // Dialogs need to be created and opened in the UI thread
    Runnable query = new Runnable() {
        @Override
        public void run() {
            String message;
            int resultId[] = { IDialogConstants.YES_ID, IDialogConstants.YES_TO_ALL_ID, IDialogConstants.NO_ID,
                    IDialogConstants.CANCEL_ID };
            String labels[] = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL,
                    IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL };

            if (destination.getType() == IResource.FOLDER) {
                if (homogenousResources(source, destination)) {
                    message = NLS.bind(IDEWorkbenchMessages.CopyFilesAndFoldersOperation_overwriteMergeQuestion,
                            destination.getFullPath().makeRelative());
                } else {
                    if (destination.isLinked()) {
                        message = NLS.bind(
                                IDEWorkbenchMessages.CopyFilesAndFoldersOperation_overwriteNoMergeLinkQuestion,
                                destination.getFullPath().makeRelative());
                    } else {
                        message = NLS.bind(
                                IDEWorkbenchMessages.CopyFilesAndFoldersOperation_overwriteNoMergeNoLinkQuestion,
                                destination.getFullPath().makeRelative());
                    }
                    resultId = new int[] { IDialogConstants.YES_ID, IDialogConstants.NO_ID,
                            IDialogConstants.CANCEL_ID };
                    labels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                            IDialogConstants.CANCEL_LABEL };
                }
            } else {
                String[] bindings = new String[] { IDEResourceInfoUtils.getLocationText(destination),
                        IDEResourceInfoUtils.getDateStringValue(destination),
                        IDEResourceInfoUtils.getLocationText(source),
                        IDEResourceInfoUtils.getDateStringValue(source) };
                message = NLS.bind(IDEWorkbenchMessages.CopyFilesAndFoldersOperation_overwriteWithDetailsQuestion,
                        bindings);
            }
            MessageDialog dialog = new MessageDialog(messageShell,
                    IDEWorkbenchMessages.CopyFilesAndFoldersOperation_resourceExists, null, message,
                    MessageDialog.QUESTION, labels, 0);
            dialog.open();
            if (dialog.getReturnCode() == SWT.DEFAULT) {
                // A window close returns SWT.DEFAULT, which has to be
                // mapped to a cancel
                result[0] = IDialogConstants.CANCEL_ID;
            } else {
                result[0] = resultId[dialog.getReturnCode()];
            }
        }
    };
    messageShell.getDisplay().syncExec(query);
    return result[0];
}
 
Example 20
/**
 * {@inheritDoc}
 */
public Point computeSize(int wHint, int hHint, boolean changed) {
	checkWidget();

	int overallWidth = 0;
	int overallHeight = 0;
	int borderWidth = getBorderWidth();

	// use user defined values if they are specified.
	if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) {
		overallWidth = wHint;
		overallHeight = hHint;
	} else {
		TableItem[] tableItems = table.getItems();

		GC gc = new GC(text);
		int spacer = gc.stringExtent(" ").x; //$NON-NLS-1$
		int maxTextWidth = gc.stringExtent(text.getText()).x;
		int colIndex = getDisplayColumnIndex();
		int maxImageHeight = 0;
		int currTextWidth = 0;

		// calculate the maximum text width and image height.
		for (int i = 0; i < tableItems.length; i++) {
			currTextWidth = gc.stringExtent(tableItems[i].getText(colIndex)).x;

			// take image into account if there is one for the tableitem.
			if (tableItems[i].getImage() != null) {
				currTextWidth += tableItems[i].getImage().getBounds().width;
				maxImageHeight = Math.max(tableItems[i].getImage().getBounds().height, maxImageHeight);
			}

			maxTextWidth = Math.max(currTextWidth, maxTextWidth);
		}

		gc.dispose();
		Point textSize = text.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed);
		Point arrowSize = arrow.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed);
		Point tableSize = table.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed);

		overallHeight = Math.max(textSize.y, arrowSize.y);
		overallHeight = Math.max(maxImageHeight, overallHeight);
		overallWidth = Math.max(maxTextWidth + 2 * spacer + arrowSize.x + 2 * borderWidth, tableSize.x);

		// use user specified if they were entered.
		if (wHint != SWT.DEFAULT)
			overallWidth = wHint;
		if (hHint != SWT.DEFAULT)
			overallHeight = hHint;
	}

	return new Point(overallWidth + 2 * borderWidth, overallHeight + 2 * borderWidth);
}