@Override
  public Composite doGetEditor(Composite parent, Object object) {
    if (composite == null) {
      context = new EMFDataBindingContext();
      if (getEditor().isModelFragment()) {
        composite = new Composite(parent, SWT.NONE);
        stackLayout = new EStackLayout();
        composite.setLayout(stackLayout);
        createForm(composite, context, getMaster(), false);
        createForm(composite, context, getMaster(), true);
      } else {
        composite = createForm(parent, context, getMaster(), false);
      }
    }

    if (getEditor().isModelFragment()) {
      Control topControl;
      if (Util.isImport((EObject) object)) {
        topControl = composite.getChildren()[1];
      } else {
        topControl = composite.getChildren()[0];
      }

      if (stackLayout.topControl != topControl) {
        stackLayout.topControl = topControl;
        composite.layout(true, true);
      }
    }

    getMaster().setValue(object);
    return composite;
  }
Exemple #2
0
  /** reset the algorithm. Executed when pressed the plus or minus button */
  public void reset() {
    view.enableMenu(false);
    showDialog = false;
    execute = false;

    equationGroup.setEnabled(true);
    for (Equation equation : equations.getEquationSet()) {
      equation.setEquationEnable(true);
    }

    step1Text.setFont(FontService.getSmallBoldFont());
    step2Text.setFont(FontService.getSmallFont());
    step3Text.setFont(FontService.getSmallFont());
    step4Text.setFont(FontService.getSmallFont());
    resultText.setFont(FontService.getSmallFont());
    resultValueText.setFont(FontService.getSmallFont());
    resultMoreText.setFont(FontService.getSmallFont());
    resultXText.setFont(FontService.getSmallFont());

    step1Group.setEnabled(true);
    step2Group.setEnabled(false);
    step3Group.setEnabled(false);
    step4Group.setEnabled(false);
    resultGroup.setEnabled(false);

    step1Text.setEnabled(true);
    step2Text.setEnabled(false);
    step3Text.setEnabled(false);
    step4Text.setEnabled(false);

    step1nextButton.setEnabled(true);
    step2nextButton.setEnabled(false);
    step3nextButton.setEnabled(false);
    step4nextButton.setEnabled(false);

    resultText.setEnabled(false);
    resultMoreText.setEnabled(false);
    resultValueText.setEnabled(false);
    resultXText.setEnabled(false);
    resultValueText.setText(""); // $NON-NLS-1$

    nextButton.setEnabled(false);
    previousButton.setEnabled(false);

    /*
     * dispose the inverse and verify group for the next turn of calculating
     */
    for (Control elem : inverseGroup.getChildren()) {
      elem.dispose();
    }
    inverseGroup.pack();

    for (Control elem : verifyGroup.getChildren()) {
      elem.dispose();
    }
    verifyGroup.pack();
  }
 private void disposeToolbarIfNecessary(MUIElement element) {
   Composite composite = (Composite) element.getWidget();
   ToolBar toolbar = findToolbar(composite);
   if (toolbar != null && hasOnlySeparators(toolbar)) {
     toolbar.dispose();
     if (composite.getChildren().length > 0) {
       composite.getChildren()[0].dispose();
     }
   }
 }
 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);
       }
     }
   }
 }
 private void updateApplicationCreationModeControls() {
   this.skipApplicationButton.setSelection(this.applicationMode == SKIP_APPLICATION);
   this.createJavaApplicationButton.setSelection(this.applicationMode == APPLICATION_JAVA);
   this.createWebxmlApplicationButton.setSelection(this.applicationMode == APPLICATION_WEB_XML);
   // enable/disable sub containers, disable status, reset
   for (Control control : javaApplicationControlsContainer.getChildren()) {
     control.setEnabled(this.applicationMode == APPLICATION_JAVA);
   }
   for (Control control : webxmlApplicationControlsContainer.getChildren()) {
     control.setEnabled(this.applicationMode == APPLICATION_WEB_XML);
   }
   doStatusUpdate();
 }
  static void create(final List actions, final Composite actionBar) {
    Control[] children = actionBar.getChildren();
    for (int i = 0; i < children.length; i++) {
      children[i].dispose();
    }

    actionBar.setLayout(new RowLayout());
    Iterator iterator = actions.iterator();
    while (iterator.hasNext()) {
      Object next = iterator.next();
      if (next instanceof Action) {
        final Action action = (Action) next;
        new ActionBarButton(action, actionBar);
        Label separator = new Label(actionBar, SWT.NONE);
        separator.setText(" ");
        Label separator2 = new Label(actionBar, SWT.NONE);
        separator2.setText(" ");
        Label separator3 = new Label(actionBar, SWT.NONE);
        separator3.setText(" ");
      } else {
        Label separator = new Label(actionBar, SWT.SEPARATOR | SWT.VERTICAL);
        separator.setForeground(Graphics.getColor(255, 255, 255));
        Label separator2 = new Label(actionBar, SWT.NONE);
        separator2.setText(" ");
        Label separator3 = new Label(actionBar, SWT.NONE);
        separator3.setText(" ");
      }
    }
    actionBar.layout();
  }
 public boolean doVisit(Widget widget) {
   if (widget instanceof Composite) {
     Composite composite = (Composite) widget;
     composite.changed(composite.getChildren());
   }
   return true;
 }
Exemple #8
0
  /**
   * @return the total GridData.horizontalSpan of all controls, except excluded controls and the
   *     control we are about lay out.
   */
  private int getTotalHorizontalSpan(Composite composite) {

    Control[] children = composite.getChildren();

    int totalHorizontalSpan = 0;

    for (int loop = 0, length = children.length - 1; loop < length; loop++) {

      Control child = children[loop];
      GridData gridData = (GridData) child.getLayoutData();

      // Manually added controls, that have not been laid out yet, will have no GridData

      if (gridData == null) {
        continue;
      }

      // Stubs will be excluded

      if (gridData.exclude) {
        continue;
      }

      totalHorizontalSpan += gridData.horizontalSpan;
    }

    return totalHorizontalSpan;
  }
 private void disposeDataTable() {
   if (contextTableComp != null && !contextTableComp.isDisposed()) {
     for (Control control : contextTableComp.getChildren()) {
       control.dispose();
     }
   }
 }
  /**
   * Accepts the given visitor.
   *
   * <p>The visitor's <code>visit</code> method is called on the given composite first, or last,
   * depending on the value of <code>depthFirst</code>. This will not occur if <code>visitRoot
   * </code> is set to <code>false</code> The list of children for the given composite will then be
   * visited. If the <code>visit</code> method returns true for a given child widget, and that
   * widget is also a composite, the <code>accept</code> method will be called on all children of
   * that composite as well.
   *
   * @param composite The composite to visit
   * @param visitor The visitor
   * @param depthFirst Whether to perform depth first or not
   * @param visitRoot Whether to visit the parent or to proceed directly to the children
   */
  private void accept(
      Composite composite, IWidgetVisitor visitor, boolean depthFirst, boolean visitRoot) {

    if (composite == null || composite.isDisposed()) {
      // Do not visit children if parent is disposed or null,
      // but do continue with siblings
      return;
    }

    Control children[] = composite.getChildren();
    boolean traverseChildren = true;

    if (!depthFirst && visitRoot) traverseChildren = visitor.visit(composite);

    if (traverseChildren) {
      for (int i = 0; i < children.length; i++) {
        if (children[i] instanceof Composite) {
          accept(((Composite) children[i]), visitor, depthFirst, true);
        } else {
          visitor.visit(children[i]);
        }
      }
    }

    if (depthFirst && visitRoot) visitor.visit(composite);
  }
Exemple #11
0
  @Override
  public void selectionChanged(IWorkbenchPart part, ISelection selection) {
    // System.out.println("select change\n");
    //		if(!getSite().getPage().isPartVisible(this))			//if i am not visible ,i will not change
    //			return;
    if (!banner.isVisible()) return;
    if (selection != null) {
      treeObj = (TreeModel.TreeObject) ((IStructuredSelection) selection).getFirstElement();
      if (treeObj != null && !(treeObj instanceof TreeModel.TreeParent))
        if (treeObj.getModel() != null) {
          // update content
          Control[] children = left.getChildren();
          for (Control child : children) child.dispose();
          BasicModel bm = treeObj.getModel();

          // update screen shot thread's device
          if (bm instanceof MobileModel) {
            System.out.println("change model start");
            if (mMobileModel != null) mMobileModel.stopShot(this);

            mMobileModel = (MobileModel) bm;
            showInfo(left, mMobileModel);
            left.layout(true, true);

            mMobileModel.startShot(this);
            System.out.println("change model stop");
          }
        }
    }
  }
  /**
   * Creates the file sets area.
   *
   * @param fileSetsContainer the container to add the file sets area to
   */
  private Control createFileSetsArea(Composite fileSetsContainer) throws CheckstylePluginException {

    Control[] controls = fileSetsContainer.getChildren();
    for (int i = 0; i < controls.length; i++) {
      controls[i].dispose();
    }

    if (mProjectConfig.isUseSimpleConfig()) {
      mFileSetsEditor = new SimpleFileSetsEditor(this);
    } else {
      mFileSetsEditor = new ComplexFileSetsEditor(this);
    }

    mFileSetsEditor.setFileSets(mProjectConfig.getFileSets());

    Control editor = mFileSetsEditor.createContents(mFileSetsContainer);

    fileSetsContainer.setLayout(new FormLayout());
    FormData fd = new FormData();
    fd.left = new FormAttachment(0);
    fd.top = new FormAttachment(0);
    fd.right = new FormAttachment(100);
    fd.bottom = new FormAttachment(100);
    editor.setLayoutData(fd);

    return fileSetsContainer;
  }
Exemple #13
0
  protected void layout(Composite composite, boolean flushCache) {
    Rectangle clientArea = composite.getClientArea();
    Control[] children = composite.getChildren();
    int nbOfVisibleChildren = 0;
    for (int i = 0; i < children.length; i++) {
      // if (children[i].isVisible())
      nbOfVisibleChildren++;
    }
    if (nbOfVisibleChildren == 0) return;

    int r = rows;
    int c = columns;
    if (r == 0) r = nbOfVisibleChildren / c + ((nbOfVisibleChildren % c) == 0 ? 0 : 1);
    else if (c == 0) c = nbOfVisibleChildren / r + ((nbOfVisibleChildren % r) == 0 ? 0 : 1);
    int width = (clientArea.width - (c - 1) * hgap) / c;
    int height = (clientArea.height - (r - 1) * vgap) / r;

    int x = clientArea.x;
    int y = clientArea.y;
    for (int i = 0; i < children.length; i++) {
      // if (!children[i].isVisible())
      // continue;
      children[i].setBounds(x, y, width, height);
      if (((i + 1) % c) == 0) // if new line
      {
        x = clientArea.x;
        y += height + vgap;
      } else x += width + hgap;
    }
  }
  /**
   * Sets the enable status of output type.
   *
   * @param enable The enable status.
   */
  private void setOutputEnable(boolean enable) {
    allRadio.setEnabled(enable);
    specRadio.setEnabled(enable);
    group.setEnabled(enable);
    Composite container = getCurrentContainer();
    Control[] children = container.getChildren();
    if (container == allContainer) {
      for (int i = 0; i < children.length; i++) {
        children[i].setEnabled(enable);
      }
    } else {
      for (int i = 0; i < children.length; i++) {
        if (children[i] instanceof ExpressionComposite) continue;
        children[i].setEnabled(enable);
      }

      for (int i = 0; i < outputDescriptorProvider.getTypeInfo().length; i++) {
        ((ExpressionComposite) specExpressions.get(outputDescriptorProvider.getTypeInfo()[i]))
            .setEnabled(
                hideCheckbox.getSelection()
                    && ((Button) specCheckButtons.get(outputDescriptorProvider.getTypeInfo()[i]))
                        .getSelection());
      }
    }
  }
Exemple #15
0
  /* (non-Javadoc)
   * @see org.eclipse.swt.widgets.Layout#computeSize(org.eclipse.swt.widgets.Composite, int, int, boolean)
   */
  @Override
  protected Point computeSize(Composite composite, int whint, int hhint, boolean flushCache) {
    int minX = Integer.MAX_VALUE;
    int minY = Integer.MAX_VALUE;
    int maxX = Integer.MIN_VALUE;
    int maxY = Integer.MIN_VALUE;

    for (Control kid : composite.getChildren()) {
      Point kidSize = kid.computeSize(-1, -1);
      Point kidOffs = kid.getLocation();
      if (kidOffs.x < minX) minX = kidOffs.x;
      if (kidOffs.y < minY) minY = kidOffs.y;
      if (kidOffs.x + kidSize.x > maxX) maxX = kidOffs.x + kidSize.x;
      if (kidOffs.y + kidSize.y > maxY) maxY = kidOffs.y + kidSize.y;
    }

    if (whint > 0) {
      if (whint + minX > maxX) maxX = whint + minX;
    }
    if (hhint > 0) {
      if (hhint + minY > maxY) maxY = hhint + minY;
    }

    return new Point(maxX - minX, maxY - minY);
  }
Exemple #16
0
 /** resets the model and view to its initial state */
 public void reset() {
   Control[] children = parent.getChildren();
   for (Control control : children) {
     control.dispose();
   }
   createPartControl(parent);
 }
Exemple #17
0
 /** Disposes all elements except the new content. content might be null to clear preview. */
 private void setContent(Composite content) {
   for (Control c : container.getChildren()) {
     if (c != content) {
       c.dispose();
     }
   }
 }
 public void remove(Object[] links) {
   for (int i = 0; i < links.length; i++) {
     disposeLink(links[i]);
   }
   updateMoreState(linkContainer.getChildren().length > linkNumberLimit);
   reflow();
 }
    @Override
    public Point computeSize(Composite composite, int wHint, int hHint, boolean force) {
      if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) {
        return new Point(wHint, hHint);
      }
      int x = minimumPageSize.x;
      int y = minimumPageSize.y;
      Control[] children = composite.getChildren();
      for (int i = 0; i < children.length; i++) {
        Point size = children[i].computeSize(SWT.DEFAULT, SWT.DEFAULT, force);
        x = Math.max(x, size.x);
        y = Math.max(y, size.y);
      }

      // As pages can implement thier own computeSize
      // take it into account
      if (currentPage != null) {
        Point size = currentPage.computeSize();
        x = Math.max(x, size.x);
        y = Math.max(y, size.y);
      }

      if (wHint != SWT.DEFAULT) {
        x = wHint;
      }
      if (hHint != SWT.DEFAULT) {
        y = hHint;
      }
      return new Point(x, y);
    }
Exemple #20
0
 /*
  * @see Layout#computeSize(Composite, int, int, boolean)
  */
 protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
   Control[] children = composite.getChildren();
   Point s = children[children.length - 1].computeSize(SWT.DEFAULT, SWT.DEFAULT, flushCache);
   if (fVerticalRuler != null && fIsVerticalRulerVisible)
     s.x += fVerticalRuler.getWidth() + fGap;
   return s;
 }
Exemple #21
0
 private void init(Composite composite) {
   Control[] children = composite.getChildren();
   sizes = new Point[children.length];
   for (int i = 0; i < children.length; i++) {
     sizes[i] = children[i].computeSize(SWT.DEFAULT, SWT.DEFAULT);
   }
 }
 private ToolBar findToolbar(Composite intermediate) {
   for (Control child : intermediate.getChildren()) {
     if (child.getData() instanceof ToolBarManager) {
       return (ToolBar) child;
     }
   }
   return null;
 }
    protected void layout(Composite composite, boolean flushCache) {
      Rectangle rect = composite.getClientArea();

      Control[] children = composite.getChildren();
      for (int i = 0; i < children.length; i++) {
        children[i].setBounds(rect);
      }
    }
 protected void updateCountLabel() {
   if (totalFileCount == 0) {
     totalFileCount = tableViewer.getTable().getItemCount();
   }
   selectedFileCount = selector.getSelectedModels().size();
   label.setText(selectedFileCount + " selected out of " + totalFileCount);
   buttonComposite.changed(buttonComposite.getChildren());
 }
 private Hyperlink find(Object object) {
   Control[] children = linkContainer.getChildren();
   for (int i = 0; i < children.length; i++) {
     Control child = children[i];
     if (child.getData().equals(object)) return (Hyperlink) child;
   }
   return null;
 }
 @Override
 public void layout(Composite composite, boolean force) {
   Rectangle rect = composite.getClientArea();
   Control[] children = composite.getChildren();
   for (int i = 0; i < children.length; i++) {
     children[i].setSize(rect.width, rect.height);
   }
 }
 protected void handleSpecificDatatypeEdition(final Data data) {
   if (gridLayout.numColumns > 1) {
     mainComposite.getChildren()[1].dispose();
     gridLayout.numColumns--;
     viewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
     mainComposite.layout();
   }
 }
 protected void setSearchFieldsEnablement(boolean enabled) {
   if (!searchComposite.isDisposed()) {
     searchComposite.setEnabled(enabled);
     for (Control c : searchComposite.getChildren()) {
       c.setEnabled(enabled);
     }
   }
 }
  public void testFlatSectionAroundNestedSectionLayoutDecorator() {

    SwtMetawidget metawidget =
        new SwtMetawidget(new Shell(SwtMetawidgetTests.TEST_DISPLAY, SWT.NONE), SWT.NONE);
    metawidget.setMetawidgetLayout(
        new SeparatorLayoutDecorator(
            new SeparatorLayoutDecoratorConfig()
                .setLayout(
                    new TabFolderLayoutDecorator(
                        new TabFolderLayoutDecoratorConfig().setLayout(new GridLayout())))));
    metawidget.setToInspect(new Baz());

    Composite composite = (Composite) metawidget.getChildren()[0];
    assertEquals(((org.eclipse.swt.layout.GridLayout) composite.getLayout()).marginWidth, 0);
    assertEquals("Foo", ((Label) composite.getChildren()[0]).getText());
    assertEquals((composite.getChildren()[1].getStyle() & SWT.SEPARATOR), SWT.SEPARATOR);

    TabFolder innerTabFolder = (TabFolder) metawidget.getChildren()[1];
    assertEquals("Bar", innerTabFolder.getItem(0).getText());
    Composite innerPanel = (Composite) innerTabFolder.getChildren()[0];
    assertEquals("Abc:", ((Label) innerPanel.getChildren()[0]).getText());
    assertTrue(innerPanel.getChildren()[1] instanceof Text);
    assertEquals(2, innerPanel.getChildren().length);

    composite = (Composite) metawidget.getChildren()[2];
    assertEquals(((org.eclipse.swt.layout.GridLayout) composite.getLayout()).marginWidth, 0);
    assertEquals("Baz", ((Label) composite.getChildren()[0]).getText());
    assertEquals((composite.getChildren()[1].getStyle() & SWT.SEPARATOR), SWT.SEPARATOR);

    assertEquals("Def:", ((Label) metawidget.getChildren()[3]).getText());
    assertTrue(metawidget.getChildren()[4] instanceof Button);
    assertEquals((metawidget.getChildren()[4].getStyle() & SWT.CHECK), SWT.CHECK);
    assertEquals(5, metawidget.getChildren().length);
  }
Exemple #30
0
 @Override
 protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
   //		System.out.println("YO " + composite + " " + wHint + " " + hHint + " " + flushCache);
   Control children[] = composite.getChildren();
   if (flushCache || sizes == null || sizes.length != children.length) {
     initialize(composite, wHint, hHint);
   }
   return new Point(totalWidth, totalHeight);
 }