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

The following examples show how to use org.eclipse.swt.SWT#UP . 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: NativeHeaderTest.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
public void testSetSortDirection() {
Header header = new Header(shell, SWT.NONE);

assertEquals(SWT.NONE, header.getSortDirection());

int[] values = { SWT.UP, SWT.DOWN, SWT.NONE };
for (int value : values) {
    header.setSortDirection(value);

    assertEquals(value, header.getSortDirection());
}

try {
    header.setSortDirection(-1);
    fail();
} catch (RuntimeException rex) {
    // expected
}
   }
 
Example 2
Source File: TableViewerSorter.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
@SuppressWarnings({
	"rawtypes", "unchecked"
})
private int compareElements(Object e1, Object e2){
	IColumnContentProvider columnValueProvider =
		(IColumnContentProvider) tableViewer.getContentProvider();
	
	Table table = tableViewer.getTable();
	
	int index = Arrays.asList(table.getColumns()).indexOf(table.getSortColumn());
	int result = 0;
	if (index != -1) {
		Comparable c1 = columnValueProvider.getValue(e1, index);
		Comparable c2 = columnValueProvider.getValue(e2, index);
		if (c1 instanceof String && c2 instanceof String) {
			String _c1 = (String) c1;
			String _c2 = (String) c2;
			result = _c1.compareToIgnoreCase(_c2);
		} else {
			result = c1.compareTo(c2);
		}
	}
	
	return table.getSortDirection() == SWT.UP ? result : -result;
}
 
Example 3
Source File: ShellSlider.java    From BiglyBT with GNU General Public License v2.0 6 votes vote down vote up
private boolean canContinue() {
	if (shell == null || shell.isDisposed())
		return false;

	if (shellBounds == null)
		return true;

	//System.out.println((slideIn ? "In" : "Out") + ";" + direction + ";S:" + shellBounds + ";" + endBounds);
	if (slideIn) {
		if (direction == SWT.UP) {
			return shellBounds.y > endBounds.y;
		}
		// TODO: Other directions
	} else {
		if (direction == SWT.RIGHT) {
			// stop early, because some OSes have trim, and won't allow the window
			// to go smaller than it.
			return shellBounds.width > 10;
		}
	}
	return false;
}
 
Example 4
Source File: AbapGitStagingTreeComparator.java    From ADT_Frontend with MIT License 6 votes vote down vote up
private int compareElements(Viewer viewer, Object e1, Object e2) {
	TreeViewer treeViewer = (TreeViewer) viewer;
	if (e1 instanceof IAbapGitObject && e2 instanceof IAbapGitObject) {
		IAbapGitObject object1 = (IAbapGitObject) e1;
		IAbapGitObject object2 = (IAbapGitObject) e2;
		//set "non-code and meta files" as the first node
		if (object1.getType() == null) {
			return treeViewer.getTree().getSortDirection() == SWT.UP ? -1 : 1;
		}
		if (object2.getType() == null) {
			return treeViewer.getTree().getSortDirection() == SWT.UP ? 1 : -1;
		}
		int result = object1.getName().compareToIgnoreCase(object2.getName());
		return treeViewer.getTree().getSortDirection() == SWT.UP ? result : -result;
	}
	return 0;
}
 
Example 5
Source File: AbstractSortColumnSelectionListener.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void widgetSelected(SelectionEvent e) {
	Widget parent = getParent(e);
	// 4) Compute the (inverse) sort direction
	sortDirection = sortDirection == SWT.DOWN ? SWT.UP : SWT.DOWN;
	// 5) Modify the sort of the page controller
	super.getController(parent).setSort(sortPropertyName, sortDirection);
	// 6) Modify the SWT Table sort
	sort(e);
}
 
Example 6
Source File: BeanComparator.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private int compare(Comparable c1, Comparable c2) {
	if (sortDirection == SWT.UP) {
		return c2.compareTo(c1);
	}
	return c1.compareTo(c2);
}
 
Example 7
Source File: VControl.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Javadoc out of date // TODO: update javadoc
 * @param panel
 * @param style
 */
public VControl(VPanel panel, int style) {
	setParent(panel);

	this.style = style;
	bounds = new Rectangle(0, 0, 0, 0);

	if((style & SWT.OK) != 0) {
		setPolygon(Points_OK);
		setForeground(Display.getDefault().getSystemColor(SWT.COLOR_DARK_GREEN));
	} else if((style & SWT.CANCEL) != 0) {
		setPolygon(Points_Cancel);
		setForeground(Display.getDefault().getSystemColor(SWT.COLOR_DARK_RED));
	} else if((style & SWT.ARROW) != 0) {
		if((style & SWT.DOWN) != 0) {
			setPolygon(Points_Down);
		} else if((style & SWT.LEFT) != 0) {
			setPolygon(Points_Left);
		} else if((style & SWT.RIGHT) != 0) {
			setPolygon(Points_Right);
		} else if((style & SWT.UP) != 0) {
			setPolygon(Points_Up);
		}
	} else if((style & SWT.UP) != 0) {
		setPolygon(Points_Add);
	} else if((style & SWT.DOWN) != 0) {
		setPolygon(Points_Subtract);
	}

	if(foreground == null) {
		setForeground(Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND));
	}
	if(fill == null) {
		setFill(getForeground());
	}
}
 
Example 8
Source File: AbstractPaintManager.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public void drawArrowHead(final int x, final int y, final int face, final GC gc) {
    switch (face) {
        case SWT.UP:
            gc.drawLine(x, y + 3, x, y + 3);
            gc.drawLine(x - 1, y + 4, x + 1, y + 4);
            gc.drawLine(x - 2, y + 5, x + 2, y + 5);
            gc.drawLine(x - 3, y + 6, x + 3, y + 6);
            gc.drawLine(x - 4, y + 7, x + 4, y + 7);
            break;
        case SWT.DOWN:
            gc.drawLine(x, y + 7, x, y + 7);
            gc.drawLine(x - 1, y + 6, x + 1, y + 6);
            gc.drawLine(x - 2, y + 5, x + 2, y + 5);
            gc.drawLine(x - 3, y + 4, x + 3, y + 4);
            gc.drawLine(x - 4, y + 3, x + 4, y + 3);
            break;
        case SWT.RIGHT:
            // don't need 1 as a line will be on it
            gc.drawLine(x + 3, y - 4, x + 3, y + 4);
            gc.drawLine(x + 4, y - 3, x + 4, y + 3);
            gc.drawLine(x + 5, y - 2, x + 5, y + 2);
            gc.drawLine(x + 6, y - 1, x + 6, y + 1);
            break;
        case SWT.LEFT:
            // don't need 1 as a line will be on it
            gc.drawLine(x - 3, y - 4, x - 3, y + 4);
            gc.drawLine(x - 4, y - 3, x - 4, y + 3);
            gc.drawLine(x - 5, y - 2, x - 5, y + 2);
            gc.drawLine(x - 6, y - 1, x - 6, y + 1);
            break;
        default:
            break;
    }
}
 
Example 9
Source File: InvoiceListView.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void widgetSelected(SelectionEvent e){
	TableColumn sortColumn = tableViewerInvoiceList.getTable().getSortColumn();
	TableColumn selectedColumn = (TableColumn) e.widget;
	int sortDirection = tableViewerInvoiceList.getTable().getSortDirection();
	if (sortColumn == selectedColumn) {
		sortDirection = sortDirection == SWT.UP ? SWT.DOWN : SWT.UP;
	} else {
		tableViewerInvoiceList.getTable().setSortColumn(selectedColumn);
		sortDirection = SWT.UP;
	}
	
	setSortOrder(selectedColumn, sortDirection);
}
 
Example 10
Source File: AbstractNativeHeader.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
    * Set the sort direction.
    * 
    * @param direct one of SWT.UP, SWT.DOWN, SWT.NONE 
    * @throws RuntimeException if direction has an invalid value
    * @see #setSortColumn(int);
    */
public void setSortDirection(int direction) {
	if (!(direction == SWT.NONE || direction == SWT.UP || direction == SWT.DOWN)) {
		throw new IllegalArgumentException("direction= " + direction);
	}
	headerTable.setSortDirection(direction);
	sortDirection = direction;
}
 
Example 11
Source File: NodeKindTableControl.java    From depan with Apache License 2.0 5 votes vote down vote up
private int getSortDirection(TableColumn column) {
  Table tableControl = (Table) kindViewer.getControl();
  if (column != tableControl.getSortColumn()) {
    return SWT.DOWN;
  }
  // If it is unsorted (SWT.NONE), assume down sort
  return (SWT.DOWN == tableControl.getSortDirection())
      ? SWT.UP : SWT.DOWN;
}
 
Example 12
Source File: CoverageViewerComparator.java    From tlaplus with MIT License 5 votes vote down vote up
@Override
public int compare(final Viewer viewer, final Object e1, final Object e2) {
	final ActionInformationItem a1 = (ActionInformationItem) e1;
	final ActionInformationItem a2 = (ActionInformationItem) e2;

	final Table table = (Table) viewer.getControl();
	final TableColumn sortColumn = table.getSortColumn();
	if (sortColumn == null) {
		// a) Compare by distinct states first (we want actions with zero distinct states
		// to appear at the top).
		if (Long.compare(a1.getUnseen(), a2.getUnseen()) == 0L) {
			// b) Compare by location
			return a1.getModuleLocation().compareTo(a2.getModuleLocation());
		} else {
			return Long.compare(a1.getUnseen(), a2.getUnseen());
		}
	} else {
		// User requested to sort a specific column up or down.
		@SuppressWarnings("unchecked")
		final Comparator<ActionInformationItem> comp = (Comparator<ActionInformationItem>) sortColumn
				.getData(CoverageLabelProvider.COVERAGE_COMPARATOR);
		if (table.getSortDirection() == SWT.UP) {
			return comp.compare(a2, a1);
		} else {
			return comp.compare(a1, a2);
		}
	}
}
 
Example 13
Source File: RelationSetTableControl.java    From depan with Apache License 2.0 5 votes vote down vote up
private void setSortColumn(
    TableColumn column, int colIndex, int direction) {

  ViewerComparator sorter = buildColumnSorter(colIndex);
  if (SWT.UP == direction) {
    sorter = new InverseSorter(sorter);
  }

  Table tableControl = (Table) relSetViewer.getControl();
  relSetViewer.setComparator(sorter);
  tableControl.setSortColumn(column);
  tableControl.setSortDirection(direction);
}
 
Example 14
Source File: ColumnBindingDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public int compare( Object o1, Object o2 )
{
	ComputedColumnHandle binding1 = (ComputedColumnHandle) o1;
	ComputedColumnHandle binding2 = (ComputedColumnHandle) o2;
	String columnText1 = labelProvider.getColumnText( binding1,
			sortingColumnIndex );
	String columnText2 = labelProvider.getColumnText( binding2,
			sortingColumnIndex );
	int result = ( columnText1 == null ? "" : columnText1 ).compareTo( ( columnText2 == null ? ""
			: columnText2 ) );
	if ( sortDirection == SWT.UP )
		return result;
	else
		return 0 - result;
}
 
Example 15
Source File: SelectValueDialog.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public int compare( Viewer viewer, Object e1, Object e2 )
{
	if ( sortDir == SWT.UP )
	{
		if ( e1 instanceof NullValue )
		{
			return -1;
		}
		if ( e2 instanceof NullValue )
		{
			return 1;
		}
		if ( e1 instanceof Integer )
		{
			return ( (Integer) e1 ).compareTo( (Integer) e2 );
		}
		else if ( e1 instanceof Double )
		{
			return ( (Double) e1 ).compareTo( (Double) e2 );
		}
		else if ( e1 instanceof BigDecimal )
		{
			return ( (BigDecimal) e1 ).compareTo( (BigDecimal) e2 );
		}
		else
		{
			return getDataText( e1 ).compareTo( getDataText( e2 ) );
		}
	}
	else if ( sortDir == SWT.DOWN )
	{
		if ( e1 instanceof NullValue )
		{
			return 1;
		}
		if ( e2 instanceof NullValue )
		{
			return -1;
		}
		if ( e2 instanceof Double )
		{
			return ( (Double) e2 ).compareTo( (Double) e1 );
		}
		else if ( e2 instanceof BigDecimal )
		{
			return ( (BigDecimal) e2 ).compareTo( (BigDecimal) e1 );
		}
		else
		{
			return getDataText( e2 ).compareTo( getDataText( e1 ) );
		}
	}
	return 0;
}
 
Example 16
Source File: FindingsView.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
public int getDirection(){
	return direction == 1 ? SWT.DOWN : SWT.UP;
}
 
Example 17
Source File: BuyOrderComparator.java    From offspring with MIT License 4 votes vote down vote up
public int getDirection() {
  return direction == 1 ? SWT.DOWN : SWT.UP;
}
 
Example 18
Source File: SellOrderComparator.java    From offspring with MIT License 4 votes vote down vote up
public int getDirection() {
  return direction == 1 ? SWT.DOWN : SWT.UP;
}
 
Example 19
Source File: BriefAuswahl.java    From elexis-3-core with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * for sort direction
 * 
 * @return SWT.DOWN or SWT.UP
 */
public int getDirection(){
	return direction ? SWT.DOWN : SWT.UP;
}
 
Example 20
Source File: AssignStickerDialog.java    From elexis-3-core with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * for sort direction
 * 
 * @return SWT.DOWN or SWT.UP
 */
public int getDirection(){
	return direction ? SWT.DOWN : SWT.UP;
}