예제 #1
0
  public void positionWindow(boolean resetToDefault) {
    String mapWindow;

    mapShellBounds = mapShell.getBounds();
    mapWindow = prefs.get(RadarConsts.PREF_KEY_MAP_WINDOW, "");

    if (mapWindow.equals("") || resetToDefault) {
      Rectangle dispBounds, tableBounds;

      dispBounds = ((Display.getCurrent()).getPrimaryMonitor()).getClientArea();
      tableBounds = display.getShells()[1].getBounds();

      mapShellBounds.width = dispBounds.width - tableBounds.width;
      mapShellBounds.height = dispBounds.height;
      mapShellBounds.x = dispBounds.x + tableBounds.width;
      mapShellBounds.y = dispBounds.y;
    } else {
      String[] tokens = mapWindow.split(",");

      mapShellBounds =
          new Rectangle(
              new Integer(tokens[0]), // X value
              new Integer(tokens[1]), // Y value
              new Integer(tokens[2]), // Width
              new Integer(tokens[3]) // Height
              );
    }
    mapShell.setBounds(mapShellBounds);
  }
예제 #2
0
 /**
  * Returns the receiver's image data. This is the icon that is associated with the receiver in the
  * operating system.
  *
  * @return the image data for the program, may be null
  */
 public ImageData getImageData() {
   NSAutoreleasePool pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
   try {
     NSWorkspace workspace = NSWorkspace.sharedWorkspace();
     NSString fullPath;
     if (this.fullPath != null) {
       fullPath = NSString.stringWith(this.fullPath);
     } else {
       fullPath = workspace.fullPathForApplication(NSString.stringWith(name));
     }
     if (fullPath != null) {
       NSImage nsImage = workspace.iconForFile(fullPath);
       if (nsImage != null) {
         NSSize size = new NSSize();
         size.width = size.height = 16;
         nsImage.setSize(size);
         nsImage.retain();
         Image image = Image.cocoa_new(Display.getCurrent(), SWT.BITMAP, nsImage);
         ImageData imageData = image.getImageData();
         image.dispose();
         return imageData;
       }
     }
     return null;
   } finally {
     pool.release();
   }
 }
예제 #3
0
 static long /*int*/ MenuItemSelectedProc(long /*int*/ widget, long /*int*/ user_data) {
   Display display = Display.getCurrent();
   ToolItem item = (ToolItem) display.getWidget(user_data);
   if (item != null) {
     return item.getParent().menuItemSelected(widget, item);
   }
   return 0;
 }
예제 #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;
 }
  public void test_changedLorg_eclipse_swt_browser_ProgressEvent() {
    Display display = Display.getCurrent();
    Shell shell = new Shell(display);
    Browser browser = new Browser(shell, SWT.NONE);
    browser.addProgressListener(
        new ProgressListener() {
          public void changed(ProgressEvent event) {}

          public void completed(ProgressEvent event) {}
        });
    shell.close();
  }
 static Browser findBrowser(long /*int*/ handle) {
   Display display = Display.getCurrent();
   return (Browser) display.findWidget(handle);
 }