Java Code Examples for org.eclipse.swt.widgets.Display.readAndDispatch()

The following are Jave code examples for showing how to use readAndDispatch() of the org.eclipse.swt.widgets.Display class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: parabuild-ci   File: SWTPieChartDemo1.java   View Source Code Vote up 7 votes
/**
 * 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 2
Project: parabuild-ci   File: SWTBarChartDemo1.java   View Source Code Vote up 6 votes
/**
 * 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, 300);
    shell.setLayout(new FillLayout());
    shell.setText("Test for jfreechart running with SWT");
    final ChartComposite frame = new ChartComposite(shell, SWT.NONE, chart,
            true);
    frame.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
}
 
Example 3
Project: eclipse-batch-editor   File: AbstractQuickDialog.java   View Source Code Vote up 6 votes
private void runEventLoop(Shell loopShell) {
	Display display;
	if (getShell() == null) {
		display = Display.getCurrent();
	} else {
		display = loopShell.getDisplay();
	}

	while (loopShell != null && !loopShell.isDisposed()) {
		try {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		} catch (Throwable e) {
			EclipseUtil.logError("UI problems on dispatch",e);
		}
	}
	if (!display.isDisposed()) {
		display.update();
	}
}
 
Example 4
Project: parabuild-ci   File: SWTMultipleAxisDemo1.java   View Source Code Vote up 6 votes
/**
 * Starting point for the demonstration application.
 *
 * @param args  ignored.
 */
public static void main( String[] args ) 
{
    final JFreeChart chart = createChart();
    final Display display = new Display();
    Shell shell = new Shell(display);
    shell.setSize(600, 300);
    shell.setLayout(new FillLayout());
    shell.setText("Test for jfreechart running with SWT");
    ChartComposite frame = new ChartComposite(shell, SWT.NONE, chart, true);
    frame.setDisplayToolTips(false);
    frame.setHorizontalAxisTrace(true);
    frame.setVerticalAxisTrace(true);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
}
 
Example 5
Project: avoCADo   File: AboutAvoCADoGPLShell.java   View Source Code Vote up 6 votes
/**
 * create the startup splash shell and display it
 * @param display
 */
public AboutAvoCADoGPLShell(Display display){
	shell = new Shell(display, SWT.PRIMARY_MODAL);
	
	setupShell(); 				// place components in the avoCADo license shell
	
	shell.setText("avoCADo GPLv2");
	shell.setSize(583, 350);	//TODO: set initial size to last known size
	Rectangle b = display.getBounds();
	int xPos = Math.max(0, (b.width-583)/2);
	int yPos = Math.max(0, (b.height-350)/2);
	shell.setLocation(xPos, yPos);
	shell.open();
	
	// handle events while the shell is not disposed
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
}
 
Example 6
Project: JavaFX-FrameRateMeter   File: SWTTestUtil.java   View Source Code Vote up 6 votes
public static void openShell(String format, int weight, int height, Function<Shell, Control> function) {

    Display display = new Display();

    Shell shell = new Shell(display);

    shell.setSize(weight, height);
    shell.setLayout(new FillLayout());

    function.apply(shell);

    shell.open();

    while(!shell.isDisposed()) {
      if(!display.readAndDispatch()) {
        display.sleep();
      }
    }
    display.dispose();
  }
 
Example 7
Project: AppleCommander   File: Sleak.java   View Source Code Vote up 6 votes
public static void main (String [] args) {
	DeviceData data = new DeviceData();
	data.tracking = true;
	Display display = new Display (data);
	Sleak sleak = new Sleak ();
	sleak.open ();

	// Launch your application here
	SwtAppleCommander ac = new SwtAppleCommander();
	ac.launch(display);
	// End of AC code...	
	
	while (!sleak.shell.isDisposed ()) {
		if (!display.readAndDispatch ()) display.sleep ();
	}
	display.dispose ();
}
 
Example 8
Project: pdi   File: Interface.java   View Source Code Vote up 6 votes
public static void main(String args[]) {
    OpenCVUtils.loadLibrary();

    try {
        Display display = Display.getDefault();
        Interface shell = new Interface(display);
        shell.open();
        shell.layout();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 9
Project: applecommander   File: SwtAppleCommander.java   View Source Code Vote up 5 votes
/**
 * Launch SwtAppleCommander with a given display.
 * Primary motivation is getting S-Leak to work!
 */
public void launch(Display display) {
	imageManager = new ImageManager(display);
	SwtAppleCommander application = new SwtAppleCommander();
	Shell shell = application.open(display);
	shell.forceActive();
	
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) display.sleep();
	}
	
	UserPreferences.getInstance().save();
}
 
Example 10
Project: pandionj   File: TestMatrixWidget.java   View Source Code Vote up 5 votes
public static void main(String[] args) {
	Shell shell = new Shell(new Display());
	shell.setSize(1200, 500);
	shell.setLayout(new GridLayout());
	shell.setLocation(100, 150);
	
	Figure root = new Figure();
	root.setFont(shell.getFont());
	//		XYLayout layout = new XYLayout();
	//		root.setLayoutManager(layout);
	
	org.eclipse.draw2d.GridLayout layout = new org.eclipse.draw2d.GridLayout(2,false);
	layout.horizontalSpacing = 100;
	root.setLayoutManager(layout);
	
	Canvas canvas = new Canvas(shell, SWT.DOUBLE_BUFFERED);
	canvas.setBackground(ColorConstants.white);
	canvas.setLayoutData(new GridData(GridData.FILL_BOTH));
	
	MatrixWidget widget = new MatrixWidget();
	MockArray array = new MockArray("int[]", new int[]{1,2,3}, new int[]{4,5,6}, new int[]{7,8,9}, new int[]{10,11,12});
	root.add(widget.createFigure(array));
	
	LightweightSystem lws = new LightweightSystem(canvas);
	lws.setContents(root);
	
	Display display = shell.getDisplay();
	shell.open();
	while (!shell.isDisposed()) {
		while (!display.readAndDispatch()) {
			display.sleep();
		}
	}
}
 
Example 11
Project: pmTrans   File: AboutDialog.java   View Source Code Vote up 5 votes
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 12
Project: pmTrans   File: PmTrans.java   View Source Code Vote up 5 votes
private PmTrans(GlobalKeyListener gkl) {
	// Initialize the interface
	d = new Display();
	shell = new Shell(d);
	menuManager = new MenuManager(shell, this);
	barManager = new BarManager(shell, this);

	// Global keys
	this.gKL = gkl;

	initState();
	initGui();
	startAutoSave();

	shell.open();

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

	if (player != null) {
		player.close();
		player = null;
	}
	GlobalScreen.unregisterNativeHook();
	saveState();
	try {
		Config.getInstance().save();
	} catch (IOException e) {
		// ignore
	}
}
 
Example 13
Project: convertigo-eclipse   File: KTable.java   View Source Code Vote up 5 votes
public static void main(String[] args) {
  // create a shell...
  Display display = new Display();
  Shell shell = new Shell(display);
  shell.setLayout(new FillLayout());
  shell.setText("KTable examples");

  // put a tab folder in it...
  TabFolder tabFolder = new TabFolder(shell, SWT.NONE);

  // Item 1: a Text Table
  TabItem item1 = new TabItem(tabFolder, SWT.NONE);
  item1.setText("Text Table");
  Composite comp1 = new Composite(tabFolder, SWT.NONE);
  item1.setControl(comp1);
  comp1.setLayout(new FillLayout());

  // put a table in tabItem1...
  KTable table = new KTable(comp1, SWT.V_SCROLL | SWT.H_SCROLL);
  table.setRowSelectionMode(true);
  //table.setMultiSelectionMode(true);
  table.setModel(new KTableModelExample());

  // display the shell...
  shell.setSize(600, 600);
  shell.open();
  while (!shell.isDisposed()) {
    if (!display.readAndDispatch())
      display.sleep();
  }
  display.dispose();
}
 
Example 14
Project: APITools   File: CharSetDialog.java   View Source Code Vote up 5 votes
/**
 * Open the dialog.
 * 
 * @return the result
 */
public Object[] open(String requestCharset, String responseCharSet) {
	this.requestCharSet = requestCharset;
	this.responseCharSet = responseCharSet;
	createContents();
	shell.open();
	shell.layout();
	Display display = getParent().getDisplay();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
	return (new Object[] { saveFlag, this.requestCharSet, this.responseCharSet });
}
 
Example 15
Project: APITools   File: AboutTools.java   View Source Code Vote up 5 votes
public Object open(String exlplain, String version) {
	createContents(exlplain, version);
	aboutToolsShell.open();
	aboutToolsShell.layout();
	Display display = getParent().getDisplay();

	while (!aboutToolsShell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
	return result;
}
 
Example 16
Project: APITools   File: EditModDialog.java   View Source Code Vote up 5 votes
/**
 * Open the dialog.
 * 
 * @return the result
 */
public Object[] open(String modname, String des) {
	this.name = modname;
	this.description = des;
	createContents();
	shell.open();
	shell.layout();
	Display display = getParent().getDisplay();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
	return (new Object[] { saveFlag, name, description });
}
 
Example 17
Project: codelens-eclipse   File: CodeLensDemo.java   View Source Code Vote up 5 votes
public static void main(String[] args) throws Exception {
	// create the widget's shell
	Shell shell = new Shell();
	shell.setLayout(new FillLayout());
	shell.setSize(500, 500);
	Display display = shell.getDisplay();

	Composite parent = new Composite(shell, SWT.NONE);
	parent.setLayout(new GridLayout(2, false));

	ITextViewer textViewer = new TextViewer(parent, SWT.V_SCROLL | SWT.BORDER);
	String delim = textViewer.getTextWidget().getLineDelimiter();
	textViewer.setDocument(new Document(delim + " class A" + delim + "new A" + delim + "new A" + delim + "class B"
			+ delim + "new B" + delim + "interface I" + delim + "class C implements I"));
	StyledText styledText = textViewer.getTextWidget();
	styledText.setLayoutData(new GridData(GridData.FILL_BOTH));

	CodeLensProviderRegistry registry = CodeLensProviderRegistry.getInstance();
	registry.register(CONTENT_TYPE_ID, new ClassReferencesCodeLensProvider());
	registry.register(CONTENT_TYPE_ID, new ClassImplementationsCodeLensProvider());

	CodeLensStrategy codelens = new CodeLensStrategy(new DefaultCodeLensContext(textViewer), false);
	codelens.addTarget(CONTENT_TYPE_ID).reconcile(null);

	styledText.addModifyListener(new ModifyListener() {

		@Override
		public void modifyText(ModifyEvent event) {
			codelens.reconcile(null);
		}
	});

	shell.open();
	while (!shell.isDisposed())
		if (!display.readAndDispatch())
			display.sleep();
}
 
Example 18
Project: BiglyBT   File: SimpleBrowserWindow.java   View Source Code Vote up 5 votes
public static void main(String[] args) {
	Display display = new Display();
	Shell shell = new Shell(display, SWT.DIALOG_TRIM);
	shell.setSize(800, 600);

	new SimpleBrowserWindow(shell, "http://google.com", 0.8, 0.5, true, false);

	shell.open();

	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
}
 
Example 19
Project: APITools   File: UrlEncodeTools.java   View Source Code Vote up 5 votes
public Object open() {
	createContents();
	urlEncodeToolsShell.open();
	urlEncodeToolsShell.layout();
	Display display = getParent().getDisplay();
	while (!urlEncodeToolsShell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
	return result;
}
 
Example 20
Project: applecommander   File: Wizard.java   View Source Code Vote up 5 votes
/**
 * Open and display the dialog.
 */
public void open() {
	createDialog();
	SwtUtil.center(parent, dialog);
	dialog.open();
	Display display = dialog.getDisplay();
	while (!dialog.isDisposed()) {
		if (!display.readAndDispatch()) display.sleep ();
	}
}