Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Copyright (c) 2015 Andrzej Borucki, see LICENSE file
- package com.blogspot.borneq;
- import java.util.ArrayList;
- import java.util.List;
- import org.eclipse.swt.widgets.Display;
- /**
- * Start application class with static {@code main} method
- * which creates {@code Display} object and call main window constructor
- * @author Andrzej Borucki
- * @version 1.0
- * @since 2015-07-13
- */
- public class IconEditApp {
- static private List<ShellMain> shellList;
- private static Display display;
- static public void registerShell(ShellMain shell) {
- shellList.add(shell);
- }
- static private int getWaitingShellCount()
- {
- int countWaiting = 0;
- int startSize = shellList.size();
- //this for loop it gives me more control than
- //for (: shellList) where was error for empty list
- for (int i=startSize-1; i>=0; i--)
- {
- ShellMain shell = shellList.get(i);
- if (!shell.isDisposed())
- countWaiting++;
- else
- shellList.remove(i); //enable GC dispose memory
- }
- return countWaiting;
- }
- static private void startEventLoop() {
- while (getWaitingShellCount()>0) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- }
- /**
- * Entry point of application
- * @param args list of arguments
- */
- public static void main(String[] args) {
- shellList = new ArrayList<ShellMain>();
- display = new Display();
- registerShell(new ShellMain());
- startEventLoop();
- display.dispose();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment