Java Code Examples for org.eclipse.swt.widgets.Composite#getBounds()
The following examples show how to use
org.eclipse.swt.widgets.Composite#getBounds() .
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: TransitionTest1.java From nebula with Eclipse Public License 2.0 | 6 votes |
private void setCompImage(Composite comp) { int index = -1; if (comp == comp1) { index = 0; } else if (comp == comp2) { index = 1; } else if (comp == comp3) { index = 2; } if (index > -1) { tf.setSelection(index); comp.redraw(); comp.getDisplay().update(); comp.getDisplay().readAndDispatch(); Image image = new Image(comp.getDisplay(), comp.getBounds().width, comp.getBounds().height); GC gc = new GC(comp); gc.copyArea(image, 0, 0); gc.dispose(); compImage[index] = image; } }
Example 2
Source File: ImageLabel.java From SWET with MIT License | 6 votes |
@Override protected void onLayout(Composite composite, boolean flushCache) { Rectangle bounds = composite.getBounds(); Point imgPrefSize = image.computeSize(SWT.DEFAULT, bounds.height); Point textPrefSize = text.computeSize(bounds.width - imgPrefSize.x, SWT.DEFAULT); int y = 0; if (alignment == SWT.CENTER) y = (bounds.height - textPrefSize.y) / 2; else if (alignment == SWT.BOTTOM) y = bounds.height - textPrefSize.y; image.setBounds(0, 0, imgPrefSize.x, imgPrefSize.y); text.setBounds(imgPrefSize.x + hgap, y, textPrefSize.x, textPrefSize.y); }
Example 3
Source File: SWTUtil.java From SWET with MIT License | 5 votes |
public static void center(Composite parent, Shell child, double xfrac, double yfrac) { Display dsp = child.getDisplay(); Rectangle region = parent.isVisible() ? parent.getBounds() : getCurrentMonitorBounds(dsp); center(region, child, xfrac, yfrac); }
Example 4
Source File: SWTHelper.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
/** Ein Objekt innerhalb des parents zentrieren */ public static void center(final Shell parent, final Composite child){ if (parent != null && child != null) { Rectangle par = parent.getBounds(); Rectangle ch = child.getBounds(); if (par != null && ch != null) { int xOff = (par.width - ch.width) / 2; int yOff = (par.height - ch.height) / 2; child.setBounds(par.x + xOff, par.y + yOff, ch.width, ch.height); } } }
Example 5
Source File: BorderPainter.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
public void paintControl(PaintEvent e) { Composite composite = (Composite) e.widget; Rectangle bounds = composite.getBounds(); GC gc = e.gc; gc.setLineStyle(SWT.LINE_DOT); gc.drawLine(bounds.x, bounds.y, bounds.x + bounds.width, bounds.y); }
Example 6
Source File: EditableControlWidget.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected void drawBorder(final Composite container, Event e) { final GC gc = e.gc; final Display display = e.display; if (display != null && gc != null && !gc.isDisposed()) { final Control focused = display.getFocusControl(); gc.setAdvanced(true); gc.setForeground(getBorderColor(focused, container)); gc.setLineWidth(1); final Rectangle r = container.getBounds(); gc.drawRectangle(0, 0, r.width - 1, r.height - 1); } }
Example 7
Source File: GraphModelDialog.java From knowbi-pentaho-pdi-neo4j-output with Apache License 2.0 | 4 votes |
private void addGraphTab() { CTabItem wGraphTab = new CTabItem( wTabs, SWT.NONE ); wGraphTab.setText( "Graph" ); ScrolledComposite wGraphSComp = new ScrolledComposite( wTabs, SWT.V_SCROLL | SWT.H_SCROLL ); wGraphSComp.setLayout( new FillLayout() ); Composite wGraphComp = new Composite( wGraphSComp, SWT.NONE ); props.setLook( wGraphComp ); FormLayout formLayout = new FormLayout(); formLayout.marginWidth = 3; formLayout.marginHeight = 3; wGraphComp.setLayout( formLayout ); Button wAuto = new Button( wGraphComp, SWT.PUSH ); wAuto.setText( "Auto" ); FormData fdAuto = new FormData(); fdAuto.right = new FormAttachment( 100, 0 ); fdAuto.bottom = new FormAttachment( 100, 0 ); wAuto.setLayoutData( fdAuto ); wAuto.addListener( SWT.Selection, this::autoModelLayout ); // This is the canvas on which we draw the graph // wCanvas = new Canvas( wGraphComp, SWT.NONE ); props.setLook( wCanvas ); FormData fdCanvas = new FormData(); fdCanvas.left = new FormAttachment( 0, 0 ); fdCanvas.right = new FormAttachment( 100, 0 ); fdCanvas.top = new FormAttachment( 0, 0 ); fdCanvas.bottom = new FormAttachment( 100, 0 ); wCanvas.setLayoutData( fdCanvas ); wCanvas.addPaintListener( this::paintCanvas ); wCanvas.addListener( SWT.MouseDown, this::graphMouseDown ); wCanvas.addListener( SWT.MouseUp, this::graphMouseUp ); wCanvas.addListener( SWT.MouseMove, this::moveGraphObject ); wCanvas.addListener( SWT.MouseDoubleClick, this::editGraphObject ); FormData fdGraphComp = new FormData(); fdGraphComp.left = new FormAttachment( 0, 0 ); fdGraphComp.top = new FormAttachment( 0, 0 ); fdGraphComp.right = new FormAttachment( 100, 0 ); fdGraphComp.bottom = new FormAttachment( wAuto, -margin ); wGraphComp.setLayoutData( fdGraphComp ); wGraphComp.pack(); Rectangle bounds = wGraphComp.getBounds(); wGraphSComp.setContent( wGraphComp ); wGraphSComp.setExpandHorizontal( true ); wGraphSComp.setExpandVertical( true ); wGraphSComp.setMinWidth( bounds.width ); wGraphSComp.setMinHeight( bounds.height ); wGraphTab.setControl( wGraphSComp ); }
Example 8
Source File: StarModelerPerspective.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public void createTabForDomain(final StarDomain starDomain) throws Exception { SpoonPerspectiveManager.getInstance().activatePerspective(getClass()); final XulTabAndPanel tabAndPanel = createTab(); PropsUI props = PropsUI.getInstance(); final Composite comp = (Composite) tabAndPanel.panel.getManagedObject(); props.setLook(comp); comp.setLayout(new FillLayout()); final ScrolledComposite scrolledComposite = new ScrolledComposite(comp, SWT.V_SCROLL | SWT.H_SCROLL); props.setLook(scrolledComposite); scrolledComposite.setLayout(new FillLayout()); final Composite parentComposite = new Composite(scrolledComposite, SWT.NONE); props.setLook(parentComposite); int margin = Const.MARGIN; FormLayout formLayout = new FormLayout(); formLayout.marginLeft=10; formLayout.marginRight=10; formLayout.marginTop=10; formLayout.marginBottom=10; formLayout.spacing=margin; parentComposite.setLayout(formLayout); Control lastControl = addModelsGroupToDomainTab(starDomain, tabAndPanel, parentComposite); lastControl = addSharedDimensionsGroupToDomainTab(starDomain, tabAndPanel, parentComposite, lastControl); lastControl = addPhysicalGroupToDomainTab(starDomain, tabAndPanel, parentComposite, lastControl); parentComposite.layout(true); parentComposite.pack(); // What's the size: Rectangle bounds = parentComposite.getBounds(); scrolledComposite.setContent(parentComposite); scrolledComposite.setExpandHorizontal(true); scrolledComposite.setExpandVertical(true); scrolledComposite.setMinWidth(bounds.width); scrolledComposite.setMinHeight(bounds.height); models.add(starDomain); setNameForTab(tabAndPanel.tab, starDomain.getDomain().getName(defaultLocale)); setMetaForTab(tabAndPanel.tab, starDomain); setSelectedMeta(starDomain); setActive(true); comp.layout(); Spoon.getInstance().enableMenus(); }
Example 9
Source File: JobExecutorDialog.java From pentaho-kettle with Apache License 2.0 | 4 votes |
private void addResultRowsTab() { final CTabItem wTab = new CTabItem( wTabFolder, SWT.NONE ); wTab.setText( BaseMessages.getString( PKG, "JobExecutorDialog.ResultRows.Title" ) ); wTab.setToolTipText( BaseMessages.getString( PKG, "JobExecutorDialog.ResultRows.Tooltip" ) ); ScrolledComposite scrolledComposite = new ScrolledComposite( wTabFolder, SWT.V_SCROLL | SWT.H_SCROLL ); scrolledComposite.setLayout( new FillLayout() ); Composite wInputComposite = new Composite( scrolledComposite, SWT.NONE ); props.setLook( wInputComposite ); FormLayout tabLayout = new FormLayout(); tabLayout.marginWidth = 15; tabLayout.marginHeight = 15; wInputComposite.setLayout( tabLayout ); wlResultRowsTarget = new Label( wInputComposite, SWT.RIGHT ); props.setLook( wlResultRowsTarget ); wlResultRowsTarget.setText( BaseMessages.getString( PKG, "JobExecutorDialog.ResultRowsTarget.Label" ) ); FormData fdlResultRowsTarget = new FormData(); fdlResultRowsTarget.top = new FormAttachment( 0, 0 ); fdlResultRowsTarget.left = new FormAttachment( 0, 0 ); // First one in the left wlResultRowsTarget.setLayoutData( fdlResultRowsTarget ); wResultRowsTarget = new CCombo( wInputComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER ); props.setLook( wResultRowsTarget ); wResultRowsTarget.addModifyListener( lsMod ); FormData fdResultRowsTarget = new FormData(); fdResultRowsTarget.width = 250; fdResultRowsTarget.top = new FormAttachment( wlResultRowsTarget, 5 ); fdResultRowsTarget.left = new FormAttachment( 0, 0 ); // To the right wResultRowsTarget.setLayoutData( fdResultRowsTarget ); wlResultFields = new Label( wInputComposite, SWT.NONE ); wlResultFields.setText( BaseMessages.getString( PKG, "JobExecutorDialog.ResultFields.Label" ) ); props.setLook( wlResultFields ); FormData fdlResultFields = new FormData(); fdlResultFields.left = new FormAttachment( 0, 0 ); fdlResultFields.top = new FormAttachment( wResultRowsTarget, 10 ); wlResultFields.setLayoutData( fdlResultFields ); int nrRows = ( jobExecutorMeta.getResultRowsField() != null ? jobExecutorMeta.getResultRowsField().length : 1 ); ColumnInfo[] ciResultFields = new ColumnInfo[] { new ColumnInfo( BaseMessages.getString( PKG, "JobExecutorDialog.ColumnInfo.Field" ), ColumnInfo.COLUMN_TYPE_TEXT, false, false ), new ColumnInfo( BaseMessages.getString( PKG, "JobExecutorDialog.ColumnInfo.Type" ), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaFactory.getValueMetaNames() ), new ColumnInfo( BaseMessages.getString( PKG, "JobExecutorDialog.ColumnInfo.Length" ), ColumnInfo.COLUMN_TYPE_TEXT, false ), new ColumnInfo( BaseMessages.getString( PKG, "JobExecutorDialog.ColumnInfo.Precision" ), ColumnInfo.COLUMN_TYPE_TEXT, false ), }; wResultRowsFields = new TableView( transMeta, wInputComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, ciResultFields, nrRows, false, lsMod, props, false ); FormData fdResultFields = new FormData(); fdResultFields.left = new FormAttachment( 0, 0 ); fdResultFields.top = new FormAttachment( wlResultFields, 5 ); fdResultFields.right = new FormAttachment( 100, 0 ); fdResultFields.bottom = new FormAttachment( 100, 0 ); wResultRowsFields.setLayoutData( fdResultFields ); wResultRowsFields.getTable().addListener( SWT.Resize, new ColumnsResizer( 0, 25, 25, 25, 25 ) ); wInputComposite.pack(); Rectangle bounds = wInputComposite.getBounds(); scrolledComposite.setContent( wInputComposite ); scrolledComposite.setExpandHorizontal( true ); scrolledComposite.setExpandVertical( true ); scrolledComposite.setMinWidth( bounds.width ); scrolledComposite.setMinHeight( bounds.height ); wTab.setControl( scrolledComposite ); wTabFolder.setSelection( wTab ); }
Example 10
Source File: JobExecutorDialog.java From pentaho-kettle with Apache License 2.0 | 4 votes |
private void addResultFilesTab() { final CTabItem wTab = new CTabItem( wTabFolder, SWT.NONE ); wTab.setText( BaseMessages.getString( PKG, "JobExecutorDialog.ResultFiles.Title" ) ); wTab.setToolTipText( BaseMessages.getString( PKG, "JobExecutorDialog.ResultFiles.Tooltip" ) ); ScrolledComposite scrolledComposite = new ScrolledComposite( wTabFolder, SWT.V_SCROLL | SWT.H_SCROLL ); scrolledComposite.setLayout( new FillLayout() ); Composite wInputComposite = new Composite( scrolledComposite, SWT.NONE ); props.setLook( wInputComposite ); FormLayout tabLayout = new FormLayout(); tabLayout.marginWidth = 15; tabLayout.marginHeight = 15; wInputComposite.setLayout( tabLayout ); wlResultFilesTarget = new Label( wInputComposite, SWT.RIGHT ); props.setLook( wlResultFilesTarget ); wlResultFilesTarget.setText( BaseMessages.getString( PKG, "JobExecutorDialog.ResultFilesTarget.Label" ) ); FormData fdlResultFilesTarget = new FormData(); fdlResultFilesTarget.top = new FormAttachment( 0, 0 ); fdlResultFilesTarget.left = new FormAttachment( 0, 0 ); // First one in the left wlResultFilesTarget.setLayoutData( fdlResultFilesTarget ); wResultFilesTarget = new CCombo( wInputComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER ); props.setLook( wResultFilesTarget ); wResultFilesTarget.addModifyListener( lsMod ); FormData fdResultFilesTarget = new FormData(); fdResultFilesTarget.width = 250; fdResultFilesTarget.top = new FormAttachment( wlResultFilesTarget, 5 ); fdResultFilesTarget.left = new FormAttachment( 0, 0 ); // To the right wResultFilesTarget.setLayoutData( fdResultFilesTarget ); // ResultFileNameField // wlResultFileNameField = new Label( wInputComposite, SWT.RIGHT ); props.setLook( wlResultFileNameField ); wlResultFileNameField.setText( BaseMessages.getString( PKG, "JobExecutorDialog.ResultFileNameField.Label" ) ); FormData fdlResultFileNameField = new FormData(); fdlResultFileNameField.top = new FormAttachment( wResultFilesTarget, 10 ); fdlResultFileNameField.left = new FormAttachment( 0, 0 ); // First one in the left wlResultFileNameField.setLayoutData( fdlResultFileNameField ); wResultFileNameField = new TextVar( transMeta, wInputComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER ); props.setLook( wResultFileNameField ); wResultFileNameField.addModifyListener( lsMod ); FormData fdResultFileNameField = new FormData(); fdResultFileNameField.width = 250; fdResultFileNameField.top = new FormAttachment( wlResultFileNameField, 5 ); fdResultFileNameField.left = new FormAttachment( 0, 0 ); // To the right wResultFileNameField.setLayoutData( fdResultFileNameField ); wInputComposite.pack(); Rectangle bounds = wInputComposite.getBounds(); scrolledComposite.setContent( wInputComposite ); scrolledComposite.setExpandHorizontal( true ); scrolledComposite.setExpandVertical( true ); scrolledComposite.setMinWidth( bounds.width ); scrolledComposite.setMinHeight( bounds.height ); wTab.setControl( scrolledComposite ); wTabFolder.setSelection( wTab ); }
Example 11
Source File: TransExecutorDialog.java From pentaho-kettle with Apache License 2.0 | 4 votes |
private void addResultRowsTab() { final CTabItem wTab = new CTabItem( wTabFolder, SWT.NONE ); wTab.setText( BaseMessages.getString( PKG, "TransExecutorDialog.ResultRows.Title" ) ); wTab.setToolTipText( BaseMessages.getString( PKG, "TransExecutorDialog.ResultRows.Tooltip" ) ); ScrolledComposite scrolledComposite = new ScrolledComposite( wTabFolder, SWT.V_SCROLL | SWT.H_SCROLL ); scrolledComposite.setLayout( new FillLayout() ); Composite wInputComposite = new Composite( scrolledComposite, SWT.NONE ); props.setLook( wInputComposite ); FormLayout tabLayout = new FormLayout(); tabLayout.marginWidth = 15; tabLayout.marginHeight = 15; wInputComposite.setLayout( tabLayout ); wlResultRowsTarget = new Label( wInputComposite, SWT.RIGHT ); props.setLook( wlResultRowsTarget ); wlResultRowsTarget.setText( BaseMessages.getString( PKG, "TransExecutorDialog.OutputRowsSource.Label" ) ); FormData fdlResultRowsTarget = new FormData(); fdlResultRowsTarget.top = new FormAttachment( 0, 0 ); fdlResultRowsTarget.left = new FormAttachment( 0, 0 ); // First one in the left wlResultRowsTarget.setLayoutData( fdlResultRowsTarget ); wOutputRowsSource = new CCombo( wInputComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER ); props.setLook( wOutputRowsSource ); wOutputRowsSource.addModifyListener( lsMod ); FormData fdResultRowsTarget = new FormData(); fdResultRowsTarget.width = 250; fdResultRowsTarget.top = new FormAttachment( wlResultRowsTarget, 5 ); fdResultRowsTarget.left = new FormAttachment( 0, 0 ); // To the right wOutputRowsSource.setLayoutData( fdResultRowsTarget ); wlOutputFields = new Label( wInputComposite, SWT.NONE ); wlOutputFields.setText( BaseMessages.getString( PKG, "TransExecutorDialog.ResultFields.Label" ) ); props.setLook( wlOutputFields ); FormData fdlResultFields = new FormData(); fdlResultFields.left = new FormAttachment( 0, 0 ); fdlResultFields.top = new FormAttachment( wOutputRowsSource, 10 ); wlOutputFields.setLayoutData( fdlResultFields ); int nrRows = ( transExecutorMeta.getOutputRowsField() != null ? transExecutorMeta.getOutputRowsField().length : 1 ); ColumnInfo[] ciResultFields = new ColumnInfo[] { new ColumnInfo( BaseMessages.getString( PKG, "TransExecutorDialog.ColumnInfo.Field" ), ColumnInfo.COLUMN_TYPE_TEXT, false, false ), new ColumnInfo( BaseMessages.getString( PKG, "TransExecutorDialog.ColumnInfo.Type" ), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaFactory.getValueMetaNames() ), new ColumnInfo( BaseMessages.getString( PKG, "TransExecutorDialog.ColumnInfo.Length" ), ColumnInfo.COLUMN_TYPE_TEXT, false ), new ColumnInfo( BaseMessages.getString( PKG, "TransExecutorDialog.ColumnInfo.Precision" ), ColumnInfo.COLUMN_TYPE_TEXT, false ), }; wOutputFields = new TableView( transMeta, wInputComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, ciResultFields, nrRows, false, lsMod, props, false ); FormData fdResultFields = new FormData(); fdResultFields.left = new FormAttachment( 0, 0 ); fdResultFields.top = new FormAttachment( wlOutputFields, 5 ); fdResultFields.right = new FormAttachment( 100, 0 ); fdResultFields.bottom = new FormAttachment( 100, 0 ); wOutputFields.setLayoutData( fdResultFields ); wOutputFields.getTable().addListener( SWT.Resize, new ColumnsResizer( 0, 25, 25, 25, 25 ) ); wInputComposite.pack(); Rectangle bounds = wInputComposite.getBounds(); scrolledComposite.setContent( wInputComposite ); scrolledComposite.setExpandHorizontal( true ); scrolledComposite.setExpandVertical( true ); scrolledComposite.setMinWidth( bounds.width ); scrolledComposite.setMinHeight( bounds.height ); wTab.setControl( scrolledComposite ); wTabFolder.setSelection( wTab ); }
Example 12
Source File: TransExecutorDialog.java From pentaho-kettle with Apache License 2.0 | 4 votes |
private void addResultFilesTab() { final CTabItem wTab = new CTabItem( wTabFolder, SWT.NONE ); wTab.setText( BaseMessages.getString( PKG, "TransExecutorDialog.ResultFiles.Title" ) ); wTab.setToolTipText( BaseMessages.getString( PKG, "TransExecutorDialog.ResultFiles.Tooltip" ) ); ScrolledComposite scrolledComposite = new ScrolledComposite( wTabFolder, SWT.V_SCROLL | SWT.H_SCROLL ); scrolledComposite.setLayout( new FillLayout() ); Composite wInputComposite = new Composite( scrolledComposite, SWT.NONE ); props.setLook( wInputComposite ); FormLayout tabLayout = new FormLayout(); tabLayout.marginWidth = 15; tabLayout.marginHeight = 15; wInputComposite.setLayout( tabLayout ); wlResultFilesTarget = new Label( wInputComposite, SWT.RIGHT ); props.setLook( wlResultFilesTarget ); wlResultFilesTarget.setText( BaseMessages.getString( PKG, "TransExecutorDialog.ResultFilesTarget.Label" ) ); FormData fdlResultFilesTarget = new FormData(); fdlResultFilesTarget.top = new FormAttachment( 0, 0 ); fdlResultFilesTarget.left = new FormAttachment( 0, 0 ); // First one in the left wlResultFilesTarget.setLayoutData( fdlResultFilesTarget ); wResultFilesTarget = new CCombo( wInputComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER ); props.setLook( wResultFilesTarget ); wResultFilesTarget.addModifyListener( lsMod ); FormData fdResultFilesTarget = new FormData(); fdResultFilesTarget.width = 250; fdResultFilesTarget.top = new FormAttachment( wlResultFilesTarget, 5 ); fdResultFilesTarget.left = new FormAttachment( 0, 0 ); // To the right wResultFilesTarget.setLayoutData( fdResultFilesTarget ); // ResultFileNameField // wlResultFileNameField = new Label( wInputComposite, SWT.RIGHT ); props.setLook( wlResultFileNameField ); wlResultFileNameField.setText( BaseMessages.getString( PKG, "TransExecutorDialog.ResultFileNameField.Label" ) ); FormData fdlResultFileNameField = new FormData(); fdlResultFileNameField.top = new FormAttachment( wResultFilesTarget, 10 ); fdlResultFileNameField.left = new FormAttachment( 0, 0 ); // First one in the left wlResultFileNameField.setLayoutData( fdlResultFileNameField ); wResultFileNameField = new TextVar( transMeta, wInputComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER ); props.setLook( wResultFileNameField ); wResultFileNameField.addModifyListener( lsMod ); FormData fdResultFileNameField = new FormData(); fdResultFileNameField.width = 250; fdResultFileNameField.top = new FormAttachment( wlResultFileNameField, 5 ); fdResultFileNameField.left = new FormAttachment( 0, 0 ); // To the right wResultFileNameField.setLayoutData( fdResultFileNameField ); wInputComposite.pack(); Rectangle bounds = wInputComposite.getBounds(); scrolledComposite.setContent( wInputComposite ); scrolledComposite.setExpandHorizontal( true ); scrolledComposite.setExpandVertical( true ); scrolledComposite.setMinWidth( bounds.width ); scrolledComposite.setMinHeight( bounds.height ); wTab.setControl( scrolledComposite ); wTabFolder.setSelection( wTab ); }
Example 13
Source File: DragButtonMouseEvents.java From codeexamples-eclipse with Eclipse Public License 1.0 | 4 votes |
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); final Composite composite = new Composite(shell, SWT.NONE); composite.setEnabled(false); composite.setLayout(new FillLayout()); Button button = new Button(composite, SWT.PUSH); button.setText("Button"); composite.pack(); composite.setLocation(10, 10); final Point[] offset = new Point[1]; Listener listener = new Listener() { public void handleEvent(Event event) { switch (event.type) { case SWT.MouseDown: Rectangle rect = composite.getBounds(); if (rect.contains(event.x, event.y)) { Point pt1 = composite.toDisplay(0, 0); Point pt2 = shell.toDisplay(event.x, event.y); offset[0] = new Point(pt2.x - pt1.x, pt2.y - pt1.y); } break; case SWT.MouseMove: if (offset[0] != null) { Point pt = offset[0]; composite.setLocation(event.x - pt.x, event.y - pt.y); } break; case SWT.MouseUp: offset[0] = null; break; } } }; shell.addListener(SWT.MouseDown, listener); shell.addListener(SWT.MouseUp, listener); shell.addListener(SWT.MouseMove, listener); shell.setSize(300, 300); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
Example 14
Source File: PipelineExecutorDialog.java From hop with Apache License 2.0 | 4 votes |
private void addResultFilesTab() { final CTabItem wTab = new CTabItem( wTabFolder, SWT.NONE ); wTab.setText( BaseMessages.getString( PKG, "PipelineExecutorDialog.ResultFiles.Title" ) ); wTab.setToolTipText( BaseMessages.getString( PKG, "PipelineExecutorDialog.ResultFiles.Tooltip" ) ); ScrolledComposite scrolledComposite = new ScrolledComposite( wTabFolder, SWT.V_SCROLL | SWT.H_SCROLL ); scrolledComposite.setLayout( new FillLayout() ); Composite wInputComposite = new Composite( scrolledComposite, SWT.NONE ); props.setLook( wInputComposite ); FormLayout tabLayout = new FormLayout(); tabLayout.marginWidth = 15; tabLayout.marginHeight = 15; wInputComposite.setLayout( tabLayout ); wlResultFilesTarget = new Label( wInputComposite, SWT.RIGHT ); props.setLook( wlResultFilesTarget ); wlResultFilesTarget.setText( BaseMessages.getString( PKG, "PipelineExecutorDialog.ResultFilesTarget.Label" ) ); FormData fdlResultFilesTarget = new FormData(); fdlResultFilesTarget.top = new FormAttachment( 0, 0 ); fdlResultFilesTarget.left = new FormAttachment( 0, 0 ); // First one in the left wlResultFilesTarget.setLayoutData( fdlResultFilesTarget ); wResultFilesTarget = new CCombo( wInputComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER ); props.setLook( wResultFilesTarget ); wResultFilesTarget.addModifyListener( lsMod ); FormData fdResultFilesTarget = new FormData(); fdResultFilesTarget.width = 250; fdResultFilesTarget.top = new FormAttachment( wlResultFilesTarget, 5 ); fdResultFilesTarget.left = new FormAttachment( 0, 0 ); // To the right wResultFilesTarget.setLayoutData( fdResultFilesTarget ); // ResultFileNameField // wlResultFileNameField = new Label( wInputComposite, SWT.RIGHT ); props.setLook( wlResultFileNameField ); wlResultFileNameField.setText( BaseMessages.getString( PKG, "PipelineExecutorDialog.ResultFileNameField.Label" ) ); FormData fdlResultFileNameField = new FormData(); fdlResultFileNameField.top = new FormAttachment( wResultFilesTarget, 10 ); fdlResultFileNameField.left = new FormAttachment( 0, 0 ); // First one in the left wlResultFileNameField.setLayoutData( fdlResultFileNameField ); wResultFileNameField = new TextVar( pipelineMeta, wInputComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER ); props.setLook( wResultFileNameField ); wResultFileNameField.addModifyListener( lsMod ); FormData fdResultFileNameField = new FormData(); fdResultFileNameField.width = 250; fdResultFileNameField.top = new FormAttachment( wlResultFileNameField, 5 ); fdResultFileNameField.left = new FormAttachment( 0, 0 ); // To the right wResultFileNameField.setLayoutData( fdResultFileNameField ); wInputComposite.pack(); Rectangle bounds = wInputComposite.getBounds(); scrolledComposite.setContent( wInputComposite ); scrolledComposite.setExpandHorizontal( true ); scrolledComposite.setExpandVertical( true ); scrolledComposite.setMinWidth( bounds.width ); scrolledComposite.setMinHeight( bounds.height ); wTab.setControl( scrolledComposite ); wTabFolder.setSelection( wTab ); }
Example 15
Source File: BeamPerspective.java From kettle-beam with Apache License 2.0 | 4 votes |
private void addAdminTab() throws Exception { final XulTabAndPanel tabAndPanel = createTab(); tabAndPanel.tab.setLabel( "Admin" ); PropsUI props = PropsUI.getInstance(); final Composite comp = (Composite) tabAndPanel.panel.getManagedObject(); props.setLook( comp ); comp.setLayout( new FillLayout() ); ScrolledComposite scrolledComposite = new ScrolledComposite( comp, SWT.V_SCROLL | SWT.H_SCROLL ); props.setLook( scrolledComposite ); scrolledComposite.setLayout( new FillLayout() ); final Composite parentComposite = new Composite( scrolledComposite, SWT.NONE ); props.setLook( parentComposite ); FormLayout formLayout = new FormLayout(); formLayout.marginLeft = 10; formLayout.marginRight = 10; formLayout.marginTop = 10; formLayout.marginBottom = 10; formLayout.spacing = Const.MARGIN; parentComposite.setLayout( formLayout ); parentComposite.layout( true ); parentComposite.pack(); // What's the size: Rectangle bounds = parentComposite.getBounds(); scrolledComposite.setContent( parentComposite ); scrolledComposite.setExpandHorizontal( true ); scrolledComposite.setExpandVertical( true ); scrolledComposite.setMinWidth( bounds.width ); scrolledComposite.setMinHeight( bounds.height ); comp.layout(); }
Example 16
Source File: EnterOptionsDialog.java From hop with Apache License 2.0 | 4 votes |
private void addPluginTabs() { // Add a new tab for every config plugin which is also a GuiPlugin // Then simply add the widgets on a separate tab // HopGui hopGui = HopGui.getInstance(); PluginRegistry pluginRegistry = PluginRegistry.getInstance(); List<IPlugin> configPlugins = pluginRegistry.getPlugins( ConfigPluginType.class ); for ( IPlugin configPlugin : configPlugins ) { String guiPluginId = configPlugin.getName(); // Mapped like that in ConfigPluginType if ( StringUtils.isEmpty( guiPluginId ) ) { continue; } IPlugin guiPlugin = pluginRegistry.findPluginWithId( GuiPluginType.class, guiPluginId ); if ( guiPlugin != null ) { // Load the instance // try { Object emptySourceData = pluginRegistry.loadClass( guiPlugin ); Method method = emptySourceData.getClass().getMethod( "getInstance" ); Object sourceData = method.invoke( null, null ); // This config plugin is also a GUI plugin // Add a tab // CTabItem wPluginTab = new CTabItem( wTabFolder, SWT.NONE ); wPluginTab.setText( Const.NVL( guiPlugin.getDescription(), "" ) ); ScrolledComposite sOtherComp = new ScrolledComposite( wTabFolder, SWT.V_SCROLL | SWT.H_SCROLL ); sOtherComp.setLayout( new FormLayout() ); Composite wPluginsComp = new Composite( sOtherComp, SWT.NONE ); props.setLook( wPluginsComp ); wPluginsComp.setLayout( new FormLayout() ); GuiCompositeWidgets compositeWidgets = new GuiCompositeWidgets( hopGui.getVariables(), 20 ); compositeWidgets.createCompositeWidgets( sourceData, null, wPluginsComp, guiPlugin.getIds()[ 0 ], null ); compositeWidgets.setWidgetsContents( sourceData, wPluginsComp, guiPlugin.getIds()[ 0 ] ); wPluginsComp.pack(); Rectangle bounds = wPluginsComp.getBounds(); sOtherComp.setContent( wPluginsComp ); sOtherComp.setExpandHorizontal( true ); sOtherComp.setExpandVertical( true ); sOtherComp.setMinWidth( bounds.width ); sOtherComp.setMinHeight( bounds.height ); wPluginTab.setControl( sOtherComp ); } catch ( Exception e ) { new ErrorDialog( shell, "Error", "Error handling configuration options for GUI plugin " + guiPluginId, e ); } } } // /////////////////////////////////////////////////////////// // / END OF PLUGINS TAB // /////////////////////////////////////////////////////////// }
Example 17
Source File: WorkflowExecutorDialog.java From hop with Apache License 2.0 | 4 votes |
private void addResultRowsTab() { final CTabItem wTab = new CTabItem( wTabFolder, SWT.NONE ); wTab.setText( BaseMessages.getString( PKG, "JobExecutorDialog.ResultRows.Title" ) ); wTab.setToolTipText( BaseMessages.getString( PKG, "JobExecutorDialog.ResultRows.Tooltip" ) ); ScrolledComposite scrolledComposite = new ScrolledComposite( wTabFolder, SWT.V_SCROLL | SWT.H_SCROLL ); scrolledComposite.setLayout( new FillLayout() ); Composite wInputComposite = new Composite( scrolledComposite, SWT.NONE ); props.setLook( wInputComposite ); FormLayout tabLayout = new FormLayout(); tabLayout.marginWidth = 15; tabLayout.marginHeight = 15; wInputComposite.setLayout( tabLayout ); wlResultRowsTarget = new Label( wInputComposite, SWT.RIGHT ); props.setLook( wlResultRowsTarget ); wlResultRowsTarget.setText( BaseMessages.getString( PKG, "JobExecutorDialog.ResultRowsTarget.Label" ) ); FormData fdlResultRowsTarget = new FormData(); fdlResultRowsTarget.top = new FormAttachment( 0, 0 ); fdlResultRowsTarget.left = new FormAttachment( 0, 0 ); // First one in the left wlResultRowsTarget.setLayoutData( fdlResultRowsTarget ); wResultRowsTarget = new CCombo( wInputComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER ); props.setLook( wResultRowsTarget ); wResultRowsTarget.addModifyListener( lsMod ); FormData fdResultRowsTarget = new FormData(); fdResultRowsTarget.width = 250; fdResultRowsTarget.top = new FormAttachment( wlResultRowsTarget, 5 ); fdResultRowsTarget.left = new FormAttachment( 0, 0 ); // To the right wResultRowsTarget.setLayoutData( fdResultRowsTarget ); wlResultFields = new Label( wInputComposite, SWT.NONE ); wlResultFields.setText( BaseMessages.getString( PKG, "JobExecutorDialog.ResultFields.Label" ) ); props.setLook( wlResultFields ); FormData fdlResultFields = new FormData(); fdlResultFields.left = new FormAttachment( 0, 0 ); fdlResultFields.top = new FormAttachment( wResultRowsTarget, 10 ); wlResultFields.setLayoutData( fdlResultFields ); int nrRows = ( workflowExecutorMeta.getResultRowsField() != null ? workflowExecutorMeta.getResultRowsField().length : 1 ); ColumnInfo[] ciResultFields = new ColumnInfo[] { new ColumnInfo( BaseMessages.getString( PKG, "JobExecutorDialog.ColumnInfo.Field" ), ColumnInfo.COLUMN_TYPE_TEXT, false, false ), new ColumnInfo( BaseMessages.getString( PKG, "JobExecutorDialog.ColumnInfo.Type" ), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaFactory.getValueMetaNames() ), new ColumnInfo( BaseMessages.getString( PKG, "JobExecutorDialog.ColumnInfo.Length" ), ColumnInfo.COLUMN_TYPE_TEXT, false ), new ColumnInfo( BaseMessages.getString( PKG, "JobExecutorDialog.ColumnInfo.Precision" ), ColumnInfo.COLUMN_TYPE_TEXT, false ), }; wResultRowsFields = new TableView( pipelineMeta, wInputComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, ciResultFields, nrRows, false, lsMod, props, false ); FormData fdResultFields = new FormData(); fdResultFields.left = new FormAttachment( 0, 0 ); fdResultFields.top = new FormAttachment( wlResultFields, 5 ); fdResultFields.right = new FormAttachment( 100, 0 ); fdResultFields.bottom = new FormAttachment( 100, 0 ); wResultRowsFields.setLayoutData( fdResultFields ); wResultRowsFields.getTable().addListener( SWT.Resize, new ColumnsResizer( 0, 25, 25, 25, 25 ) ); wInputComposite.pack(); Rectangle bounds = wInputComposite.getBounds(); scrolledComposite.setContent( wInputComposite ); scrolledComposite.setExpandHorizontal( true ); scrolledComposite.setExpandVertical( true ); scrolledComposite.setMinWidth( bounds.width ); scrolledComposite.setMinHeight( bounds.height ); wTab.setControl( scrolledComposite ); wTabFolder.setSelection( wTab ); }
Example 18
Source File: WorkflowExecutorDialog.java From hop with Apache License 2.0 | 4 votes |
private void addResultFilesTab() { final CTabItem wTab = new CTabItem( wTabFolder, SWT.NONE ); wTab.setText( BaseMessages.getString( PKG, "JobExecutorDialog.ResultFiles.Title" ) ); wTab.setToolTipText( BaseMessages.getString( PKG, "JobExecutorDialog.ResultFiles.Tooltip" ) ); ScrolledComposite scrolledComposite = new ScrolledComposite( wTabFolder, SWT.V_SCROLL | SWT.H_SCROLL ); scrolledComposite.setLayout( new FillLayout() ); Composite wInputComposite = new Composite( scrolledComposite, SWT.NONE ); props.setLook( wInputComposite ); FormLayout tabLayout = new FormLayout(); tabLayout.marginWidth = 15; tabLayout.marginHeight = 15; wInputComposite.setLayout( tabLayout ); wlResultFilesTarget = new Label( wInputComposite, SWT.RIGHT ); props.setLook( wlResultFilesTarget ); wlResultFilesTarget.setText( BaseMessages.getString( PKG, "JobExecutorDialog.ResultFilesTarget.Label" ) ); FormData fdlResultFilesTarget = new FormData(); fdlResultFilesTarget.top = new FormAttachment( 0, 0 ); fdlResultFilesTarget.left = new FormAttachment( 0, 0 ); // First one in the left wlResultFilesTarget.setLayoutData( fdlResultFilesTarget ); wResultFilesTarget = new CCombo( wInputComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER ); props.setLook( wResultFilesTarget ); wResultFilesTarget.addModifyListener( lsMod ); FormData fdResultFilesTarget = new FormData(); fdResultFilesTarget.width = 250; fdResultFilesTarget.top = new FormAttachment( wlResultFilesTarget, 5 ); fdResultFilesTarget.left = new FormAttachment( 0, 0 ); // To the right wResultFilesTarget.setLayoutData( fdResultFilesTarget ); // ResultFileNameField // wlResultFileNameField = new Label( wInputComposite, SWT.RIGHT ); props.setLook( wlResultFileNameField ); wlResultFileNameField.setText( BaseMessages.getString( PKG, "JobExecutorDialog.ResultFileNameField.Label" ) ); FormData fdlResultFileNameField = new FormData(); fdlResultFileNameField.top = new FormAttachment( wResultFilesTarget, 10 ); fdlResultFileNameField.left = new FormAttachment( 0, 0 ); // First one in the left wlResultFileNameField.setLayoutData( fdlResultFileNameField ); wResultFileNameField = new TextVar( pipelineMeta, wInputComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER ); props.setLook( wResultFileNameField ); wResultFileNameField.addModifyListener( lsMod ); FormData fdResultFileNameField = new FormData(); fdResultFileNameField.width = 250; fdResultFileNameField.top = new FormAttachment( wlResultFileNameField, 5 ); fdResultFileNameField.left = new FormAttachment( 0, 0 ); // To the right wResultFileNameField.setLayoutData( fdResultFileNameField ); wInputComposite.pack(); Rectangle bounds = wInputComposite.getBounds(); scrolledComposite.setContent( wInputComposite ); scrolledComposite.setExpandHorizontal( true ); scrolledComposite.setExpandVertical( true ); scrolledComposite.setMinWidth( bounds.width ); scrolledComposite.setMinHeight( bounds.height ); wTab.setControl( scrolledComposite ); wTabFolder.setSelection( wTab ); }
Example 19
Source File: PipelineExecutorDialog.java From hop with Apache License 2.0 | 4 votes |
private void addResultRowsTab() { final CTabItem wTab = new CTabItem( wTabFolder, SWT.NONE ); wTab.setText( BaseMessages.getString( PKG, "PipelineExecutorDialog.ResultRows.Title" ) ); wTab.setToolTipText( BaseMessages.getString( PKG, "PipelineExecutorDialog.ResultRows.Tooltip" ) ); ScrolledComposite scrolledComposite = new ScrolledComposite( wTabFolder, SWT.V_SCROLL | SWT.H_SCROLL ); scrolledComposite.setLayout( new FillLayout() ); Composite wInputComposite = new Composite( scrolledComposite, SWT.NONE ); props.setLook( wInputComposite ); FormLayout tabLayout = new FormLayout(); tabLayout.marginWidth = 15; tabLayout.marginHeight = 15; wInputComposite.setLayout( tabLayout ); wlResultRowsTarget = new Label( wInputComposite, SWT.RIGHT ); props.setLook( wlResultRowsTarget ); wlResultRowsTarget.setText( BaseMessages.getString( PKG, "PipelineExecutorDialog.OutputRowsSource.Label" ) ); FormData fdlResultRowsTarget = new FormData(); fdlResultRowsTarget.top = new FormAttachment( 0, 0 ); fdlResultRowsTarget.left = new FormAttachment( 0, 0 ); // First one in the left wlResultRowsTarget.setLayoutData( fdlResultRowsTarget ); wOutputRowsSource = new CCombo( wInputComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER ); props.setLook( wOutputRowsSource ); wOutputRowsSource.addModifyListener( lsMod ); FormData fdResultRowsTarget = new FormData(); fdResultRowsTarget.width = 250; fdResultRowsTarget.top = new FormAttachment( wlResultRowsTarget, 5 ); fdResultRowsTarget.left = new FormAttachment( 0, 0 ); // To the right wOutputRowsSource.setLayoutData( fdResultRowsTarget ); wlOutputFields = new Label( wInputComposite, SWT.NONE ); wlOutputFields.setText( BaseMessages.getString( PKG, "PipelineExecutorDialog.ResultFields.Label" ) ); props.setLook( wlOutputFields ); FormData fdlResultFields = new FormData(); fdlResultFields.left = new FormAttachment( 0, 0 ); fdlResultFields.top = new FormAttachment( wOutputRowsSource, 10 ); wlOutputFields.setLayoutData( fdlResultFields ); int nrRows = ( pipelineExecutorMeta.getOutputRowsField() != null ? pipelineExecutorMeta.getOutputRowsField().length : 1 ); ColumnInfo[] ciResultFields = new ColumnInfo[] { new ColumnInfo( BaseMessages.getString( PKG, "PipelineExecutorDialog.ColumnInfo.Field" ), ColumnInfo.COLUMN_TYPE_TEXT, false, false ), new ColumnInfo( BaseMessages.getString( PKG, "PipelineExecutorDialog.ColumnInfo.Type" ), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaFactory.getValueMetaNames() ), new ColumnInfo( BaseMessages.getString( PKG, "PipelineExecutorDialog.ColumnInfo.Length" ), ColumnInfo.COLUMN_TYPE_TEXT, false ), new ColumnInfo( BaseMessages.getString( PKG, "PipelineExecutorDialog.ColumnInfo.Precision" ), ColumnInfo.COLUMN_TYPE_TEXT, false ), }; wOutputFields = new TableView( pipelineMeta, wInputComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, ciResultFields, nrRows, false, lsMod, props, false ); FormData fdResultFields = new FormData(); fdResultFields.left = new FormAttachment( 0, 0 ); fdResultFields.top = new FormAttachment( wlOutputFields, 5 ); fdResultFields.right = new FormAttachment( 100, 0 ); fdResultFields.bottom = new FormAttachment( 100, 0 ); wOutputFields.setLayoutData( fdResultFields ); wOutputFields.getTable().addListener( SWT.Resize, new ColumnsResizer( 0, 25, 25, 25, 25 ) ); wInputComposite.pack(); Rectangle bounds = wInputComposite.getBounds(); scrolledComposite.setContent( wInputComposite ); scrolledComposite.setExpandHorizontal( true ); scrolledComposite.setExpandVertical( true ); scrolledComposite.setMinWidth( bounds.width ); scrolledComposite.setMinHeight( bounds.height ); wTab.setControl( scrolledComposite ); wTabFolder.setSelection( wTab ); }