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

The following are Jave code examples for showing how to use dispose() 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.
Example 1
Project: AgentWorkbench   File: PlugInApplication.java   Source Code and License Vote up 6 votes
/**
 * Starts the eclipse UI.
 * @param postWindowOpenRunnable the post window open runnable
 * @return the integer
 */
public Integer startEclipseUI(Runnable postWindowOpenRunnable) {
	
	Integer eclipseReturnValue = IApplication.EXIT_OK;
	Display display = PlatformUI.createDisplay();
	try {
		// --- Returns if visualization was closed ---- 
		int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor(postWindowOpenRunnable));
		if (returnCode == PlatformUI.RETURN_RESTART) {
			eclipseReturnValue = IApplication.EXIT_RESTART;
		} else {
			eclipseReturnValue = IApplication.EXIT_OK;
		}
		
	} finally {
		display.dispose();
		// --- Just in case of the Eclipse UI ---------
		// --- usage or after an update + restart -----
		if (this.getVisualisationPlatform()==ApplicationVisualizationBy.EclipseFramework || eclipseReturnValue==IApplication.EXIT_RESTART) {
			appReturnValue = eclipseReturnValue;
			Application.setQuitJVM(true);
		}
	}		
	return eclipseReturnValue;
}
 
Example 2
Project: neoscada   File: Application.java   Source Code and License Vote up 6 votes
@Override
public Object start ( final IApplicationContext context ) throws Exception
{
    Display display = PlatformUI.createDisplay ();
    try
    {
        int returnCode = PlatformUI.createAndRunWorkbench ( display, new ApplicationWorkbenchAdvisor () );
        if ( returnCode == PlatformUI.RETURN_RESTART )
        {
            return IApplication.EXIT_RESTART;
        }
        else
        {
            return IApplication.EXIT_OK;
        }
    }
    finally
    {
        display.dispose ();
    }

}
 
Example 3
Project: JavaFX-FrameRateMeter   File: SWTTestUtil.java   Source Code and License 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 4
Project: AppleCommander   File: Sleak.java   Source Code and License 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 5
Project: applecommander   File: Sleak.java   Source Code and License 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 6
Project: SWET   File: TipDayEx.java   Source Code and License Vote up 6 votes
public static void main(final String[] args) {
	final Display display = new Display();
	final Shell shell = new Shell(display);
	Locale.setDefault(Locale.ENGLISH);
	final TipDayEx tipDayEx = new TipDayEx();
	for (String tipMessage : new String[] { "This is the first tip",
			"This is the second tip", "This is the third tip",
			"This is the forth tip", "This is the fifth tip" }) {
		tipDayEx.addTip(String.format(
				"<h4>%s</h4>" + "<b>%s</b> " + "<u>%s</u> " + "<i>%s</i> " + "%s "
						+ "%s<br/>" + "<p color=\"#A00000\">%s</p>",
				tipMessage, tipMessage, tipMessage, tipMessage, tipMessage,
				tipMessage, tipMessage));

	}

	tipDayEx.open(shell, display);
	display.dispose();
}
 
Example 7
Project: JTouchBar   File: JTouchBarSWTTest.java   Source Code and License Vote up 6 votes
@Test
public void test() {
	JTouchBar jTouchBar = JTouchBarTestUtils.constructTouchBar();
	assertNotNull(jTouchBar);
	
	Display display = Display.getCurrent();

       Shell shell = new Shell(display);
       shell.setLayout(new FillLayout());

       shell.open();
       
       jTouchBar.show( shell );
       
       while (!shell.isDisposed()) {
           if (!display.readAndDispatch()) {
               display.sleep();
               break;
           }
       }
       
       display.dispose();
}
 
Example 8
Project: neoscada   File: Application.java   Source Code and License Vote up 5 votes
@Override
public Object start ( final IApplicationContext context ) throws Exception
{
    final Display display = PlatformUI.createDisplay ();
    try
    {
        final int returnCode = PlatformUI.createAndRunWorkbench ( display, new ApplicationWorkbenchAdvisor () );
        if ( returnCode == PlatformUI.RETURN_RESTART )
        {
            return IApplication.EXIT_RESTART;
        }
        else
        {
            return IApplication.EXIT_OK;
        }
    }
    finally
    {
        display.dispose ();
    }

}
 
Example 9
Project: neoscada   File: Application.java   Source Code and License Vote up 5 votes
public Object start(IApplicationContext context) throws Exception {
	Display display = PlatformUI.createDisplay();
	try {
		int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
		if (returnCode == PlatformUI.RETURN_RESTART)
			return IApplication.EXIT_RESTART;
		else
			return IApplication.EXIT_OK;
	} finally {
		display.dispose();
	}
	
}
 
Example 10
Project: convertigo-eclipse   File: SWTX.java   Source Code and License 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 11
Project: convertigo-eclipse   File: KTable.java   Source Code and License 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 12
Project: avoCADo   File: AvoCADo.java   Source Code and License Vote up 5 votes
public AvoCADo(){
	display = new Display();

	// splash screen.. loads before openGL is needed
	// since that can take a few seconds.  This gives
	// more immediate feedback that the app has started.
	new StartupSplashShell(display);
	
	// create the main shell and display it
	new MainAvoCADoShell(display);
	
	display.dispose();
}
 
Example 13
Project: SWET   File: SimpleToolBarEx.java   Source Code and License Vote up 5 votes
public static void main(String[] args) {
	display = new Display();

	SimpleToolBarEx simpleToolBarEx = new SimpleToolBarEx();
	simpleToolBarEx.setCodeGenImage("code_128.png");

	simpleToolBarEx.open(display);
	simpleToolBarEx.finalize();
	display.dispose();
}
 
Example 14
Project: SWET   File: TipDayEx.java   Source Code and License Vote up 5 votes
public static void main(final String[] args) {
	final Display display = new Display();
	final Shell shell = new Shell(display);
	Locale.setDefault(Locale.ENGLISH);
	final TipDayEx tipDayEx = new TipDayEx();

	String yamlFile = String.format("%s/src/main/resources/%s",
			System.getProperty("user.dir"), "help.yaml");
	help = YamlHelper.loadHelp(yamlFile);
	for (Entry<String, String> helpdata : help.entrySet()) {
		String title = helpdata.getKey();
		String description = helpdata.getValue();
		tipDayEx.addTip(String.format("<h4>%s</h4>%s", title, description));
	}
	if (tipDayEx.getTips().size() == 0) {
		for (String tipMessage : new String[] { "This is the first tip",
				"This is the second tip", "This is the third tip",
				"This is the forth tip", "This is the fifth tip" }) {
			tipDayEx.addTip(String.format(
					"<h4>%s</h4>" + "<b>%s</b> " + "<u>%s</u> " + "<i>%s</i> " + "%s "
							+ "%s<br/>" + "<p color=\"#A00000\">%s</p>",
					tipMessage, tipMessage, tipMessage, tipMessage, tipMessage,
					tipMessage, tipMessage));

		}
	}

	tipDayEx.open(shell, display);
	display.dispose();
}
 
Example 15
Project: Hydrograph   File: Application.java   Source Code and License Vote up 5 votes
public Object start(IApplicationContext context) throws Exception {
	Display display = PlatformUI.createDisplay();
	Shell shell = WorkbenchPlugin.getSplashShell(display);

	if (OSValidator.isWindows() && !PreStartActivity.isDevLaunchMode(context.getArguments())) {
		PreStartActivity activity = new PreStartActivity(shell);
		if (ToolProvider.getSystemJavaCompiler() == null) {
			activity.performPreStartActivity();
		} else {
			activity.updateINIOnJDkUpgrade();
		}
	}
	try {
		Object instanceLocationCheck = checkInstanceLocation(shell, context.getArguments());
		if (instanceLocationCheck != null) {
           	WorkbenchPlugin.unsetSplashShell(display);
               context.applicationRunning();
               return instanceLocationCheck;
           }
		int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
		if (returnCode == PlatformUI.RETURN_RESTART)
			return IApplication.EXIT_RESTART;
		else
			return IApplication.EXIT_OK;
	} finally {
		if (display != null) {
			display.dispose();
		}
		Location instanceLoc = Platform.getInstanceLocation();
		if (instanceLoc != null){
			instanceLoc.release();
		}
	}
	
}
 
Example 16
Project: BiglyBT   File: SplashWindow.java   Source Code and License Vote up 5 votes
public static void main(String args[]) {
	Display display = new Display();

	final SplashWindow splash = new SplashWindow(display);

	Thread t = new Thread() {
		@Override
		public void run() {
			try {
				int percent = 0;
				while (percent <= 100) {
					splash.reportPercent(percent++);
					splash.reportCurrentTask(percent
							+ "% Loading dbnvsudn vjksfdh fgshdu fbhsduh bvsfd fbsd fbvsdb fsuid opnum supnum boopergood haha text doot subliminal.".substring(
									0, (int) (1 + Math.random() * 110)));
					Thread.sleep(100);
				}
			} catch (Exception e) {
				// TODO: handle exception
			}
			splash.closeSplash();
		}
	};
	t.start();

	while (!splash.splash.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
	display.dispose();
}
 
Example 17
Project: openaudible   File: AppLoader.java   Source Code and License Vote up 5 votes
/**
 * Load GUI and display a Splashscreen while loading
 */
public AppLoader(String args[]) {

    if (didStartup == false) {
        // System.out.println("LM: Startup...");
        startupProcess(args);
    }

    // System.out.println("LM: syncloader.. "+Globals.WORKING_DIR);
    /* Apply application name to Display */
    Display.setAppName(getAppName());

    display = new Display();

    /* Shell should not be visible in the taskbar */
    invisibleShell = new Shell(display, SWT.NONE);
    new FontShop(display);

    GUI g = createApp(display);

    g.startUp();
    guiBuilt = true;
    g.run();
    // Call exit to close any audio threads...
    display.dispose();
    Runtime.getRuntime().exit(0);
    System.exit(0);
}
 
Example 18
Project: CS360proj1   File: ViewGUI.java   Source Code and License Vote up 4 votes
public void actionPerformed(ActionEvent arg0) {
			
			//Test URL string for window
			//String url = "https://maps.googleapis.com/maps/api/staticmap?&size=500x500&markers=size:small%7ccolor:green%7cHammond+Gavit+High+School,IN&markers=size:small%7ccolor:blue%7clabel:S%7c41.5762616,-87.4875017%7c41.5545436,-87.5048099%7c41.5481653,-87.45544319999999%7c41.5864118,-87.4398167%7c41.60522599999999,-87.509568%7c41.6283089,-87.491937%7c41.6179983,-87.5235321%7c41.5327164,-87.436207%7c41.59385,-87.4078595%7c41.6403209,-87.4853127%7c41.5476375,-87.4092115%7c41.5977957,-87.39227699999999%7c41.6782559,-87.50683839999999%7c&maptype=roadmap";
			
			//Readme instructions for user(LEGEND)
			
			String message="Welcome to the map view!\n The host School"
					+ " is marked with a green label"
					+ " and \n the other schools in the sectional are marked "
					+ " with blue labels on the map.  ";
			JOptionPane.showMessageDialog(null, message);
			
			
			//build new MapBuilder Obj
			MapBuilder map = new MapBuilder(currentSect.getHostSchool(),currentSect.getSchools());
			
			map.BuildURL();
			
			String url = map.getFinalURL();

			Display display = new Display();
			
	        Shell shell = new Shell(display);
	        shell.setSize(552, 575);
	        
	        new MapGUI(shell, SWT.NONE, url);

//	         the layout manager handle the layout
//	         of the widgets in the container
	        shell.setLayout(new FillLayout());

	        //add some widgets to the Shell
	        shell.open();
	        while (!shell.isDisposed()) {
	            if (!display.readAndDispatch()) {
	                display.sleep();
	            }
	        }
	        display.dispose();			
		}
 
Example 19
Project: n4js   File: N4JSApplication.java   Source Code and License Vote up 4 votes
@Override
public Object start(final IApplicationContext appContext) throws Exception {
	final Display display = createDisplay();

	try {

		// look and see if there's a splash shell we can parent off of
		final Shell shell = WorkbenchPlugin.getSplashShell(display);
		if (shell != null) {
			// should should set the icon and message for this shell to be the
			// same as the chooser dialog - this will be the guy that lives in
			// the task bar and without these calls you'd have the default icon
			// with no message.
			shell.setText(ChooseWorkspaceDialog.getWindowTitle());
			shell.setImages(Window.getDefaultImages());
		}

		final Object instanceLocationCheck = checkInstanceLocation(shell, appContext.getArguments());
		if (instanceLocationCheck != null) {
			WorkbenchPlugin.unsetSplashShell(display);
			appContext.applicationRunning();
			return instanceLocationCheck;
		}

		// create the workbench with this advisor and run it until it exits
		// N.B. createWorkbench remembers the advisor, and also registers
		// the workbench globally so that all UI plug-ins can find it using
		// PlatformUI.getWorkbench() or AbstractUIPlugin.getWorkbench()
		final int returnCode = createAndRunWorkbench(display, new N4JSApplicationWorkbenchAdvisor());

		// the workbench doesn't support relaunch yet (bug 61809) so
		// for now restart is used, and exit data properties are checked
		// here to substitute in the relaunch return code if needed
		if (returnCode != PlatformUI.RETURN_RESTART) {
			return EXIT_OK;
		}

		// if the exit code property has been set to the relaunch code, then
		// return that code now, otherwise this is a normal restart
		return EXIT_RELAUNCH.equals(Integer.getInteger(PROP_EXIT_CODE)) ? EXIT_RELAUNCH
				: EXIT_RESTART;
	} finally {
		if (display != null) {
			display.dispose();
		}
		final Location instanceLoc = Platform.getInstanceLocation();
		if (instanceLoc != null)
			instanceLoc.release();
	}
}
 
Example 20
Project: SWET   File: IconAndMessageDialogEx.java   Source Code and License Vote up 4 votes
public static void main(String[] args) {
	final Display display = new Display();
	final Shell shell = new Shell(display);
	(new IconAndMessageDialogEx(shell)).open();
	display.dispose();
}