/**
   * Perform any cleanup necessary to exit the program (save configuration, etc).
   *
   * @see org.eclipse.jface.window.Window#close()
   */
  public boolean close() {
    try {
      int modified = modifiedCount();
      if (modified > 0) {
        MessageBox message = new MessageBox(getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
        message.setMessage(modified + " document(s) not saved, still exit?");
        int confirm = message.open();
        if (confirm == SWT.NO) {
          return false;
        }
      }

      Point currentSize = this.getShell().getSize();
      config.setInitialSize(currentSize.x, currentSize.y);
      config.save();

      CTabItem[] items = tabFolder.getItems();
      for (int i = items.length - 1; i >= 0; --i) {
        Control control = items[i].getControl();
        if (control instanceof WikiViewer) {
          ((WikiViewer) control).dispose();
        } else {
          LOG.debug("Control is not of type WikiViewer : " + control.getClass().getName());
        }
      }
    } catch (ConfigurationException e) {
      logError("Cannot save configuration", e);
    }

    return super.close();
  }
 private void printControls(String prefix, Composite composite) {
   Control[] children = composite.getChildren();
   for (Control ctrl : children) {
     System.out.println(prefix + " " + ctrl.getClass().getName());
     if (ctrl instanceof Composite) {
       Composite c = (Composite) ctrl;
       if (c.getChildren().length > 0) {
         printControls(prefix + "\t", c);
       }
     }
   }
 }
 // Debugging utilities for widget trees.
 public static void check(Control control) {
   String name = control.getClass().getSimpleName();
   if (control.isDisposed()) {
     System.err.println(name + " disposed!");
     return;
   }
   if (control instanceof Composite) {
     ((Composite) control).layout(true);
   }
   control.computeSize(SWT.DEFAULT, SWT.DEFAULT);
   Point sz = control.getSize();
   if (sz.x == 0 || sz.y == 0) System.err.println(name + " zero size!");
 }
Beispiel #4
0
 public static int getIntHandle(Control control) {
   try {
     Field handleField = control.getClass().getField("handle");
     handleField.setAccessible(true);
     return (Integer) handleField.get(control);
   } catch (SecurityException e) {
     e.printStackTrace();
   } catch (IllegalArgumentException e) {
     e.printStackTrace();
   } catch (NoSuchFieldException e) {
     e.printStackTrace();
   } catch (IllegalAccessException e) {
     e.printStackTrace();
   }
   return -1;
 }