Java 类com.intellij.uiDesigner.core.Util 实例源码

项目:intellij-ce-playground    文件:GuiEditor.java   
private static void refreshImpl(final RadComponent component) {
  if (component.getParent() != null) {
    final Dimension size = component.getSize();
    final int oldWidth = size.width;
    final int oldHeight = size.height;
    Util.adjustSize(component.getDelegee(), component.getConstraints(), size);

    if (oldWidth != size.width || oldHeight != size.height) {
      if (component.getParent().isXY()) {
        component.setSize(size);
      }
      component.getDelegee().invalidate();
    }
  }

  if (component instanceof RadContainer) {
    component.refresh();

    final RadContainer container = (RadContainer)component;
    for (int i = container.getComponentCount() - 1; i >= 0; i--) {
      refreshImpl(container.getComponent(i));
    }
  }
}
项目:tools-idea    文件:GuiEditor.java   
private static void refreshImpl(final RadComponent component) {
  if (component.getParent() != null) {
    final Dimension size = component.getSize();
    final int oldWidth = size.width;
    final int oldHeight = size.height;
    Util.adjustSize(component.getDelegee(), component.getConstraints(), size);

    if (oldWidth != size.width || oldHeight != size.height) {
      if (component.getParent().isXY()) {
        component.setSize(size);
      }
      component.getDelegee().invalidate();
    }
  }

  if (component instanceof RadContainer) {
    component.refresh();

    final RadContainer container = (RadContainer)component;
    for (int i = container.getComponentCount() - 1; i >= 0; i--) {
      refreshImpl(container.getComponent(i));
    }
  }
}
项目:intellij-ce-playground    文件:GridBuildUtil.java   
/**
 * @param x array of <code>X</code> coordinates of components that should be layed out in a grid.
 * This is input/output parameter.
 *
 * @param y array of <code>Y</code> coordinates of components that should be layed out in a grid.
 * This is input/output parameter.
 *
 * @param rowSpans output parameter.
 *
 * @param colSpans output parameter.
 *
 * @return pair that says how many (rows, columns) are in the composed grid.
 */
public static Couple<Integer> layoutInGrid(
  final int[] x,
  final int[] y,
  final int[] rowSpans,
  final int[] colSpans
){
  LOG.assertTrue(x.length == y.length);
  LOG.assertTrue(y.length == colSpans.length);
  LOG.assertTrue(colSpans.length == rowSpans.length);

  for (int i = 0; i < x.length; i++) {
    colSpans[i] = Math.max(colSpans[i], 1);
    rowSpans[i] = Math.max(rowSpans[i], 1);

    if (colSpans[i] > GRID_TREMOR * 4) {
      colSpans[i] -= GRID_TREMOR * 2;
      x[i] += GRID_TREMOR;
    }
    if (rowSpans[i] > GRID_TREMOR * 4) {
      rowSpans[i] -= GRID_TREMOR * 2;
      y[i] += GRID_TREMOR;
    }
  }


  return Couple.of(
    new Integer(Util.eliminate(y, rowSpans, null)),
    new Integer(Util.eliminate(x, colSpans, null))
  );
}
项目:tools-idea    文件:GridBuildUtil.java   
/**
 * @param x array of <code>X</code> coordinates of components that should be layed out in a grid.
 * This is input/output parameter.
 *
 * @param y array of <code>Y</code> coordinates of components that should be layed out in a grid.
 * This is input/output parameter.
 *
 * @param rowSpans output parameter.
 *
 * @param colSpans output parameter.
 *
 * @return pair that says how many (rows, columns) are in the composed grid.
 */
public static Pair<Integer, Integer> layoutInGrid(
  final int[] x,
  final int[] y,
  final int[] rowSpans,
  final int[] colSpans
){
  LOG.assertTrue(x.length == y.length);
  LOG.assertTrue(y.length == colSpans.length);
  LOG.assertTrue(colSpans.length == rowSpans.length);

  for (int i = 0; i < x.length; i++) {
    colSpans[i] = Math.max(colSpans[i], 1);
    rowSpans[i] = Math.max(rowSpans[i], 1);

    if (colSpans[i] > GRID_TREMOR * 4) {
      colSpans[i] -= GRID_TREMOR * 2;
      x[i] += GRID_TREMOR;
    }
    if (rowSpans[i] > GRID_TREMOR * 4) {
      rowSpans[i] -= GRID_TREMOR * 2;
      y[i] += GRID_TREMOR;
    }
  }


  return new Pair<Integer, Integer>(
    new Integer(Util.eliminate(y, rowSpans, null)),
    new Integer(Util.eliminate(x, colSpans, null))
  );
}
项目:consulo-ui-designer    文件:GridBuildUtil.java   
/**
 * @param x array of <code>X</code> coordinates of components that should be layed out in a grid.
 * This is input/output parameter.
 *
 * @param y array of <code>Y</code> coordinates of components that should be layed out in a grid.
 * This is input/output parameter.
 *
 * @param rowSpans output parameter.
 *
 * @param colSpans output parameter.
 *
 * @return pair that says how many (rows, columns) are in the composed grid.
 */
public static Pair<Integer, Integer> layoutInGrid(
  final int[] x,
  final int[] y,
  final int[] rowSpans,
  final int[] colSpans
){
  LOG.assertTrue(x.length == y.length);
  LOG.assertTrue(y.length == colSpans.length);
  LOG.assertTrue(colSpans.length == rowSpans.length);

  for (int i = 0; i < x.length; i++) {
    colSpans[i] = Math.max(colSpans[i], 1);
    rowSpans[i] = Math.max(rowSpans[i], 1);

    if (colSpans[i] > GRID_TREMOR * 4) {
      colSpans[i] -= GRID_TREMOR * 2;
      x[i] += GRID_TREMOR;
    }
    if (rowSpans[i] > GRID_TREMOR * 4) {
      rowSpans[i] -= GRID_TREMOR * 2;
      y[i] += GRID_TREMOR;
    }
  }


  return new Pair<Integer, Integer>(
    new Integer(Util.eliminate(y, rowSpans, null)),
    new Integer(Util.eliminate(x, colSpans, null))
  );
}
项目:consulo-ui-designer    文件:GuiEditor.java   
private static void refreshImpl(final RadComponent component)
{
    if(component.getParent() != null)
    {
        final Dimension size = component.getSize();
        final int oldWidth = size.width;
        final int oldHeight = size.height;
        Util.adjustSize(component.getDelegee(), component.getConstraints(), size);

        if(oldWidth != size.width || oldHeight != size.height)
        {
            if(component.getParent().isXY())
            {
                component.setSize(size);
            }
            component.getDelegee().invalidate();
        }
    }

    if(component instanceof RadContainer)
    {
        component.refresh();

        final RadContainer container = (RadContainer) component;
        for(int i = container.getComponentCount() - 1; i >= 0; i--)
        {
            refreshImpl(container.getComponent(i));
        }
    }
}
项目:intellij-ce-playground    文件:GridBagConverter.java   
private Result convert(final JComponent component, final GridConstraints constraints) {
  final Result result = new Result(component);

  int endRow = constraints.getRow() + constraints.getRowSpan()-1;
  myLastRow = Math.max(myLastRow, endRow);
  int endCol = constraints.getColumn() + constraints.getColSpan()-1;
  myLastCol = Math.max(myLastCol, endCol);

  int indent = Util.DEFAULT_INDENT * constraints.getIndent();

  constraintsToGridBag(constraints, result.constraints);
  result.constraints.weightx = getWeight(constraints, true);
  result.constraints.weighty = getWeight(constraints, false);
  result.constraints.insets = new Insets(myInsets.top, myInsets.left + indent, myInsets.bottom, myInsets.right);

  Dimension minSize = constraints.myMinimumSize;
  if (component != null && minSize.width <= 0 && minSize.height <= 0) {
    minSize = component.getMinimumSize();
  }

  if ((constraints.getHSizePolicy() & GridConstraints.SIZEPOLICY_CAN_SHRINK) == 0) {
    minSize.width = constraints.myPreferredSize.width > 0 || component == null
                    ? constraints.myPreferredSize.width
                    : component.getPreferredSize().width;
  }
  if ((constraints.getVSizePolicy() & GridConstraints.SIZEPOLICY_CAN_SHRINK) == 0) {
    minSize.height = constraints.myPreferredSize.height > 0 || component == null
                     ? constraints.myPreferredSize.height
                     : component.getPreferredSize().height;
  }

  if (minSize.width != -1 || minSize.height != -1) {
    result.minimumSize = minSize;
  }

  if (constraints.myPreferredSize.width > 0 && constraints.myPreferredSize.height > 0) {
    result.preferredSize = constraints.myPreferredSize;
  }
  if (constraints.myMaximumSize.width > 0 && constraints.myMaximumSize.height > 0) {
    result.maximumSize = constraints.myMaximumSize;
  }

  return result;
}
项目:intellij-ce-playground    文件:InsertComponentProcessor.java   
public void processComponentInsert(ComponentItem item, final ComponentDropLocation location) {
  myEditor.getActiveDecorationLayer().removeFeedback();
  myEditor.setDesignTimeInsets(2);

  item = replaceAnyComponentItem(myEditor, item, UIDesignerBundle.message("palette.non.palette.component.title"));
  if (item == null) {
    return;
  }

  if (!validateNestedFormInsert(item)) {
    return;
  }

  if (!checkAddDependencyOnInsert(item)) {
    return;
  }

  if (!myEditor.ensureEditable()) {
    return;
  }

  final boolean forceBinding = item.isAutoCreateBinding();
  myInsertedComponent = createInsertedComponent(myEditor, item);
  setCursor(Cursor.getDefaultCursor());
  if (myInsertedComponent == null) {
    if (!mySticky) {
      PaletteToolWindowManager.getInstance(myEditor).clearActiveItem();
    }
    return;
  }

  final ComponentItemDragObject dragObject = new ComponentItemDragObject(item);
  if (location.canDrop(dragObject)) {
    CommandProcessor.getInstance().executeCommand(
      myEditor.getProject(),
      new Runnable() {
        public void run() {
          createBindingWhenDrop(myEditor, myInsertedComponent, forceBinding);

          final RadComponent[] components = new RadComponent[]{myInsertedComponent};
          location.processDrop(myEditor, components, null, dragObject);

          FormEditingUtil.selectSingleComponent(myEditor, myInsertedComponent);

          if (location.getContainer() != null && location.getContainer().isXY()) {
            Dimension newSize = myInsertedComponent.getPreferredSize();
            Util.adjustSize(myInsertedComponent.getDelegee(), myInsertedComponent.getConstraints(), newSize);
            myInsertedComponent.setSize(newSize);
          }

          if (myInsertedComponent.getParent() instanceof RadRootContainer &&
              myInsertedComponent instanceof RadAtomicComponent) {
            GridBuildUtil.convertToGrid(myEditor);
            FormEditingUtil.selectSingleComponent(myEditor, myInsertedComponent);
          }

          checkBindTopLevelPanel();

          if (!mySticky) {
            PaletteToolWindowManager.getInstance(myEditor).clearActiveItem();
          }

          myEditor.refreshAndSave(false);
        }
      }, UIDesignerBundle.message("command.insert.component"), null);
  }
  myComponentToInsert = null;
}
项目:intellij-ce-playground    文件:RadComponent.java   
public final Dimension getMinimumSize() {
  return Util.getMinimumSize(myDelegee, myConstraints, false);
}
项目:intellij-ce-playground    文件:RadComponent.java   
public final Dimension getPreferredSize() {
  return Util.getPreferredSize(myDelegee, myConstraints, false);
}
项目:tools-idea    文件:GridBagConverter.java   
private Result convert(final JComponent component, final GridConstraints constraints) {
  final Result result = new Result(component);

  int endRow = constraints.getRow() + constraints.getRowSpan()-1;
  myLastRow = Math.max(myLastRow, endRow);
  int endCol = constraints.getColumn() + constraints.getColSpan()-1;
  myLastCol = Math.max(myLastCol, endCol);

  int indent = Util.DEFAULT_INDENT * constraints.getIndent();

  constraintsToGridBag(constraints, result.constraints);
  result.constraints.weightx = getWeight(constraints, true);
  result.constraints.weighty = getWeight(constraints, false);
  result.constraints.insets = new Insets(myInsets.top, myInsets.left + indent, myInsets.bottom, myInsets.right);

  Dimension minSize = constraints.myMinimumSize;
  if (component != null && minSize.width <= 0 && minSize.height <= 0) {
    minSize = component.getMinimumSize();
  }

  if ((constraints.getHSizePolicy() & GridConstraints.SIZEPOLICY_CAN_SHRINK) == 0) {
    minSize.width = constraints.myPreferredSize.width > 0 || component == null
                    ? constraints.myPreferredSize.width
                    : component.getPreferredSize().width;
  }
  if ((constraints.getVSizePolicy() & GridConstraints.SIZEPOLICY_CAN_SHRINK) == 0) {
    minSize.height = constraints.myPreferredSize.height > 0 || component == null
                     ? constraints.myPreferredSize.height
                     : component.getPreferredSize().height;
  }

  if (minSize.width != -1 || minSize.height != -1) {
    result.minimumSize = minSize;
  }

  if (constraints.myPreferredSize.width > 0 && constraints.myPreferredSize.height > 0) {
    result.preferredSize = constraints.myPreferredSize;
  }
  if (constraints.myMaximumSize.width > 0 && constraints.myMaximumSize.height > 0) {
    result.maximumSize = constraints.myMaximumSize;
  }

  return result;
}
项目:tools-idea    文件:InsertComponentProcessor.java   
public void processComponentInsert(ComponentItem item, final ComponentDropLocation location) {
  myEditor.getActiveDecorationLayer().removeFeedback();
  myEditor.setDesignTimeInsets(2);

  item = replaceAnyComponentItem(myEditor, item, UIDesignerBundle.message("palette.non.palette.component.title"));
  if (item == null) {
    return;
  }

  if (!validateNestedFormInsert(item)) {
    return;
  }

  if (!checkAddDependencyOnInsert(item)) {
    return;
  }

  if (!myEditor.ensureEditable()) {
    return;
  }

  final boolean forceBinding = item.isAutoCreateBinding();
  myInsertedComponent = createInsertedComponent(myEditor, item);
  setCursor(Cursor.getDefaultCursor());
  if (myInsertedComponent == null) {
    if (!mySticky) {
      PaletteManager.getInstance(myEditor.getProject()).clearActiveItem();
    }
    return;
  }

  final ComponentItemDragObject dragObject = new ComponentItemDragObject(item);
  if (location.canDrop(dragObject)) {
    CommandProcessor.getInstance().executeCommand(
      myEditor.getProject(),
      new Runnable() {
        public void run() {
          createBindingWhenDrop(myEditor, myInsertedComponent, forceBinding);

          final RadComponent[] components = new RadComponent[]{myInsertedComponent};
          location.processDrop(myEditor, components, null, dragObject);

          FormEditingUtil.selectSingleComponent(myEditor, myInsertedComponent);

          if (location.getContainer() != null && location.getContainer().isXY()) {
            Dimension newSize = myInsertedComponent.getPreferredSize();
            Util.adjustSize(myInsertedComponent.getDelegee(), myInsertedComponent.getConstraints(), newSize);
            myInsertedComponent.setSize(newSize);
          }

          if (myInsertedComponent.getParent() instanceof RadRootContainer &&
              myInsertedComponent instanceof RadAtomicComponent) {
            GridBuildUtil.convertToGrid(myEditor);
            FormEditingUtil.selectSingleComponent(myEditor, myInsertedComponent);
          }

          checkBindTopLevelPanel();

          if (!mySticky) {
            PaletteManager.getInstance(myEditor.getProject()).clearActiveItem();
          }

          myEditor.refreshAndSave(false);
        }
      }, UIDesignerBundle.message("command.insert.component"), null);
  }
  myComponentToInsert = null;
}
项目:tools-idea    文件:RadComponent.java   
public final Dimension getMinimumSize() {
  return Util.getMinimumSize(myDelegee, myConstraints, false);
}
项目:tools-idea    文件:RadComponent.java   
public final Dimension getPreferredSize() {
  return Util.getPreferredSize(myDelegee, myConstraints, false);
}
项目:consulo-ui-designer    文件:InsertComponentProcessor.java   
public void processComponentInsert(ComponentItem item, final ComponentDropLocation location)
{
    myEditor.getActiveDecorationLayer().removeFeedback();
    myEditor.setDesignTimeInsets(2);

    item = replaceAnyComponentItem(myEditor, item, UIDesignerBundle.message("palette.non.palette.component.title"));
    if(item == null)
    {
        return;
    }

    if(!validateNestedFormInsert(item))
    {
        return;
    }

    if(!checkAddDependencyOnInsert(item))
    {
        return;
    }

    if(!myEditor.ensureEditable())
    {
        return;
    }

    final boolean forceBinding = item.isAutoCreateBinding();
    myInsertedComponent = createInsertedComponent(myEditor, item);
    setCursor(Cursor.getDefaultCursor());
    if(myInsertedComponent == null)
    {
        if(!mySticky)
        {
            PaletteToolWindowManager.getInstance(myEditor).clearActiveItem();
        }
        return;
    }

    final ComponentItemDragObject dragObject = new ComponentItemDragObject(item);
    if(location.canDrop(dragObject))
    {
        CommandProcessor.getInstance().executeCommand(myEditor.getProject(), new Runnable()
        {
            @Override
            public void run()
            {
                createBindingWhenDrop(myEditor, myInsertedComponent, forceBinding);

                final RadComponent[] components = new RadComponent[]{myInsertedComponent};
                location.processDrop(myEditor, components, null, dragObject);

                FormEditingUtil.selectSingleComponent(myEditor, myInsertedComponent);

                if(location.getContainer() != null && location.getContainer().isXY())
                {
                    Dimension newSize = myInsertedComponent.getPreferredSize();
                    Util.adjustSize(myInsertedComponent.getDelegee(), myInsertedComponent.getConstraints(), newSize);
                    myInsertedComponent.setSize(newSize);
                }

                if(myInsertedComponent.getParent() instanceof RadRootContainer && myInsertedComponent instanceof RadAtomicComponent)
                {
                    GridBuildUtil.convertToGrid(myEditor);
                    FormEditingUtil.selectSingleComponent(myEditor, myInsertedComponent);
                }

                checkBindTopLevelPanel();

                if(!mySticky)
                {
                    PaletteToolWindowManager.getInstance(myEditor).clearActiveItem();
                }

                myEditor.refreshAndSave(false);
            }
        }, UIDesignerBundle.message("command.insert.component"), null);
    }
    myComponentToInsert = null;
}
项目:consulo-ui-designer    文件:RadComponent.java   
public final Dimension getMinimumSize() {
  return Util.getMinimumSize(myDelegee, myConstraints, false);
}
项目:consulo-ui-designer    文件:RadComponent.java   
public final Dimension getPreferredSize() {
  return Util.getPreferredSize(myDelegee, myConstraints, false);
}