Java Code Examples for org.eclipse.swt.widgets.Button#addTraverseListener()

The following examples show how to use org.eclipse.swt.widgets.Button#addTraverseListener() . 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: ImportDialog.java    From http4e with Apache License 2.0 5 votes vote down vote up
protected void createButtonsForButtonBar( Composite parent){
   Button ok = createButton(parent, IDialogConstants.OK_ID, "Import Packet", true);
   createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
   ok.addMouseListener(okListener);
   ok.addTraverseListener(new TraverseListener() {

      public void keyTraversed( TraverseEvent e){
         if (SWT.TRAVERSE_RETURN == e.detail) {
         }
      }
   });
}
 
Example 2
Source File: ParameterizeDialog.java    From http4e with Apache License 2.0 5 votes vote down vote up
protected void createButtonsForButtonBar( Composite parent){
   Button ok = createButton(parent, IDialogConstants.OK_ID, "Close", true);
   // createButton(parent, IDialogConstants.CANCEL_ID,
   // IDialogConstants.CANCEL_LABEL, false);
   ok.addMouseListener(okListener);
   ok.addTraverseListener(new TraverseListener() {

      public void keyTraversed( TraverseEvent e){
         if (SWT.TRAVERSE_RETURN == e.detail) {
         }
      }
   });
}
 
Example 3
Source File: CustomPreviewTable.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void addHeaderButton( int style, String sColumnHeading, int iWidth )
{
	Button btnHeader = new Button( cmpHeaders, style );
	FormData fd = new FormData( );
	fd.top = new FormAttachment( 2 );
	int i = btnHeaders.size( );
	if ( i == 0 )
	{
		fd.left = new FormAttachment( 0 );
	}
	else
	{
		Button btnNeighbor = btnHeaders.get( i - 1 );
		fd.left = new FormAttachment( btnNeighbor, SPLITTER_WIDTH );
	}
	fd.width = iWidth - SPLITTER_WIDTH;
	// fd.height = HEADER_HEIGHT;
	btnHeader.setLayoutData( fd );
	btnHeader.setText( sColumnHeading );
	btnHeader.setVisible( true );
	btnHeader.addListener( SWT.Selection, headerButtonListener );
	btnHeader.addKeyListener( this );
	btnHeader.addTraverseListener( traverseListener );
	btnHeader.addListener( SWT.FocusIn, headerButtonListener );
	btnHeader.addMouseListener( this );
	btnHeader.addMouseMoveListener( this );
	// Add drag support
	addDragListenerToHeaderButton( btnHeader );

	btnHeaders.add( btnHeader );

	// create menu
	fireMenuEvent( btnHeader, false );

	// Use this splitter to resize the column
	addHeaderSplitter( );
}
 
Example 4
Source File: TableView.java    From hop with Apache License 2.0 4 votes vote down vote up
private void editButton( TableItem row, int rownr, int colnr ) {
  beforeEdit = getItemText( row );
  fieldChanged = false;

  ColumnInfo colinfo = columns[ colnr - 1 ];

  if ( colinfo.isReadOnly() ) {
    return;
  }

  if ( colinfo.getDisabledListener() != null ) {
    boolean disabled = colinfo.getDisabledListener().isFieldDisabled( rownr );
    if ( disabled ) {
      return;
    }
  }

  button = new Button( table, SWT.PUSH );
  props.setLook( button, Props.WIDGET_STYLE_TABLE );
  String buttonText = columns[ colnr - 1 ].getButtonText();
  if ( buttonText != null ) {
    button.setText( buttonText );
  }
  button.setImage( GuiResource.getInstance().getImage( "ui/images/edittext.svg" ) );

  SelectionListener selAdpt = colinfo.getSelectionAdapter();
  if ( selAdpt != null ) {
    button.addSelectionListener( selAdpt );
  }

  buttonRownr = rownr;
  buttonColnr = colnr;

  // button.addTraverseListener(lsTraverse);
  buttonContent = row.getText( colnr );

  String tooltip = columns[ colnr - 1 ].getToolTip();
  if ( tooltip != null ) {
    button.setToolTipText( tooltip );
  } else {
    button.setToolTipText( "" );
  }
  button.addTraverseListener( lsTraverse ); // hop to next field
  button.addTraverseListener( new TraverseListener() {
    @Override
    public void keyTraversed( TraverseEvent arg0 ) {
      closeActiveButton();
    }
  } );

  editor.horizontalAlignment = SWT.LEFT;
  editor.verticalAlignment = SWT.TOP;
  editor.grabHorizontal = false;
  editor.grabVertical = false;

  Point size = button.computeSize( SWT.DEFAULT, SWT.DEFAULT );
  editor.minimumWidth = size.x;
  editor.minimumHeight = size.y - 2;

  // setRowNums();
  editor.layout();

  // Open the text editor in the correct column of the selected row.
  editor.setEditor( button );

  button.setFocus();

  // if the button loses focus, destroy it...
  /*
   * button.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent e) { button.dispose(); } } );
   */
}
 
Example 5
Source File: CustomPreviewTable.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
private void addHeaderButton( int style, ColumnBindingInfo columnHeader,
		int iWidth , int index)
{
	Button btnHeader = new Button( cmpHeaders, style );
	
	btnHeader.setText( columnHeader.getName( ) );
	if ( columnHeader.getImageName( ) != null )
	{
		btnHeader.setImage( UIHelper.getImage( columnHeader.getImageName( ) ) );
	}
	if ( columnHeader.getTooltip( ) != null )
	{
		btnHeader.setToolTipText( columnHeader.getTooltip( ) );
	}
	
	FormData fd = new FormData( );
	fd.top = new FormAttachment( 2 );
	int i = btnHeaders.size( );
	if ( i == 0 )
	{
		fd.left = new FormAttachment( 0 );
	}
	else
	{
		Button btnNeighbor = btnHeaders.get( i - 1 );
		fd.left = new FormAttachment( btnNeighbor, SPLITTER_WIDTH );
	}
	int defaultWidth = iWidth - SPLITTER_WIDTH;
	int preferWidth = btnHeader.computeSize( SWT.DEFAULT, SWT.DEFAULT ).x;
	if ( preferWidth > defaultWidth )
	{
		fd.width = preferWidth;
		columnWidths.remove( index );
		columnWidths.add( index, Integer.valueOf( preferWidth + SPLITTER_WIDTH ) );
	}
	else
	{
		fd.width = defaultWidth;
	}
	// fd.height = HEADER_HEIGHT;
	int h = ChartUIUtil.getImageButtonDefaultHeightByPlatform( );
	if ( h > 0 )
	{
		fd.height = h;
	}
	btnHeader.setLayoutData( fd );

	btnHeader.setVisible( true );
	btnHeader.addListener( SWT.Selection, headerButtonListener );
	btnHeader.addKeyListener( this );
	btnHeader.addTraverseListener( traverseListener );
	btnHeader.addListener( SWT.FocusIn, headerButtonListener );
	btnHeader.addMouseListener( this );
	btnHeader.addMouseMoveListener( this );
	// Add drag support
	addDragListenerToHeaderButton( btnHeader );

	btnHeaders.add( btnHeader );

	// create menu
	fireMenuEvent( btnHeader, false );

	// Use this splitter to resize the column
	addHeaderSplitter( );
}
 
Example 6
Source File: TableView.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private void editButton( TableItem row, int rownr, int colnr ) {
  beforeEdit = getItemText( row );
  fieldChanged = false;

  ColumnInfo colinfo = columns[colnr - 1];

  if ( colinfo.isReadOnly() ) {
    return;
  }

  if ( colinfo.getDisabledListener() != null ) {
    boolean disabled = colinfo.getDisabledListener().isFieldDisabled( rownr );
    if ( disabled ) {
      return;
    }
  }

  button = new Button( table, SWT.PUSH );
  props.setLook( button, Props.WIDGET_STYLE_TABLE );
  String buttonText = columns[colnr - 1].getButtonText();
  if ( buttonText != null ) {
    button.setText( buttonText );
  }
  button.setImage( GUIResource.getInstance().getImage( "ui/images/edittext.svg" ) );

  SelectionListener selAdpt = colinfo.getSelectionAdapter();
  if ( selAdpt != null ) {
    button.addSelectionListener( selAdpt );
  }

  buttonRownr = rownr;
  buttonColnr = colnr;

  // button.addTraverseListener(lsTraverse);
  buttonContent = row.getText( colnr );

  String tooltip = columns[colnr - 1].getToolTip();
  if ( tooltip != null ) {
    button.setToolTipText( tooltip );
  } else {
    button.setToolTipText( "" );
  }
  button.addTraverseListener( lsTraverse ); // hop to next field
  button.addTraverseListener( new TraverseListener() {
    @Override
    public void keyTraversed( TraverseEvent arg0 ) {
      closeActiveButton();
    }
  } );

  editor.horizontalAlignment = SWT.LEFT;
  editor.verticalAlignment = SWT.TOP;
  editor.grabHorizontal = false;
  editor.grabVertical = false;

  Point size = button.computeSize( SWT.DEFAULT, SWT.DEFAULT );
  editor.minimumWidth = size.x;
  editor.minimumHeight = size.y - 2;

  // setRowNums();
  editor.layout();

  // Open the text editor in the correct column of the selected row.
  editor.setEditor( button );

  button.setFocus();

  // if the button loses focus, destroy it...
  /*
   * button.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent e) { button.dispose(); } } );
   */
}