Java Code Examples for org.eclipse.swt.widgets.Shell#isDisposed()

The following examples show how to use org.eclipse.swt.widgets.Shell#isDisposed() . 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: ProgressCircleSnippet.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
public static void main(final String[] args) {
	final Display display = new Display();
	final Shell shell = new Shell(display);
	shell.setLayout(new GridLayout(3, true));
	final Color white = display.getSystemColor(SWT.COLOR_WHITE);
	shell.setBackground(white);

	new PercentagePanel(shell);
	new AbsolutePanel(shell);
	new TimePanel(shell);

	shell.pack();
	shell.open();

	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
	display.dispose();
}
 
Example 2
Source File: NumberFormatterSnippet2.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
public static void main(String[] args) {
	Display display = new Display();
   Shell shell = new Shell(display);
   shell.setLayout(new GridLayout());

   FormattedText text = new FormattedText(shell, SWT.BORDER | SWT.RIGHT);
   text.setFormatter(new NumberFormatter(Locale.FRENCH));
   GridData data = new GridData();
   data.widthHint = 100;
   text.getControl().setLayoutData(data);

   shell.open();
   while ( ! shell.isDisposed() ) {
   	if (!display.readAndDispatch()) display.sleep();
   }
   display.dispose();
}
 
Example 3
Source File: LEDSnippet.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @param args
 */
public static void main(final String[] args) {
	final Display display = new Display();
	shell = new Shell(display);
	shell.setText("LED Snippet");
	shell.setLayout(new GridLayout(1, true));
	shell.setBackground(display.getSystemColor(SWT.COLOR_WHITE));

	createTopPart();
	createBottomPart();

	shell.pack();
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}

	display.dispose();

}
 
Example 4
Source File: SWTPieChartDemo1.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Starting point for the demonstration application.
 *
 * @param args  ignored.
 */
public static void main(String[] args) 
{
    JFreeChart chart = createChart(createDataset());
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setSize(600, 400);
    shell.setLayout(new FillLayout());
    shell.setText("Test for jfreechart running with SWT");
    final ChartComposite frame = new ChartComposite(shell, SWT.NONE, chart, true);
    //frame.setDisplayToolTips(false);
    frame.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
}
 
Example 5
Source File: TmfAbstractToolTipHandler.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Dispose the shell if we exit the range.
 *
 * @param e
 *            The event which occurred
 */
private void disposeIfExited(Event e) {
    if (!(e.widget instanceof Control)) {
        return;
    }
    Control control = (Control) e.widget;
    if (control != null && !control.isDisposed()) {
        Point pt = control.toDisplay(e.x, e.y);
        Shell tipShell = fTipShell;
        if (tipShell != null && !tipShell.isDisposed()) {
            Rectangle bounds = getBounds(tipShell);
            bounds.x -= OFFSET;
            bounds.y -= OFFSET;
            bounds.height += 2 * OFFSET;
            bounds.width += 2 * OFFSET;
            if (!bounds.contains(pt) && !fInitialDeadzone.contains(pt)) {
                tipShell.dispose();
            }
        }
    }
}
 
Example 6
Source File: JobEntryJobDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public JobEntryInterface open() {
  Shell parent = getParent();
  display = parent.getDisplay();

  shell = new Shell( parent, props.getJobsDialogStyle() );
  props.setLook( shell );
  JobDialog.setShellImage( shell, jobEntry );

  backupChanged = jobEntry.hasChanged();

  createElements();

  // Detect [X] or ALT-F4 or something that kills this window...
  shell.addShellListener( new ShellAdapter() {
    public void shellClosed( ShellEvent e ) {
      cancel();
    }
  } );

  getData();
  setActive();

  BaseStepDialog.setSize( shell );

  int width = 750;
  int height = Const.isWindows() ? 730 : 718;

  shell.setSize( width, height );
  shell.open();
  while ( !shell.isDisposed() ) {
    if ( !display.readAndDispatch() ) {
      display.sleep();
    }
  }
  return jobEntry;
}
 
Example 7
Source File: CDTSnippet01.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @param args
 */
public static void main(String[] args) {
	final Display display = new Display();
	final Shell shell = new Shell(display);
	shell.setText("Nebula CDateTime");
	shell.setLayout(new GridLayout());

	GridLayout layout = new GridLayout();
	shell.setLayout(layout);

	final CDateTime cdt = new CDateTime(shell, CDT.BORDER | CDT.DROP_DOWN);
	cdt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

	shell.pack();
	Point size = shell.getSize();
	Rectangle screen = display.getMonitors()[0].getBounds();
	shell.setBounds(
			(screen.width-size.x)/2,
			(screen.height-size.y)/2,
			size.x,
			size.y
	);
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
}
 
Example 8
Source File: AboutDialog.java    From pmTrans with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void open() {
	// Create the dialog window
	Shell shell = new Shell(getParent(), getStyle());
	shell.setText(getText());
	createContents(shell);
	shell.pack();
	shell.open();
	Display display = getParent().getDisplay();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
}
 
Example 9
Source File: Regression_141706_svg.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
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_141706_svg siv = new Regression_141706_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 10
Source File: ComboPageableTableExample.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public static void main(String[] args) {
	Display display = new Display();
	Shell shell = new Shell(display);
	GridLayout layout = new GridLayout(1, false);
	shell.setLayout(layout);

	final List<String> items = createList();

	// 1) Create pageable table with 10 items per page
	// This SWT Component create internally a SWT Table+JFace TreeViewer
	int pageSize = 10;
	PageableTable pageableTable = new PageableTable(shell, SWT.BORDER,
			SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL, pageSize,
			PageResultContentProvider.getInstance(),
			NavigationPageComboRendererFactory.getFactory(), null);
	pageableTable.setLayoutData(new GridData(GridData.FILL_BOTH));

	// 2) Initialize the table viewer
	TableViewer viewer = pageableTable.getViewer();
	viewer.setContentProvider(ArrayContentProvider.getInstance());
	viewer.setLabelProvider(new LabelProvider());

	// 3) Set the page loader used to load a page (sublist of String)
	// according the page index selected, the page size etc.
	pageableTable.setPageLoader(new PageResultLoaderList<String>(items));

	// 4) Set current page to 0 to display the first page
	pageableTable.setCurrentPage(0);

	shell.setSize(350, 250);
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
}
 
Example 11
Source File: Regression_136069_svg.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
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_136069_svg siv = new Regression_136069_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( "UrlRedirect" );//$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 12
Source File: NoBeepSoundFormatterSnippet.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public static void main(String[] args) {
	Display display = new Display();
   Shell shell = new Shell(display);
   shell.setLayout(new GridLayout());

   final FormattedText text = new FormattedText(shell, SWT.BORDER);
   text.setFormatter(new DateFormatter());
   GridData data = new GridData();
   data.widthHint = 70;
   text.getControl().setLayoutData(data);

   Button toggleBeep = new Button(shell, SWT.PUSH);
   toggleBeep.setText("Toggle beep sound");
   toggleBeep.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			FormattedText.setBeepSound(! FormattedText.isBeepSound());
			text.getControl().setFocus();
		}
   });

   shell.open();
   while ( ! shell.isDisposed() ) {
   	if (!display.readAndDispatch()) display.sleep();
   }
   display.dispose();
}
 
Example 13
Source File: Regression_117876_svg.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public static void main( String args[] )
{
	display = Display.getDefault( );
	Shell shell = new Shell( display );
	shell.setLocation( display.getClientArea( ).width / 2 - 110, display
			.getClientArea( ).height / 2 - 40 );
	shell.setSize( 620, 450 );
	shell.setLayout( new GridLayout( ) );

	Regression_117876_svg siv = new Regression_117876_svg( shell, SWT.NONE );
	GridData gd = new GridData( GridData.BEGINNING );
	gd.widthHint = 1;
	gd.heightHint = 1;
	siv.setLayoutData( gd );

	try
	{
		RunTimeContext rtc = new RunTimeContext( );
		rtc.setULocale( ULocale.getDefault( ) );

		IDeviceRenderer idr = null;
		Chart cm = toggleVisibility_MeterChart( );

		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( );
	}

	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( );
	while ( !shell.isDisposed( ) )
	{
		if ( !display.readAndDispatch( ) )
			display.sleep( );
	}
	display.dispose( );
}
 
Example 14
Source File: StaircaseExample.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
public static void main(final String[] args) {
	// Main window (shell)
	final Shell shell = new Shell();
	shell.setSize(800, 500);
	shell.open();

	// XYGraph
	final LightweightSystem lws = new LightweightSystem(shell);
	final ToolbarArmedXYGraph plot = new ToolbarArmedXYGraph(new XYGraph(),
			XYGraphFlags.SEPARATE_ZOOM | XYGraphFlags.STAGGER);
	final XYGraph xygraph = (XYGraph) plot.getXYGraph();
	xygraph.setTransparent(false);
	xygraph.setTitle("You should see a line. Zoom out to see more data");
	lws.setContents(plot);

	// Add data & trace
	final CircularBufferDataProvider data = new CircularBufferDataProvider(true);
	data.addSample(new Sample(next_x++, 1, 1, 1, 0, 0));
	data.addSample(new Sample(next_x++, 2, 1, 1, 0, 0));
	data.addSample(new Sample(next_x++, 3, 1, 1, 0, 0));
	data.addSample(new Sample(next_x++, 1, 1, 1, 0, 0));
	data.addSample(new Sample(next_x++, 1, 1, 1, 0, 0));
	data.addSample(new Sample(next_x++, 1, 1, 1, 0, 0));
	// Add Double.NaN gap, single point
	data.addSample(new Sample(next_x++, Double.NaN, 0, 0, 0, 0, "Disconnected"));
	data.addSample(new Sample(next_x++, 1, 0, 0, 0, 0));
	// Another gap, single point
	data.addSample(new Sample(next_x++, Double.NaN, 0, 0, 0, 0, "Disconnected"));
	data.addSample(new Sample(next_x++, 2, 0, 0, 0, 0));
	// Last value is valid 'forever'
	data.addSample(new Sample(Double.MAX_VALUE, 2, 0, 0, 0, 0));

	// Always looked OK with this range
	xygraph.getPrimaryXAxis().setRange(data.getXDataMinMax());
	xygraph.getPrimaryYAxis().setRange(data.getYDataMinMax());

	// With STEP_HORIZONTALLY this should have shown just a horizontal
	// line, but a bug resulted in nothing when both the 'start' and 'end'
	// point of the horizontal line were outside the plot range.
	// Similarly, using STEP_VERTICALLY failed to draw anything when
	// both end-points of the horizontal or vertical section of the step
	// were outside the plot. (fixed)
	//
	// There's still a question about handling 'YErrorInArea':
	// For now, the axis intersection removes x/y errors,
	// so when moving a sample with y error left or right outside
	// of the plot range, the error area suddenly shrinks when
	// the axis intersection is assumed to have +-0 y error.
	xygraph.getPrimaryXAxis().setRange(4.1, 4.9);

	// Gap, start of X range, sample @ x==8, gap @ 9, end of range.
	// Bug failed to show line from that sample up to gap @ 9.
	xygraph.getPrimaryXAxis().setRange(7.5, 9.5);

	final Trace trace = new Trace("Demo", xygraph.getPrimaryXAxis(), xygraph.getPrimaryYAxis(), data);
	trace.setTraceType(TraceType.STEP_HORIZONTALLY);
	// trace.setTraceType(TraceType.STEP_VERTICALLY);

	// // SOLID_LINE does not show individual points
	// trace.setTraceType(TraceType.SOLID_LINE);
	// trace.setPointStyle(PointStyle.CIRCLE);

	trace.setErrorBarEnabled(true);
	trace.setDrawYErrorInArea(true);
	xygraph.addTrace(trace);

	Font LEGEND_FONT = XYGraphMediaFactory.getInstance().getFont(new FontData("Lucida Sans", 11, SWT.BOLD));
	
	Legend legend = xygraph.getLegend(trace);
	legend.setDrawBorder(true);
	legend.setPreferredHeight(100);
	legend.setTextFont(LEGEND_FONT);
	
	// SWT main loop
	final Display display = Display.getDefault();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
}
 
Example 15
Source File: MyXViewerTest.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
public static void main(String[] args) {
   // Get the Display. Create on if none exists
   Display Display_1 = Display.getCurrent();
   boolean displayCreated = false;
   if (Display_1 == null) {
      Display_1 = Display.getDefault();
      displayCreated = true;
   } else {
      Display_1 = Display.getDefault();
   }

   Shell Shell_1 = new Shell(Display_1, SWT.SHELL_TRIM);
   Shell_1.setText("XViewer Test");
   Shell_1.setBounds(0, 0, 1000, 500);
   Shell_1.setLayout(new GridLayout());
   Shell_1.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.HORIZONTAL_ALIGN_BEGINNING));

   // Button composite for state transitions, etc
   Composite toolBarComposite = new Composite(Shell_1, SWT.NONE);
   toolBarComposite.setLayout(new GridLayout(2, false));
   toolBarComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

   // Set property that this xviewer is outside the Eclipse workbench
   XViewerDisplay.setStandaloneXViewer(true, Display_1);

   myXviewer = new MyXViewer(Shell_1, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
   myXviewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
   myXviewer.setContentProvider(new MyXViewerContentProvider());
   myXviewer.setLabelProvider(new MyXViewerLabelProvider(myXviewer));

   // XViewerEditAdapter
   XViewerControlFactory cFactory = new DefaultXViewerControlFactory();
   XViewerConverter converter = new MyXViewerConverter();
   myXviewer.setXViewerEditAdapter(new XViewerMultiEditAdapter(cFactory, converter));

   createTaskActionBar(toolBarComposite);

   List<Object> tasks = new ArrayList<>();
   for (int x = 0; x < 1; x++) {
      tasks.addAll(getTestTasks());
   }
   /**
    * Note: setInputXViewer must be called instead of setInput for XViewer to operate properly
    */
   myXviewer.setInputXViewer(tasks);
   Shell_1.open();
   while (!Shell_1.isDisposed()) {
      if (!Display_1.readAndDispatch()) {
         Display_1.sleep();
      }
   }

   if (displayCreated) {
      Display_1.dispose();
   }
}
 
Example 16
Source File: ProgressBarExample.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
public static void main(String[] args) {
	final Shell shell = new Shell();
	shell.setSize(300, 120);
    shell.open();
    
    //use LightweightSystem to create the bridge between SWT and draw2D
	final LightweightSystem lws = new LightweightSystem(shell);		
	
	//Create Gauge
	final ProgressBarFigure progressBarFigure = new ProgressBarFigure();
	
	//Init gauge
	progressBarFigure.setFillColor(
			XYGraphMediaFactory.getInstance().getColor(0, 255, 0));
			
	progressBarFigure.setRange(-100, 100);
	progressBarFigure.setLoLevel(-50);
	progressBarFigure.setLoloLevel(-80);
	progressBarFigure.setHiLevel(60);
	progressBarFigure.setHihiLevel(80);
	progressBarFigure.setMajorTickMarkStepHint(50);
	progressBarFigure.setHorizontal(true);
	progressBarFigure.setOriginIgnored(true);
	
	lws.setContents(progressBarFigure);		
	
	//Update the gauge in another thread.
	ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
	ScheduledFuture<?> future = scheduler.scheduleAtFixedRate(new Runnable() {
		
		@Override
		public void run() {
			Display.getDefault().asyncExec(new Runnable() {					
				@Override
				public void run() {
					progressBarFigure.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 17
Source File: StyledTextPrintExample.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Executes the StyledTextPrint example.
 *
 * @param args
 *            the command line arguments.
 */
public static void main(String[] args) {
	final Display display = new Display();

	final Shell shell = new Shell(display, SWT.SHELL_TRIM);
	shell.setText("StyledTextPrintExample.java");
	shell.setLayout(new GridLayout());
	shell.setSize(600, 800);

	final PrintJob job = new PrintJob("StyledTextPrintExample.java",
			createPrint());

	Composite buttonPanel = new Composite(shell, SWT.NONE);
	buttonPanel
			.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
	buttonPanel.setLayout(new RowLayout(SWT.HORIZONTAL));

	final PrintPreview preview = new PrintPreview(shell, SWT.BORDER);

	Button prev = new Button(buttonPanel, SWT.PUSH);
	prev.setText("<< Prev");
	prev.addListener(SWT.Selection, event -> {
		preview.setPageIndex(Math.max(preview.getPageIndex() - 1, 0));
	});

	Button next = new Button(buttonPanel, SWT.PUSH);
	next.setText("Next >>");
	next.addListener(SWT.Selection, event -> {
		preview.setPageIndex(Math.min(preview.getPageIndex() + 1,
				preview.getPageCount() - 1));
	});

	Button print = new Button(buttonPanel, SWT.PUSH);
	print.setText("Print");
	print.addListener(SWT.Selection, event -> {
		PrintDialog dialog = new PrintDialog(shell);
		PrinterData printerData = dialog.open();
		if (printerData != null)
			PaperClips.print(job, printerData);
	});

	preview.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	preview.setFitHorizontal(true);
	preview.setFitVertical(true);
	preview.setPrintJob(job);

	shell.open();

	while (!shell.isDisposed())
		if (!display.readAndDispatch())
			display.sleep();

	display.dispose();
}
 
Example 18
Source File: HopGui.java    From hop with Apache License 2.0 4 votes vote down vote up
/**
 * Build the shell
 */
protected void open() {
  shell = new Shell( display, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX );
  shell.setImage( GuiResource.getInstance().getImageHopUi() );

  shell.setText( BaseMessages.getString( PKG, "HopGui.Application.Name" ) );
  addMainMenu();
  addMainToolbar();
  addPerspectivesToolbar();
  addMainPerspectivesComposite();

  loadPerspectives();

  replaceKeyboardShortcutListeners( this );

  shell.addListener( SWT.Close, this::closeEvent );

  BaseTransformDialog.setSize( shell );

  // Open the Hop GUI shell and wait until it's closed
  //
  // shell.pack();
  shell.open();

  openingLastFiles = true; // TODO: make this configurable.

  try {
    ExtensionPointHandler.callExtensionPoint( log, HopExtensionPoint.HopGuiStart.id, this );
  } catch ( Exception e ) {
    new ErrorDialog( shell, "Error", "Error calling extension point '" + HopExtensionPoint.HopGuiStart.id + "'", e );
  }
  // Open the previously used files. Extension points can disable this
  //
  if ( openingLastFiles ) {
    auditDelegate.openLastFiles();
  }
  boolean retry = true;
  while ( retry ) {
    try {
      while ( !shell.isDisposed() ) {
        if ( !display.readAndDispatch() ) {
          display.sleep();
        }
      }
      retry = false;
    } catch ( Throwable throwable ) {
      System.err.println( "Error in the Hop GUI : " + throwable.getMessage() + Const.CR + Const.getClassicStackTrace( throwable ) );
    }
  }
  display.dispose();
}
 
Example 19
Source File: BlurredPanel.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Constructs a new instance of this class given its parent.
 *
 * @param shell a shell that will be the parent of the new instance (cannot
 *            be null)
 * @exception IllegalArgumentException
 *                <ul>
 *                <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
 *                </ul>
 * @exception SWTException
 *                <ul>
 *                <li>ERROR_WIDGET_DISPOSED - if the parent has been
 *                disposed</li>
 *                <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
 *                thread that created the parent</li>
 *                </ul>
 */
public BlurredPanel(final Shell shell) {
	if (shell == null) {
		SWT.error(SWT.ERROR_NULL_ARGUMENT);
	}

	if (shell.isDisposed()) {
		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
	}

	parent = shell;
	if (shell.getData(BLURED_PANEL_KEY) != null) {
		throw new IllegalArgumentException("This shell has already an infinite panel attached on it !");
	}
	shell.setData(BLURED_PANEL_KEY, this);
	radius = 2;
}
 
Example 20
Source File: CDTSnippet11.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @param args
 */
public static void main(String[] args) {
	final Display display = new Display();
	final Shell shell = new Shell(display);
	shell.setText("CDateTime");
	shell.setLayout(new GridLayout());

	CDateTimeBuilder builder = CDateTimeBuilder.getStandard();
	builder.setMinDate(Calendar.getInstance());
	
	Calendar max = Calendar.getInstance();
	max.add(Calendar.DAY_OF_MONTH, 5);
	builder.setMaxDate(max);

	final CDateTime cdt1 = new CDateTime(shell, CDT.BORDER | CDT.DROP_DOWN);
	cdt1.setBuilder(builder);
	cdt1.setSelection(new Date());
	cdt1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
	
	final CDateTime cdt2 = new CDateTime(shell, CDT.BORDER | CDT.DROP_DOWN);
	cdt2.setBuilder(builder);
	cdt2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
	cdt2.setSelection(new Date());
	cdt2.setEditable(false);
	
	final CDateTime cdt3 = new CDateTime(shell, CDT.BORDER | CDT.SIMPLE);
	cdt3.setBuilder(builder);
	cdt3.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
	cdt3.setEditable(false);
	
	shell.pack();
	Point size = shell.getSize();
	Rectangle screen = display.getMonitors()[0].getBounds();
	shell.setBounds(
			(screen.width-size.x)/2,
			(screen.height-size.y)/2,
			size.x,
			size.y
	);
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
}