Java Code Examples for org.eclipse.swt.widgets.Composite#addPaintListener()

The following examples show how to use org.eclipse.swt.widgets.Composite#addPaintListener() . 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: InternalCompositeTable.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Utility method: Creates a new row object or recycles one that had been
 * previously created but was no longer needed.
 * 
 * @return The new row object.
 */
private TableRow getNewRow() {
	if (spareRows.size() > 0) {
		TableRow recycledRow = (TableRow) spareRows.removeFirst();
		recycledRow.setVisible(true);
		return recycledRow;
	}
	Control newControl = createInternalControl(controlHolder,
			rowConstructor);
	if (menu != null) {
		newControl.setMenu(menu);
	}
	fireRowConstructionEvent(newControl);
	TableRow newRow = new TableRow(this, newControl);
	if (newRow.getRowControl() instanceof Composite) {
		Composite rowComp = (Composite) newRow.getRowControl();
		if (rowComp.getLayout() instanceof GridRowLayout) {
			rowComp.setBackground(getBackground());
			rowComp.addPaintListener(rowPaintListener);
		}
	}
	return newRow;
}
 
Example 2
Source File: CustomWidgetBubbleExample.java    From swt-bling with MIT License 6 votes vote down vote up
public void run(Display display, final Shell shell) {
  shell.setLayout(new FillLayout());
  parentComposite = new Composite(shell, SWT.NONE);
  parentComposite.setLayout(new FillLayout());

  widget = new CustomImageWidget(parentComposite, display.getSystemImage(SWT.ICON_QUESTION));

  parentComposite.addPaintListener(new PaintListener() {
    public void paintControl(PaintEvent e) {
      Point shellSize = shell.getSize();
      Point centered = new Point((shellSize.x / 2) - (widget.getSize().x / 2),
                                 (shellSize.y / 2) - (widget.getSize().y / 2));
      widget.setLocation(centered);
      e.gc.drawImage(widget.getImage(), centered.x, centered.y);
    }
  });

  Bubble.createBubbleForCustomWidget(widget, "Here's some info about the custom icon. This item is drawn with a GC," +
          " and would traditionally have un-tooltip-able");

  shell.setSize(200, 200);
  shell.open();
}
 
Example 3
Source File: PatternImageEditorDialog.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public ItemFrame( Composite parent, Context context )
{
	super( parent, SWT.BORDER );

	this.context = context;
	GridLayout gl = createGridLayout( );
	gl.marginTop = MARGIN;
	gl.marginBottom = MARGIN;
	gl.marginLeft = MARGIN;
	gl.marginRight = MARGIN;
	setLayout( gl );
	view = new Composite( this, SWT.NO_BACKGROUND );
	view.setLayoutData( new GridData( VIEW_WIDTH, VIEW_HEIGHT ) );
	view.addPaintListener( this );
	view.addListener( SWT.MouseDown, this );
	view.addListener( SWT.KeyDown, this );
	view.addListener( SWT.Traverse, this );
	view.addListener( SWT.FocusIn, this );
	view.addListener( SWT.FocusOut, this );

	btnDropDown = new Button( this, SWT.ARROW | SWT.DOWN );
	btnDropDown.setLayoutData( new GridData( BUTTON_WIDTH,
			VIEW_HEIGHT ) );
	btnDropDown.addListener( SWT.Selection, this );
}
 
Example 4
Source File: PatternImageEditorDialog.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected Composite createDropDown( Composite parent )
{
	Composite composite = new Composite( parent, SWT.BORDER
			| SWT.DOUBLE_BUFFERED );
	GridData gd = new GridData( );
	gd.widthHint = CELL_WIDTH * 8 + MARGIN;
	gd.heightHint = CELL_HEIGHT * 8 + MARGIN;
	composite.setLayoutData( gd );

	composite.addListener( SWT.MouseDown, this );
	composite.addListener( SWT.FocusOut, this );
	composite.addListener( SWT.FocusIn, this );
	composite.addListener( SWT.KeyDown, this );
	composite.addListener( SWT.Traverse, this );
	composite.addPaintListener( this );
	return composite;
}
 
Example 5
Source File: OptionsConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
protected void highlight(final Composite parent, final Label labelControl, final Combo comboBox, final int color) {
	Object data= labelControl.getData();
	if (data == null) {
		if (color != HIGHLIGHT_NONE) {
			PaintListener painter= new HighlightPainter(parent, labelControl, comboBox, color);
			parent.addPaintListener(painter);
			labelControl.setData(painter);
		} else {
			return;
		}
	} else {
		if (color == HIGHLIGHT_NONE) {
			parent.removePaintListener((PaintListener) data);
			labelControl.setData(null);
		} else if (color != ((HighlightPainter) data).fColor){
			((HighlightPainter) data).fColor= color;
		} else {
			return;
		}
	}
	
	parent.redraw();
}
 
Example 6
Source File: CrosstabGrandTotalDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private Composite createTitleArea( Composite parent )
{
	int heightMargins = 3;
	int widthMargins = 8;
	final Composite titleArea = new Composite( parent, SWT.NONE );
	FormLayout layout = new FormLayout( );
	layout.marginHeight = heightMargins;
	layout.marginWidth = widthMargins;
	titleArea.setLayout( layout );

	Display display = parent.getDisplay( );
	Color background = JFaceColors.getBannerBackground( display );
	GridData layoutData = new GridData( GridData.FILL_HORIZONTAL );
	layoutData.heightHint = 20 + ( heightMargins * 2 );
	titleArea.setLayoutData( layoutData );
	titleArea.setBackground( background );

	titleArea.addPaintListener( new PaintListener( ) {

		public void paintControl( PaintEvent e )
		{
			e.gc.setForeground( titleArea.getDisplay( )
					.getSystemColor( SWT.COLOR_WIDGET_NORMAL_SHADOW ) );
			Rectangle bounds = titleArea.getClientArea( );
			bounds.height = bounds.height - 2;
			bounds.width = bounds.width - 1;
			e.gc.drawRectangle( bounds );
		}
	} );

	Label label = new Label( titleArea, SWT.NONE );
	label.setBackground( background );
	label.setFont( FontManager.getFont( label.getFont( ).toString( ),
			10,
			SWT.BOLD ) );
	label.setText( getTitle( ) );
	UIUtil.bindHelp( parent,
			IHelpContextIds.INSERT_EDIT_GRAND_TOTAL_DIALOG_ID );
	return titleArea;
}
 
Example 7
Source File: CrosstabPageBreakDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private Composite createTitleArea( Composite parent )
{
	int heightMargins = 3;
	int widthMargins = 8;
	final Composite titleArea = new Composite( parent, SWT.NONE );
	FormLayout layout = new FormLayout( );
	layout.marginHeight = heightMargins;
	layout.marginWidth = widthMargins;
	titleArea.setLayout( layout );

	Display display = parent.getDisplay( );
	Color background = JFaceColors.getBannerBackground( display );
	GridData layoutData = new GridData( GridData.FILL_HORIZONTAL );
	layoutData.heightHint = 20 + ( heightMargins * 2 );
	titleArea.setLayoutData( layoutData );
	titleArea.setBackground( background );

	titleArea.addPaintListener( new PaintListener( ) {

		public void paintControl( PaintEvent e )
		{
			e.gc.setForeground( titleArea.getDisplay( )
					.getSystemColor( SWT.COLOR_WIDGET_NORMAL_SHADOW ) );
			Rectangle bounds = titleArea.getClientArea( );
			bounds.height = bounds.height - 2;
			bounds.width = bounds.width - 1;
			e.gc.drawRectangle( bounds );
		}
	} );

	Label label = new Label( titleArea, SWT.NONE );
	label.setBackground( background );
	label.setFont( FontManager.getFont( label.getFont( ).toString( ),
			10,
			SWT.BOLD ) );
	label.setText( getTitle( ) );

	return titleArea;
}
 
Example 8
Source File: CrosstabSubTotalDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private Composite createTitleArea( Composite parent )
{
	int heightMargins = 3;
	int widthMargins = 8;
	final Composite titleArea = new Composite( parent, SWT.NONE );
	FormLayout layout = new FormLayout( );
	layout.marginHeight = heightMargins;
	layout.marginWidth = widthMargins;
	titleArea.setLayout( layout );

	Display display = parent.getDisplay( );
	Color background = JFaceColors.getBannerBackground( display );
	GridData layoutData = new GridData( GridData.FILL_HORIZONTAL );
	layoutData.heightHint = 20 + ( heightMargins * 2 );
	titleArea.setLayoutData( layoutData );
	titleArea.setBackground( background );

	titleArea.addPaintListener( new PaintListener( ) {

		public void paintControl( PaintEvent e )
		{
			e.gc.setForeground( titleArea.getDisplay( )
					.getSystemColor( SWT.COLOR_WIDGET_NORMAL_SHADOW ) );
			Rectangle bounds = titleArea.getClientArea( );
			bounds.height = bounds.height - 2;
			bounds.width = bounds.width - 1;
			e.gc.drawRectangle( bounds );
		}
	} );

	Label label = new Label( titleArea, SWT.NONE );
	label.setBackground( background );
	label.setFont( FontManager.getFont( label.getFont( ).toString( ),
			10,
			SWT.BOLD ) );
	label.setText( getTitle( ) );

	return titleArea;
}
 
Example 9
Source File: SelectableControlList.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
protected void addSeparator(Composite scrolledContents) {
  // a separator between connector descriptors
  Composite separator = new Composite(scrolledContents, SWT.NULL);
  GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 1).applyTo(
      separator);
  GridLayoutFactory.fillDefaults().applyTo(separator);
  separator.addPaintListener(new BorderPainter());
}
 
Example 10
Source File: BaseSelectableControlListControlFactory.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
protected void addSeparator(Composite parent) {
  Composite border = new Composite(parent, SWT.NULL);
  GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 1).applyTo(
      border);
  GridLayoutFactory.fillDefaults().applyTo(border);
  border.addPaintListener(new BorderPainter());
}
 
Example 11
Source File: GroupDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates the title area
 * 
 * @param parent
 *            the parent composite
 */
private void createTitleArea( Composite parent )
{
	int heightMargins = 3;
	int widthMargins = 8;
	final Composite titleArea = new Composite( parent, SWT.NONE );
	FormLayout layout = new FormLayout( );
	layout.marginHeight = heightMargins;
	layout.marginWidth = widthMargins;
	titleArea.setLayout( layout );

	Display display = parent.getDisplay( );
	Color background = JFaceColors.getBannerBackground( display );
	GridData layoutData = new GridData( GridData.FILL_HORIZONTAL );
	layoutData.heightHint = 20 + ( heightMargins * 2 );
	titleArea.setLayoutData( layoutData );
	titleArea.setBackground( background );

	titleArea.addPaintListener( new PaintListener( ) {

		public void paintControl( PaintEvent e )
		{
			e.gc.setForeground( titleArea.getDisplay( )
					.getSystemColor( SWT.COLOR_WIDGET_NORMAL_SHADOW ) );
			Rectangle bounds = titleArea.getClientArea( );
			bounds.height = bounds.height - 2;
			bounds.width = bounds.width - 1;
			e.gc.drawRectangle( bounds );
		}
	} );

	Label label = new Label( titleArea, SWT.NONE );
	label.setBackground( background );
	label.setFont( FontManager.getFont( label.getFont( ).toString( ),
			10,
			SWT.BOLD ) );
	label.setText( GROUP_DLG_AREA_MSG );
}
 
Example 12
Source File: FormWidgetFactory.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void paintBordersFor( Composite parent )
{
	// if (borderStyle == SWT.BORDER)
	// return;
	if ( borderPainter == null )
		borderPainter = new BorderPainter( );
	parent.removePaintListener( borderPainter );
	parent.addPaintListener( borderPainter );
}
 
Example 13
Source File: ModelSelectionPage.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void registerInputHandler(Composite composite) {
	composite.addPaintListener(new PaintListener() {
		private boolean init = false;

		@Override
		public void paintControl(PaintEvent e) {
			if (init) {
				composite.removePaintListener(this);
				return;
			}
			init = true;
			setInitialInput();
		}
	});
}
 
Example 14
Source File: InternalCompositeTable.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * If the header control hasn't been created yet, create and show it.
 */
private void showHeader() {
	if (myHeader == null && headerConstructor != null) {
		myHeader = createInternalControl(controlHolder, headerConstructor);
		fireHeaderConstructionEvent(myHeader);
		if (myHeader instanceof Composite) {
			Composite headerComp = (Composite) myHeader;
			if (headerComp.getLayout() instanceof GridRowLayout) {
				headerComp.addPaintListener(headerPaintListener);
			}
		}
           layoutHeaderOrRow(myHeader);
	}
}
 
Example 15
Source File: ReverseConversionWizardPage.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 创建文件列表区域
 * @param contents
 *            ;
 */
private Composite createFilesGroup(Composite contents) {
	Composite filesComposite = new Composite(contents, SWT.NONE);
	filesComposite.setLayout(new GridLayout(1, false));
	filesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));

	filesTable = new Table(filesComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI
			| SWT.FULL_SELECTION);

	GridData tableData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
	tableData.heightHint = 100;
	filesTable.setLayoutData(tableData);
	filesTable.setLinesVisible(true);
	filesTable.setHeaderVisible(true);

	filesTable.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			TableItem[] selected = filesTable.getSelection();
			if (selected.length == 0) {
				return;
			}

			String strTgtEnc = ""; //$NON-NLS-1$

			for (int i = 0; i < selected.length; i++) {
				String curTgtEnc = selected[i].getText(2);
				if (i == 0) {
					strTgtEnc = curTgtEnc;
				} else {
					if (!strTgtEnc.equals(curTgtEnc)) {
						strTgtEnc = ""; //$NON-NLS-1$
						break;
					}
				}
			}

			if (!"".equals(strTgtEnc)) { //$NON-NLS-1$
				tgtEncCombo.setText(strTgtEnc);
			} else {
				tgtEncCombo.deselectAll();
			}
		}
	});
	tableViewer = new TableViewer(filesTable);

	lineNumberColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
	lineNumberColumn.setText(Messages.getString("wizard.ReverseConversionWizardPage.lineNumberColumn"));
	
	xliffColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
	xliffColumn.setText(Messages.getString("wizard.ReverseConversionWizardPage.xliffColumn")); //$NON-NLS-1$

	tgtEncColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
	tgtEncColumn.setText(Messages.getString("wizard.ReverseConversionWizardPage.tgtEncColumn")); //$NON-NLS-1$

	targetColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
	targetColumn.setText(Messages.getString("wizard.ReverseConversionWizardPage.targetColumn")); //$NON-NLS-1$

	IValueProperty[] valueProperties = BeanProperties.values(ConversionConfigBean.class, new String[] {
			"index","source", "targetEncoding", "target" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
	ViewerSupport.bind(tableViewer, new WritableList(conversionConfigBeans, ConversionConfigBean.class),
			valueProperties);

	filesComposite.addPaintListener(new PaintListener() {
		public void paintControl(PaintEvent arg0) {
			int width = filesTable.getClientArea().width;
			lineNumberColumn.setWidth(width * 1 / 10);
			targetColumn.setWidth(width * 4 / 10);
			tgtEncColumn.setWidth(width * 1 / 10);
			xliffColumn.setWidth(width * 4 / 10);
		}
	});
	return filesComposite;
}
 
Example 16
Source File: ReverseConversionWizardPage.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 创建文件列表区域
 * @param contents
 *            ;
 */
private Composite createFilesGroup(Composite contents) {
	Composite filesComposite = new Composite(contents, SWT.NONE);
	filesComposite.setLayout(new GridLayout(1, false));
	filesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));

	filesTable = new Table(filesComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI
			| SWT.FULL_SELECTION);

	GridData tableData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
	tableData.heightHint = 100;
	filesTable.setLayoutData(tableData);
	filesTable.setLinesVisible(true);
	filesTable.setHeaderVisible(true);

	filesTable.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			TableItem[] selected = filesTable.getSelection();
			if (selected.length == 0) {
				return;
			}

			String strTgtEnc = ""; //$NON-NLS-1$

			for (int i = 0; i < selected.length; i++) {
				String curTgtEnc = selected[i].getText(1);
				if (i == 0) {
					strTgtEnc = curTgtEnc;
				} else {
					if (!strTgtEnc.equals(curTgtEnc)) {
						strTgtEnc = ""; //$NON-NLS-1$
						break;
					}
				}
			}

			if (!"".equals(strTgtEnc)) { //$NON-NLS-1$
				tgtEncCombo.setText(strTgtEnc);
			} else {
				tgtEncCombo.deselectAll();
			}
		}
	});
	tableViewer = new TableViewer(filesTable);

	xliffColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
	xliffColumn.setText("XLIFF 文件"); //$NON-NLS-1$

	tgtEncColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
	tgtEncColumn.setText("目标编码"); //$NON-NLS-1$

	targetColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
	targetColumn.setText("目标文件"); //$NON-NLS-1$

	IValueProperty[] valueProperties = BeanProperties.values(ConversionConfigBean.class, new String[] {
			"source", "targetEncoding", "target" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
	ViewerSupport.bind(tableViewer, new WritableList(conversionConfigBeans, ConversionConfigBean.class),
			valueProperties);

	filesComposite.addPaintListener(new PaintListener() {
		public void paintControl(PaintEvent arg0) {
			int width = filesTable.getClientArea().width;
			targetColumn.setWidth(width * 4 / 10);
			tgtEncColumn.setWidth(width * 2 / 10);
			xliffColumn.setWidth(width * 4 / 10);
		}
	});
	return filesComposite;
}
 
Example 17
Source File: ReverseConversionWizardPage.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 创建文件列表区域
 * @param contents
 *            ;
 */
private Composite createFilesGroup(Composite contents) {
	Composite filesComposite = new Composite(contents, SWT.NONE);
	filesComposite.setLayout(new GridLayout(1, false));
	filesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));

	filesTable = new Table(filesComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI
			| SWT.FULL_SELECTION);

	GridData tableData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
	tableData.heightHint = 100;
	filesTable.setLayoutData(tableData);
	filesTable.setLinesVisible(true);
	filesTable.setHeaderVisible(true);

	filesTable.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			TableItem[] selected = filesTable.getSelection();
			if (selected.length == 0) {
				return;
			}

			String strTgtEnc = ""; //$NON-NLS-1$

			for (int i = 0; i < selected.length; i++) {
				String curTgtEnc = selected[i].getText(2);
				if (i == 0) {
					strTgtEnc = curTgtEnc;
				} else {
					if (!strTgtEnc.equals(curTgtEnc)) {
						strTgtEnc = ""; //$NON-NLS-1$
						break;
					}
				}
			}

			if (!"".equals(strTgtEnc)) { //$NON-NLS-1$
				tgtEncCombo.setText(strTgtEnc);
			} else {
				tgtEncCombo.deselectAll();
			}
		}
	});
	tableViewer = new TableViewer(filesTable);

	lineNumberColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
	lineNumberColumn.setText(Messages.getString("wizard.ReverseConversionWizardPage.lineNumberColumn"));
	
	xliffColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
	xliffColumn.setText(Messages.getString("wizard.ReverseConversionWizardPage.xliffColumn")); //$NON-NLS-1$

	tgtEncColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
	tgtEncColumn.setText(Messages.getString("wizard.ReverseConversionWizardPage.tgtEncColumn")); //$NON-NLS-1$

	targetColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
	targetColumn.setText(Messages.getString("wizard.ReverseConversionWizardPage.targetColumn")); //$NON-NLS-1$

	IValueProperty[] valueProperties = BeanProperties.values(ConversionConfigBean.class, new String[] {
			"index","source", "targetEncoding", "target" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
	ViewerSupport.bind(tableViewer, new WritableList(conversionConfigBeans, ConversionConfigBean.class),
			valueProperties);

	filesComposite.addPaintListener(new PaintListener() {
		public void paintControl(PaintEvent arg0) {
			int width = filesTable.getClientArea().width;
			lineNumberColumn.setWidth(width * 1 / 10);
			targetColumn.setWidth(width * 4 / 10);
			tgtEncColumn.setWidth(width * 1 / 10);
			xliffColumn.setWidth(width * 4 / 10);
		}
	});
	return filesComposite;
}
 
Example 18
Source File: ReverseConversionWizardPage.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 创建文件列表区域
 * @param contents
 *            ;
 */
private Composite createFilesGroup(Composite contents) {
	Composite filesComposite = new Composite(contents, SWT.NONE);
	filesComposite.setLayout(new GridLayout(1, false));
	filesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));

	filesTable = new Table(filesComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI
			| SWT.FULL_SELECTION);

	GridData tableData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
	tableData.heightHint = 100;
	filesTable.setLayoutData(tableData);
	filesTable.setLinesVisible(true);
	filesTable.setHeaderVisible(true);

	filesTable.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			TableItem[] selected = filesTable.getSelection();
			if (selected.length == 0) {
				return;
			}

			String strTgtEnc = ""; //$NON-NLS-1$

			for (int i = 0; i < selected.length; i++) {
				String curTgtEnc = selected[i].getText(1);
				if (i == 0) {
					strTgtEnc = curTgtEnc;
				} else {
					if (!strTgtEnc.equals(curTgtEnc)) {
						strTgtEnc = ""; //$NON-NLS-1$
						break;
					}
				}
			}

			if (!"".equals(strTgtEnc)) { //$NON-NLS-1$
				tgtEncCombo.setText(strTgtEnc);
			} else {
				tgtEncCombo.deselectAll();
			}
		}
	});
	tableViewer = new TableViewer(filesTable);

	xliffColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
	xliffColumn.setText("XLIFF 文件"); //$NON-NLS-1$

	tgtEncColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
	tgtEncColumn.setText("目标编码"); //$NON-NLS-1$

	targetColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
	targetColumn.setText("目标文件"); //$NON-NLS-1$

	IValueProperty[] valueProperties = BeanProperties.values(ConversionConfigBean.class, new String[] {
			"source", "targetEncoding", "target" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
	ViewerSupport.bind(tableViewer, new WritableList(conversionConfigBeans, ConversionConfigBean.class),
			valueProperties);

	filesComposite.addPaintListener(new PaintListener() {
		public void paintControl(PaintEvent arg0) {
			int width = filesTable.getClientArea().width;
			targetColumn.setWidth(width * 4 / 10);
			tgtEncColumn.setWidth(width * 2 / 10);
			xliffColumn.setWidth(width * 4 / 10);
		}
	});
	return filesComposite;
}
 
Example 19
Source File: DecisionTableWizardPage.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void createControl(final Composite parent) {
    if (decisionTable.getDefaultAction() == null && wizard.getPossibleDefaultTableActions() != null
            && wizard.getPossibleDefaultTableActions().length > 0) {
        decisionTable.setDefaultAction(wizard.getPossibleDefaultTableActions()[0]);
    }

    final Composite res = new Composite(parent, SWT.NONE);
    res.setLayout(new GridLayout(1, false));

    final Group gridGroup = new Group(res, SWT.NONE);
    gridGroup.setText(Messages.table);
    gridGroup.setLayout(new GridLayout(1, false));
    final Label tableDescriptionLabel = new Label(gridGroup, SWT.WRAP);
    tableDescriptionLabel.setText(Messages.tableDescriptionLabel);
    tableDescriptionLabel.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
    final GridData gridGrouplayoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
    gridGrouplayoutData.minimumHeight = 150;
    gridGroup.setLayoutData(gridGrouplayoutData);
    gridParentScrollable = new ScrolledComposite(gridGroup, SWT.H_SCROLL | SWT.V_SCROLL);
    gridParentScrollable.setLayout(new GridLayout(1, false));
    gridParentScrollable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    gridPlaceHolder = new Composite(gridParentScrollable, SWT.BORDER);
    zebraGridPaintListener = new DecisionTableGridPaintListener();
    gridPlaceHolder.addPaintListener(zebraGridPaintListener);
    gridParentScrollable.setContent(gridPlaceHolder);

    final Group editLineGroup = new Group(res, SWT.NONE);
    editLineGroup.setText(Messages.editRow);
    editLineGroup.setLayout(new GridLayout(1, false));
    final GridData editLineGrouplayoutData = new GridData(SWT.FILL, SWT.FILL, true, false);
    gridGrouplayoutData.minimumHeight = 150;
    editLineGroup.setLayoutData(editLineGrouplayoutData);
    lineParentScrollable = new ScrolledComposite(editLineGroup, SWT.H_SCROLL | SWT.V_SCROLL);
    lineParentScrollable.setLayout(new FillLayout());
    lineParentScrollable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    linePlaceHolder = new Composite(lineParentScrollable, SWT.NONE);
    lineParentScrollable.setContent(linePlaceHolder);

    final Composite buttonComposite = new Composite(editLineGroup, SWT.NONE);
    buttonComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.DEFAULT, true, true));
    buttonComposite.setLayout(new GridLayout(3, false));
    updateLineButton = new Button(buttonComposite, SWT.PUSH);
    updateLineButton.setText(Messages.updateLine);
    updateLineButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            final int i = decisionTable.getLines().indexOf(toEditLine);
            decisionTable.getLines().remove(toEditLine);
            addLine(i, toEditLine.getAction());
            refresh(true, true);
        }
    });

    updateLineButton.setEnabled(false);

    refreshGrid();
    refreshLine();

    setControl(res);
}