Java Code Examples for org.eclipse.swt.widgets.Shell#open()
The following examples show how to use
org.eclipse.swt.widgets.Shell#open() .
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: RichTextViewerExample.java From nebula with Eclipse Public License 2.0 | 6 votes |
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setText("SWT Rich Text Editor example"); shell.setSize(800, 600); shell.setLayout(new GridLayout(1, true)); RichTextViewerExample example = new RichTextViewerExample(); example.createControls(shell); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
Example 2
Source File: MapFigure.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * Minimal standalone example, used for testing * * @param args */ @SuppressWarnings("nls") public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); FigureCanvas canvas = new FigureCanvas(shell); MapFigure mapFigure = new MapFigure(); mapFigure.setZoomLevel(8); mapFigure.setLocation(10.4234, 63.4242); canvas.setContents(mapFigure); shell.setText("MapFigure example"); shell.setSize(600, 600); shell.open(); while (!shell.isDisposed()) { while (!display.readAndDispatch()) { display.sleep(); } } }
Example 3
Source File: LogAnalysis.java From AndroidRobot with Apache License 2.0 | 6 votes |
/** * Open the window. */ public void open() { display = Display.getDefault(); shell = new Shell(); shell.setLayout(new FormLayout()); shell.open(); shell.setSize(800, 600); shell.setText("日志分析系统"); shell.setImage(new Image(display, ClassLoader.getSystemResourceAsStream("icons/log.png"))); createToolBar(); createSashForm(); createStatusBar(); loadLogs(); shell.layout(); while (shell != null & !shell.isDisposed()) { if (display != null && !display.readAndDispatch()) { display.sleep(); } } }
Example 4
Source File: DemoSelectableControlList.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Demo ControlList"); shell.setBounds(100, 100, 300, 400); FillLayout layout = new FillLayout(); layout.type = SWT.VERTICAL; shell.setLayout(layout); createContents(shell); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
Example 5
Source File: TestWithMain.java From nebula with Eclipse Public License 2.0 | 6 votes |
private static void test2() { Display display = new Display(); Shell shell = new Shell( display ); Grid grid = new Grid( shell, SWT.CHECK ); grid.setSize( 200, 200 ); grid.setLinesVisible( true ); grid.setHeaderVisible( true ); GridColumn[] columns = createGridColumns( grid, 3, SWT.NONE ); createGridItems( grid, 10, 0, false ); shell.pack(); shell.open(); grid.setColumnOrder( new int[] { 2, 0, 1 } ); assertTrue( columns[ 2 ].isCheck() ); while( !shell.isDisposed() ) { if( !display.readAndDispatch() ) display.sleep(); } display.dispose(); }
Example 6
Source File: DemoSelectableControlListViewer.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
public static void main(String[] args) { Display display = new Display(); COLOR_RED = getRegisteredColor("red", 255, 0, 0); COLOR_WHITE = getRegisteredColor("white", 255, 255, 255); Shell shell = new Shell(display); shell.setText("Demo ControlList"); shell.setBounds(100, 100, 300, 400); FillLayout layout = new FillLayout(); layout.type = SWT.VERTICAL; shell.setLayout(layout); createContents(shell); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
Example 7
Source File: Translator.java From hop with Apache License 2.0 | 5 votes |
public void open() { shell = new Shell( display ); shell.setLayout( new FillLayout() ); shell.setText( APP_NAME ); shell.setImage( GuiResource.getInstance().getImageLogoSmall() ); try { readFiles(); } catch ( Exception e ) { new ErrorDialog( shell, "Error reading translations", "There was an unexpected error reading the translations", e ); } // Put something on the screen sashform = new SashForm( shell, SWT.HORIZONTAL ); sashform.setLayout( new FormLayout() ); addLists(); addGrid(); addListeners(); sashform.setWeights( new int[] { 30, 70 } ); sashform.setVisible( true ); shell.pack(); refresh(); wPackages.optWidth( true ); wPackages.getTable().getColumn( 1 ).setWidth( 1 ); BaseTransformDialog.setSize( shell); shell.open(); }
Example 8
Source File: Regression_131260_svg.java From birt with Eclipse Public License 1.0 | 5 votes |
public static void main( String args[] ) { display = Display.getDefault( ); Shell shell = new Shell( display ); shell.setSize( 220, 80 ); shell.setLocation( display.getClientArea( ).width / 2 - 110, display .getClientArea( ).height / 2 - 40 ); shell.setLayout( new GridLayout( ) ); Regression_131260_svg siv = new Regression_131260_svg( shell, SWT.NONE ); GridData gd = new GridData( GridData.BEGINNING ); gd.widthHint = 1; gd.heightHint = 1; siv.setLayoutData( gd ); Composite cBottom = new Composite( shell, SWT.NONE ); cBottom.setLayoutData( new GridData( GridData.CENTER ) ); cBottom.setLayout( new RowLayout( ) ); Label la = new Label( cBottom, SWT.NONE ); la.setText( "Choose: " );//$NON-NLS-1$ cbType = new Combo( cBottom, SWT.DROP_DOWN | SWT.READ_ONLY ); cbType.add( "Show Tooltip" );//$NON-NLS-1$ cbType.select( 0 ); btn = new Button( cBottom, SWT.NONE ); btn.setText( "Show" );//$NON-NLS-1$ btn.addSelectionListener( siv ); shell.open( ); while ( !shell.isDisposed( ) ) { if ( !display.readAndDispatch( ) ) display.sleep( ); } display.dispose( ); }
Example 9
Source File: PropertyTableSnippet.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * @param args */ public static void main(final String[] args) { Locale.setDefault(Locale.ENGLISH); final Display display = new Display(); final Shell shell = new Shell(display); shell.setText("PropertyTable snippet"); shell.setLayout(new FillLayout(SWT.VERTICAL)); final TabFolder tabFolder = new TabFolder(shell, SWT.BORDER); final TabItem item1 = new TabItem(tabFolder, SWT.NONE); item1.setText("First"); item1.setControl(buildPropertyTable(tabFolder, true, true, true)); final TabItem item2 = new TabItem(tabFolder, SWT.NONE); item2.setText("Second"); item2.setControl(buildPropertyTable(tabFolder, false, true, false)); final TabItem item3 = new TabItem(tabFolder, SWT.NONE); item3.setText("Third"); item3.setControl(buildPropertyTable(tabFolder, true, false, true)); final TabItem item4 = new TabItem(tabFolder, SWT.NONE); item4.setText("Forth"); item4.setControl(buildPropertyTable(tabFolder, true, false, false)); shell.setSize(800, 600); shell.open(); SWTGraphicUtil.centerShell(shell); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
Example 10
Source File: ExcelExportProgessBar.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
public void open(int minValue, int maxValue) { childShell = new Shell(shell.getDisplay(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); childShell.setText("Exporting to Excel.. please wait"); progressBar = new ProgressBar(childShell, SWT.SMOOTH); progressBar.setMinimum(minValue); progressBar.setMaximum(maxValue); progressBar.setBounds(0, 0, 400, 25); progressBar.setFocus(); childShell.pack(); childShell.open(); }
Example 11
Source File: CTabFolderExample.java From codeexamples-eclipse with Eclipse Public License 1.0 | 5 votes |
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout()); // SWT.BOTTOM to show at the bottom CTabFolder folder = new CTabFolder(shell, SWT.TOP); GridData data = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1); folder.setLayoutData(data); CTabItem cTabItem1 = new CTabItem(folder, SWT.NONE); cTabItem1.setText("Tab1"); CTabItem cTabItem2 = new CTabItem(folder, SWT.NONE); cTabItem2.setText("Tab2"); CTabItem cTabItem3 = new CTabItem(folder, SWT.NONE); cTabItem3.setText("Tab3"); CTabItem cTabItem4 = new CTabItem(folder, SWT.NONE); cTabItem4.setText("Tab4"); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }
Example 12
Source File: Regression_78699_swt.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * main() method for constructing the layout. * * @param args */ public static void main( String[] args ) { Display display = Display.getDefault( ); Shell shell = new Shell( display ); shell.setSize( 600, 400 ); shell.setLayout( new GridLayout( ) ); Regression_78699_swt siv = new Regression_78699_swt( shell, SWT.NO_BACKGROUND ); siv.setLayoutData( new GridData( GridData.FILL_BOTH ) ); siv.addPaintListener( siv ); Composite cBottom = new Composite( shell, SWT.NONE ); cBottom.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); cBottom.setLayout( new RowLayout( ) ); Label la = new Label( cBottom, SWT.NONE ); la.setText( "Choose: " );//$NON-NLS-1$ cbType = new Combo( cBottom, SWT.DROP_DOWN | SWT.READ_ONLY ); cbType.add( "Bar Chart" ); cbType.select( 0 ); btn = new Button( cBottom, SWT.NONE ); btn.setText( "Update" );//$NON-NLS-1$ btn.addSelectionListener( siv ); shell.open( ); while ( !shell.isDisposed( ) ) { if ( !display.readAndDispatch( ) ) display.sleep( ); } display.dispose( ); }
Example 13
Source File: BrowserEnvironmentWarningDialog.java From pentaho-kettle with Apache License 2.0 | 5 votes |
/** * showWarningDialog * * Shows a SWT dialog warning the user that something is wrong with the browser environment. * * @param title the title on the top of the window. * @param message the message at the center of the screen. * @param helpLink a string that contains a hyperlink to a help web page. * @param maxTextWidth the width for the text inside the dialog. */ private void showWarningDialog( String title, String message, String helpLink, EnvironmentCase environment, int maxTextWidth ) { if ( this.getParent().isDisposed() ) { return; } this.props = PropsUI.getInstance(); Display display = this.getParent().getDisplay(); shell = new Shell( this.getParent(), SWT.TITLE | SWT.APPLICATION_MODAL ); props.setLook( shell ); FormLayout formLayout = new FormLayout(); formLayout.marginWidth = margin; formLayout.marginHeight = margin; shell.setLayout( formLayout ); // setting layout shell.setText( title ); //setting title of the window setWarningIcon( display ); //adding icon setWarningText( message, maxTextWidth ); //adding text setHelpLink( display, helpLink, maxTextWidth, environment ); //adding link setCloseButton(); //adding button shell.setSize( shell.computeSize( SWT.DEFAULT, SWT.DEFAULT, true ) ); Rectangle screenSize = display.getPrimaryMonitor().getBounds(); shell.setLocation( ( screenSize.width - shell.getBounds().width ) / 2, ( screenSize.height - shell.getBounds().height ) / 2 ); closeButton.setFocus(); shell.open(); while ( !shell.isDisposed() ) { if ( !display.readAndDispatch() ) { display.sleep(); } } }
Example 14
Source File: Regression_131658_svg.java From birt with Eclipse Public License 1.0 | 4 votes |
public void widgetSelected( SelectionEvent e ) { if ( e.widget == btn ) { int i = cbType.getSelectionIndex( ); switch ( i ) { case 0 : cm = createMeterChart( ); break; } try { RunTimeContext rtc = new RunTimeContext( ); rtc.setULocale( ULocale.getDefault( ) ); idr = PluginSettings.instance( ).getDevice( "dv.SVG" ); //$NON-NLS-1$ Generator gr = Generator.instance( ); GeneratedChartState gcs = null; Bounds bo = BoundsImpl.create( 0, 0, 450, 300 ); gcs = gr.build( idr.getDisplayServer( ), cm, bo, null, rtc, null ); idr .setProperty( IDeviceRenderer.FILE_IDENTIFIER, "c:/test.svg" ); //$NON-NLS-1$ idr.setProperty( IDeviceRenderer.UPDATE_NOTIFIER, new EmptyUpdateNotifier( cm, gcs.getChartModel( ) ) ); gr.render( idr, gcs ); } catch ( ChartException ce ) { ce.printStackTrace( ); } Shell shell = new Shell( display ); shell.setSize( 620, 450 ); shell.setLayout( new GridLayout( ) ); Browser br = new Browser( shell, SWT.NONE ); br.setLayoutData( new GridData( GridData.FILL_BOTH ) ); br.setUrl( "c:/test.svg" );//$NON-NLS-1$ br.setVisible( true ); shell.open( ); } }
Example 15
Source File: GridSnippet6.java From nebula with Eclipse Public License 2.0 | 4 votes |
public static void main (String [] args) { Display display = new Display (); Shell shell = new Shell (display); shell.setLayout(new FillLayout()); Grid grid = new Grid(shell,SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); grid.setHeaderVisible(true); GridColumn column = new GridColumn(grid,SWT.NONE); column.setText("Column 1"); column.setWidth(100); GridColumnGroup columnGroup = new GridColumnGroup(grid,SWT.TOGGLE); columnGroup.setText("Column Group"); GridColumn column2 = new GridColumn(columnGroup,SWT.NONE); column2.setText("Column 2"); column2.setWidth(60); column2.setSummary(false); GridColumn column3 = new GridColumn(columnGroup,SWT.NONE); column3.setText("Column 3"); column3.setWidth(60); column3.setSummary(false); GridColumn summaryColumn = new GridColumn(columnGroup,SWT.NONE); summaryColumn.setText("Sum"); summaryColumn.setWidth(93); summaryColumn.setDetail(false); summaryColumn.setSummary(true); GridItem item1 = new GridItem(grid,SWT.NONE); item1.setText("First Item"); item1.setText(1,"100"); item1.setText(2,"42"); item1.setText(3,"142"); GridItem item2 = new GridItem(grid,SWT.NONE); item2.setText("Second Item"); item2.setText(1,"63"); item2.setText(2,"92"); item2.setText(3,"155"); GridItem item3 = new GridItem(grid,SWT.NONE); item3.setText("Third Item"); item3.setText(1,"7"); item3.setText(2,"3"); item3.setText(3,"10"); shell.setSize(250,250); shell.open (); while (!shell.isDisposed()) { if (!display.readAndDispatch ()) display.sleep (); } display.dispose (); }
Example 16
Source File: NoWindowTest.java From ermaster-b with Apache License 2.0 | 4 votes |
private static void run(Display display, int x) { Shell shell = new Shell(display); shell.setBounds(0, 0, 350, 350); shell.setLayout(new FillLayout(SWT.VERTICAL)); // display.syncExec(new Runnable() { // public void run() { ERDiagramEditPartFactory editPartFactory = new ERDiagramEditPartFactory(); GraphicalViewer viewer = new ScrollingGraphicalViewer(); viewer.setControl(new FigureCanvas(shell)); ScalableFreeformRootEditPart rootEditPart = new PagableFreeformRootEditPart( diagram); viewer.setRootEditPart(rootEditPart); viewer.setEditPartFactory(editPartFactory); viewer.setContents(diagram); viewer.getContents().refresh(); // } // }); shell.pack(); shell.open(); int count = 0; while (count < x) { if (!display.readAndDispatch()) { try { Thread.sleep(1000); count++; } catch (InterruptedException e) { e.printStackTrace(); } } } viewer.getContents().deactivate(); // display.dispose(); }
Example 17
Source File: SnippetSimpleGroupImageHScroll.java From nebula with Eclipse Public License 2.0 | 4 votes |
public static void main(String[] args) { Display display = new Display(); Image itemImage = new Image(display, Program.findProgram("jpg") //$NON-NLS-1$ .getImageData()); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Gallery gallery = new Gallery(shell, SWT.H_SCROLL | SWT.MULTI); // Renderers DefaultGalleryGroupRenderer gr = new DefaultGalleryGroupRenderer(); gr.setMinMargin(2); gr.setItemHeight(56); gr.setItemWidth(72); gr.setAutoMargin(true); gallery.setGroupRenderer(gr); DefaultGalleryItemRenderer ir = new DefaultGalleryItemRenderer(); gallery.setItemRenderer(ir); for (int g = 0; g < 3; g++) { GalleryItem group = new GalleryItem(gallery, SWT.NONE); group.setText("Group " + g); //$NON-NLS-1$ group.setExpanded(true); group.setImage(itemImage); if (g > 0) group.setText(1, "descr1"); //$NON-NLS-1$ if (g > 1) group.setText(2, "descr2"); //$NON-NLS-1$ for (int i = 0; i < 50; i++) { GalleryItem item = new GalleryItem(group, SWT.NONE); if (itemImage != null) { item.setImage(itemImage); } item.setText("Item " + i); //$NON-NLS-1$ } } shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } if (itemImage != null) itemImage.dispose(); display.dispose(); }
Example 18
Source File: TankExample.java From nebula with Eclipse Public License 2.0 | 4 votes |
public static void main(String[] args) { final Shell shell = new Shell(); shell.setSize(300, 250); shell.open(); //use LightweightSystem to create the bridge between SWT and draw2D final LightweightSystem lws = new LightweightSystem(shell); //Create widget final TankFigure tank = new TankFigure(); //Init widget tank.setBackgroundColor( XYGraphMediaFactory.getInstance().getColor(255, 255, 255)); tank.setBorder(new SchemeBorder(SchemeBorder.SCHEMES.ETCHED)); tank.setRange(-100, 100); tank.setLoLevel(-50); tank.setLoloLevel(-80); tank.setHiLevel(60); tank.setHihiLevel(80); tank.setMajorTickMarkStepHint(50); lws.setContents(tank); //Update the widget in another thread. ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); ScheduledFuture<?> future = scheduler.scheduleAtFixedRate(new Runnable() { public void run() { Display.getDefault().asyncExec(new Runnable() { public void run() { tank.setValue(Math.sin(counter++/10.0)*100); } }); } }, 100, 100, TimeUnit.MILLISECONDS); Display display = Display.getDefault(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } future.cancel(true); scheduler.shutdown(); }
Example 19
Source File: Snippet163old.java From http4e with Apache License 2.0 | 4 votes |
public static void main(String [] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); StyledText styledText = new StyledText(shell, SWT.WRAP | SWT.BORDER); styledText.setText(text); FontData data = styledText.getFont().getFontData()[0]; Font font1 = new Font(display, data.getName(), data.getHeight() * 2, data.getStyle()); Font font2 = new Font(display, data.getName(), data.getHeight() * 4 / 5, data.getStyle()); StyleRange[] styles = new StyleRange[8]; styles[0] = new StyleRange(); styles[0].font = font1; styles[1] = new StyleRange(); styles[1].rise = data.getHeight() / 3; styles[2] = new StyleRange(); styles[2].background = display.getSystemColor(SWT.COLOR_GREEN); styles[3] = new StyleRange(); styles[3].foreground = display.getSystemColor(SWT.COLOR_MAGENTA); styles[4] = new StyleRange(); styles[4].font = font2; styles[4].foreground = display.getSystemColor(SWT.COLOR_BLUE);; styles[4].underline = true; styles[5] = new StyleRange(); styles[5].rise = -data.getHeight() / 3; styles[5].strikeout = true; styles[5].underline = true; styles[6] = new StyleRange(); styles[6].font = font1; styles[6].foreground = display.getSystemColor(SWT.COLOR_YELLOW); styles[6].background = display.getSystemColor(SWT.COLOR_BLUE); styles[7] = new StyleRange(); styles[7].rise = data.getHeight() / 3; styles[7].underline = true; styles[7].fontStyle = SWT.BOLD; styles[7].foreground = display.getSystemColor(SWT.COLOR_RED); styles[7].background = display.getSystemColor(SWT.COLOR_BLACK); int[] ranges = new int[] {16, 4, 61, 13, 107, 10, 122, 10, 134, 3, 143, 6, 160, 7, 168, 7}; styledText.setStyleRanges(ranges, styles); shell.setSize(300, 300); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } font1.dispose(); font2.dispose(); display.dispose(); }
Example 20
Source File: SWTToggleVisibilityViewer.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * main() method for constructing the layout. * * @param args */ public static void main( String[] args ) { Display display = Display.getDefault( ); Shell shell = new Shell( display ); shell.setSize( 600, 400 ); shell.setLayout( new GridLayout( ) ); SWTToggleVisibilityViewer siv = new SWTToggleVisibilityViewer( shell, SWT.NO_BACKGROUND ); siv.setLayoutData( new GridData( GridData.FILL_BOTH ) ); siv.addPaintListener( siv ); Composite cBottom = new Composite( shell, SWT.NONE ); cBottom.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); cBottom.setLayout( new RowLayout( ) ); Label la = new Label( cBottom, SWT.NONE ); la.setText( "Choose: " );//$NON-NLS-1$ cbType = new Combo( cBottom, SWT.DROP_DOWN | SWT.READ_ONLY ); cbType.add( "Area Chart" ); cbType.add( "Bar Chart" ); cbType.add( "Line Chart" ); cbType.add( "Meter Chart" ); cbType.add( "Pie Chart" ); cbType.add( "Scatter Chart" ); cbType.add( "Stock Chart" ); cbType.select( 0 ); btn = new Button( cBottom, SWT.NONE ); btn.setText( "Update" );//$NON-NLS-1$ btn.addSelectionListener( siv ); shell.open( ); while ( !shell.isDisposed( ) ) { if ( !display.readAndDispatch( ) ) display.sleep( ); } display.dispose( ); }