Java 类com.intellij.uiDesigner.snapShooter.SnapshotContext 实例源码

项目:intellij-ce-playground    文件:IntroColorProperty.java   
@Override
public void importSnapshotValue(final SnapshotContext context, final JComponent component, final RadComponent radComponent) {
  try {
    if (component.getParent() != null) {
      Color componentColor = (Color) myReadMethod.invoke(component, EMPTY_OBJECT_ARRAY);
      Color parentColor = (Color) myReadMethod.invoke(component.getParent(), EMPTY_OBJECT_ARRAY);
      ColorDescriptor defaultColor = getDefaultValue(component);
      if (componentColor != null && !Comparing.equal(componentColor, parentColor) && !Comparing.equal(componentColor, defaultColor)) {
        setValue(radComponent, new ColorDescriptor(componentColor));
      }
    }
  }
  catch (Exception e) {
    // ignore
  }
}
项目:intellij-ce-playground    文件:RadSwingGridLayoutManager.java   
@Override
public void createSnapshotLayout(final SnapshotContext context,
                                 final JComponent parent,
                                 final RadContainer container,
                                 final LayoutManager layout) {
  GridLayout gridLayout = (GridLayout) layout;

  int ncomponents = parent.getComponentCount();
  int nrows = gridLayout.getRows();
  int ncols = gridLayout.getColumns();

  if (nrows > 0) {
      ncols = (ncomponents + nrows - 1) / nrows;
  } else {
      nrows = (ncomponents + ncols - 1) / ncols;
  }

  container.setLayout(new GridLayoutManager(nrows, ncols,
                                            new Insets(0, 0, 0, 0),
                                            gridLayout.getHgap(), gridLayout.getVgap(),
                                            true, true));
}
项目:tools-idea    文件:IntroColorProperty.java   
@Override
public void importSnapshotValue(final SnapshotContext context, final JComponent component, final RadComponent radComponent) {
  try {
    if (component.getParent() != null) {
      Color componentColor = (Color) myReadMethod.invoke(component, EMPTY_OBJECT_ARRAY);
      Color parentColor = (Color) myReadMethod.invoke(component.getParent(), EMPTY_OBJECT_ARRAY);
      ColorDescriptor defaultColor = getDefaultValue(component);
      if (componentColor != null && !Comparing.equal(componentColor, parentColor) && !Comparing.equal(componentColor, defaultColor)) {
        setValue(radComponent, new ColorDescriptor(componentColor));
      }
    }
  }
  catch (Exception e) {
    // ignore
  }
}
项目:tools-idea    文件:RadSwingGridLayoutManager.java   
@Override
public void createSnapshotLayout(final SnapshotContext context,
                                 final JComponent parent,
                                 final RadContainer container,
                                 final LayoutManager layout) {
  GridLayout gridLayout = (GridLayout) layout;

  int ncomponents = parent.getComponentCount();
  int nrows = gridLayout.getRows();
  int ncols = gridLayout.getColumns();

  if (nrows > 0) {
      ncols = (ncomponents + nrows - 1) / nrows;
  } else {
      nrows = (ncomponents + ncols - 1) / ncols;
  }

  container.setLayout(new GridLayoutManager(nrows, ncols,
                                            new Insets(0, 0, 0, 0),
                                            gridLayout.getHgap(), gridLayout.getVgap(),
                                            true, true));
}
项目:consulo-ui-designer    文件:IntroColorProperty.java   
@Override
public void importSnapshotValue(final SnapshotContext context, final JComponent component, final RadComponent radComponent) {
  try {
    if (component.getParent() != null) {
      Color componentColor = (Color) myReadMethod.invoke(component, EMPTY_OBJECT_ARRAY);
      Color parentColor = (Color) myReadMethod.invoke(component.getParent(), EMPTY_OBJECT_ARRAY);
      ColorDescriptor defaultColor = getDefaultValue(component);
      if (componentColor != null && !Comparing.equal(componentColor, parentColor) && !Comparing.equal(componentColor, defaultColor)) {
        setValue(radComponent, new ColorDescriptor(componentColor));
      }
    }
  }
  catch (Exception e) {
    // ignore
  }
}
项目:consulo-ui-designer    文件:RadSwingGridLayoutManager.java   
@Override
public void createSnapshotLayout(final SnapshotContext context,
                                 final JComponent parent,
                                 final RadContainer container,
                                 final LayoutManager layout) {
  GridLayout gridLayout = (GridLayout) layout;

  int ncomponents = parent.getComponentCount();
  int nrows = gridLayout.getRows();
  int ncols = gridLayout.getColumns();

  if (nrows > 0) {
      ncols = (ncomponents + nrows - 1) / nrows;
  } else {
      nrows = (ncomponents + ncols - 1) / ncols;
  }

  container.setLayout(new GridLayoutManager(nrows, ncols,
                                            new Insets(0, 0, 0, 0),
                                            gridLayout.getHgap(), gridLayout.getVgap(),
                                            true, true));
}
项目:intellij-ce-playground    文件:IntrospectedProperty.java   
public void importSnapshotValue(final SnapshotContext context, final JComponent component, final RadComponent radComponent) {
  try {
    //noinspection unchecked
    V value = (V) myReadMethod.invoke(component, EMPTY_OBJECT_ARRAY);
    V defaultValue = getDefaultValue(radComponent.getDelegee());
    if (!Comparing.equal(value, defaultValue)) {
      setValue(radComponent, value);
    }
  }
  catch (Exception e) {
    // ignore
  }
}
项目:intellij-ce-playground    文件:IntroStringProperty.java   
@Override public void importSnapshotValue(final SnapshotContext context, final JComponent component, final RadComponent radComponent) {
  try {
    Object value = myReadMethod.invoke(component, EMPTY_OBJECT_ARRAY);
    if (value != null) {
      setValue(radComponent, stringDescriptorFromValue(null, component));
    }
  }
  catch (Exception e) {
    // ignore
  }
}
项目:intellij-ce-playground    文件:IntroComponentProperty.java   
@Override public void importSnapshotValue(final SnapshotContext context, final JComponent component, final RadComponent radComponent) {
  Component value;
  try {
    value = (Component) myReadMethod.invoke(component, EMPTY_OBJECT_ARRAY);
  }
  catch (Exception e) {
    return;
  }
  if (value != null && value instanceof JComponent) {
    context.registerComponentProperty(component, getName(), (JComponent) value);
  }
}
项目:intellij-ce-playground    文件:IntroDimensionProperty.java   
@Override
public void importSnapshotValue(final SnapshotContext context, final JComponent component, final RadComponent radComponent) {
  if (getName().equals(SwingProperties.MINIMUM_SIZE) ||
      getName().equals(SwingProperties.MAXIMUM_SIZE) ||
      getName().equals(SwingProperties.PREFERRED_SIZE)) {
    return;
  }
  super.importSnapshotValue(context, component, radComponent);
}
项目:intellij-ce-playground    文件:IntroIntProperty.java   
@Override
public void importSnapshotValue(final SnapshotContext context, final JComponent component, final RadComponent radComponent) {
  // exclude property from snapshot import to avoid exceptions because of not imported model 
  if (!getName().equals(SwingProperties.SELECTED_INDEX)) {
    super.importSnapshotValue(context, component, radComponent);
  }
}
项目:intellij-ce-playground    文件:RadBoxLayoutManager.java   
@Override
public void createSnapshotLayout(final SnapshotContext context,
                                 final JComponent parent,
                                 final RadContainer container,
                                 final LayoutManager layout) {
  int rowCount = 1;
  int colCount = 1;

  boolean hasFiller = false;
  // workaround for lack of BoxLayout.getAxis()
  if (parent.getComponentCount() > 1) {
    for(Component component: parent.getComponents()) {
      if (component instanceof Box.Filler) {
        hasFiller = true;
      }
    }

    Rectangle bounds1 = parent.getComponent(0).getBounds();
    Rectangle bounds2 = parent.getComponent(1).getBounds();
    if (bounds2.x >= bounds1.x + bounds1.width) {
      colCount = parent.getComponentCount();
      if (!hasFiller) colCount++;
      myHorizontal = true;
    }
    else {
      rowCount = parent.getComponentCount();
      if (!hasFiller) rowCount++;
    }
  }
  container.setLayout(new GridLayoutManager(rowCount, colCount));
  if (!hasFiller) {
    if (myHorizontal) {
      container.addComponent(new RadHSpacer(context.newId(), colCount-1));
    }
    else {
      container.addComponent(new RadVSpacer(context.newId(), rowCount-1));
    }
  }
}
项目:intellij-ce-playground    文件:RadGridBagLayoutManager.java   
@Override
public void createSnapshotLayout(final SnapshotContext context,
                                 final JComponent parent,
                                 final RadContainer container,
                                 final LayoutManager layout) {
  container.setLayout(new GridBagLayout());
}
项目:intellij-ce-playground    文件:RadCardLayoutManager.java   
@Override public void createSnapshotLayout(final SnapshotContext context,
                                           final JComponent parent,
                                           final RadContainer container,
                                           final LayoutManager layout) {
  CardLayout cardLayout = (CardLayout) layout;
  container.setLayout(new CardLayout(cardLayout.getHgap(), cardLayout.getVgap()));
}
项目:intellij-ce-playground    文件:RadSplitPane.java   
private void importSideComponent(final Component sideComponent,
                                 final SnapshotContext context,
                                 final String position) {
  if (sideComponent instanceof JComponent) {
    RadComponent radSideComponent = createSnapshotComponent(context, (JComponent) sideComponent);
    if (radSideComponent != null) {
      radSideComponent.setCustomLayoutConstraints(position);
      addComponent(radSideComponent);
    }
  }
}
项目:intellij-ce-playground    文件:RadTabbedPane.java   
@Override
protected void importSnapshotComponent(final SnapshotContext context, final JComponent component) {
  JTabbedPane tabbedPane = (JTabbedPane) component;
  for(int i=0; i<tabbedPane.getTabCount(); i++) {
    String title = tabbedPane.getTitleAt(i);
    Component child = tabbedPane.getComponentAt(i);
    if (child instanceof JComponent) {
      RadComponent childComponent = createSnapshotComponent(context, (JComponent) child);
      if (childComponent != null) {
        childComponent.setCustomLayoutConstraints(new LwTabbedPane.Constraints(StringDescriptor.create(title)));
        addComponent(childComponent);
      }
    }
  }
}
项目:intellij-ce-playground    文件:RadBorderLayoutManager.java   
@Override public void createSnapshotLayout(final SnapshotContext context,
                                           final JComponent parent,
                                           final RadContainer container,
                                           final LayoutManager layout) {
  BorderLayout borderLayout = (BorderLayout) layout;
  container.setLayout(new BorderLayout(borderLayout.getHgap(), borderLayout.getVgap()));
}
项目:intellij-ce-playground    文件:RadContainer.java   
@Override
protected void importSnapshotComponent(final SnapshotContext context, final JComponent component) {
  getLayoutManager().createSnapshotLayout(context, component, this, component.getLayout());
  importSnapshotBorder(component);
  for (Component child : component.getComponents()) {
    if (child instanceof JComponent) {
      RadComponent childComponent = createSnapshotComponent(context, (JComponent)child);
      if (childComponent != null) {
        getLayoutManager().addSnapshotComponent(component, (JComponent)child, this, childComponent);
      }
    }
  }
}
项目:intellij-ce-playground    文件:RadScrollPane.java   
@Override
protected void importSnapshotComponent(final SnapshotContext context, final JComponent component) {
  JScrollPane scrollPane = (JScrollPane) component;
  final Component view = scrollPane.getViewport().getView();
  if (view instanceof JComponent) {
    RadComponent childComponent = createSnapshotComponent(context, (JComponent) view);
    if (childComponent != null) {
      addComponent(childComponent);
    }
  }
}
项目:intellij-ce-playground    文件:RadFlowLayoutManager.java   
@Override
public void createSnapshotLayout(final SnapshotContext context,
                                 final JComponent parent,
                                 final RadContainer container,
                                 final LayoutManager layout) {
  FlowLayout flowLayout = (FlowLayout) layout;
  container.setLayout(new FlowLayout(flowLayout.getAlignment(), flowLayout.getHgap(), flowLayout.getVgap()));
}
项目:tools-idea    文件:IntrospectedProperty.java   
public void importSnapshotValue(final SnapshotContext context, final JComponent component, final RadComponent radComponent) {
  try {
    //noinspection unchecked
    V value = (V) myReadMethod.invoke(component, EMPTY_OBJECT_ARRAY);
    V defaultValue = getDefaultValue(radComponent.getDelegee());
    if (!Comparing.equal(value, defaultValue)) {
      setValue(radComponent, value);
    }
  }
  catch (Exception e) {
    // ignore
  }
}
项目:tools-idea    文件:IntroStringProperty.java   
@Override public void importSnapshotValue(final SnapshotContext context, final JComponent component, final RadComponent radComponent) {
  try {
    Object value = myReadMethod.invoke(component, EMPTY_OBJECT_ARRAY);
    if (value != null) {
      setValue(radComponent, stringDescriptorFromValue(null, component));
    }
  }
  catch (Exception e) {
    // ignore
  }
}
项目:tools-idea    文件:IntroComponentProperty.java   
@Override public void importSnapshotValue(final SnapshotContext context, final JComponent component, final RadComponent radComponent) {
  Component value;
  try {
    value = (Component) myReadMethod.invoke(component, EMPTY_OBJECT_ARRAY);
  }
  catch (Exception e) {
    return;
  }
  if (value != null && value instanceof JComponent) {
    context.registerComponentProperty(component, getName(), (JComponent) value);
  }
}
项目:tools-idea    文件:IntroDimensionProperty.java   
@Override
public void importSnapshotValue(final SnapshotContext context, final JComponent component, final RadComponent radComponent) {
  if (getName().equals(SwingProperties.MINIMUM_SIZE) ||
      getName().equals(SwingProperties.MAXIMUM_SIZE) ||
      getName().equals(SwingProperties.PREFERRED_SIZE)) {
    return;
  }
  super.importSnapshotValue(context, component, radComponent);
}
项目:tools-idea    文件:IntroIntProperty.java   
@Override
public void importSnapshotValue(final SnapshotContext context, final JComponent component, final RadComponent radComponent) {
  // exclude property from snapshot import to avoid exceptions because of not imported model 
  if (!getName().equals(SwingProperties.SELECTED_INDEX)) {
    super.importSnapshotValue(context, component, radComponent);
  }
}
项目:tools-idea    文件:RadBoxLayoutManager.java   
@Override
public void createSnapshotLayout(final SnapshotContext context,
                                 final JComponent parent,
                                 final RadContainer container,
                                 final LayoutManager layout) {
  int rowCount = 1;
  int colCount = 1;

  boolean hasFiller = false;
  // workaround for lack of BoxLayout.getAxis()
  if (parent.getComponentCount() > 1) {
    for(Component component: parent.getComponents()) {
      if (component instanceof Box.Filler) {
        hasFiller = true;
      }
    }

    Rectangle bounds1 = parent.getComponent(0).getBounds();
    Rectangle bounds2 = parent.getComponent(1).getBounds();
    if (bounds2.x >= bounds1.x + bounds1.width) {
      colCount = parent.getComponentCount();
      if (!hasFiller) colCount++;
      myHorizontal = true;
    }
    else {
      rowCount = parent.getComponentCount();
      if (!hasFiller) rowCount++;
    }
  }
  container.setLayout(new GridLayoutManager(rowCount, colCount));
  if (!hasFiller) {
    if (myHorizontal) {
      container.addComponent(new RadHSpacer(context.newId(), colCount-1));
    }
    else {
      container.addComponent(new RadVSpacer(context.newId(), rowCount-1));
    }
  }
}
项目:tools-idea    文件:RadGridBagLayoutManager.java   
@Override
public void createSnapshotLayout(final SnapshotContext context,
                                 final JComponent parent,
                                 final RadContainer container,
                                 final LayoutManager layout) {
  container.setLayout(new GridBagLayout());
}
项目:tools-idea    文件:RadCardLayoutManager.java   
@Override public void createSnapshotLayout(final SnapshotContext context,
                                           final JComponent parent,
                                           final RadContainer container,
                                           final LayoutManager layout) {
  CardLayout cardLayout = (CardLayout) layout;
  container.setLayout(new CardLayout(cardLayout.getHgap(), cardLayout.getVgap()));
}
项目:tools-idea    文件:RadSplitPane.java   
private void importSideComponent(final Component sideComponent,
                                 final SnapshotContext context,
                                 final String position) {
  if (sideComponent instanceof JComponent) {
    RadComponent radSideComponent = createSnapshotComponent(context, (JComponent) sideComponent);
    if (radSideComponent != null) {
      radSideComponent.setCustomLayoutConstraints(position);
      addComponent(radSideComponent);
    }
  }
}
项目:tools-idea    文件:RadTabbedPane.java   
@Override
protected void importSnapshotComponent(final SnapshotContext context, final JComponent component) {
  JTabbedPane tabbedPane = (JTabbedPane) component;
  for(int i=0; i<tabbedPane.getTabCount(); i++) {
    String title = tabbedPane.getTitleAt(i);
    Component child = tabbedPane.getComponentAt(i);
    if (child instanceof JComponent) {
      RadComponent childComponent = createSnapshotComponent(context, (JComponent) child);
      if (childComponent != null) {
        childComponent.setCustomLayoutConstraints(new LwTabbedPane.Constraints(StringDescriptor.create(title)));
        addComponent(childComponent);
      }
    }
  }
}
项目:tools-idea    文件:RadBorderLayoutManager.java   
@Override public void createSnapshotLayout(final SnapshotContext context,
                                           final JComponent parent,
                                           final RadContainer container,
                                           final LayoutManager layout) {
  BorderLayout borderLayout = (BorderLayout) layout;
  container.setLayout(new BorderLayout(borderLayout.getHgap(), borderLayout.getVgap()));
}
项目:tools-idea    文件:RadContainer.java   
@Override
protected void importSnapshotComponent(final SnapshotContext context, final JComponent component) {
  getLayoutManager().createSnapshotLayout(context, component, this, component.getLayout());
  importSnapshotBorder(component);
  for (Component child : component.getComponents()) {
    if (child instanceof JComponent) {
      RadComponent childComponent = createSnapshotComponent(context, (JComponent)child);
      if (childComponent != null) {
        getLayoutManager().addSnapshotComponent(component, (JComponent)child, this, childComponent);
      }
    }
  }
}
项目:tools-idea    文件:RadScrollPane.java   
@Override
protected void importSnapshotComponent(final SnapshotContext context, final JComponent component) {
  JScrollPane scrollPane = (JScrollPane) component;
  final Component view = scrollPane.getViewport().getView();
  if (view instanceof JComponent) {
    RadComponent childComponent = createSnapshotComponent(context, (JComponent) view);
    if (childComponent != null) {
      addComponent(childComponent);
    }
  }
}
项目:tools-idea    文件:RadFlowLayoutManager.java   
@Override
public void createSnapshotLayout(final SnapshotContext context,
                                 final JComponent parent,
                                 final RadContainer container,
                                 final LayoutManager layout) {
  FlowLayout flowLayout = (FlowLayout) layout;
  container.setLayout(new FlowLayout(flowLayout.getAlignment(), flowLayout.getHgap(), flowLayout.getVgap()));
}
项目:consulo-ui-designer    文件:IntrospectedProperty.java   
public void importSnapshotValue(final SnapshotContext context, final JComponent component, final RadComponent radComponent) {
  try {
    //noinspection unchecked
    V value = (V) myReadMethod.invoke(component, EMPTY_OBJECT_ARRAY);
    V defaultValue = getDefaultValue(radComponent.getDelegee());
    if (!Comparing.equal(value, defaultValue)) {
      setValue(radComponent, value);
    }
  }
  catch (Exception e) {
    // ignore
  }
}
项目:consulo-ui-designer    文件:IntroStringProperty.java   
@Override public void importSnapshotValue(final SnapshotContext context, final JComponent component, final RadComponent radComponent) {
  try {
    Object value = myReadMethod.invoke(component, EMPTY_OBJECT_ARRAY);
    if (value != null) {
      setValue(radComponent, stringDescriptorFromValue(null, component));
    }
  }
  catch (Exception e) {
    // ignore
  }
}
项目:consulo-ui-designer    文件:IntroComponentProperty.java   
@Override public void importSnapshotValue(final SnapshotContext context, final JComponent component, final RadComponent radComponent) {
  Component value;
  try {
    value = (Component) myReadMethod.invoke(component, EMPTY_OBJECT_ARRAY);
  }
  catch (Exception e) {
    return;
  }
  if (value != null && value instanceof JComponent) {
    context.registerComponentProperty(component, getName(), (JComponent) value);
  }
}
项目:consulo-ui-designer    文件:IntroDimensionProperty.java   
@Override
public void importSnapshotValue(final SnapshotContext context, final JComponent component, final RadComponent radComponent) {
  if (getName().equals(SwingProperties.MINIMUM_SIZE) ||
      getName().equals(SwingProperties.MAXIMUM_SIZE) ||
      getName().equals(SwingProperties.PREFERRED_SIZE)) {
    return;
  }
  super.importSnapshotValue(context, component, radComponent);
}
项目:consulo-ui-designer    文件:IntroIntProperty.java   
@Override
public void importSnapshotValue(final SnapshotContext context, final JComponent component, final RadComponent radComponent) {
  // exclude property from snapshot import to avoid exceptions because of not imported model 
  if (!getName().equals(SwingProperties.SELECTED_INDEX)) {
    super.importSnapshotValue(context, component, radComponent);
  }
}
项目:consulo-ui-designer    文件:RadBoxLayoutManager.java   
@Override
public void createSnapshotLayout(final SnapshotContext context,
                                 final JComponent parent,
                                 final RadContainer container,
                                 final LayoutManager layout) {
  int rowCount = 1;
  int colCount = 1;

  boolean hasFiller = false;
  // workaround for lack of BoxLayout.getAxis()
  if (parent.getComponentCount() > 1) {
    for(Component component: parent.getComponents()) {
      if (component instanceof Box.Filler) {
        hasFiller = true;
      }
    }

    Rectangle bounds1 = parent.getComponent(0).getBounds();
    Rectangle bounds2 = parent.getComponent(1).getBounds();
    if (bounds2.x >= bounds1.x + bounds1.width) {
      colCount = parent.getComponentCount();
      if (!hasFiller) colCount++;
      myHorizontal = true;
    }
    else {
      rowCount = parent.getComponentCount();
      if (!hasFiller) rowCount++;
    }
  }
  container.setLayout(new GridLayoutManager(rowCount, colCount));
  if (!hasFiller) {
    if (myHorizontal) {
      container.addComponent(new RadHSpacer(context.newId(), colCount-1));
    }
    else {
      container.addComponent(new RadVSpacer(context.newId(), rowCount-1));
    }
  }
}