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

The following examples show how to use org.eclipse.swt.SWT#DOWN . 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: AbstractTimeGraphView.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private void restoreViewContext() {
    ViewContext viewContext = fViewContext.get(fTrace);
    if (fColumnComparators != null) {
        // restore sort settings
        fSortDirection = SWT.DOWN;
        fCurrentSortColumn = fInitialSortColumn;
        if (viewContext != null) {
            fSortDirection = viewContext.getSortDirection();
            fCurrentSortColumn = viewContext.getSortColumn();
        }
        if ((fCurrentSortColumn < fColumnComparators.length) && (fColumnComparators[fCurrentSortColumn] != null)) {
            Comparator<ITimeGraphEntry> comparator = fColumnComparators[fCurrentSortColumn];
            if (comparator instanceof ITimeGraphEntryComparator) {
                ((ITimeGraphEntryComparator) comparator).setDirection(fSortDirection);
            }
            if (fSortDirection != SWT.DOWN) {
                comparator = checkNotNull(Collections.reverseOrder(comparator));
            }
            setEntryComparator(comparator);
        }
    }
    fIsHideRowsFilterActive = (viewContext == null) ? false : viewContext.isHideRowFilterActive();
}
 
Example 2
Source File: ResultSetColumnPage.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected void buttonPressed( int buttonId )
{
	ResultSetColumnModel model = getSelectedColumn( );
	int index = columnList.indexOf( model );
	columnList.remove( index );
	switch ( buttonId )
	{
		case SWT.UP :
			columnList.add( index - 1, model );
			break;
		case SWT.DOWN :
			columnList.add( index + 1, model );
			break;
	}
	updateTable( );
	updateButtons( );
}
 
Example 3
Source File: SpinnerYear.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private void initComponents( )
{
	up = new Button( this, SWT.ARROW | SWT.UP );
	down = new Button( this, SWT.ARROW | SWT.DOWN );
	text = new SpinnerText( this, SWT.NONE );
	label = new Label( this, SWT.NONE );

	label.setBackground( Display.getCurrent( )
			.getSystemColor( SWT.COLOR_WHITE ) );
	//		Font font = new Font( Display.getCurrent( ), "Dialog", 12, SWT.BOLD
	// ); //$NON-NLS-1$
	//		text.setFont( font );
	text.setFont( FontManager.getFont( "Dialog", 12, SWT.BOLD ) ); //$NON-NLS-1$

	text.setTextLimit( 5 );

}
 
Example 4
Source File: EventViewTable.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void widgetSelected ( final SelectionEvent e )
{
    final Table table = this.tableViewer.getTable ();
    final TableColumn newColumn = (TableColumn)e.widget;
    final TableColumn currentColumn = table.getSortColumn ();

    final EventTableColumn column = (EventTableColumn)newColumn.getData ( COLUMN_KEY );
    if ( column == EventTableColumn.reservedColumnSourceTimestamp || column == EventTableColumn.reservedColumnEntryTimestamp )
    {
        final int currentDir = table.getSortDirection ();
        int newDir = SWT.UP;
        if ( newColumn == currentColumn )
        {
            newDir = currentDir == SWT.UP ? SWT.DOWN : SWT.UP;
        }
        else
        {
            table.setSortColumn ( newColumn );
        }
        table.setSortDirection ( newDir );
        this.tableViewer.setSorter ( new EventTableSorter ( column, newDir ) );
    }
}
 
Example 5
Source File: RelationSetTableControl.java    From depan with Apache License 2.0 5 votes vote down vote up
private int getSortDirection(TableColumn column) {
  Table tableControl = (Table) relSetViewer.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 6
Source File: AbstractNativeHeader.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private int toggleSortDirection() {
    if (sortDirection == SWT.NONE) {
        sortDirection = SWT.DOWN;
    } else if (sortDirection == SWT.DOWN) {
        sortDirection = SWT.UP;
    } else if (sortDirection == SWT.UP) {
        sortDirection = SWT.DOWN;
    }
    return sortDirection;
}
 
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: BlockDetailDisplay.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public void setDirection(int value){
	if (value == SWT.DOWN) {
		direction = 1;
	} else if (value == SWT.UP) {
		direction = -1;
	} else {
		direction = 0;
	}
}
 
Example 11
Source File: RelationDisplayTableControl.java    From depan with Apache License 2.0 5 votes vote down vote up
private int getSortDirection(TableColumn column) {
  Table tableControl = (Table) propViewer.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: MonitorsViewTable.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
@SuppressWarnings ( { "unchecked", "rawtypes" } )
@Override
public int compare ( final Viewer viewer, final Object e1, final Object e2 )
{
    final MonitorStatusInformation m1 = ( (DecoratedMonitor)e1 ).getMonitor ();
    final MonitorStatusInformation m2 = ( (DecoratedMonitor)e2 ).getMonitor ();
    Comparable v1 = 0;
    Comparable v2 = 0;
    switch ( this.column )
    {
        case ID:
            v1 = m1.getId ();
            v2 = m2.getId ();
            break;
        case STATE:
            v1 = m1.getStatus ();
            v2 = m2.getStatus ();
            break;
        case VALUE:
            v1 = m1.getValue () == null ? Variant.NULL : m1.getValue ();
            v2 = m2.getValue () == null ? Variant.NULL : m2.getValue ();
            break;
        case LAST_FAIL_TIMESTAMP:
            v1 = m1.getLastFailTimestamp ();
            v2 = m2.getLastFailTimestamp ();
            break;
        case LAST_FAIL_VALUE:
            v1 = m1.getLastFailValue () == null ? Variant.NULL : m1.getLastFailValue ();
            v2 = m2.getLastFailValue () == null ? Variant.NULL : m2.getLastFailValue ();
            break;
        case ACK_USER:
            v1 = m1.getLastAknUser () == null ? "" : m1.getLastAknUser (); //$NON-NLS-1$
            v2 = m2.getLastAknUser () == null ? "" : m2.getLastAknUser (); //$NON-NLS-1$
            break;
        case ACK_TIMESTAMP:
            v1 = m1.getLastAknTimestamp () == null ? DEFAULT_DATE : m1.getLastAknTimestamp ();
            v2 = m2.getLastAknTimestamp () == null ? DEFAULT_DATE : m2.getLastAknTimestamp ();
            break;
        case ITEM:
            v1 = m1.getAttributes ().get ( "item" ) == null ? Variant.NULL : m1.getAttributes ().get ( "item" ); //$NON-NLS-1$ //$NON-NLS-2$
            v2 = m2.getAttributes ().get ( "item" ) == null ? Variant.NULL : m2.getAttributes ().get ( "item" ); //$NON-NLS-1$ //$NON-NLS-2$
            break;
        case ITEM_DESCRIPTION:
            v1 = m1.getAttributes ().get ( "itemDescription" ) == null ? Variant.NULL : m1.getAttributes ().get ( "itemDescription" ); //$NON-NLS-1$ //$NON-NLS-2$
            v2 = m2.getAttributes ().get ( "itemDescription" ) == null ? Variant.NULL : m2.getAttributes ().get ( "itemDescription" ); //$NON-NLS-1$ //$NON-NLS-2$
            break;
        case MESSAGE:
            v1 = m1.getAttributes ().get ( "message" ) == null ? Variant.NULL : m1.getAttributes ().get ( "message" ); //$NON-NLS-1$ //$NON-NLS-2$
            v2 = m2.getAttributes ().get ( "message" ) == null ? Variant.NULL : m2.getAttributes ().get ( "message" ); //$NON-NLS-1$ //$NON-NLS-2$
            break;
        case STATUS_TIMESTAMP:
            v1 = m1.getStatusTimestamp ();
            v2 = m2.getStatusTimestamp ();
            break;
        case SEVERITY:
            v1 = m1.getSeverity ();
            v2 = m2.getSeverity ();
            break;
    }
    if ( v1 == v2 )
    {
        return 0;
    }
    if ( v1 == null )
    {
        return -1;
    }
    if ( v2 == null )
    {
        return 1;
    }
    // first compare the given column
    int result = v1.compareTo ( v2 );
    // use given order for sorting
    result = this.dir == SWT.DOWN ? -result : result;
    // if values are the same, order by timestamp in descending order
    if ( this.column != Columns.LAST_FAIL_TIMESTAMP && result == 0 )
    {
        result = Long.valueOf ( m2.getStatusTimestamp () ).compareTo ( m1.getStatusTimestamp () );
    }
    // if values are still the same, order by id in ascending order
    if ( this.column != Columns.ID && result == 0 )
    {
        result = m1.getId ().compareTo ( m2.getId () );
    }
    return result;
}
 
Example 13
Source File: PeerComparator.java    From offspring with MIT License 4 votes vote down vote up
public int getDirection() {
  return direction == 1 ? SWT.DOWN : SWT.UP;
}
 
Example 14
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 15
Source File: EventTableSorter.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
private int invert ( final int result )
{
    return ( this.dir == SWT.DOWN ? -1 : 1 ) * result;
}
 
Example 16
Source File: CustomChooserComposite.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
private void initControls( )
{
	// THE LAYOUT OF THIS COMPOSITE (FILLS EVERYTHING INSIDE IT)
	FillLayout flMain = new FillLayout( );
	flMain.marginHeight = 0;
	flMain.marginWidth = 0;
	setLayout( flMain );

	// THE LAYOUT OF THE INNER COMPOSITE (ANCHORED NORTH AND ENCAPSULATES
	// THE CANVAS + BUTTON)
	cmpContent = new Composite( this, SWT.BORDER );
	GridLayout glContentInner = new GridLayout( );
	glContentInner.verticalSpacing = 0;
	glContentInner.horizontalSpacing = 0;
	glContentInner.marginHeight = 0;
	glContentInner.marginWidth = 0;
	glContentInner.numColumns = 2;
	cmpContent.setLayout( glContentInner );

	final int iSize = itemHeight;
	// THE CANVAS
	cnvSelection = createChoice( cmpContent, null );
	GridData gdCNVSelection = new GridData( GridData.FILL_BOTH );
	gdCNVSelection.heightHint = iSize;
	cnvSelection.setLayoutData( gdCNVSelection );
	cnvSelection.setValue( iCurrentValue );
	cnvSelection.addListener( SWT.KeyDown, canvasListener );
	cnvSelection.addListener( SWT.Traverse, canvasListener );
	cnvSelection.addListener( SWT.FocusIn, canvasListener );
	cnvSelection.addListener( SWT.FocusOut, canvasListener );
	cnvSelection.addListener( SWT.MouseDown, canvasListener );

	// THE BUTTON
	btnDown = new Button( cmpContent, SWT.ARROW | SWT.DOWN );
	GridData gdBDown = new GridData( GridData.FILL );
	gdBDown.verticalAlignment = GridData.BEGINNING;
	gdBDown.widthHint = iSize - 1;
	gdBDown.heightHint = iSize;
	btnDown.setLayoutData( gdBDown );
	btnDown.addListener( SWT.Selection, new Listener( ) {

		public void handleEvent( Event event )
		{
			toggleDropDown( );
		}
	} );

	layout( );

	initAccessible( );
}
 
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: SelectParameterDefaultValueDialog.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 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 if ( getDataText( e1 ) != null )
		{
			return getDataText( e1 ).compareTo( getDataText( e2 ) );
		}
	}
	else if ( sortDir == SWT.DOWN )
	{
		if ( e2 instanceof Integer )
		{
			return ( (Integer) e2 ).compareTo( (Integer) e1 );
		}
		else if ( e2 instanceof Double )
		{
			return ( (Double) e2 ).compareTo( (Double) e1 );
		}
		else if ( e2 instanceof BigDecimal )
		{
			return ( (BigDecimal) e2 ).compareTo( (BigDecimal) e1 );
		}
		else if ( getDataText( e2 ) != null )
		{
			return getDataText( e2 ).compareTo( getDataText( e1 ) );
		}
	}
	return 0;
}
 
Example 19
Source File: CommonLineNumberRulerColumn.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Scrolls the viewer into the given direction.
 *
 * @param direction the scroll direction
 */
private void autoScroll(int direction) {

	if (fAutoScrollDirection == direction)
		return;

	final int TIMER_INTERVAL= 5;
	final Display display= fCanvas.getDisplay();
	Runnable timer= null;
	switch (direction) {
		case SWT.UP:
			timer= new Runnable() {
				public void run() {
					if (fAutoScrollDirection == SWT.UP) {
						int top= getInclusiveTopIndex();
						if (top > 0) {
							fCachedTextViewer.setTopIndex(top -1);
							expandSelection(top -1);
							display.timerExec(TIMER_INTERVAL, this);
						}
					}
				}
			};
			break;
		case  SWT.DOWN:
			timer= new Runnable() {
				public void run() {
					if (fAutoScrollDirection == SWT.DOWN) {
						int top= getInclusiveTopIndex();
						fCachedTextViewer.setTopIndex(top +1);
						expandSelection(top +1 + fCachedViewportSize);
						display.timerExec(TIMER_INTERVAL, this);
					}
				}
			};
			break;
	}

	if (timer != null) {
		fAutoScrollDirection= direction;
		display.timerExec(TIMER_INTERVAL, timer);
	}
}
 
Example 20
Source File: PopulationInspectView.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
@Override
public int compare(final Object e1, final Object e2) {
	final IAgent p1 = (IAgent) e1;
	final IAgent p2 = (IAgent) e2;
	final IScope scope = getScope();
	int rc = 0;
	if (attribute == null || attribute.equals(ID_ATTRIBUTE)) {
		rc = p1.compareTo(p2);
	} else {
		try {
			final Object v1 = scope.getAgentVarValue(p1, attribute);
			if (v1 == null) {
				rc = -1;
			} else {
				final Object v2 = scope.getAgentVarValue(p2, attribute);
				if (v2 == null) {
					rc = 1;
				} else {
					final IVariable v = getOutput().getSpecies().getVar(attribute);
					final int id = v.getType().id();
					switch (id) {
						case IType.INT:
							rc = ((Integer) v1).compareTo((Integer) v2);
							break;
						case IType.FLOAT:
							rc = ((Double) v1).compareTo((Double) v2);
							break;
						case IType.STRING:
							rc = stringComparator.compare(v1, v2);
							break;
						case IType.POINT:
							rc = ((ILocation) v1).compareTo(v2);
							break;
						default:
							rc = Cast.toGaml(v1).compareTo(Cast.toGaml(v2));
					}
				}
			}
		} catch (final Exception ex) {
			ex.printStackTrace();
		}
	}

	// If descending order, flip the direction
	if (direction == SWT.DOWN) {
		rc = -rc;
	}
	return rc;
}