@Override
 protected void setUp() {
   super.setUp();
   display = Display.getDefault();
   monitors = display.getMonitors();
   primary = display.getPrimaryMonitor();
 }
Пример #2
0
 @Subscribe
 public void showError(ApplicationError error) {
   error.getThrowable().printStackTrace();
   MessageBox box = new MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_ERROR);
   box.setMessage(error.getMessage());
   box.setText(resourceBundle.getString("mainForm.error"));
   box.open();
 }
 public void onFinish() {
   Display.getDefault()
       .syncExec(
           new Runnable() {
             public void run() {
               listener.onFinish();
             }
           });
 }
Пример #4
0
 /**
  * Constructs a new instance of this class given the display to create it on and a style value
  * describing its behavior and appearance.
  *
  * <p>The style value is either one of the style constants defined in class <code>SWT</code> which
  * is applicable to instances of this class, or must be built by <em>bitwise OR</em>'ing together
  * (that is, using the <code>int</code> "|" operator) two or more of those <code>SWT</code> style
  * constants. The class description lists the style constants that are applicable to the class.
  * Style bits are also inherited from superclasses.
  *
  * <p>Note: Currently, null can be passed in for the display argument. This has the effect of
  * creating the tracker on the currently active display if there is one. If there is no current
  * display, the tracker is created on a "default" display. <b>Passing in null as the display
  * argument is not considered to be good coding style, and may not be supported in a future
  * release of SWT.</b>
  *
  * @param display the display to create the tracker on
  * @param style the style of control to construct
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
  *       <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
  *     </ul>
  *
  * @see SWT#LEFT
  * @see SWT#RIGHT
  * @see SWT#UP
  * @see SWT#DOWN
  */
 public Tracker(Display display, int style) {
   if (display == null) display = Display.getCurrent();
   if (display == null) display = Display.getDefault();
   if (!display.isValidThread()) {
     error(SWT.ERROR_THREAD_INVALID_ACCESS);
   }
   this.style = checkStyle(style);
   this.display = display;
 }
Пример #5
0
 public static void runInUI(@Nullable Shell shell, @NotNull Runnable runnable) {
   final Display display =
       shell == null || shell.isDisposed() ? Display.getDefault() : shell.getDisplay();
   if (display.getThread() != Thread.currentThread()) {
     display.syncExec(runnable);
   } else {
     runnable.run();
   }
 }
 public void onRuleFinished(final VRule rule, final VObject object) {
   Display.getDefault()
       .syncExec(
           new Runnable() {
             public void run() {
               listener.onRuleFinished(rule, object);
             }
           });
 }
 public void onRuleApplied(final VRule rule, final VObject object, final VResult[] results) {
   Display.getDefault()
       .syncExec(
           new Runnable() {
             public void run() {
               listener.onRuleApplied(rule, object, results);
             }
           });
 }
Пример #8
0
 /* (non-Javadoc)
  * @see org.eclipse.ui.IStartup#earlyStartup()
  */
 public void earlyStartup() {
   final Display display = Display.getDefault();
   display.syncExec(
       new AERunnable() {
         public void runSupport() {
           hookApplicationMenu(display);
         }
       });
 }
Пример #9
0
 static final int quitAppProc(int theAppleEvent, int reply, int handlerRefcon) {
   UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
   if (uiFunctions != null) {
     uiFunctions.dispose(false, false);
   } else {
     UIExitUtilsSWT.setSkipCloseCheck(true);
     Display.getDefault().dispose();
   }
   return noErr;
 }
Пример #10
0
 /** Open the window. */
 public void open() {
   Display display = Display.getDefault();
   createContents();
   shlUCEditor.open();
   shlUCEditor.layout();
   while (!shlUCEditor.isDisposed()) {
     if (!display.readAndDispatch()) {
       display.sleep();
     }
   }
 }
Пример #11
0
 public static void runInDetachedUI(@Nullable Shell shell, @NotNull Runnable runnable) {
   if (shell == null) {
     Display.getDefault().asyncExec(runnable);
   } else {
     try {
       shell.getDisplay().asyncExec(runnable);
     } catch (SWTException e) {
       // DF: Widget has been disposed, too late for some processing then..
     }
   }
 }
Пример #12
0
 public static void main(String[] args) {
   // Locale.setDefault(new Locale("nl", "NL"));
   // MessageText.changeLocale(new Locale("nl", "NL"));
   System.out.println(Locale.getDefault().getCountry());
   new WelcomeWindow(null);
   Display display = Display.getDefault();
   while (true) {
     if (!display.readAndDispatch()) {
       display.sleep();
     }
   }
 }
Пример #13
0
  public void performFinish(IProgressMonitor monitor) {
    Display.getDefault()
        .asyncExec(
            new Runnable() {

              public void run() {
                PHPUiPlugin.getDefault()
                    .getPreferenceStore()
                    .setValue(
                        (PreferenceConstants.JavaScriptSupportEnable),
                        fJavaScriptSupportGroup.getSelection());
              }
            });
  }
Пример #14
0
 void createStyledText() {
   text =
       new org.eclipse.swt.custom.StyledText(
           shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
   org.eclipse.swt.layout.GridData spec = new org.eclipse.swt.layout.GridData();
   spec.horizontalAlignment = GridData.FILL;
   spec.grabExcessHorizontalSpace = true;
   spec.verticalAlignment = GridData.FILL;
   spec.grabExcessVerticalSpace = true;
   text.setLayoutData(spec);
   text.addLineStyleListener(lineStyler);
   text.setEditable(false);
   org.eclipse.swt.graphics.Color bg = Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
   text.setBackground(bg);
 }
Пример #15
0
 public static void main(String[] args) {
   Display display = Display.getDefault();
   Shell shell = new Shell(display);
   @SuppressWarnings("unused")
   MainWindow inst = new MainWindow(shell, SWT.NULL);
   shell.setLayout(new FillLayout());
   shell.setImage(SWTResourceManager.getImage("images/16x16.png"));
   shell.setText("Change This Title");
   shell.setBackgroundImage(SWTResourceManager.getImage("images/ToolbarBackground.gif"));
   shell.layout();
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) display.sleep();
   }
 }
 protected void handleServerButtonSelected() {
   final Server newServer = getServerFromWizard();
   if (newServer != null) {
     Display.getDefault()
         .asyncExec(
             new Runnable() {
               public void run() {
                 servers.add(newServer);
                 serverCombo.add(newServer.getName());
                 serverCombo.select(serverCombo.indexOf(newServer.getName()));
                 handleServerSelection();
               }
             });
   }
 }
Пример #17
0
 void initializeColors() {
   Display display = Display.getDefault();
   colors =
       new Color[] {
         new Color(display, new RGB(0, 0, 0)), // black
         new Color(display, new RGB(255, 0, 0)), // red
         new Color(display, new RGB(0, 255, 0)), // green
         new Color(display, new RGB(0, 0, 255)) // blue
       };
   tokenColors = new int[MAXIMUM_TOKEN];
   tokenColors[WORD] = 0;
   tokenColors[WHITE] = 0;
   tokenColors[KEY] = 3;
   tokenColors[COMMENT] = 1;
   tokenColors[STRING] = 2;
   tokenColors[OTHER] = 0;
   tokenColors[NUMBER] = 0;
 }
 private void deleteLaunchConfiguration(final ILaunchConfiguration launchConfig)
     throws CoreException {
   Display.getDefault()
       .asyncExec(
           new Runnable() {
             public void run() {
               ILaunchConfiguration config = launchConfig;
               try {
                 if (config instanceof ILaunchConfigurationWorkingCopy) {
                   config = ((ILaunchConfigurationWorkingCopy) config).getOriginal();
                 }
                 if (config != null) {
                   config.delete();
                 }
               } catch (CoreException ce) {
                 // Ignore
               }
             }
           });
 }
 public void propertyChange(PropertyChangeEvent evt) {
   if (evt.getPropertyName().equals(InstallOptionsModel.PROPERTY_INDEX)) {
     mDialog.moveChild(mCurrentWidget, ((Integer) evt.getNewValue()).intValue());
   } else if (evt.getPropertyName().equals(InstallOptionsModel.PROPERTY_CHILDREN)) {
     if (Common.objectsAreEqual(mCurrentWidget, evt.getOldValue())
         && evt.getNewValue() instanceof InstallOptionsWidget) {
       InstallOptionsWidget widget = (InstallOptionsWidget) evt.getNewValue();
       mCurrentWidget.removeModelCommandListener(InstallOptionsWidgetEditorDialog.this);
       mCurrentWidget.removePropertyChangeListener(InstallOptionsWidgetEditorDialog.this);
       mCurrentWidget = widget;
       mSection = mCurrentWidget.getSection();
       mCurrentWidget.addModelCommandListener(InstallOptionsWidgetEditorDialog.this);
       mCurrentWidget.addPropertyChangeListener(InstallOptionsWidgetEditorDialog.this);
       Display.getDefault()
           .asyncExec(
               new Runnable() {
                 public void run() {
                   mPage.selectionChanged(null, new StructuredSelection(mCurrentWidget));
                 }
               });
     }
   }
 }
Пример #20
0
 @Override
 protected Control createMessageArea(Composite composite) {
   // create composite
   // create image
   Image image = getImage();
   if (image != null) {
     imageLabel = new Label(composite, SWT.NULL);
     image.setBackground(imageLabel.getBackground());
     imageLabel.setImage(image);
     addAccessibleListeners(imageLabel, image);
     GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.BEGINNING).applyTo(imageLabel);
   }
   // create message
   if (message != null) {
     FormToolkit toolkit = new FormToolkit(Display.getDefault());
     Composite toolkitComp = toolkit.createComposite(composite);
     toolkitComp.setLayout(new FillLayout(SWT.HORIZONTAL | SWT.VERTICAL));
     FormText text = toolkit.createFormText(toolkitComp, false);
     text.setText(message, true, true);
     text.setBackground(composite.getBackground());
     GridDataFactory.fillDefaults()
         .align(SWT.FILL, SWT.BEGINNING)
         .grab(true, false)
         .hint(
             convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH),
             SWT.DEFAULT)
         .applyTo(toolkitComp);
     text.addHyperlinkListener(
         new HyperlinkAdapter() {
           public void linkActivated(HyperlinkEvent event) {
             try {
               URI uri = URI.create((String) event.data);
               if ("pref".equals(uri.getScheme())) { // $NON-NLS-1$
                 Map<String, String> para = new HashMap<String, String>();
                 para.put(
                     IWorkbenchCommandConstants.WINDOW_PREFERENCES_PARM_PAGEID,
                     uri.getAuthority());
                 Command prefCommand =
                     PlatformUI.getWorkbench()
                         .getActiveWorkbenchWindow()
                         .getService(ICommandService.class)
                         .getCommand(IWorkbenchCommandConstants.WINDOW_PREFERENCES);
                 prefCommand.executeWithChecks(new ExecutionEvent(prefCommand, para, null, null));
               }
             } catch (ExecutionException e) {
               Platform.getLog(Platform.getBundle(Constants.Bundle_ID))
                   .log(new Status(IStatus.ERROR, Constants.Bundle_ID, e.getMessage(), e));
             } catch (NotDefinedException e) {
               Platform.getLog(Platform.getBundle(Constants.Bundle_ID))
                   .log(new Status(IStatus.ERROR, Constants.Bundle_ID, e.getMessage(), e));
             } catch (NotEnabledException e) {
               Platform.getLog(Platform.getBundle(Constants.Bundle_ID))
                   .log(new Status(IStatus.ERROR, Constants.Bundle_ID, e.getMessage(), e));
             } catch (NotHandledException e) {
               Platform.getLog(Platform.getBundle(Constants.Bundle_ID))
                   .log(new Status(IStatus.ERROR, Constants.Bundle_ID, e.getMessage(), e));
             }
           }
         });
   }
   return composite;
 }
Пример #21
0
 public static Color getDefaultTitleBackGround() {
   return Display.getDefault().getSystemColor(SWT.COLOR_TITLE_BACKGROUND);
 }