public PersonTableView(final IViewContext context, final IBeanTableModel<IPerson> model) {
    final IContainer container = context.getContainer();
    container.setLayout(MigLayoutFactory.growingInnerCellLayout());

    final ICapApiBluePrintFactory cbpf = CapUiToolkit.bluePrintFactory();
    final IBeanTable<IPerson> table =
        container.add(cbpf.beanTable(model), MigLayoutFactory.GROWING_CELL_CONSTRAINTS);

    table.getCellPopMenu().addAction(PersonLongLastingActionFactory.create(model));
  }
  @Override
  public void createViewContent(final IContainer container, final IBluePrintFactory bpFactory) {
    // set the layout
    container.setLayout(new MigLayoutDescriptor("[]", "[]"));

    // create the labels blue print
    final ILabelBluePrint labelBp = bpFactory.label().setIcon(Icons.INFO);

    // add the label blue print to the container
    container.add(labelBp, "");
  }
Exemple #3
0
  /** Check if something has changed and if so recrete it to the cached objects. */
  private void checkCache() {
    //		final long start = System.nanoTime();
    //		final boolean calculateCache = calculateCache();
    //		if (calculateCache) {
    checkChildren();

    // Check if the grid is valid
    final int mc = MigLayoutToolkitImpl.getMigPlatformDefaults().getModCount();
    if (lastModCount != mc) {
      grid = null;
      lastModCount = mc;
      reason.append("lastmodcount,");
    }

    int hash = container.getSize().hashCode();
    for (final Iterator<IComponentWrapperCommon> it = ccMap.keySet().iterator(); it.hasNext(); ) {
      hash += it.next().getLayoutHashCode();
    }

    if (hash != lastHash) {
      reason.append("hash " + hash + " vs " + lastHash + ",");
      reason.append(container.getSize() + ",");
      grid = null;
      lastHash = hash;
    }
    //		}

    if (grid == null) {
      // CHECKSTYLE:OFF
      // System.out.println("new Grid for " + this + " [" + reason + "]");
      // CHECKSTYLE:ON
      grid = new GridCommon(cacheParentW, lc, rowSpecs, colSpecs, ccMap, callbackList);
      reason.setLength(0);
    }

    //		if (calculateCache) {
    //			final long end = System.nanoTime();
    //			final long currentTime = end - start;
    //
    //			if (currentTime > 1000000) {
    //				return;
    //			}
    //			if (cacheTime < currentTime) {
    //				cacheTime = currentTime;
    //				//cacheTimeSetMs = System.currentTimeMillis();
    //				cacheTimeSetNano = end;
    //				//CHECKSTYLE:OFF
    //				System.out.println("nano time: " + (cacheTime) + " [" + this + "]");
    //				//CHECKSTYLE:ON
    //			}
    //		}
  }
Exemple #4
0
  private void checkChildren() {
    final List<IControl> comps = new LinkedList<IControl>(container.getChildren());

    final List<IComponentWrapperCommon> removed = new LinkedList<IComponentWrapperCommon>();
    for (final IComponentWrapperCommon cw : ccMap.keySet()) {
      if (comps.contains(cw.getComponent())) {
        comps.remove(cw.getComponent());
        continue;
      }
      removed.add(cw);
    }

    for (final IComponentWrapperCommon cw : removed) {
      scrConstrMap.remove(cw.getComponent());
      ccMap.remove(cw);
    }

    if (comps.size() != scrConstrMap.size()) {
      for (final IControl c : comps) {
        if (scrConstrMap.containsKey(c)) {
          continue;
        }

        setComponentConstraintsImpl(c, c.getLayoutConstraints(), true);
      }
    }
  }
  public UserTableView(
      final IViewContext context,
      final IBeanTableModel<IUser> tableModel,
      final ValueHolder<Integer> parameter) {

    this.beanTableModel = tableModel;
    this.parameter = parameter;

    final IContainer container = context.getContainer();

    container.setLayout(MigLayoutFactory.growingInnerCellLayout());

    this.table =
        container.add(
            CapUiToolkit.bluePrintFactory().beanTable(beanTableModel),
            MigLayoutFactory.GROWING_CELL_CONSTRAINTS);

    final IToolBarModel toolBar = context.getToolBar();
    toolBar.addContainer(createDelayFieldCreator());
    toolBar.addAction(createClearAction());
    toolBar.addAction(createPackAction());

    table.getCellPopMenu().addAction(new ChangeGenderAction(tableModel));
    table.getCellPopMenu().addAction(new ChangeBirthdayAction(tableModel));
    table.getCellPopMenu().addAction(new LongLastingAction(tableModel));
    table.getCellPopMenu().addAction(new CreateTransientUserAction(table));

    table.getCellPopMenu().addSeparator();

    // example for dynamic menu
    final Random random = new Random();
    final IMenuModel dynamicMenuModel = createDynamicMenuModelStub();
    table.getCellPopMenu().addItem(dynamicMenuModel);
    table.addCellMenuListener(
        new IPopupMenuListener<ITableCellPopupEvent>() {
          @Override
          public void beforeMenuShow(final ITableCellPopupEvent event) {
            fillDynamicMenuModel(dynamicMenuModel, random, event);
          }
        });

    beanTableModel.load();
  }
Exemple #6
0
  @Override
  public void layout() {
    checkCache();

    final Rectangle r = container.getClientArea();
    final int[] b = new int[] {r.getX(), r.getY(), r.getWidth(), r.getHeight()};

    final boolean layoutAgain = grid.layout(b, lc.getAlignX(), lc.getAlignY(), false, true);

    if (layoutAgain) {
      grid = null;
      checkCache();
      grid.layout(b, lc.getAlignX(), lc.getAlignY(), false, false);
    }
  }
Exemple #7
0
 @Override
 public Dimension getMaxSize() {
   return container.computeDecoratedSize(getSize(LayoutUtilCommon.MAX));
 }
Exemple #8
0
 @Override
 public Dimension getPreferredSize() {
   return container.computeDecoratedSize(getSize(LayoutUtilCommon.PREF));
 }