Java 类com.intellij.uiDesigner.radComponents.RadRootContainer 实例源码

项目:intellij-ce-playground    文件:FormEditingUtil.java   
@Nullable
public static RadContainer getRadContainerAt(final RadRootContainer rootContainer, final int x, final int y,
                                             int epsilon) {
  RadComponent component = getRadComponentAt(rootContainer, x, y);
  if (isNullOrRoot(component) && epsilon > 0) {
    // try to find component near specified location
    component = getRadComponentAt(rootContainer, x - epsilon, y - epsilon);
    if (isNullOrRoot(component)) component = getRadComponentAt(rootContainer, x - epsilon, y + epsilon);
    if (isNullOrRoot(component)) component = getRadComponentAt(rootContainer, x + epsilon, y - epsilon);
    if (isNullOrRoot(component)) component = getRadComponentAt(rootContainer, x + epsilon, y + epsilon);
  }

  if (component != null) {
    return component instanceof RadContainer
           ? (RadContainer)component
           : component.getParent();
  }
  return null;
}
项目:intellij-ce-playground    文件:SnapShooterDaemon.java   
@NonNls
private String doSnapshotCommand(final String command) {
  int id = Integer.parseInt(command.substring(1));
  Component component = myIdMap.get(id);
  XmlWriter xmlWriter = new XmlWriter();
  RadRootContainer rootContainer = null;
  try {
    rootContainer = createFormSnapshot((JComponent) component);
  }
  catch (Exception ex) {
    ex.printStackTrace();
    return "E:" + ex.getMessage() + "\n";
  }
  rootContainer.write(xmlWriter);
  return xmlWriter.getText();
}
项目:intellij-ce-playground    文件:BindingProperty.java   
@Nullable
public static PsiField findBoundField(@NotNull final RadRootContainer root, final String fieldName) {
  final Project project = root.getProject();
  final String classToBind = root.getClassToBind();
  if (classToBind != null) {
    final PsiManager manager = PsiManager.getInstance(project);
    PsiClass aClass = JavaPsiFacade.getInstance(manager.getProject()).findClass(classToBind, GlobalSearchScope.allScope(project));
    if (aClass != null) {
      final PsiField oldBindingField = aClass.findFieldByName(fieldName, false);
      if (oldBindingField != null) {
        return oldBindingField;
      }
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:BindingProperty.java   
public static void checkCreateBindingFromText(final RadComponent component, final String text) {
  if (!component.isDefaultBinding()) {
    return;
  }
  RadRootContainer root = (RadRootContainer)FormEditingUtil.getRoot(component);
  PsiField boundField = findBoundField(root, component.getBinding());
  if (boundField == null || !isFieldUnreferenced(boundField)) {
    return;
  }

  String binding = suggestBindingFromText(component, text);
  if (binding != null) {
    new BindingProperty(component.getProject()).setValueEx(component, binding);
    // keep the binding marked as default
    component.setDefaultBinding(true);
  }
}
项目:intellij-ce-playground    文件:IntroStringProperty.java   
private static void checkUpdateBindingFromText(final RadComponent component, final StringDescriptor value, final SupportCode.TextWithMnemonic textWithMnemonic) {
  if (component.isLoadingProperties()) {
    return;
  }
  // only generate binding from text if default locale is active (IDEADEV-9427)
  if (value.getValue() == null) {
    RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(component);
    Locale locale = root.getStringDescriptorLocale();
    if (locale != null && locale.getDisplayName().length() > 0) {
      return;
    }
  }

  BindingProperty.checkCreateBindingFromText(component, textWithMnemonic.myText);
  if (component.getDelegee() instanceof JLabel) {
    for(IProperty prop: component.getModifiedProperties()) {
      if (prop.getName().equals(SwingProperties.LABEL_FOR) && prop instanceof IntroComponentProperty) {
        ((IntroComponentProperty) prop).updateLabelForBinding(component);
      }
    }
  }
}
项目:intellij-ce-playground    文件:IntroComponentProperty.java   
void updateLabelForBinding(final RadComponent component) {
  String value = getValue(component);
  String text = FormInspectionUtil.getText(component.getModule(), component);
  if (text != null && value != null) {
    RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(component);
    if (root != null) {
      RadComponent valueComponent = (RadComponent)FormEditingUtil.findComponent(root, value);
      if (valueComponent != null) {
        if (valueComponent instanceof RadScrollPane && ((RadScrollPane) valueComponent).getComponentCount() == 1) {
          valueComponent = ((RadScrollPane) valueComponent).getComponent(0);
        }
        BindingProperty.checkCreateBindingFromText(valueComponent, text);
      }
    }
  }
}
项目:intellij-ce-playground    文件:LabelPropertyRenderer.java   
public JLabel getComponent(final RadRootContainer rootContainer, final V value, final boolean selected, final boolean hasFocus){
  // Reset text and icon
  setText(null);
  setIcon(null);

  // Background and foreground
  if(selected){
    setForeground(UIUtil.getTableSelectionForeground());
    setBackground(UIUtil.getTableSelectionBackground());
  }else{
    setForeground(UIUtil.getTableForeground());
    setBackground(UIUtil.getTableBackground());
  }

  if (value != null) {
    customize(value);
  }

  return this;
}
项目:intellij-ce-playground    文件:FlattenAction.java   
private static boolean canFlatten(final RadComponent c) {
  if (!(c instanceof RadContainer)) {
    return false;
  }
  if (c.getParent() instanceof RadRootContainer) {
    return false;
  }
  RadContainer container = (RadContainer) c;
  if (container.getLayoutManager().isGrid() && container.getParent().getLayoutManager().isGrid()) {
    return true;
  }
  if (container.getComponentCount() <= 1) {
    return true;
  }
  return false;
}
项目:intellij-ce-playground    文件:GroupButtonsAction.java   
public static void groupButtons(final GuiEditor editor, final List<RadComponent> selectedComponents) {
  if (!editor.ensureEditable()) return;
  String groupName = Messages.showInputDialog(editor.getProject(),
                                              UIDesignerBundle.message("group.buttons.name.prompt"),
                                              UIDesignerBundle.message("group.buttons.title"),
                                              Messages.getQuestionIcon(),
                                              editor.getRootContainer().suggestGroupName(),
                                              new IdentifierValidator(editor.getProject()));
  if (groupName == null) return;
  RadRootContainer rootContainer = editor.getRootContainer();
  RadButtonGroup group = rootContainer.createGroup(groupName);
  for(RadComponent component: selectedComponents) {
    rootContainer.setGroupForComponent(component, group);
  }
  editor.refreshAndSave(true);
}
项目:intellij-ce-playground    文件:GroupSelectionProcessor.java   
private void markRectangle(
  final RadComponent component,
  final Rectangle rectangle,
  final Component coordinateOriginComponent
){
  if (!(component instanceof RadRootContainer) && !component.equals(myComponent)) {
    final Rectangle bounds = component.getBounds();
    final Point point = SwingUtilities.convertPoint(component.getDelegee().getParent(), bounds.x, bounds.y, coordinateOriginComponent);
    bounds.setLocation(point);

    if(rectangle.intersects(bounds)){
      component.setSelected(true);
      return;
    }
  }

  if (component instanceof RadContainer){
    final RadContainer container = (RadContainer)component;
    // [anton] it is very important to iterate through a STORED array because setSelected can
    // change order of components so iteration via getComponent(i) is incorrect 
    final RadComponent[] components = container.getComponents();
    for (RadComponent component1 : components) {
      markRectangle(component1, rectangle, coordinateOriginComponent);
    }
  }
}
项目:intellij-ce-playground    文件:ComponentPtrDescriptor.java   
public boolean update() {
  myPtr.validate();
  if(!myPtr.isValid()) {
    myPtr=null;
    return true;
  }

  final String oldBinding = myBinding;
  final String oldTitle = myTitle;
  final RadComponent component = myPtr.getComponent();
  if (component.getModule().isDisposed()) {
    return false;
  }
  if(component instanceof RadRootContainer) {
    myBinding = ((RadRootContainer)component).getClassToBind();
  }
  else{
    myBinding = component.getBinding();
  }
  myTitle = component.getComponentTitle();
  return !Comparing.equal(oldBinding,myBinding) || !Comparing.equal(oldTitle, myTitle);
}
项目:tools-idea    文件:FormEditingUtil.java   
@Nullable
public static RadContainer getRadContainerAt(final RadRootContainer rootContainer, final int x, final int y,
                                             int epsilon) {
  RadComponent component = getRadComponentAt(rootContainer, x, y);
  if (isNullOrRoot(component) && epsilon > 0) {
    // try to find component near specified location
    component = getRadComponentAt(rootContainer, x - epsilon, y - epsilon);
    if (isNullOrRoot(component)) component = getRadComponentAt(rootContainer, x - epsilon, y + epsilon);
    if (isNullOrRoot(component)) component = getRadComponentAt(rootContainer, x + epsilon, y - epsilon);
    if (isNullOrRoot(component)) component = getRadComponentAt(rootContainer, x + epsilon, y + epsilon);
  }

  if (component != null) {
    return component instanceof RadContainer
           ? (RadContainer)component
           : component.getParent();
  }
  return null;
}
项目:tools-idea    文件:SnapShooterDaemon.java   
@NonNls
private String doSnapshotCommand(final String command) {
  int id = Integer.parseInt(command.substring(1));
  Component component = myIdMap.get(id);
  XmlWriter xmlWriter = new XmlWriter();
  RadRootContainer rootContainer = null;
  try {
    rootContainer = createFormSnapshot((JComponent) component);
  }
  catch (Exception ex) {
    ex.printStackTrace();
    return "E:" + ex.getMessage() + "\n";
  }
  rootContainer.write(xmlWriter);
  return xmlWriter.getText();
}
项目:tools-idea    文件:BindingProperty.java   
@Nullable
public static PsiField findBoundField(@NotNull final RadRootContainer root, final String fieldName) {
  final Project project = root.getProject();
  final String classToBind = root.getClassToBind();
  if (classToBind != null) {
    final PsiManager manager = PsiManager.getInstance(project);
    PsiClass aClass = JavaPsiFacade.getInstance(manager.getProject()).findClass(classToBind, GlobalSearchScope.allScope(project));
    if (aClass != null) {
      final PsiField oldBindingField = aClass.findFieldByName(fieldName, false);
      if (oldBindingField != null) {
        return oldBindingField;
      }
    }
  }
  return null;
}
项目:tools-idea    文件:BindingProperty.java   
public static void checkCreateBindingFromText(final RadComponent component, final String text) {
  if (!component.isDefaultBinding()) {
    return;
  }
  RadRootContainer root = (RadRootContainer)FormEditingUtil.getRoot(component);
  PsiField boundField = findBoundField(root, component.getBinding());
  if (boundField == null || !isFieldUnreferenced(boundField)) {
    return;
  }

  String binding = suggestBindingFromText(component, text);
  if (binding != null) {
    new BindingProperty(component.getProject()).setValueEx(component, binding);
    // keep the binding marked as default
    component.setDefaultBinding(true);
  }
}
项目:tools-idea    文件:IntroStringProperty.java   
private static void checkUpdateBindingFromText(final RadComponent component, final StringDescriptor value, final SupportCode.TextWithMnemonic textWithMnemonic) {
  if (component.isLoadingProperties()) {
    return;
  }
  // only generate binding from text if default locale is active (IDEADEV-9427)
  if (value.getValue() == null) {
    RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(component);
    Locale locale = root.getStringDescriptorLocale();
    if (locale != null && locale.getDisplayName().length() > 0) {
      return;
    }
  }

  BindingProperty.checkCreateBindingFromText(component, textWithMnemonic.myText);
  if (component.getDelegee() instanceof JLabel) {
    for(IProperty prop: component.getModifiedProperties()) {
      if (prop.getName().equals(SwingProperties.LABEL_FOR) && prop instanceof IntroComponentProperty) {
        ((IntroComponentProperty) prop).updateLabelForBinding(component);
      }
    }
  }
}
项目:tools-idea    文件:IntroComponentProperty.java   
void updateLabelForBinding(final RadComponent component) {
  String value = getValue(component);
  String text = FormInspectionUtil.getText(component.getModule(), component);
  if (text != null && value != null) {
    RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(component);
    if (root != null) {
      RadComponent valueComponent = (RadComponent)FormEditingUtil.findComponent(root, value);
      if (valueComponent != null) {
        if (valueComponent instanceof RadScrollPane && ((RadScrollPane) valueComponent).getComponentCount() == 1) {
          valueComponent = ((RadScrollPane) valueComponent).getComponent(0);
        }
        BindingProperty.checkCreateBindingFromText(valueComponent, text);
      }
    }
  }
}
项目:tools-idea    文件:LabelPropertyRenderer.java   
public JLabel getComponent(final RadRootContainer rootContainer, final V value, final boolean selected, final boolean hasFocus){
  // Reset text and icon
  setText(null);
  setIcon(null);

  // Background and foreground
  if(selected){
    setForeground(UIUtil.getTableSelectionForeground());
    setBackground(UIUtil.getTableSelectionBackground());
  }else{
    setForeground(UIUtil.getTableForeground());
    setBackground(UIUtil.getTableBackground());
  }

  if (value != null) {
    customize(value);
  }

  return this;
}
项目:tools-idea    文件:FlattenAction.java   
private static boolean canFlatten(final RadComponent c) {
  if (!(c instanceof RadContainer)) {
    return false;
  }
  if (c.getParent() instanceof RadRootContainer) {
    return false;
  }
  RadContainer container = (RadContainer) c;
  if (container.getLayoutManager().isGrid() && container.getParent().getLayoutManager().isGrid()) {
    return true;
  }
  if (container.getComponentCount() <= 1) {
    return true;
  }
  return false;
}
项目:tools-idea    文件:GroupButtonsAction.java   
public static void groupButtons(final GuiEditor editor, final List<RadComponent> selectedComponents) {
  if (!editor.ensureEditable()) return;
  String groupName = Messages.showInputDialog(editor.getProject(),
                                              UIDesignerBundle.message("group.buttons.name.prompt"),
                                              UIDesignerBundle.message("group.buttons.title"),
                                              Messages.getQuestionIcon(),
                                              editor.getRootContainer().suggestGroupName(),
                                              new IdentifierValidator(editor.getProject()));
  if (groupName == null) return;
  RadRootContainer rootContainer = editor.getRootContainer();
  RadButtonGroup group = rootContainer.createGroup(groupName);
  for(RadComponent component: selectedComponents) {
    rootContainer.setGroupForComponent(component, group);
  }
  editor.refreshAndSave(true);
}
项目:tools-idea    文件:GroupSelectionProcessor.java   
private void markRectangle(
  final RadComponent component,
  final Rectangle rectangle,
  final Component coordinateOriginComponent
){
  if (!(component instanceof RadRootContainer) && !component.equals(myComponent)) {
    final Rectangle bounds = component.getBounds();
    final Point point = SwingUtilities.convertPoint(component.getDelegee().getParent(), bounds.x, bounds.y, coordinateOriginComponent);
    bounds.setLocation(point);

    if(rectangle.intersects(bounds)){
      component.setSelected(true);
      return;
    }
  }

  if (component instanceof RadContainer){
    final RadContainer container = (RadContainer)component;
    // [anton] it is very important to iterate through a STORED array because setSelected can
    // change order of components so iteration via getComponent(i) is incorrect 
    final RadComponent[] components = container.getComponents();
    for (RadComponent component1 : components) {
      markRectangle(component1, rectangle, coordinateOriginComponent);
    }
  }
}
项目:tools-idea    文件:GridInsertProcessor.java   
public static RadContainer getDropTargetContainer(final RadRootContainer rootContainer, final Point aPoint) {
  int EPSILON = 4;
  RadContainer container = FormEditingUtil.getRadContainerAt(rootContainer, aPoint.x, aPoint.y, EPSILON);
  // to facilitate initial component adding, increase stickiness if there is one container at top level
  if (container instanceof RadRootContainer && rootContainer.getComponentCount() == 1) {
    final RadComponent singleComponent = rootContainer.getComponents()[0];
    if (singleComponent instanceof RadContainer) {
      Rectangle rc = singleComponent.getDelegee().getBounds();
      rc.grow(EPSILON*2, EPSILON*2);
      if (rc.contains(aPoint)) {
        container = (RadContainer) singleComponent;
        EPSILON *= 2;
      }
    }
  }
  return container;
}
项目:tools-idea    文件:ComponentPtrDescriptor.java   
public boolean update() {
  myPtr.validate();
  if(!myPtr.isValid()) {
    myPtr=null;
    return true;
  }

  final String oldBinding = myBinding;
  final String oldTitle = myTitle;
  final RadComponent component = myPtr.getComponent();
  if (component.getModule().isDisposed()) {
    return false;
  }
  if(component instanceof RadRootContainer) {
    myBinding = ((RadRootContainer)component).getClassToBind();
  }
  else{
    myBinding = component.getBinding();
  }
  myTitle = component.getComponentTitle();
  return !Comparing.equal(oldBinding,myBinding) || !Comparing.equal(oldTitle, myTitle);
}
项目:consulo-ui-designer    文件:SnapShooterDaemon.java   
@NonNls
private String doSnapshotCommand(final String command) {
  int id = Integer.parseInt(command.substring(1));
  Component component = myIdMap.get(id);
  XmlWriter xmlWriter = new XmlWriter();
  RadRootContainer rootContainer = null;
  try {
    rootContainer = createFormSnapshot((JComponent) component);
  }
  catch (Exception ex) {
    ex.printStackTrace();
    return "E:" + ex.getMessage() + "\n";
  }
  rootContainer.write(xmlWriter);
  return xmlWriter.getText();
}
项目:consulo-ui-designer    文件:BindingProperty.java   
@Nullable
public static PsiField findBoundField(@NotNull final RadRootContainer root, final String fieldName) {
  final Project project = root.getProject();
  final String classToBind = root.getClassToBind();
  if (classToBind != null) {
    final PsiManager manager = PsiManager.getInstance(project);
    PsiClass aClass = JavaPsiFacade.getInstance(manager.getProject()).findClass(classToBind, GlobalSearchScope.allScope(project));
    if (aClass != null) {
      final PsiField oldBindingField = aClass.findFieldByName(fieldName, false);
      if (oldBindingField != null) {
        return oldBindingField;
      }
    }
  }
  return null;
}
项目:consulo-ui-designer    文件:BindingProperty.java   
public static void checkCreateBindingFromText(final RadComponent component, final String text) {
  if (!component.isDefaultBinding()) {
    return;
  }
  RadRootContainer root = (RadRootContainer)FormEditingUtil.getRoot(component);
  PsiField boundField = findBoundField(root, component.getBinding());
  if (boundField == null || !isFieldUnreferenced(boundField)) {
    return;
  }

  String binding = suggestBindingFromText(component, text);
  if (binding != null) {
    new BindingProperty(component.getProject()).setValueEx(component, binding);
    // keep the binding marked as default
    component.setDefaultBinding(true);
  }
}
项目:consulo-ui-designer    文件:IntroStringProperty.java   
private static void checkUpdateBindingFromText(final RadComponent component, final StringDescriptor value, final SupportCode.TextWithMnemonic textWithMnemonic) {
  if (component.isLoadingProperties()) {
    return;
  }
  // only generate binding from text if default locale is active (IDEADEV-9427)
  if (value.getValue() == null) {
    RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(component);
    Locale locale = root.getStringDescriptorLocale();
    if (locale != null && locale.getDisplayName().length() > 0) {
      return;
    }
  }

  BindingProperty.checkCreateBindingFromText(component, textWithMnemonic.myText);
  if (component.getDelegee() instanceof JLabel) {
    for(IProperty prop: component.getModifiedProperties()) {
      if (prop.getName().equals(SwingProperties.LABEL_FOR) && prop instanceof IntroComponentProperty) {
        ((IntroComponentProperty) prop).updateLabelForBinding(component);
      }
    }
  }
}
项目:consulo-ui-designer    文件:IntroComponentProperty.java   
void updateLabelForBinding(final RadComponent component) {
  String value = getValue(component);
  String text = FormInspectionUtil.getText(component.getModule(), component);
  if (text != null && value != null) {
    RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(component);
    if (root != null) {
      RadComponent valueComponent = (RadComponent)FormEditingUtil.findComponent(root, value);
      if (valueComponent != null) {
        if (valueComponent instanceof RadScrollPane && ((RadScrollPane) valueComponent).getComponentCount() == 1) {
          valueComponent = ((RadScrollPane) valueComponent).getComponent(0);
        }
        BindingProperty.checkCreateBindingFromText(valueComponent, text);
      }
    }
  }
}
项目:consulo-ui-designer    文件:LabelPropertyRenderer.java   
public JLabel getComponent(final RadRootContainer rootContainer, final V value, final boolean selected, final boolean hasFocus){
  // Reset text and icon
  setText(null);
  setIcon(null);

  // Background and foreground
  if(selected){
    setForeground(UIUtil.getTableSelectionForeground());
    setBackground(UIUtil.getTableSelectionBackground());
  }else{
    setForeground(UIUtil.getTableForeground());
    setBackground(UIUtil.getTableBackground());
  }

  if (value != null) {
    customize(value);
  }

  return this;
}
项目:consulo-ui-designer    文件:FlattenAction.java   
private static boolean canFlatten(final RadComponent c) {
  if (!(c instanceof RadContainer)) {
    return false;
  }
  if (c.getParent() instanceof RadRootContainer) {
    return false;
  }
  RadContainer container = (RadContainer) c;
  if (container.getLayoutManager().isGrid() && container.getParent().getLayoutManager().isGrid()) {
    return true;
  }
  if (container.getComponentCount() <= 1) {
    return true;
  }
  return false;
}
项目:consulo-ui-designer    文件:GroupButtonsAction.java   
public static void groupButtons(final GuiEditor editor, final List<RadComponent> selectedComponents) {
  if (!editor.ensureEditable()) return;
  String groupName = Messages.showInputDialog(editor.getProject(),
                                              UIDesignerBundle.message("group.buttons.name.prompt"),
                                              UIDesignerBundle.message("group.buttons.title"),
                                              Messages.getQuestionIcon(),
                                              editor.getRootContainer().suggestGroupName(),
                                              new IdentifierValidator(editor.getProject()));
  if (groupName == null) return;
  RadRootContainer rootContainer = editor.getRootContainer();
  RadButtonGroup group = rootContainer.createGroup(groupName);
  for(RadComponent component: selectedComponents) {
    rootContainer.setGroupForComponent(component, group);
  }
  editor.refreshAndSave(true);
}
项目:consulo-ui-designer    文件:GroupSelectionProcessor.java   
private void markRectangle(
  final RadComponent component,
  final Rectangle rectangle,
  final Component coordinateOriginComponent
){
  if (!(component instanceof RadRootContainer) && !component.equals(myComponent)) {
    final Rectangle bounds = component.getBounds();
    final Point point = SwingUtilities.convertPoint(component.getDelegee().getParent(), bounds.x, bounds.y, coordinateOriginComponent);
    bounds.setLocation(point);

    if(rectangle.intersects(bounds)){
      component.setSelected(true);
      return;
    }
  }

  if (component instanceof RadContainer){
    final RadContainer container = (RadContainer)component;
    // [anton] it is very important to iterate through a STORED array because setSelected can
    // change order of components so iteration via getComponent(i) is incorrect 
    final RadComponent[] components = container.getComponents();
    for (RadComponent component1 : components) {
      markRectangle(component1, rectangle, coordinateOriginComponent);
    }
  }
}
项目:consulo-ui-designer    文件:GridInsertProcessor.java   
public static RadContainer getDropTargetContainer(final RadRootContainer rootContainer, final Point aPoint) {
  int EPSILON = 4;
  RadContainer container = FormEditingUtil.getRadContainerAt(rootContainer, aPoint.x, aPoint.y, EPSILON);
  // to facilitate initial component adding, increase stickiness if there is one container at top level
  if (container instanceof RadRootContainer && rootContainer.getComponentCount() == 1) {
    final RadComponent singleComponent = rootContainer.getComponents()[0];
    if (singleComponent instanceof RadContainer) {
      Rectangle rc = singleComponent.getDelegee().getBounds();
      rc.grow(EPSILON*2, EPSILON*2);
      if (rc.contains(aPoint)) {
        container = (RadContainer) singleComponent;
        EPSILON *= 2;
      }
    }
  }
  return container;
}
项目:consulo-ui-designer    文件:ComponentPtrDescriptor.java   
public boolean update() {
  myPtr.validate();
  if(!myPtr.isValid()) {
    myPtr=null;
    return true;
  }

  final String oldBinding = myBinding;
  final String oldTitle = myTitle;
  final RadComponent component = myPtr.getComponent();
  if (component.getModule().isDisposed()) {
    return false;
  }
  if(component instanceof RadRootContainer) {
    myBinding = ((RadRootContainer)component).getClassToBind();
  }
  else{
    myBinding = component.getBinding();
  }
  myTitle = component.getComponentTitle();
  return !Comparing.equal(oldBinding,myBinding) || !Comparing.equal(oldTitle, myTitle);
}
项目:intellij-ce-playground    文件:FormEditingUtil.java   
public static boolean canDeleteSelection(final GuiEditor editor) {
  final ArrayList<RadComponent> selection = getSelectedComponents(editor);
  if (selection.isEmpty()) return false;
  final RadRootContainer rootContainer = editor.getRootContainer();
  if (rootContainer.getComponentCount() > 0 && selection.contains(rootContainer.getComponent(0))) {
    return false;
  }
  return true;
}
项目:intellij-ce-playground    文件:FormEditingUtil.java   
/**
 * @param x in editor pane coordinates
 * @param y in editor pane coordinates
 */
public static RadComponent getRadComponentAt(final RadRootContainer rootContainer, final int x, final int y) {
  Point location = new Point(x, y);
  SwingUtilities.convertPointToScreen(location, rootContainer.getDelegee());
  Component c = getDeepestEmptyComponentAt(rootContainer.getDelegee(), location);

  if (c == null) {
    c = SwingUtilities.getDeepestComponentAt(rootContainer.getDelegee(), x, y);
  }

  RadComponent result = null;

  while (c != null) {
    if (c instanceof JComponent) {
      final RadComponent component = (RadComponent)((JComponent)c).getClientProperty(RadComponent.CLIENT_PROP_RAD_COMPONENT);
      if (component != null) {

        if (result == null) {
          result = component;
        }
        else {
          final Point p = SwingUtilities.convertPoint(rootContainer.getDelegee(), x, y, c);
          if (Painter.getResizeMask(component, p.x, p.y) != 0) {
            result = component;
          }
        }
      }
    }
    c = c.getParent();
  }

  return result;
}
项目:intellij-ce-playground    文件:FormEditingUtil.java   
/**
 * @param rootContainer
 * @return id
 */
public static String generateId(final RadRootContainer rootContainer) {
  while (true) {
    final String id = Integer.toString((int)(Math.random() * 1024 * 1024), 16);
    if (findComponent(rootContainer, id) == null) {
      return id;
    }
  }
}
项目:intellij-ce-playground    文件:SnapShooterDaemon.java   
private RadRootContainer createFormSnapshot(final JComponent component) {
  SnapshotContext context = new SnapshotContext();
  final RadComponent radComponent = RadComponent.createSnapshotComponent(context, component);
  if (radComponent != null) {
    radComponent.setBounds(new Rectangle(new Point(10, 10), component.getPreferredSize()));
    context.getRootContainer().addComponent(radComponent);
    context.postProcess();
  }
  return context.getRootContainer();
}
项目:intellij-ce-playground    文件:BindingProperty.java   
protected void setValueImpl(final RadComponent component, final String value) throws Exception {
  if (Comparing.strEqual(value, component.getBinding(), true)) {
    return;
  }

  if (value.length() > 0 && !PsiNameHelper.getInstance(component.getProject()).isIdentifier(value)) {
    throw new Exception("Value '" + value + "' is not a valid identifier");
  }

  final RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(component);
  final String oldBinding = getValue(component);

  // Check that binding remains unique

  if (value.length() > 0) {
    if (!FormEditingUtil.isBindingUnique(component, value, root)) {
      throw new Exception(UIDesignerBundle.message("error.binding.not.unique"));
    }

    component.setBinding(value);
    component.setDefaultBinding(false);
  }
  else {
    if (component.isCustomCreateRequired()) {
      throw new Exception(UIDesignerBundle.message("error.custom.create.binding.required"));
    }
    component.setBinding(null);
    component.setCustomCreate(false);
  }

  // Set new value or rename old one. It means that previous binding exists
  // and the new one doesn't exist we need to ask user to create new field
  // or rename old one.

  updateBoundFieldName(root, oldBinding, value, component.getComponentClassName());
}
项目:intellij-ce-playground    文件:BindingProperty.java   
public static void checkRemoveUnusedField(final RadRootContainer rootContainer, final String fieldName, final Object undoGroupId) {
  final PsiField oldBindingField = findBoundField(rootContainer, fieldName);
  if (oldBindingField == null) {
    return;
  }
  final Project project = oldBindingField.getProject();
  final PsiClass aClass = oldBindingField.getContainingClass();
  if (isFieldUnreferenced(oldBindingField)) {
    if (!CommonRefactoringUtil.checkReadOnlyStatus(project, aClass)) {
      return;
    }
    ApplicationManager.getApplication().runWriteAction(
      new Runnable() {
        public void run() {
          CommandProcessor.getInstance().executeCommand(
            project,
            new Runnable() {
              public void run() {
                try {
                  oldBindingField.delete();
                }
                catch (IncorrectOperationException e) {
                  Messages.showErrorDialog(project, UIDesignerBundle.message("error.cannot.delete.unused.field", e.getMessage()),
                                           CommonBundle.getErrorTitle());
                }
              }
            },
            UIDesignerBundle.message("command.delete.unused.field"), undoGroupId
          );
        }
      }
    );
  }
}