@Override
 protected void compute(Set<String> values) {
   DiagramEditorPageDef diagramPageDef = context(DiagramEditorPageDef.class);
   ElementList<IDiagramPaletteCompartmentDef> compartments =
       diagramPageDef.getPaletteCompartments();
   if (compartments.size() == 0) {
     values.add(DiagramPaletteCompartmentConstants.NODES_COMPARTMENT_ID);
     values.add(DiagramPaletteCompartmentConstants.CONNECTIONS_COMPARTMENT_ID);
   } else {
     for (IDiagramPaletteCompartmentDef compartment : compartments) {
       values.add(compartment.getId().content());
     }
   }
 }
Exemplo n.º 2
0
 public void moveChild(ShapePart childPart, int newIndex) {
   ElementList<Element> list = this.modelElement.property(this.modelProperty);
   int oldIndex = list.indexOf(childPart.getLocalModelElement());
   this.modelElement.detach(this.shapePropertyListener, this.propertyName);
   if (oldIndex < newIndex) {
     for (int i = oldIndex; i < newIndex; i++) {
       list.moveDown(childPart.getLocalModelElement());
     }
   } else {
     for (int i = newIndex; i < oldIndex; i++) {
       list.moveUp(childPart.getLocalModelElement());
     }
   }
   this.modelElement.attach(this.shapePropertyListener, this.propertyName);
   this.children.remove(childPart);
   this.children.add(newIndex, childPart);
   broadcast(new ShapeReorderEvent(this));
 }
  @Override
  protected String compute() {
    final PortletColumnElement column = (PortletColumnElement) context(Element.class);

    final PortletLayoutElement parentLayout = column.nearest(PortletLayoutElement.class);
    final LayoutTplElement layoutTpl = column.nearest(LayoutTplElement.class);

    int weightSum = 0;

    ElementList<PortletColumnElement> portletColumns = parentLayout.getPortletColumns();
    for (PortletColumnElement col : portletColumns) {
      if (col != column) {
        weightSum += col.getWeight().content().intValue();
      }
    }

    final int fullWeight = column.getFullWeight().content().intValue();
    int initialWeight = layoutTpl.getBootstrapStyle().content() ? 3 : 25;

    if (weightSum >= 0 && weightSum < fullWeight) {
      initialWeight = fullWeight - weightSum;
    } else if (weightSum == fullWeight) {
      // the index of last valid column is portletColumns.size() - 2
      // because portletColumns().size() -1 is the new inserted column
      PortletColumnElement lastValidColumn = portletColumns.get(portletColumns.size() - 2);
      int lastValidWeight = lastValidColumn.getWeight().content().intValue();

      if (lastValidWeight > 1) {
        initialWeight = lastValidWeight / 2;
        lastValidWeight = lastValidWeight - initialWeight;
        lastValidColumn.setWeight(lastValidWeight);
      }
    }

    return String.valueOf(initialWeight);
  }
  public static void updateActiveProfilesValue(
      final NewLiferayPluginProjectOp op, final ElementList<Profile> profiles) {
    final StringBuilder sb = new StringBuilder();

    if (profiles.size() > 0) {
      for (Profile profile : profiles) {
        if (!profile.getId().empty()) {
          sb.append(profile.getId().content());
          sb.append(',');
        }
      }
    }

    // remove trailing ','
    op.setActiveProfilesValue(sb.toString().replaceAll("(.*),$", "$1"));
  }
Exemplo n.º 5
0
 public ShapePart newShape(JavaType javaType) {
   ElementList<?> list = this.modelElement.property(this.modelProperty);
   final Class cl = javaType.artifact();
   Element element = list.insert(cl);
   return getShapePart(element);
 }