Exemple #1
0
  public void remove(MUFModule module) {
    if (playing) {
      delayRemove.offer(module);
      return;
    }

    // set to true
    playing = true;
    adding = false;
    moduleToBeRemoved = module;

    // exclude from layout
    modules.remove(module.getId());
    GridData data = (GridData) module.self.getLayoutData();
    data.exclude = true;
    module.self.setLayoutData(data);
    module.self.setVisible(false);

    if (content.isVisible()) {
      // get destination size
      frame = 1;
      Point newSize = content.computeSize(SWT.DEFAULT, SWT.DEFAULT);
      dx = Math.min(0, (newSize.x - oldSize.x) / FRAMES);
      dy = Math.min(0, (newSize.y - oldSize.y) / FRAMES);
      Display.getCurrent().timerExec(0, runnable);
    } else {
      oldSize = content.computeSize(SWT.DEFAULT, SWT.DEFAULT);
      playing = false;
      delayDispose.offer(module.self);
    }
    module.dispose();
  }
  @Override
  protected Control createDialogArea(final Composite parent) {
    // parent has GridLayout with 1 column

    ScrolledComposite scrolledComposite =
        new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
    scrolledComposite.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));

    Composite mainArea = new Composite(scrolledComposite, SWT.NONE);

    scrolledComposite.setContent(mainArea);

    GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.verticalSpacing = 10;
    mainArea.setLayout(gridLayout);

    /*
     * createViewer(mainArea);
     */
    createWidgetRows(mainArea);

    // 1)
    // mainArea.setSize(mainArea.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    // 2)
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);
    scrolledComposite.setMinSize(mainArea.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    return scrolledComposite;
  }
  /**
   * Resize the scrolled composite enclosing the sections, which may result in the addition or
   * removal of scroll bars.
   *
   * @since 3.5
   */
  public void resizeScrolledComposite() {
    Point currentTabSize = new Point(0, 0);
    if (currentTab != null) {
      final Composite sizeReference = (Composite) tabToComposite.get(currentTab);
      if (sizeReference != null) {
        currentTabSize = sizeReference.computeSize(SWT.DEFAULT, SWT.DEFAULT);
      }
    }
    tabbedPropertyComposite.getScrolledComposite().setMinSize(currentTabSize);

    final ScrollBar verticalScrollBar =
        tabbedPropertyComposite.getScrolledComposite().getVerticalBar();
    if (verticalScrollBar != null) {
      final Rectangle clientArea = tabbedPropertyComposite.getScrolledComposite().getClientArea();
      final int increment = clientArea.height - 5;
      verticalScrollBar.setPageIncrement(increment);
    }

    final ScrollBar horizontalScrollBar =
        tabbedPropertyComposite.getScrolledComposite().getHorizontalBar();
    if (horizontalScrollBar != null) {
      final Rectangle clientArea = tabbedPropertyComposite.getScrolledComposite().getClientArea();
      final int increment = clientArea.width - 5;
      horizontalScrollBar.setPageIncrement(increment);
    }
  }
  /**
   * 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;
  }
  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();
  }
  protected void addCheckboxes() {
    for (T item : itemList) {
      if (isItemVisible(item)) {
        boolean selected = preSelectedElements.contains(item);
        if (LOG.isDebugEnabled()) {
          LOG.debug(item.toString() + " is visible, select state is: " + selected);
        }
        Button checkbox = new Button(innerComposite, SWT.CHECK);
        checkbox.setText(getLabel(item));
        checkbox.setData(item);
        checkbox.addSelectionListener(organizationListener);
        if (selected) {
          checkbox.setSelection(true);
          selectedElement = item;
          selectedElementSet.add(item);
        }
        if (itemList.size() == 1) {
          checkbox.setSelection(true);
          selectedElement = item;
          selectedElementSet.add(item);
        }
        checkboxMap.put(item, checkbox);
      }
    }

    scrolledComposite.setVisible(true);
    Point size = innerComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    size.y += itemList.size() * 2;
    innerComposite.setSize(size);
    group.layout();
  }
Exemple #7
0
  public void add(MUFModule module) {
    if (playing) {
      delayAdd.offer(module);
      return;
    }

    // set to true
    playing = true;
    adding = true;

    // initialize module and add it
    module.create(this);
    modules.put(module.getId(), module);

    if (content.isVisible()) {
      // play a animation
      frame = 1;
      Point moduleSize = module.getPreferredSize();
      dx = Math.max(0, (moduleSize.x - oldSize.x) / FRAMES);
      dy = Math.max(0, moduleSize.y / FRAMES);
      content.pack();
      Display.getCurrent().timerExec(0, runnable);
    } else {
      oldSize = content.computeSize(SWT.DEFAULT, SWT.DEFAULT);
      playing = false;
    }
  }
  /**
   * Create contents of the wizard.
   *
   * @param parent
   */
  @Override
  public void createControl(Composite parent) {
    ScrolledComposite scrolledComposite =
        new ScrolledComposite(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    setControl(scrolledComposite);
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);

    Composite composite = new Composite(scrolledComposite, SWT.NONE);
    scrolledComposite.setSize(500, 500);
    composite.setLayout(new GridLayout(1, false));
    radioButtons = new Button[imNames.length];
    for (int i = 0; i < imNames.length; i++) {
      radioButtons[i] = new Button(composite, SWT.RADIO);
      radioButtons[i].setImage(
          sia.ui.org.eclipse.wb.swt.SWTResourceManager.getImage(
              ImportChooseIM.class,
              "/sia/ui/resources/ims/"
                  + Dictionaries.getInstance().getDataSources().get(imNames[i])
                  + ".png"));
      radioButtons[i].setText(imNames[i]);
      radioButtons[i].addSelectionListener((ImportWizard) getWizard());
    }

    scrolledComposite.setContent(composite);
    scrolledComposite.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
  }
  /**
   * Implement the user interface for the preference page. Returns a control that should be used as
   * the main control for the page.
   *
   * <p>User interface defined here supports the definition of preference settings used by the
   * management logic. {@inheritDoc}
   */
  protected Control createContents(Composite parent) {
    /** Add layer to parent widget */
    final ScrolledComposite scrollComposite =
        new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
    final Composite composite = new Composite(scrollComposite, SWT.NONE);

    /** Define laout rules for widget placement */
    compositeGridData(composite, 1);
    // add widgets to composite
    createShowContainerCount(composite);
    createShortCutsArea(composite);
    // context sensitive help
    Plugin.getHelpSystem().setHelp(parent, ContextHelpIds.PREFPAGE_OBJECT_MAP);
    initPreferences();
    scrollComposite.setContent(composite);
    scrollComposite.setExpandHorizontal(true);
    scrollComposite.setExpandVertical(true);
    scrollComposite.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    scrollComposite.addControlListener(
        new ControlAdapter() {
          public void controlResized(ControlEvent e) {
            scrollComposite.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
          }
        });
    return scrollComposite;
  }
 @Override
 public void setSize(int width, int height) {
   if (!isResizable() && fDetailPaneComposite != null) {
     // add height of details pane
     height += fDetailPaneComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
   }
   super.setSize(width, height);
 }
Exemple #11
0
 private void setLineLayout(final Composite lineComposite) {
   setCssName(lineComposite);
   RowLayout layout = new RowLayout();
   GridData data = new GridData();
   int scrollBarSize = ((Integer) UIManager.get("ScrollBar.width")); // $NON-NLS-1$
   data.widthHint = lineComposite.computeSize(getSize().x, getSize().y).x - scrollBarSize;
   lineComposite.setLayoutData(data);
   lineComposite.setLayout(layout);
 }
 @Override
 protected Control createDialogArea(Composite parent) {
   Composite composite = (Composite) super.createDialogArea(parent);
   createFileNameFields(composite);
   createPropsFields(composite);
   setData();
   composite.setSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
   return composite;
 }
 private void dealParentLayout(Composite container) {
   if (container == null) return;
   if (!(container instanceof ScrolledComposite)) {
     dealParentLayout(container.getParent());
     return;
   }
   ScrolledComposite composite = (ScrolledComposite) container;
   Composite control = (Composite) composite.getContent();
   composite.setMinSize(control.computeSize(SWT.DEFAULT, SWT.DEFAULT));
   control.layout();
 }
  /**
   * Recomputes the body layout and the scroll bars. The method should be used when changes
   * somewhere in the form body invalidate the current layout and/or scroll bars.
   *
   * @param flushCache if <code>true</code>, drop the cached data
   */
  public void reflow(boolean flushCache) {
    Composite c = (Composite) getContent();
    Rectangle clientArea = getClientArea();
    if (c == null) return;

    Point newSize = c.computeSize(clientArea.width, SWT.DEFAULT, flushCache);

    setMinSize(newSize);
    updatePageIncrement();
    layout(flushCache);
  }
  private void configureUICompositeIconPanelBounds() {
    // Determine the size of the panel and position it at the bottom-right
    // of the splash screen.
    Point panelSize = fIconPanel.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);

    int x_coord = getSplash().getSize().x - F_SPLASH_SCREEN_BEVEL - panelSize.x;
    int y_coord = getSplash().getSize().y - F_SPLASH_SCREEN_BEVEL - panelSize.y;
    int x_width = panelSize.x;
    int y_width = panelSize.y;

    fIconPanel.setBounds(x_coord, y_coord, x_width, y_width);
  }
  @Override
  public Point computeSizeHint() {
    updateInput();
    final Point sizeConstraints = getSizeConstraints();
    final Rectangle trim = computeTrim();

    //		int charWidth = 20;
    //		if (fInput.detailInfo != null) {
    //			final int count = Math.min(6, fInfoText.getLineCount());
    //			for (int i = 0; i < count; i++) {
    //				charWidth = Math.max(charWidth, fInfoText.getLine(i).length());
    //			}
    //		}
    int widthHint =
        fInfoText.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x + LayoutUtil.defaultHSpacing();
    final int widthMax2 = LayoutUtil.hintWidth(fInfoText, PREF_DETAIL_PANE_FONT, 80);
    final int widthMax =
        ((sizeConstraints != null && sizeConstraints.x != SWT.DEFAULT)
                ? sizeConstraints.x
                : widthMax2)
            - trim.width;
    fLayoutHint = true;
    final int titleHint =
        LayoutUtil.defaultHMargin()
            + fTitleImage.getSize().x
            + LayoutUtil.defaultHSpacing()
            + fTitleText.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
    fLayoutHint = false;
    if (titleHint > widthHint && widthMax2 > widthHint) {
      widthHint = Math.min(widthMax2, titleHint);
    }
    if (widthMax < widthHint) {
      widthHint = widthMax;
    }
    // avoid change of wrapping caused by scrollbar
    if (widthHint < titleHint && widthHint + fInfoText.computeTrim(0, 0, 0, 0).width >= titleHint) {
      widthHint = titleHint;
    }

    final int heightMax =
        ((sizeConstraints != null && sizeConstraints.y != SWT.DEFAULT)
                ? sizeConstraints.y
                : fInfoText.getLineHeight() * 12)
            - trim.height;

    final Point size = fContentComposite.computeSize(widthHint, SWT.DEFAULT, true);
    size.y += LayoutUtil.defaultVSpacing();
    size.x = Math.max(Math.min(size.x, widthMax), 200) + trim.width;
    size.y = Math.max(Math.min(size.y, heightMax), 100) + trim.height;
    return size;
  }
Exemple #17
0
  @Override
  protected Control createDialogArea(Composite parent) {
    updateTitle();
    final Composite composite = (Composite) super.createDialogArea(parent);
    composite.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WHITE));
    final ScrolledComposite scrolledComposite =
        new ScrolledComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL);
    scrolledComposite.setBackground(composite.getBackground());
    scrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    scrolledComposite.setExpandVertical(true);
    scrolledComposite.setExpandHorizontal(true);

    final Composite content = new Composite(scrolledComposite, SWT.NONE);
    content.setBackground(composite.getBackground());
    GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).applyTo(content);
    GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(content);

    try {
      if (view == null) {
        ECPSWTViewRenderer.INSTANCE.render(content, selection);
      } else {
        ECPSWTViewRenderer.INSTANCE.render(content, selection, view);
      }
    } catch (final ECPRendererException ex) {
      Activator.log(ex);
    }

    scrolledComposite.setContent(content);
    final Point point = content.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    content.setSize(point);
    scrolledComposite.setMinSize(point);

    objectChangeAdapter =
        new AdapterImpl() {

          /**
           * {@inheritDoc}
           *
           * @see
           *     org.eclipse.emf.common.notify.impl.AdapterImpl#notifyChanged(org.eclipse.emf.common.notify.Notification)
           */
          @Override
          public void notifyChanged(Notification msg) {
            super.notifyChanged(msg);
            updateTitle();
          }
        };
    selection.eAdapters().add(objectChangeAdapter);

    return composite;
  }
Exemple #18
0
  private void fillBuddies(Composite composite) {

    List buddies = getBuddies();

    showNoBuddiesPanel(buddies.size() == 0);

    for (Iterator iterator = buddies.iterator(); iterator.hasNext(); ) {
      VuzeBuddySWT vuzeBuddy = (VuzeBuddySWT) iterator.next();
      createBuddyControls(composite, vuzeBuddy);
    }
    composite.layout();
    Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    composite.setSize(size);
  }
  /**
   * Creates and associates the required composites to present the parameters and the demo image for
   * the spatial operation.
   *
   * @param builder
   */
  @Override
  protected void createContents() {

    assert this.presenterFactory != null : "builder cannot not be null";

    GridLayout gridLayout = new GridLayout();
    setLayout(gridLayout);

    this.sash = new SashForm(this, SWT.NONE);
    GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessVerticalSpace = true;
    gridData.grabExcessHorizontalSpace = true;
    gridData.verticalAlignment = GridData.FILL;
    this.sash.setLayoutData(gridData);

    this.dataScrollComposite = new ScrolledComposite(this.sash, SWT.BORDER | SWT.H_SCROLL);
    this.dataScrollComposite.setLayout(new FillLayout());

    this.dataComposite =
        (Composite) this.presenterFactory.createDataComposite(this.dataScrollComposite, SWT.BORDER);

    dataComposite.setLayoutData(gridData);

    this.dataScrollComposite.setContent(dataComposite);
    this.dataScrollComposite.setExpandHorizontal(true);
    this.dataScrollComposite.setExpandVertical(true);
    this.dataScrollComposite.setMinSize(dataComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    ScrolledComposite demoScrollComposite = new ScrolledComposite(sash, SWT.BORDER | SWT.H_SCROLL);
    demoScrollComposite.setLayout(new FillLayout());

    IImageOperation demoImages = this.presenterFactory.createDemoImages();

    this.demoComposite = new DemoComposite(demoScrollComposite, SWT.BORDER, demoImages);

    this.demoComposite.setLayoutData(gridData);

    demoScrollComposite.setContent(this.demoComposite);
    demoScrollComposite.setExpandHorizontal(true);
    demoScrollComposite.setExpandVertical(true);
    demoScrollComposite.setMinSize(demoComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    sash.setWeights(new int[] {70, 30});

    super.addPresenter((AggregatedPresenter) dataComposite);
  }
  /**
   * Creates the composite holding the details.
   *
   * @param parent the parent
   * @return the right panel/detail composite
   */
  protected ScrolledComposite createRightPanelContent(Composite parent) {
    rightPanel = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
    rightPanel.setShowFocusedControl(true);
    rightPanel.setExpandVertical(true);
    rightPanel.setExpandHorizontal(true);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(rightPanel);
    rightPanel.setLayout(GridLayoutFactory.fillDefaults().create());
    rightPanel.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));

    container = new Composite(rightPanel, SWT.FILL);
    container.setLayout(GridLayoutFactory.fillDefaults().create());
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(container);
    container.setBackground(rightPanel.getBackground());

    /* The header */
    final Composite header = new Composite(container, SWT.FILL);
    final GridLayout headerLayout = GridLayoutFactory.fillDefaults().create();
    headerLayout.marginWidth = 5;
    header.setLayout(headerLayout);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(header);
    header.setBackground(rightPanel.getBackground());

    final Label label = new Label(header, SWT.WRAP);
    label.setText("Details"); // $NON-NLS-1$
    detailsFont = new Font(label.getDisplay(), getDefaultFontName(label), 10, SWT.BOLD);
    label.setFont(detailsFont);
    label.setForeground(getTitleColor(parent));
    label.setBackground(header.getBackground());

    rightPanelContainerComposite = new Composite(container, SWT.FILL);
    rightPanelContainerComposite.setLayout(GridLayoutFactory.fillDefaults().create());
    GridDataFactory.fillDefaults()
        .align(SWT.FILL, SWT.FILL)
        .grab(true, true)
        .applyTo(rightPanelContainerComposite);
    rightPanelContainerComposite.setBackground(rightPanel.getBackground());

    rightPanel.setContent(container);

    rightPanel.layout();
    container.layout();

    final Point point = container.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    rightPanel.setMinSize(point);

    return rightPanel;
  }
  /**
   * Creates page for mark occurrences preferences.
   *
   * @param parent the parent composite
   * @return the control for the preference page
   */
  public Control createControl(Composite parent) {
    ScrolledPageContent scrolled = new ScrolledPageContent(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    scrolled.setExpandHorizontal(true);
    scrolled.setExpandVertical(true);

    Composite control = new Composite(scrolled, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    control.setLayout(layout);

    addSmartInsertModeMessage(control);

    Composite composite;

    composite =
        createSubsection(
            control, null, PreferencesMessages.SmartTypingConfigurationBlock_autoclose_title);
    addAutoclosingSection(composite);

    composite =
        createSubsection(
            control, null, PreferencesMessages.SmartTypingConfigurationBlock_automove_title);
    addAutopositionSection(composite);

    composite =
        createSubsection(
            control, null, PreferencesMessages.SmartTypingConfigurationBlock_indentation_title);
    addIndentationSection(composite);

    composite =
        createSubsection(
            control, null, PreferencesMessages.SmartTypingConfigurationBlock_pasting_title);
    addPasteSection(composite);

    composite =
        createSubsection(
            control, null, PreferencesMessages.SmartTypingConfigurationBlock_strings_title);
    addStringsSection(composite);

    scrolled.setContent(control);
    final Point size = control.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    scrolled.setMinSize(size.x, size.y);
    return scrolled;
  }
 protected void setSize(Composite composite) {
   if (composite != null) {
     // Note: The font is set here in anticipation that the class inheriting
     //       this base class may add widgets to the dialog.   setSize
     //       is assumed to be called just before we go live.
     applyDialogFont(composite);
     Point minSize = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
     composite.setSize(minSize);
     // set scrollbar composite's min size so page is expandable but
     // has scrollbars when needed
     if (composite.getParent() instanceof ScrolledComposite) {
       ScrolledComposite sc1 = (ScrolledComposite) composite.getParent();
       sc1.setMinSize(minSize);
       sc1.setExpandHorizontal(true);
       sc1.setExpandVertical(true);
     }
   }
 }
Exemple #23
0
        public void run() {
          if (frame < FRAMES) {
            Point size = content.getParent().getSize();
            content.getParent().setSize(size.x + dx, size.y + dy);
            frame++;
            Display.getCurrent().timerExec(INTERVAL, this);
          } else {
            // set size
            oldSize = content.computeSize(SWT.DEFAULT, SWT.DEFAULT);
            content.getParent().setSize(content.getParent().computeSize(SWT.DEFAULT, SWT.DEFAULT));

            playing = false;
            if (delayDispose.peek() != null) delayDispose.poll().dispose();
            if (!adding) delayDispose.offer(moduleToBeRemoved.self);
            if (!delayAdd.isEmpty()) add(delayAdd.poll());
            else if (!delayRemove.isEmpty()) remove(delayRemove.poll());
          }
        }
  /**
   * Resizes the Section's client and updates the Property Viewer's {@link ScrolledComposite} to
   * account for GridLayouts in the client.
   */
  private void resizePropertyView() {
    // Disable re-drawing for the ScrolledComposite.
    scrollComposite.setRedraw(false);

    int verticalPadding = scrollComposite.getHorizontalBar().getSize().y;
    int horizontalPadding = scrollComposite.getVerticalBar().getSize().x;
    Rectangle clientArea = scrollComposite.getClientArea();
    Point clientAreaSize =
        new Point(clientArea.width - horizontalPadding, clientArea.height - verticalPadding);

    // Recompute the size of the first Composite in the ScrolledComposite
    // based on the width of the ScrolledComposite's client area.
    Point size = scrollCompositeClient.computeSize(clientAreaSize.x, clientAreaSize.y);

    // Update the size of the ScrolledComposite's client.
    scrollCompositeClient.setSize(size);

    // Set the minimum size at which the ScrolledComposite will start
    // drawing scroll bars. This should be the size of its client area minus
    // the spaces the scroll bars would consume.
    scrollComposite.setMinSize(clientAreaSize.x + 1, clientAreaSize.y + 1);

    // We need to call layout() so the ScrolledComposite will update.
    scrollComposite.layout();

    // Set the height hint for the Section's parent Composite. This keeps
    // the TableViewer from going beyond the bottom edge of the Properties
    // Viewer. We want to keep the add and delete buttons visible, and the
    // TableViewer already has its own scroll bars!
    Composite sectionParent = section.getParent();
    GridData gridData = (GridData) sectionParent.getLayoutData();
    GridLayout gridLayout = (GridLayout) sectionParent.getParent().getLayout();
    gridData.heightHint = sectionParent.getParent().getSize().y - gridLayout.marginTop;

    // The parent of the Section has a FillLayout. Its parent has a
    // GridLayout, but sometimes it does not update. Tell it to layout so
    // the Section's parent will update its size.
    section.getParent().getParent().layout();

    // Enable re-drawing for the ScrolledComposite.
    scrollComposite.setRedraw(true);

    return;
  }
  /**
   * Create contents of the dialog.
   *
   * @param parent
   */
  @Override
  protected Control createDialogArea(Composite parent) {
    setMessage("Icon Selection");
    Composite area = (Composite) super.createDialogArea(parent);
    Composite container = new Composite(area, SWT.NONE);
    container.setLayout(new GridLayout(1, false));
    container.setLayoutData(new GridData(GridData.FILL_BOTH));

    ScrolledComposite scrolledComposite =
        new ScrolledComposite(container, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    scrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);

    Composite composite = new Composite(scrolledComposite, SWT.NONE);
    composite.setLayout(new GridLayout(9, true));

    for (Descriptor i : IconRegistry.getRegisteredImages()) {
      Button btnCheckButton = new Button(composite, SWT.RADIO);
      btnCheckButton.setImage(IconRegistry.getImage(i.id));
      btnCheckButton.setData(i);

      btnCheckButton.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              Object source = e.getSource();
              if (source instanceof Button) {
                Button btn = (Button) source;
                Object data = btn.getData();
                if (data instanceof Descriptor) {
                  Descriptor desc = (Descriptor) data;
                  imageSelected = desc.id;
                }
              }
            }
          });
    }

    scrolledComposite.setContent(composite);
    scrolledComposite.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    return area;
  }
  @Override
  protected void createWorkarea(Composite parent) {
    parent.setLayout(new FillLayout());
    final Color bgColor = LnfManager.getLnf().getColor(LnfKeyConstants.SUB_MODULE_BACKGROUND);

    final ScrolledComposite scrolled = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    scrolled.setExpandHorizontal(true);
    scrolled.setExpandVertical(true);
    scrolled.setBackground(bgColor);

    final Composite newParent = new Composite(scrolled, SWT.DOUBLE_BUFFERED);
    scrolled.setContent(newParent);
    newParent.setBackground(bgColor);

    basicCreatePartControl(newParent);
    afterBasicCreatePartControl(newParent);

    scrolled.setMinSize(newParent.computeSize(640, 480));
  }
 /** 刷新过滤器设置组件 */
 private void refresh() {
   filterNameTxt.setText("");
   andBtn.setSelection(true);
   orBtn.setSelection(false);
   btnIsTagged.setSelection(false);
   btnQT.setSelection(false);
   btnPT.setSelection(false);
   if (btnIsRemoveFromSrc != null) {
     btnIsRemoveFromSrc.setSelection(false);
   }
   for (Control ctl : conditionList) {
     if (!ctl.isDisposed()) {
       ctl.dispose();
     }
   }
   conditionList.clear();
   new DynaComposite(dynaComp, SWT.NONE);
   scroll.setMinSize(dynaComp.computeSize(SWT.DEFAULT, SWT.DEFAULT));
   dynaComp.layout();
 }
Exemple #28
0
  public MUFContainer(Composite parent) {
    content = new Composite(parent, SWT.NONE);

    // set layout
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = layout.horizontalSpacing = 3;
    layout.marginHeight = layout.marginWidth = 0;
    content.setLayout(layout);

    // init member
    modules = new HashMap<String, MUFModule>();
    center = new NotificationCenter(this);
    delayAdd = new LinkedList<MUFModule>();
    delayRemove = new LinkedList<MUFModule>();
    delayDispose = new LinkedList<Composite>();

    // get init size
    playing = false;
    oldSize = content.computeSize(SWT.DEFAULT, SWT.DEFAULT);
  }
  /** @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(Composite) */
  public void createControl(Composite parent) {

    ScrolledCompositeImpl scrolledComposite = new ScrolledCompositeImpl(parent, SWT.V_SCROLL);
    Composite composite = new Composite(scrolledComposite, SWT.NONE);
    composite.setLayout(new GridLayout(1, false));

    createServerControl(composite);
    createFileComponent(composite);
    createURLControl(composite);
    createExtensionControls(composite);

    Dialog.applyDialogFont(composite);
    scrolledComposite.setContent(composite);
    Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    scrolledComposite.setMinSize(size.x, size.y);

    PlatformUI.getWorkbench()
        .getHelpSystem()
        .setHelp(parent, IPHPHelpContextIds.DEBUGGING_A_PHP_WEB_PAGE);
    setControl(scrolledComposite);
  }
  /**
   * When any <code>ProgressReporterPanel</code> in this window is expanded or collapsed re-layout
   * the controls and window appropriately
   */
  public void isCollapsed(boolean value) {
    if (null != shell && false == shell.isDisposed()) {
      scrollable.setRedraw(false);
      Rectangle r = scrollable.getClientArea();
      scrollable.setMinSize(scrollChild.computeSize(r.width, SWT.DEFAULT));

      /*
       * Resizing to fit the panel if there is only one
       */
      if (pReporters.length == 1) {
        Point p = shell.computeSize(defaultShellWidth, SWT.DEFAULT);
        if (shell.getSize().y != p.y) {
          p.x = shell.getSize().x;
          shell.setSize(p);
        }
      }

      scrollable.layout();
      scrollable.setRedraw(true);
    }
  }