public void createControl(Composite parent) {

    Composite pageContent = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    pageContent.setLayout(layout);
    pageContent.setLayoutData(new GridData(GridData.FILL_BOTH));

    // variable never used ... is pageContent.getLayoutData() needed?
    // GridData outerFrameGridData = (GridData)
    pageContent.getLayoutData();

    //		outerFrameGridData.horizontalAlignment = GridData.HORIZONTAL_ALIGN_FILL;
    //		outerFrameGridData.verticalAlignment = GridData.VERTICAL_ALIGN_FILL;

    //    WorkbenchHelp.setHelp(
    //        pageContent,
    //        B2BGUIContextIds.BTBG_SELECT_MULTI_FILE_PAGE);

    createLabels(pageContent);
    createSourceViewer(pageContent);
    createButtonPanel(pageContent);
    createSelectedListBox(pageContent);
    createImportButton(pageContent);

    setControl(pageContent);
    if (isFileMandatory) setPageComplete(false);
  }
예제 #2
0
 void drawRectangles(Rectangle[] rects, boolean stippled) {
   int xDisplay = display.xDisplay;
   int color = OS.XWhitePixel(xDisplay, 0);
   int xWindow = OS.XDefaultRootWindow(xDisplay);
   if (parent != null) {
     xWindow = OS.XtWindow(parent.handle);
     if (xWindow == 0) return;
     int foreground = parent.getForegroundPixel();
     Control control = parent.findBackgroundControl();
     if (control == null) control = parent;
     int background = control.getBackgroundPixel();
     color = foreground ^ background;
   }
   int gc = OS.XCreateGC(xDisplay, xWindow, 0, null);
   OS.XSetForeground(xDisplay, gc, color);
   OS.XSetSubwindowMode(xDisplay, gc, OS.IncludeInferiors);
   OS.XSetFunction(xDisplay, gc, OS.GXxor);
   int stipplePixmap = 0;
   if (stippled) {
     byte[] bits = {-86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0};
     stipplePixmap = OS.XCreateBitmapFromData(xDisplay, xWindow, bits, 8, 8);
     OS.XSetStipple(xDisplay, gc, stipplePixmap);
     OS.XSetFillStyle(xDisplay, gc, OS.FillStippled);
     OS.XSetLineAttributes(xDisplay, gc, 3, OS.LineSolid, OS.CapButt, OS.JoinMiter);
   }
   for (int i = 0; i < rects.length; i++) {
     Rectangle rect = rects[i];
     OS.XDrawRectangle(xDisplay, xWindow, gc, rect.x, rect.y, rect.width, rect.height);
   }
   if (stippled) {
     OS.XFreePixmap(xDisplay, stipplePixmap);
   }
   OS.XFreeGC(xDisplay, gc);
 }
예제 #3
0
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout());
    final ScrolledComposite sc =
        new ScrolledComposite(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    sc.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    Composite c = new Composite(sc, SWT.NONE);
    c.setLayout(new GridLayout(10, true));
    for (int i = 0; i < 300; i++) {
      Button b = new Button(c, SWT.PUSH);
      b.setText("Button " + i);
    }
    sc.setContent(c);
    sc.setExpandHorizontal(true);
    sc.setExpandVertical(true);
    sc.setMinSize(c.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    sc.setShowFocusedControl(true);

    shell.setSize(300, 500);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
예제 #4
0
  public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setText("SWT and Swing DND Example");
    GridLayout layout = new GridLayout(1, false);
    shell.setLayout(layout);

    Text swtText = new Text(shell, SWT.BORDER);
    swtText.setText("SWT Text");
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    swtText.setLayoutData(data);
    setDragDrop(swtText);

    Composite comp = new Composite(shell, SWT.EMBEDDED);
    java.awt.Frame frame = SWT_AWT.new_Frame(comp);
    JTextField swingText = new JTextField(40);
    swingText.setText("Swing Text");
    swingText.setDragEnabled(true);
    frame.add(swingText);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = swingText.getPreferredSize().height;
    comp.setLayoutData(data);

    shell.setSize(400, 200);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
  /**
   * Creates an instance of a ControlExample embedded inside the supplied parent Composite.
   *
   * @param parent the container of the example
   */
  public ControlExample(Composite parent) {
    initResources();
    tabFolder = new TabFolder(parent, SWT.NONE);
    tabs = createTabs();
    for (Tab tab : tabs) {
      TabItem item = new TabItem(tabFolder, SWT.NONE);
      item.setText(tab.getTabText());
      item.setControl(tab.createTabFolderPage(tabFolder));
      item.setData(tab);
    }

    /* Workaround: if the tab folder is wider than the screen,
     * Mac platforms clip instead of somehow scrolling the tab items.
     * We try to recover some width by using shorter tab names. */
    Point size = parent.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    Rectangle monitorArea = parent.getMonitor().getClientArea();
    boolean isMac = SWT.getPlatform().equals("cocoa");
    if (size.x > monitorArea.width && isMac) {
      TabItem[] tabItems = tabFolder.getItems();
      for (int i = 0; i < tabItems.length; i++) {
        tabItems[i].setText(tabs[i].getShortTabText());
      }
    }
    startup = false;
  }
예제 #6
0
 void update() {
   if (parent != null) {
     if (parent.isDisposed()) return;
     parent.getShell().update();
   } else {
     display.update();
   }
 }
예제 #7
0
  public TermWinUI(Shell parent) {
    self = new Shell(parent, SWT.SHELL_TRIM);
    self.setLayout(new GridLayout());

    mainPane = new Composite(self, SWT.NONE);
    mainPane.setLayout(new GridLayout(3, false));
    mainPane.setLayoutData(new GridData(GridData.FILL_BOTH));

    createContent();
  }
  protected Control createContents(Composite parent) {
    initializeValues();
    Composite composite = new Composite(parent, SWT.NULL);
    composite.setLayout(new GridLayout(1, false));
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    createControls(composite);

    return getControl();
  }
 public void createContents(Composite parent) {
   shell = parent.getShell();
   parent.setLayout(new FillLayout());
   folder = new TabFolder(shell, SWT.BORDER);
   labelTab();
   directoryDialogTab();
   buttonTab();
   sliderTab();
   scribbleTab();
   browserTab();
 }
예제 #10
0
  public SpinnerFieldEditor(
      String name,
      String labelText,
      Composite parent,
      int min,
      int max,
      int increment,
      int pageIncrement) {
    init(name, labelText);

    GridLayout layout = new GridLayout();
    layout.numColumns = getNumberOfControls();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.horizontalSpacing = HORIZONTAL_GAP;
    parent.setLayout(layout);

    // create label control
    getLabelControl(parent);

    spinner = new BigDecimalSpinner(parent, SWT.NONE, 0, min, max, increment, pageIncrement);

    spinner.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent event) {
            valueChanged();
          }
        });

    doFillIntoGrid(parent, layout.numColumns);
  }
예제 #11
0
  private int QueryContinueDrag(int fEscapePressed, int grfKeyState) {
    if (topControl != null && topControl.isDisposed()) return COM.DRAGDROP_S_CANCEL;
    if (fEscapePressed != 0) {
      if (hwndDrag != 0) OS.ImageList_DragLeave(hwndDrag);
      return COM.DRAGDROP_S_CANCEL;
    }
    /*
     * Bug in Windows.  On some machines that do not have XBUTTONs,
     * the MK_XBUTTON1 and OS.MK_XBUTTON2 bits are sometimes set,
     * causing mouse capture to become stuck.  The fix is to test
     * for the extra buttons only when they exist.
     */
    int mask = OS.MK_LBUTTON | OS.MK_MBUTTON | OS.MK_RBUTTON;
    //	if (display.xMouse) mask |= OS.MK_XBUTTON1 | OS.MK_XBUTTON2;
    if ((grfKeyState & mask) == 0) {
      if (hwndDrag != 0) OS.ImageList_DragLeave(hwndDrag);
      return COM.DRAGDROP_S_DROP;
    }

    if (hwndDrag != 0) {
      POINT pt = new POINT();
      OS.GetCursorPos(pt);
      RECT rect = new RECT();
      OS.GetWindowRect(hwndDrag, rect);
      OS.ImageList_DragMove(pt.x - rect.left, pt.y - rect.top);
    }
    return COM.S_OK;
  }
 public static void sliderTab() {
   TabItem tab = new TabItem(folder, SWT.CLOSE);
   tab.setText("Sliders and Progress bars");
   tab.setToolTipText("Tied Slider to ProgressBar");
   Composite composite = new Composite(folder, SWT.NONE);
   composite.setLayout(new GridLayout(2, true));
   final Slider slider = new Slider(composite, SWT.HORIZONTAL);
   final ProgressBar progress = new ProgressBar(composite, SWT.HORIZONTAL);
   slider.addSelectionListener(
       new SelectionAdapter() {
         public void widgetSelected(SelectionEvent event) {
           progress.setSelection(slider.getSelection());
         }
       });
   tab.setControl(composite);
 }
 public Control createControl(Composite parent) {
   control = new Composite(parent, SWT.NONE);
   control.setLayout(bl);
   constants.createControl(control);
   dependency.createControl(control);
   enableComponent(-1);
   return control;
 }
 public static void buttonTab() {
   TabItem tab = new TabItem(folder, SWT.CLOSE);
   tab.setText("Buttons");
   tab.setToolTipText("Different kinds of Buttons");
   Composite composite = new Composite(folder, SWT.NONE);
   composite.setLayout(new GridLayout(4, true));
   for (int dir : new int[] {SWT.UP, SWT.RIGHT, SWT.LEFT, SWT.DOWN}) {
     Button b = new Button(composite, SWT.ARROW | dir);
     b.addListener(SWT.MouseDown, listener);
   }
   newButton(composite, SWT.CHECK, "Check button");
   newButton(composite, SWT.PUSH, "Push button");
   newButton(composite, SWT.RADIO, "Radio button");
   newButton(composite, SWT.TOGGLE, "Toggle button");
   newButton(composite, SWT.FLAT, "Flat button");
   tab.setControl(composite);
 }
예제 #15
0
 void setOrientation(boolean create) {
   super.setOrientation(create);
   if (items != null) {
     for (int i = 0; i < items.length; i++) {
       if (items[i] != null) items[i].setOrientation(create);
     }
   }
 }
예제 #16
0
 public MainWindow(Composite parent, int style) {
   super(parent, style);
   initGUI();
   setPreferences();
   waitCursor = getDisplay().getSystemCursor(SWT.CURSOR_WAIT);
   defaultCursor = getDisplay().getSystemCursor(SWT.CURSOR_ARROW);
   clientArea.setFocus();
 }
예제 #17
0
 @Override
 void setOrientation(boolean create) {
   super.setOrientation(create);
   ToolItem[] items = _getItems();
   for (int i = 0; i < items.length; i++) {
     items[i].setOrientation(create);
   }
 }
예제 #18
0
 void removeControl(Control control) {
   super.removeControl(control);
   int count = getItemCount();
   for (int i = 0; i < count; i++) {
     TabItem item = items[i];
     if (item.control == control) item.setControl(null);
   }
 }
예제 #19
0
 @Override
 void setForegroundColor(GdkColor color) {
   super.setForegroundColor(color);
   ToolItem[] items = getItems();
   for (int i = 0; i < items.length; i++) {
     items[i].setForegroundColor(color);
   }
 }
예제 #20
0
 void setForegroundColor(GdkColor color) {
   super.setForegroundColor(color);
   TabItem[] items = getItems();
   for (int i = 0; i < items.length; i++) {
     if (items[i] != null) {
       items[i].setForegroundColor(color);
     }
   }
 }
예제 #21
0
 void setFontDescription(long /*int*/ font) {
   super.setFontDescription(font);
   TabItem[] items = getItems();
   for (int i = 0; i < items.length; i++) {
     if (items[i] != null) {
       items[i].setFontDescription(font);
     }
   }
 }
예제 #22
0
 @Override
 void setFontDescription(long /*int*/ font) {
   super.setFontDescription(font);
   ToolItem[] items = getItems();
   for (int i = 0; i < items.length; i++) {
     items[i].setFontDescription(font);
   }
   relayout();
 }
예제 #23
0
 @Override
 void setBackgroundColor(long /*int*/ context, long /*int*/ handle, GdkRGBA rgba) {
   if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
     String css = "GtkToolbar {background-color: " + gtk_rgba_to_css_string(rgba) + "}";
     gtk_css_provider_load_from_css(context, css);
   } else {
     super.setBackgroundColor(context, handle, rgba);
   }
 }
예제 #24
0
 @Override
 void removeControl(Control control) {
   super.removeControl(control);
   ToolItem[] items = getItems();
   for (int i = 0; i < items.length; i++) {
     ToolItem item = items[i];
     if (item.control == control) item.setControl(null);
   }
 }
  private void createButtonPanel(Composite pageContent) {
    Composite buttonPanel = new Composite(pageContent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    buttonPanel.setLayout(layout);

    GridData gridData = new GridData();
    gridData.grabExcessHorizontalSpace = false;
    gridData.grabExcessVerticalSpace = true;
    gridData.verticalAlignment = GridData.CENTER;
    gridData.horizontalAlignment = GridData.CENTER;
    buttonPanel.setLayoutData(gridData);

    addButton = new Button(buttonPanel, SWT.PUSH);
    addButton.setText(Messages._UI_ADD_BUTTON);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.CENTER;
    addButton.setLayoutData(gridData);
    addButton.addSelectionListener(new ButtonSelectListener());
    addButton.setToolTipText(Messages._UI_ADD_BUTTON_TOOL_TIP);
    addButton.setEnabled(false);

    removeButton = new Button(buttonPanel, SWT.PUSH);
    removeButton.setText(Messages._UI_REMOVE_BUTTON);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.CENTER;
    removeButton.setLayoutData(gridData);
    removeButton.addSelectionListener(new ButtonSelectListener());
    removeButton.setToolTipText(Messages._UI_REMOVE_BUTTON_TOOL_TIP);
    removeButton.setEnabled(false);

    removeAllButton = new Button(buttonPanel, SWT.PUSH);
    removeAllButton.setText(Messages._UI_REMOVE_ALL_BUTTON);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.CENTER;
    removeAllButton.setLayoutData(gridData);
    removeAllButton.addSelectionListener(new ButtonSelectListener());
    removeAllButton.setToolTipText(Messages._UI_REMOVE_ALL_BUTTON_TOOL_TIP);
    removeAllButton.setEnabled(false);
  }
예제 #26
0
 @Override
 public void setToolTipText(String string) {
   checkWidget();
   super.setToolTipText(string);
   Shell shell = _getShell();
   ToolItem[] items = getItems();
   for (int i = 0; i < items.length; i++) {
     String newString = string != null ? null : items[i].toolTipText;
     shell.setToolTipText(items[i].handle, newString);
   }
 }
예제 #27
0
 @Override
 void reskinChildren(int flags) {
   ToolItem[] items = _getItems();
   if (items != null) {
     for (int i = 0; i < items.length; i++) {
       ToolItem item = items[i];
       if (item != null) item.reskin(flags);
     }
   }
   super.reskinChildren(flags);
 }
예제 #28
0
 @Override
 void releaseChildren(boolean destroy) {
   ToolItem[] items = getItems();
   for (int i = 0; i < items.length; i++) {
     ToolItem item = items[i];
     if (item != null && !item.isDisposed()) {
       item.release(false);
     }
   }
   super.releaseChildren(destroy);
 }
예제 #29
0
 void releaseChildren(boolean destroy) {
   if (items != null) {
     for (int i = 0; i < items.length; i++) {
       TabItem item = items[i];
       if (item != null && !item.isDisposed()) {
         item.release(false);
       }
     }
     items = null;
   }
   super.releaseChildren(destroy);
 }
예제 #30
0
 @Override
 void releaseChildren(boolean destroy) {
   if (caret != null) {
     caret.release(false);
     caret = null;
   }
   if (ime != null) {
     ime.release(false);
     ime = null;
   }
   super.releaseChildren(destroy);
 }