コード例 #1
0
ファイル: TCFAnnotationManager.java プロジェクト: eclipse/tcf
 private void displayExec(Runnable r) {
   synchronized (Device.class) {
     if (!display.isDisposed()) {
       display.asyncExec(r);
     }
   }
 }
コード例 #2
0
  public void updateProgress(
      final InetAddress currentAddress, final int runningThreads, final int percentageComplete) {
    if (display.isDisposed()) return;
    display.asyncExec(
        new Runnable() {
          public void run() {
            if (statusBar.isDisposed()) return;

            // update status bar
            if (currentAddress != null) {
              statusBar.setStatusText(
                  Labels.getLabel("state.scanning") + currentAddress.getHostAddress());
            }
            statusBar.setRunningThreads(runningThreads);
            statusBar.setProgress(percentageComplete);

            // show percentage in main window title
            if (!stateMachine.inState(ScanningState.IDLE))
              statusBar.getShell().setText(percentageComplete + "% - " + mainWindowTitle);
            else statusBar.getShell().setText(mainWindowTitle);

            // change button image according to the current state
            button.setImage(buttonImages[stateMachine.getState().ordinal()]);
          }
        });
  }
コード例 #3
0
  /**
   * Adds this as element state listener in the UI thread as it can otherwise conflict with other
   * listener additions, since DocumentProvider is not thread-safe.
   *
   * @param editor the editor to get the display from
   * @param provider the document provider to register as element state listener
   */
  private void addElementStateListener(ITextEditor editor, final IDocumentProvider provider) {
    // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=66686 and
    // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=56871

    Runnable runnable =
        new Runnable() {
          public void run() {
            synchronized (fLock) {
              if (fDocumentProvider == provider)
                // addElementStateListener adds at most once - no problem to call repeatedly
                provider.addElementStateListener(LastSaveReferenceProvider.this);
            }
          }
        };

    Display display = null;
    if (editor != null) {
      IWorkbenchPartSite site = editor.getSite();
      if (site != null) {
        IWorkbenchWindow window = site.getWorkbenchWindow();
        if (window != null) {
          Shell shell = window.getShell();
          if (shell != null) display = shell.getDisplay();
        }
      }
    }

    if (display != null && !display.isDisposed()) {
      display.asyncExec(runnable);
    } else {
      runnable.run();
    }
  }
コード例 #4
0
ファイル: GuiTestMain.java プロジェクト: pcaillou/InnovNation
  public void clickVoteOnIdea() {

    if (display.isDisposed()) return;

    if ((clientWhiteboard.getSelectionControl().getSelectedIdeas().size()
            + clientWhiteboard.getSelectionControl().getSelectedIdeas().size())
        == 0) return;

    GuiCreateComment guicomment =
        new GuiCreateComment(getPlayerId(), display, clientCore.getGame(), clientCore);

    guicomment.init(
        clientWhiteboard.getSelectionControl().getSelectedIdeas(),
        clientWhiteboard.getSelectionControl().getSelectedComments());

    guicomment.run();

    if (guicomment.getResultName() == null) return; // user cancelled

    /*		try {
    	clientCore.getGame().addIdea(
    			getPlayerId(),
    			guiCreateIdea.getResultName(),
    			guiCreateIdea.getResultItemIds(),
    			guiCreateIdea.getResultParentIds()
    			);
    } catch (Exception e) {
    	displayError("error while creating the idea", e);
    }*/

  }
コード例 #5
0
ファイル: GuiTestMain.java プロジェクト: pcaillou/InnovNation
  public void clickCreateIdea() {

    if (display.isDisposed()) return;

    GuiCreateIdea guiCreateIdea = new GuiCreateIdea(getPlayerId(), display, clientCore.getGame());

    guiCreateIdea.init(
        clientWhiteboard.getSelectionControl().getSelectedIdeas(),
        clientWhiteboard.getSelectionControl().getSelectedItems());

    guiCreateIdea.run();

    if (guiCreateIdea.getResultName() == null) return; // user probably cancelled

    try {
      clientCore
          .getGame()
          .addIdea(
              getPlayerId(),
              guiCreateIdea.getResultName(),
              guiCreateIdea.getResultDesc(),
              guiCreateIdea.getResultItemIds(),
              guiCreateIdea.getResultParentIds());
    } catch (Exception e) {
      displayError("error while creating the idea", e);
    }
  }
コード例 #6
0
  /**
   * Update the presentation.
   *
   * @param textPresentation the text presentation
   * @param addedPositions the added positions
   * @param removedPositions the removed positions
   */
  private void updatePresentation(
      TextPresentation textPresentation,
      List<Position> addedPositions,
      List<Position> removedPositions) {
    Runnable runnable =
        fJobPresenter.createUpdateRunnable(textPresentation, addedPositions, removedPositions);
    if (runnable == null) {
      return;
    }

    DartEditor editor = fEditor;
    if (editor == null) {
      return;
    }

    IWorkbenchPartSite site = editor.getSite();
    if (site == null) {
      return;
    }

    Shell shell = site.getShell();
    if (shell == null || shell.isDisposed()) {
      return;
    }

    Display display = shell.getDisplay();
    if (display == null || display.isDisposed()) {
      return;
    }

    display.asyncExec(runnable);
  }
コード例 #7
0
  /* (non-Javadoc)
   * @see com.windowtester.runtime.IUIContext#wait(com.windowtester.runtime.condition.ICondition, long, int)
   */
  public void wait(ICondition condition, long timeout, int interval) throws WaitTimedOutException {
    expectDelay(timeout);

    // TODO [author=Dan] waitForShellShowing/Disposed had handleConditions
    // 		but other wait(...) methods did not, so this is a slight change
    handleConditions();

    long now = System.currentTimeMillis();
    while (!ConditionMonitor.test(this, condition)) {
      if (System.currentTimeMillis() - now > timeout) {

        // If the display is valid, then capture the screen and close open shells
        if (_display == null)
          LogHandler.log("failed to get current display in wait timeout handling");
        else if (_display.isDisposed())
          LogHandler.log("current display is disposed in wait timeout handling");
        else {
          doScreenCapture("on timeout");
          new ExceptionHandlingHelper(_display, true).closeOpenShells();
        }

        // Build diagnostic information
        throw new WaitTimedOutException(
            Diagnostic.toString("Timed out waiting for condition", condition));
      }
      // note conditions are handled in the pause
      pause(interval);
    }
  }
コード例 #8
0
  /**
   * Hook the given Listener to the Mac OS X application Quit menu and the IActions to the About and
   * Preferences menus.
   *
   * @param display The Display to use.
   * @param quitListener The listener to invoke when the Quit menu is invoked.
   * @param aboutAction The action to run when the About menu is invoked.
   * @param preferencesAction The action to run when the Preferences menu is invoked.
   */
  public void hookApplicationMenu(
      Display display, Listener quitListener, IAction aboutAction, IAction preferencesAction) {
    // This is our callbackObject whose 'actionProc' method will be called when the About or
    // Preferences menuItem is invoked.
    MenuHookObject target = new MenuHookObject(aboutAction, preferencesAction);

    try {
      // Initialize the menuItems.
      initialize(target);
    } catch (Exception e) {
      throw new IllegalStateException(e);
    }

    // Connect the quit/exit menu.
    if (!display.isDisposed()) {
      display.addListener(SWT.Close, quitListener);
    }

    // Schedule disposal of callback object
    display.disposeExec(
        new Runnable() {
          public void run() {
            invoke(proc3Args, "dispose");
          }
        });
  }
コード例 #9
0
ファイル: GuiTestMain.java プロジェクト: pcaillou/InnovNation
  private void clickCreateGame() {

    if (display.isDisposed()) return;

    GuiCreateGame guiCreateGame = new GuiCreateGame(display);
    guiCreateGame.init();
    guiCreateGame.run();

    String gameName = guiCreateGame.getGameName();
    //		.replaceAll("![a-zA-Z0-9_]", "_");
    // TODO constrain the format
    String gameTheme = guiCreateGame.getGameTheme();

    if (gameName == null) return;

    try {
      gameServer.createGame(gameName, gameTheme);
    } catch (Exception e) {
      displayError("Error while creating this game, sorry", e);
    }

    setServerMode(GuiServerMode.SERVER_WITH_GAME);

    // GuiCreateIdea guiCreateIdea = new GuiCreateIdea(compositeHost);
  }
コード例 #10
0
  public void dispose() {
    shell.dispose();
    if (trayItem != null) {
      trayItem.dispose();
      trayItem = null;
    }

    if (image != null) {
      image.dispose();
    }
    if (image2 != null) {
      image2.dispose();
    }
    try {
      if (!display.isDisposed()) {
        display.dispose();
      }
    } catch (Exception e) {
      // already disposed
    }
    // dispose AWT frames
    if (settingsFrame != null) {
      settingsFrame.dispose();
    }
    if (aboutFrame != null) {
      aboutFrame.dispose();
    }
    if (logBrokerMonitor != null) {
      logBrokerMonitor.dispose();
    }
  }
コード例 #11
0
ファイル: GeoMapTest.java プロジェクト: eclipse/nebula
 protected void handleEvents() {
   while (display != null && (!display.isDisposed()) && (!parent.isDisposed())) {
     if (!display.readAndDispatch()) {
       break; // display.sleep();
     }
   }
 }
コード例 #12
0
ファイル: GameView.java プロジェクト: fogleman/WordWarrior
 private void exec(Runnable runnable) {
   if (canvas == null) return;
   if (canvas.isDisposed()) return;
   Display display = canvas.getDisplay();
   if (!display.isDisposed()) {
     display.asyncExec(runnable);
   }
 }
コード例 #13
0
ファイル: Main.java プロジェクト: udoprog/c10t-swt
  public static void main(String[] args) {
    Display display = Display.getDefault();
    final Shell shell = new Shell(display, SWT.TITLE | SWT.CLOSE);
    shell.setText(TITLE);

    final String C10T_PATH = System.getenv("C10T_PATH");

    final C10tGraphicalInterface gui = new C10tGraphicalInterface(display, shell);
    final DetachedProcess detachedProcess = new C10tDetachedProcess(gui);
    final CommandExecutioner executioner =
        new CommandExecutioner("c10t", detachedProcess, C10T_PATH);

    gui.addRenderButtonListener(new RenderSelection(shell, gui, executioner));

    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    gridLayout.marginBottom = 8;
    gridLayout.marginTop = 8;
    gridLayout.marginLeft = 8;
    gridLayout.marginRight = 8;

    shell.setLayout(gridLayout);
    shell.pack();
    shell.open();

    shell.setSize(500, shell.getSize().y);

    try {
      executioner.findCommand();
    } catch (CommandNotFoundException e) {
      MessageBox messageBox = new MessageBox(shell, SWT.ERROR);
      messageBox.setText("c10t - Command could not be found");
      messageBox.setMessage(
          "The program `"
              + executioner.getName()
              + "' could not be located anywhere in your PATH or in the current working directory\n\n"
              + "You must be fixed this by doing one of the following:\n\n"
              + " 1) Install the command `"
              + executioner.getName()
              + "' to somewhere in your PATH or the working directory of this program `"
              + System.getProperty("user.dir")
              + "'\n"
              + " 2) Specify where the command is with the environment variable `C10T_PATH'\n\n"
              + "Your PATH is: "
              + System.getenv("PATH"));
      messageBox.open();
    }

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

    if (!display.isDisposed()) {
      display.dispose();
    }
  }
コード例 #14
0
ファイル: GuiTestMain.java プロジェクト: pcaillou/InnovNation
  private void clickEditVisuParams() {

    if (display.isDisposed()) return;

    GUIParameters guiParams =
        new GUIParameters(display, "Visu Parameters", GUIParametersMode.STANDALONE);
    guiParams.init(clientWhiteboard.getParameters());
    guiParams.refreshDirect();
    guiParams.openDirect();
  }
コード例 #15
0
 private void pruneResourceManagers() {
   Set displays = resourceManagers.keySet();
   for (Iterator iter = displays.iterator(); iter.hasNext(); ) {
     Display display = (Display) iter.next();
     if (display.isDisposed()) {
       resourceManagers.remove(display);
       iter = displays.iterator();
     }
   }
 }
コード例 #16
0
 /*
  * There are situations where this is called more than once until we know
  * why this is needed we should make this safe for multiple calls
  */
 private void cleanUp() {
   if (keyListener != null) {
     Display display = Display.getDefault();
     if (!display.isDisposed()) {
       display.removeFilter(SWT.KeyDown, keyListener);
       display.removeFilter(SWT.Traverse, keyListener);
       keyListener = null;
     }
   }
 }
コード例 #17
0
    /** Posts this runnable into the event queue. */
    public void post(IContentOutlinePage page) {
      this.page = page;
      if (posted) return;

      Display d = Display.getDefault();
      if (d != null && !d.isDisposed()) {
        posted = true;
        d.asyncExec(this);
      }
    }
コード例 #18
0
    /** Posts this runnable into the event queue. */
    public void postMessage(String message) {
      this.message = message;
      if (posted) return;

      Display d = Display.getDefault();
      if (d != null && !d.isDisposed()) {
        posted = false;
        d.asyncExec(this);
      }
    }
コード例 #19
0
 /** Processes events or waits until this modal context thread terminates. */
 public void block() {
   if (display == Display.getCurrent()) {
     int exceptionCount = 0;
     while (continueEventDispatching) {
       // Run the event loop. Handle any uncaught exceptions caused
       // by UI events.
       try {
         if (!display.readAndDispatch()) {
           display.sleep();
         }
         exceptionCount = 0;
       }
       // ThreadDeath is a normal error when the thread is dying.
       // We must
       // propagate it in order for it to properly terminate.
       catch (ThreadDeath e) {
         throw (e);
       }
       // For all other exceptions, log the problem.
       catch (Throwable t) {
         if (t instanceof VirtualMachineError) {
           throw (VirtualMachineError) t;
         }
         exceptionCount++;
         // We're counting exceptions in client code, such as asyncExecs,
         // so be generous about how many may fail consecutively before we
         // give up.
         if (exceptionCount > 50 || display.isDisposed()) {
           if (t instanceof RuntimeException) {
             throw (RuntimeException) t;
           } else if (t instanceof Error) {
             throw (Error) t;
           } else {
             throw new RuntimeException(t);
           }
         }
         Policy.getLog()
             .log(
                 new Status(
                     IStatus.ERROR,
                     Policy.JFACE,
                     "Unhandled event loop exception during blocked modal context.", //$NON-NLS-1$
                     t));
       }
     }
   } else {
     try {
       join();
     } catch (InterruptedException e) {
       throwable = e;
     }
   }
 }
コード例 #20
0
  protected String[] getAuthenticationDialog(final String realm, final String tracker) {
    final Display display = SWTThread.getInstance().getDisplay();

    if (display.isDisposed()) {

      return (null);
    }

    final AESemaphore sem = new AESemaphore("SWTAuth");

    final authDialog[] dialog = new authDialog[1];

    TOTorrent torrent = TorrentUtils.getTLSTorrent();

    final String torrent_name;

    if (torrent == null) {

      torrent_name = null;

    } else {

      torrent_name = TorrentUtils.getLocalisedName(torrent);
    }

    try {
      display.asyncExec(
          new AERunnable() {
            public void runSupport() {
              dialog[0] = new authDialog(sem, display, realm, tracker, torrent_name);
            }
          });
    } catch (Throwable e) {

      Debug.printStackTrace(e);

      return (null);
    }
    sem.reserve();

    String user = dialog[0].getUsername();
    String pw = dialog[0].getPassword();
    String persist = dialog[0].savePassword() ? "true" : "false";

    if (user == null) {

      return (null);
    }

    return (new String[] {user, pw == null ? "" : pw, persist});
  }
コード例 #21
0
  private static Display getDisplay() {
    Display display = Internal_PackageSupport.getDisplayInstance();

    // following if loop (getting default display) should be removed
    // if agreed that MobileDevice shouldn't create the display.
    if (display == null) {
      display = Display.getDefault();
    }

    if (display == null || display.isDisposed()) {
      SWT.error(SWT.ERROR_DEVICE_DISPOSED);
    }
    return display;
  }
コード例 #22
0
 private void processEvents() {
   // renderer.run(window, appContext);
   Display display = Display.getCurrent();
   if (display.isDisposed()) {
     return;
   }
   try {
     while (display.readAndDispatch()) {
       appContext.processWaiting();
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
コード例 #23
0
ファイル: MobileInfoView.java プロジェクト: icsnju/apt-dm
  public void updateShotView(final ImageData id) {

    if (display == null || display.isDisposed()) return;

    display.asyncExec(
        new Runnable() {
          @Override
          public void run() {
            // System.out.println("shot view");
            Image image = new Image(display, id);
            sstLabel.setImage(image);
            sstLabel.update();
          }
        });
  }
コード例 #24
0
ファイル: SpellingHelper.java プロジェクト: nickmain/xmind
    public synchronized void check(Display display) {
      if (display == null || display.isDisposed() || !isActive()) return;

      if (start == -1) {
        // not scheduled
        this.display = display;
        schedule();
      } else if (start == -2) {
        // working
        rescheduling = true;
      } else {
        // scheduling
        start = System.currentTimeMillis();
      }
    }
コード例 #25
0
ファイル: GuiTestMain.java プロジェクト: pcaillou/InnovNation
  private void setClientMode(GuiClientMode novelMode) {
    this.modeClient = novelMode;

    if (display.isDisposed()) return;

    display.asyncExec(
        new Runnable() {

          @Override
          public void run() {
            updateShellTitle();
            updateStates();
          }
        });
  }
コード例 #26
0
ファイル: DisplayLCA.java プロジェクト: oaperez/rap
 private static void renderFocus(Display display) {
   if (!display.isDisposed()) {
     IDisplayAdapter displayAdapter = getDisplayAdapter(display);
     RemoteAdapter widgetAdapter = getAdapter(display);
     Object oldValue = widgetAdapter.getPreserved(PROP_FOCUS_CONTROL);
     if (!widgetAdapter.isInitialized()
         || oldValue != display.getFocusControl()
         || displayAdapter.isFocusInvalidated()) {
       // TODO [rst] Added null check as a NPE occurred in some rare cases
       Control focusControl = display.getFocusControl();
       if (focusControl != null) {
         getRemoteObject(display).set(PROP_FOCUS_CONTROL, getId(display.getFocusControl()));
       }
     }
   }
 }
コード例 #27
0
ファイル: StartupJob.java プロジェクト: nacerix/xmind
 protected IStatus run(IProgressMonitor monitor) {
   monitor.beginTask(null, 3);
   doStartup(monitor);
   Display display = workbench.getDisplay();
   if (display != null && !display.isDisposed()) {
     display.asyncExec(
         new Runnable() {
           public void run() {
             System.setProperty(
                 "org.xmind.cathy.app.status", "workbenchReady"); // $NON-NLS-1$ //$NON-NLS-2$
           }
         });
   }
   monitor.done();
   return Status.OK_STATUS;
 }
コード例 #28
0
  private void abortContinueDialog(final IDebugTarget target) {
    // do not report errors for snippet editor targets
    // that do not support HCR. HCR is simulated by using
    // a new class loader for each evaluation
    // final ILaunch launch = target.getLaunch();
    // if (launch.getAttribute(ScrapbookLauncher.SCRAPBOOK_LAUNCH) != null)
    // {
    // if (!target.supportsHotCodeReplace()) {
    // return;
    // }
    // }
    final Display display = ErlideUIPlugin.getStandardDisplay();
    if (display.isDisposed()) {
      return;
    }

    String name = null;
    try {
      name = target.getName();
    } catch (final DebugException e) {
      name = ""; // never happens, ErlangDebugTarget doesn't throw this...
    }
    final String vmName = name;
    final ILaunchConfiguration config = target.getLaunch().getLaunchConfiguration();
    final String launchName = config != null ? config.getName() : "<unknown>";
    final IStatus status =
        new Status(IStatus.ERROR, ErlangCore.PLUGIN_ID, IStatus.ERROR, "Can't replace code", null);
    final String title = "Code Replace Failed";
    final String message =
        MessageFormat.format(
            "Some code changes cannot be replaced when being debugged.",
            new Object[] {vmName, launchName});
    display.asyncExec(
        new Runnable() {
          @Override
          public void run() {
            if (display.isDisposed()) {
              return;
            }
            final Shell shell = ErlideUIPlugin.getActiveWorkbenchShell();
            final HotCodeReplaceErrorDialog dialog =
                new HotCodeReplaceErrorDialog(shell, title, message, status, target);
            dialog.setBlockOnOpen(false);
            dialog.open();
          }
        });
  }
コード例 #29
0
  protected AssociationChecker(final PlatformManager _platform) {
    platform = _platform;

    display = SWTThread.getInstance().getDisplay();

    if (display.isDisposed()) {

      return;
    }

    Utils.execSWTThread(
        new AERunnable() {
          public void runSupport() {
            check();
          }
        });
  }
コード例 #30
0
  private void fireChanges(final IResource[] changes, final boolean markerChanged) {
    Display display = SWTUtil.getStandardDisplay();
    if (display != null && !display.isDisposed()) {
      display.asyncExec(
          new Runnable() {

            @Override
            public void run() {
              Object[] listeners = fListeners.getListeners();
              for (Object listener : listeners) {
                IProblemChangedListener curr = (IProblemChangedListener) listener;
                curr.problemsChanged(changes, markerChanged);
              }
            }
          });
    }
  }