org.eclipse.swt.widgets.Table#addListener ( )源码实例Demo

下面列出了org.eclipse.swt.widgets.Table#addListener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: nebula   文件: TableCombo.java
/**
 * creates the popup shell.
 *
 * @param selectionIndex
 */
void createPopup(final int selectionIndex) {
	// create shell and table
	popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP);

	// create table
	table = new Table(popup, SWT.SINGLE | SWT.FULL_SELECTION);

	if (font != null) {
		table.setFont(font);
	}
	if (foreground != null) {
		table.setForeground(foreground);
	}
	if (background != null) {
		table.setBackground(background);
	}

	// Add popup listeners
	final int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate, SWT.Help };
	for (final int popupEvent : popupEvents) {
		popup.addListener(popupEvent, listener);
	}

	// add table listeners
	final int[] tableEvents = { SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn,
			SWT.Dispose };
	for (final int tableEvent : tableEvents) {
		table.addListener(tableEvent, listener);
	}

	// set the selection
	if (selectionIndex != -1) {
		table.setSelection(selectionIndex);
	}
}
 
源代码2 项目: birt   文件: StyleCombo.java
void createPopup( Object[] items, int selectionIndex )
{
	// create shell and list
	popup = new Shell( getShell( ), SWT.NO_TRIM | SWT.ON_TOP );

	table = new Table( popup, SWT.SINGLE
			| SWT.V_SCROLL
			| SWT.FULL_SELECTION );
	new TableColumn( table, SWT.LEFT );
	if ( font != null )
		table.setFont( font );
	if ( foreground != null )
		table.setForeground( foreground );
	if ( background != null )
		table.setBackground( background );

	label.setBackground( table.getBackground( ) );
	label.setForeground( table.getForeground( ) );
	label.setFont( table.getFont( ) );

	int[] popupEvents = {
			SWT.Close, SWT.Paint, SWT.Deactivate
	};
	for ( int i = 0; i < popupEvents.length; i++ )
		popup.addListener( popupEvents[i], listener );
	int[] tableEvents = {
			SWT.MouseUp,
			SWT.Selection,
			SWT.Traverse,
			SWT.KeyDown,
			SWT.KeyUp,
			SWT.FocusIn,
			SWT.FocusOut,
			SWT.Dispose
	};
	for ( int i = 0; i < tableEvents.length; i++ )
		table.addListener( tableEvents[i], listener );
}
 
源代码3 项目: Pydev   文件: TableCombo.java
/**
 * creates the popup shell.
 * @param selectionIndex
 */
void createPopup(int selectionIndex) {
    // create shell and table
    popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP);

    // create table
    table = new Table(popup, SWT.SINGLE | SWT.FULL_SELECTION);

    if (font != null)
        table.setFont(font);
    if (foreground != null)
        table.setForeground(foreground);
    if (background != null)
        table.setBackground(background);

    // Add popup listeners
    int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate };
    for (int i = 0; i < popupEvents.length; i++) {
        popup.addListener(popupEvents[i], listener);
    }

    // add table listeners
    int[] tableEvents = { SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn,
            SWT.Dispose };
    for (int i = 0; i < tableEvents.length; i++) {
        table.addListener(tableEvents[i], listener);
    }

    // set the selection
    if (selectionIndex != -1) {
        table.setSelection(selectionIndex);
    }
}
 
源代码4 项目: Pydev   文件: KeyAssistDialog.java
/**
 * Creates a dialog area with a table of the partial matches for the current
 * key binding state. The table will be either the minimum width, or
 * <code>previousWidth</code> if it is not
 * <code>NO_REMEMBERED_WIDTH</code>.
 * 
 * @param parent
 *            The parent composite for the dialog area; must not be
 *            <code>null</code>.
 * @param partialMatches
 *            The lexicographically sorted map of partial matches for the
 *            current state; must not be <code>null</code> or empty.
 */
private final void createTableDialogArea(final Composite parent) {
    // Layout the table.
    completionsTable = new Table(parent, SWT.FULL_SELECTION | SWT.SINGLE);
    final GridData gridData = new GridData(GridData.FILL_BOTH);
    completionsTable.setLayoutData(gridData);
    completionsTable.setBackground(parent.getBackground());
    completionsTable.setLinesVisible(true);

    // Initialize the columns and rows.
    bindings.clear();
    final TableColumn columnCommandName = new TableColumn(completionsTable, SWT.LEFT, 0);
    final TableColumn columnKeySequence = new TableColumn(completionsTable, SWT.LEFT, 1);
    final Iterator itemsItr = keybindingToActionInfo.entrySet().iterator();
    while (itemsItr.hasNext()) {
        final Map.Entry entry = (Entry) itemsItr.next();
        final String sequence = (String) entry.getKey();
        final ActionInfo actionInfo = (ActionInfo) entry.getValue();
        final String[] text = { sequence, actionInfo.description };
        final TableItem item = new TableItem(completionsTable, SWT.NULL);
        item.setText(text);
        item.setData("ACTION_INFO", actionInfo);
        bindings.add(actionInfo);
    }

    Dialog.applyDialogFont(parent);
    columnKeySequence.pack();
    columnCommandName.pack();

    /*
     * If you double-click on the table, it should execute the selected
     * command.
     */
    completionsTable.addListener(SWT.DefaultSelection, new Listener() {
        @Override
        public final void handleEvent(final Event event) {
            executeKeyBinding(event);
        }
    });
}
 
源代码5 项目: saros   文件: NetworkPreferencePage.java
private Group createUpnpGroup(Composite parent) {

    Group group = new Group(parent, SWT.NONE);
    group.setText(Messages.NetworkPreferencePage_upnp_devices);

    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 1;

    group.setLayout(gridLayout);
    group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));

    gatewayInfo = new Label(group, SWT.CENTER);
    gatewayInfo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    upnpDevicesTable = new Table(group, SWT.CHECK | SWT.BORDER | SWT.FULL_SELECTION);

    upnpDevicesTable.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    upnpDevicesTable.addListener(
        SWT.Selection,
        new Listener() {
          @Override
          public void handleEvent(Event event) {
            if (event.detail == SWT.CHECK) handleGatewaySelection(event);
          }
        });

    gatewayInfo.setVisible(false);
    upnpDevicesTable.setVisible(false);

    return group;
  }
 
源代码6 项目: uima-uimaj   文件: AbstractSection.java
/**
 * New table.
 *
 * @param parent the parent
 * @param style the style
 * @param minHeight the min height
 * @param flags the flags
 * @return the table
 */
protected Table newTable(Composite parent, int style, int minHeight, int flags) {
  Table table = toolkit.createTable(parent, style);
  GridData gd = new GridData(GridData.FILL_BOTH);
  if (minHeight != NO_MIN_HEIGHT)
    gd.heightHint = minHeight;
  table.setLayoutData(gd);

  table.setLinesVisible(0 != (flags & LINES_VISIBLE));
  table.setHeaderVisible(0 != (flags & HEADER_VISIBLE));
  table.addListener(SWT.Selection, this);
  table.addListener(SWT.KeyUp, this); // delete key
  return table;
}
 
源代码7 项目: uima-uimaj   文件: AbstractDialog.java
/**
 * Styles = SWT.SINGLE / MULTI / CHECK / FULL_SELECTION / HIDE_SELECTION
 *
 * @param parent the parent
 * @param style the style
 * @return the new table widget
 */
protected Table newTable(Composite parent, int style) {
  Table table = new Table(parent, style | SWT.BORDER);
  GridData gd = new GridData(GridData.FILL_BOTH);
  table.setLayoutData(gd);
  table.addListener(SWT.Selection, this);
  table.addListener(SWT.KeyUp, this); // delete key
  return table;
}
 
源代码8 项目: olca-app   文件: TableClipboard.java
private static Action onCopy(Table table, Converter converter) {
	table.addListener(SWT.KeyUp, e -> {
		if (((e.stateMask & SWT.CTRL) == SWT.CTRL)
				&& (e.keyCode == 'c' || e.keyCode == 'C')) {
			copy(table, converter);
		}
	});
	ImageDescriptor image = Icon.COPY.descriptor();
	return Actions.create(M.Copy, image, () -> copy(table, converter));
}
 
源代码9 项目: olca-app   文件: TableClipboard.java
private static Action onPaste(Table table, Consumer<String> fn) {
	table.addListener(SWT.KeyUp, e -> {
		if (((e.stateMask & SWT.CTRL) == SWT.CTRL)
				&& (e.keyCode == 'v' || e.keyCode == 'V')) {
			paste(table, fn);
		}
	});
	ImageDescriptor image = Icon.PASTE.descriptor();
	return Actions.create(M.Paste, image, () -> paste(table, fn));
}
 
源代码10 项目: nebula   文件: PTWidgetTable.java
/**
 * @see org.eclipse.nebula.widgets.opal.propertytable.AbstractPTWidget#buildWidget(org.eclipse.swt.widgets.Composite)
 */
@Override
protected void buildWidget(final Composite parent) {
	table = new Table(parent, SWT.FULL_SELECTION);
	table.setLinesVisible(true);
	table.setHeaderVisible(true);
	table.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 3, 1));

	final TableColumn propertyColumn = new TableColumn(table, SWT.NONE);
	propertyColumn.setText(ResourceManager.getLabel(ResourceManager.PROPERTY));

	final TableColumn valueColumn = new TableColumn(table, SWT.NONE);
	valueColumn.setText(ResourceManager.getLabel(ResourceManager.VALUE));

	fillData();

	table.addControlListener(new ControlAdapter() {

		/**
		 * @see org.eclipse.swt.events.ControlAdapter#controlResized(org.eclipse.swt.events.ControlEvent)
		 */
		@Override
		public void controlResized(final ControlEvent e) {
			final Rectangle area = table.getParent().getClientArea();
			final Point size = table.computeSize(SWT.DEFAULT, SWT.DEFAULT);
			final ScrollBar vBar = table.getVerticalBar();
			int width = area.width - table.computeTrim(0, 0, 0, 0).width - vBar.getSize().x;
			if (size.y > area.height + table.getHeaderHeight()) {
				// Subtract the scrollbar width from the total column width
				// if a vertical scrollbar will be required
				final Point vBarSize = vBar.getSize();
				width -= vBarSize.x;
			}
			propertyColumn.pack();
			valueColumn.setWidth(width - propertyColumn.getWidth());
			table.removeControlListener(this);
		}

	});

	table.addListener(SWT.Selection, event -> {
		if (table.getSelectionCount() == 0 || table.getSelection()[0] == null) {
			return;
		}
		updateDescriptionPanel(table.getSelection()[0].getData());
	});

}
 
源代码11 项目: ermasterr   文件: CenteredContentCellPaint.java
public CenteredContentCellPaint(final Table tbl, final int colIndex) {
    this.colIndex = colIndex;
    tbl.addListener(SWT.EraseItem, this);
    tbl.addListener(SWT.PaintItem, this);
}
 
源代码12 项目: erflute   文件: CenteredContentCellPaint.java
public CenteredContentCellPaint(Table tbl, int colIndex) {
    this.colIndex = colIndex;
    tbl.addListener(SWT.EraseItem, this);
    tbl.addListener(SWT.PaintItem, this);
}
 
源代码13 项目: translationstudio8   文件: TableCombo.java
/**
 * creates the popup shell.
 * @param selectionIndex
 */
void createPopup(int selectionIndex) {
	// create shell and table
	popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP);

	// set style
	int style = getStyle();
	int tableStyle = SWT.SINGLE | SWT.V_SCROLL;
	if ((style & SWT.FLAT) != 0)
		tableStyle |= SWT.FLAT;
	if ((style & SWT.RIGHT_TO_LEFT) != 0)
		tableStyle |= SWT.RIGHT_TO_LEFT;
	if ((style & SWT.LEFT_TO_RIGHT) != 0)
		tableStyle |= SWT.LEFT_TO_RIGHT;

	// create table
	table = new Table(popup, SWT.SINGLE | SWT.FULL_SELECTION);

	if (font != null)
		table.setFont(font);
	if (foreground != null)
		table.setForeground(foreground);
	if (background != null)
		table.setBackground(background);

	// Add popup listeners
	int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate, SWT.Help };
	for (int i = 0; i < popupEvents.length; i++) {
		popup.addListener(popupEvents[i], listener);
	}

	// add table listeners
	int[] tableEvents = { SWT.MouseMove, SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp,
			SWT.FocusIn, SWT.Dispose };
	for (int i = 0; i < tableEvents.length; i++) {
		table.addListener(tableEvents[i], listener);
	}

	// set the selection
	if (selectionIndex != -1) {
		table.setSelection(selectionIndex);
	}
}
 
源代码14 项目: tmxeditor8   文件: TableCombo.java
/**
 * creates the popup shell.
 * @param selectionIndex
 */
void createPopup(int selectionIndex) {
	// create shell and table
	popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP);

	// set style
	int style = getStyle();
	int tableStyle = SWT.SINGLE | SWT.V_SCROLL;
	if ((style & SWT.FLAT) != 0)
		tableStyle |= SWT.FLAT;
	if ((style & SWT.RIGHT_TO_LEFT) != 0)
		tableStyle |= SWT.RIGHT_TO_LEFT;
	if ((style & SWT.LEFT_TO_RIGHT) != 0)
		tableStyle |= SWT.LEFT_TO_RIGHT;

	// create table
	table = new Table(popup, SWT.SINGLE | SWT.FULL_SELECTION);

	if (font != null)
		table.setFont(font);
	if (foreground != null)
		table.setForeground(foreground);
	if (background != null)
		table.setBackground(background);

	// Add popup listeners
	int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate, SWT.Help };
	for (int i = 0; i < popupEvents.length; i++) {
		popup.addListener(popupEvents[i], listener);
	}

	// add table listeners
	int[] tableEvents = { SWT.MouseMove, SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp,
			SWT.FocusIn, SWT.Dispose };
	for (int i = 0; i < tableEvents.length; i++) {
		table.addListener(tableEvents[i], listener);
	}

	// set the selection
	if (selectionIndex != -1) {
		table.setSelection(selectionIndex);
	}
}
 
源代码15 项目: birt   文件: ReportItemParametersDialog.java
private void buildUI( Composite parent )
{
	// sets the layout
	GridLayout layout = new GridLayout( );
	layout.horizontalSpacing = 10;
	layout.verticalSpacing = 10;
	parent.setLayout( layout );

	// create table and tableViewer
	table = new Table( parent, SWT.SINGLE
			| SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION );
	table.setLinesVisible( true );
	table.setHeaderVisible( true );
	GridData gridData = new GridData( GridData.FILL_BOTH );
	gridData.heightHint = 100;
	table.setLayoutData( gridData );
	for ( int i = 0; i < columnNames.length; i++ )
	{
		TableColumn column = new TableColumn( table, SWT.LEFT );
		column.setText( columnNames[i] );
		if ( i == 1 )
		{
			column.setWidth( 80 );
		}
		else
		{
			column.setWidth( 160 );
		}
	}
	
	table.addListener( SWT.KeyDown, new Listener( ) {

		public void handleEvent( Event event )
		{
			// Use space key to open expression builder to edit
			if ( event.keyCode == ' ' )
			{
				int selectionIndex = table.getSelectionIndex( );
				if ( selectionIndex < 0 )
				{
					return;
				}
				TableItem item = table.getItem( selectionIndex );
				Object[] pair = (Object[]) item.getData( );
				DataSetParameterHandle dataHandle = (DataSetParameterHandle) pair[0];
				ParamBindingHandle bindingHandle = (ParamBindingHandle) pair[1];
				String oldValue = bindingHandle == null ? null
						: bindingHandle.getExpression( );
				if ( oldValue == null )
				{
					oldValue = dataHandle.getDefaultValue( );
				}
				Object value = expressionCellEditor.openDialogBox( table,
						oldValue );
				setValue( bindingHandle, value, item );
			}

		}
	} );

	createTableViewer( );

}
 
源代码16 项目: ermaster-b   文件: CenteredContentCellPaint.java
public CenteredContentCellPaint(Table tbl, int colIndex) {
	this.colIndex = colIndex;
	tbl.addListener(SWT.EraseItem, this);
	tbl.addListener(SWT.PaintItem, this);
}