X-Git-Url: http://git.nikiroo.be/?p=jvcard.git;a=blobdiff_plain;f=src%2Fcom%2Fgooglecode%2Flanterna%2Fgui2%2FSameTextGUIThread.java;fp=src%2Fcom%2Fgooglecode%2Flanterna%2Fgui2%2FSameTextGUIThread.java;h=0000000000000000000000000000000000000000;hp=a22dc7e7f7fc58e489036cb13f272254b3b087c7;hb=f06c81000632cfb5f525ca458f719338f55f9f66;hpb=a73a906356c971b080c36368e71a15d87e8b8d31 diff --git a/src/com/googlecode/lanterna/gui2/SameTextGUIThread.java b/src/com/googlecode/lanterna/gui2/SameTextGUIThread.java deleted file mode 100644 index a22dc7e..0000000 --- a/src/com/googlecode/lanterna/gui2/SameTextGUIThread.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.googlecode.lanterna.gui2; - -/** - * This {@link TextGUIThread} implementation is assuming the GUI event thread will be the same as the thread that - * creates the {@link TextGUI} objects. This means on the thread you create the GUI on, when you are done you pass over - * control to lanterna and let it manage the GUI for you. When the GUI is done, you'll get back control again over the - * thread. This is different from {@code SeparateTextGUIThread} which spawns a new thread that manages the GUI and - * leaves the current thread for you to handle.

- * Here are two examples of how to use {@code SameTextGUIThread}: - *

- *     {@code
- *     MultiWindowTextGUI textGUI = new MultiWindowTextGUI(new SameTextGUIThread.Factory(), screen);
- *     // ... add components ...
- *     while(weWantToContinueRunningTheGUI) {
- *         if(!textGUI.getGUIThread().processEventsAndUpdate()) {
- *             Thread.sleep(1);
- *         }
- *     }
- *     // ... tear down ...
- *     }
- * 
- * In the example above, we use very precise control over events processing and when to update the GUI. In the example - * below we pass some of that control over to Lanterna, since the thread won't resume until the window is closed. - *
- *     {@code
- *     MultiWindowTextGUI textGUI = new MultiWindowTextGUI(new SameTextGUIThread.Factory(), screen);
- *     Window window = new MyWindow();
- *     textGUI.addWindowAndWait(window); // This call will run the event/update loop and won't return until "window" is closed
- *     // ... tear down ...
- *     }
- * 
- * @see SeparateTextGUIThread - * @see TextGUIThread - */ -public class SameTextGUIThread extends AbstractTextGUIThread { - - private final Thread guiThread; - - private SameTextGUIThread(TextGUI textGUI) { - super(textGUI); - guiThread = Thread.currentThread(); - } - - @Override - public Thread getThread() { - return guiThread; - } - - @Override - public void invokeAndWait(Runnable runnable) throws IllegalStateException, InterruptedException { - if(guiThread == null || guiThread == Thread.currentThread()) { - runnable.run(); - } - super.invokeAndWait(runnable); - } - - /** - * Default factory class for {@code SameTextGUIThread}, you need to pass this to the {@code TextGUI} constructor if - * you want it to use this class - */ - public static class Factory implements TextGUIThreadFactory { - @Override - public TextGUIThread createTextGUIThread(TextGUI textGUI) { - return new SameTextGUIThread(textGUI); - } - } -}