use of com.intellij.uiDesigner.radComponents.RadButtonGroup in project intellij-community by JetBrains.
the class ComponentTreeStructure method getChildElements.
public Object[] getChildElements(final Object element) {
if (element == myRootElement) {
ArrayList<Object> elements = new ArrayList<>();
final RadRootContainer rootContainer = myEditor.getRootContainer();
elements.add(new ComponentPtr(myEditor, rootContainer));
final LwInspectionSuppression[] suppressions = rootContainer.getInspectionSuppressions();
if (suppressions.length > 0) {
elements.add(suppressions);
}
RadButtonGroup[] buttonGroups = rootContainer.getButtonGroups();
if (buttonGroups.length > 0) {
elements.add(buttonGroups);
}
return elements.toArray();
} else if (element instanceof ComponentPtr) {
final ComponentPtr ptr = (ComponentPtr) element;
// pointer must be valid
LOG.assertTrue(ptr.isValid());
final RadComponent component = ptr.getComponent();
if (component instanceof RadContainer) {
final RadContainer container = (RadContainer) component;
final ComponentPtr[] ptrs = new ComponentPtr[container.getComponentCount()];
for (int i = 0; i < ptrs.length; i++) {
ptrs[i] = new ComponentPtr(myEditor, container.getComponent(i));
}
return ptrs;
} else {
return ourEmptyObjectArray;
}
} else if (element instanceof LwInspectionSuppression[]) {
ArrayList<LwInspectionSuppression> result = new ArrayList<>();
for (LwInspectionSuppression suppression : (LwInspectionSuppression[]) element) {
if (suppression.getComponentId() == null || FormEditingUtil.findComponent(myEditor.getRootContainer(), suppression.getComponentId()) != null) {
result.add(suppression);
}
}
return ArrayUtil.toObjectArray(result);
} else if (element instanceof RadButtonGroup[]) {
return (RadButtonGroup[]) element;
} else if (element instanceof LwInspectionSuppression || element instanceof RadButtonGroup) {
return ArrayUtil.EMPTY_OBJECT_ARRAY;
} else {
throw new IllegalArgumentException("unknown element: " + element);
}
}
use of com.intellij.uiDesigner.radComponents.RadButtonGroup in project intellij-community by JetBrains.
the class ComponentTreeStructure method getParentElement.
public Object getParentElement(final Object element) {
if (element instanceof ComponentTreeStructureRoot) {
return null;
} else if (element instanceof LwInspectionSuppression[] || element instanceof RadButtonGroup[]) {
return myRootElement;
} else if (element instanceof LwInspectionSuppression) {
return myEditor.getRootContainer().getInspectionSuppressions();
} else if (element instanceof RadButtonGroup) {
return myEditor.getRootContainer().getButtonGroups();
} else if (element instanceof ComponentPtr) {
// RadContainer is also RadComponent
final ComponentPtr ptr = (ComponentPtr) element;
if (!ptr.isValid())
return myRootElement;
final RadComponent component = ptr.getComponent();
if (component instanceof RadRootContainer) {
return myRootElement;
} else {
return component.getParent() != null ? new ComponentPtr(myEditor, component.getParent(), false) : null;
}
} else {
throw new IllegalArgumentException("unknown element: " + element);
}
}
use of com.intellij.uiDesigner.radComponents.RadButtonGroup in project intellij-community by JetBrains.
the class GroupButtonsAction method groupButtons.
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);
}
use of com.intellij.uiDesigner.radComponents.RadButtonGroup in project intellij-community by JetBrains.
the class SnapshotContext method postProcess.
public void postProcess() {
for (ButtonGroup group : myButtonGroups) {
RadButtonGroup radButtonGroup = myRootContainer.createGroup(myRootContainer.suggestGroupName());
Enumeration<AbstractButton> elements = group.getElements();
while (elements.hasMoreElements()) {
AbstractButton btn = elements.nextElement();
RadComponent c = myImportMap.get(btn);
if (c != null) {
radButtonGroup.add(c);
}
}
}
for (ComponentProperty prop : myComponentProperties) {
RadComponent radOwner = myImportMap.get(prop.owner);
RadComponent radValue = myImportMap.get(prop.value);
if (radOwner != null && radValue != null) {
final IntrospectedProperty property = radOwner.getPalette().getIntrospectedProperty(radOwner, prop.name);
assert property != null;
//noinspection unchecked
IntroComponentProperty icp = (IntroComponentProperty) property;
try {
icp.setValue(radOwner, radValue.getId());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
}
use of com.intellij.uiDesigner.radComponents.RadButtonGroup in project intellij-community by JetBrains.
the class PassiveDecorationLayer method paintPassiveDecoration.
/**
* Paints all necessary decoration for the specified <code>component</code>
*/
protected final void paintPassiveDecoration(final RadComponent component, final Graphics g) {
// Paint component bounds and grid markers
Painter.paintComponentDecoration(myEditor, component, g);
final Set<RadButtonGroup> paintedGroups = new HashSet<>();
final RadRootContainer rootContainer = myEditor.getRootContainer();
final ComponentTree componentTree = DesignerToolWindowManager.getInstance(myEditor).getComponentTree();
final Collection<RadButtonGroup> selectedGroups = componentTree != null ? componentTree.getSelectedElements(RadButtonGroup.class) : Collections.<RadButtonGroup>emptyList();
// Paint selection and dragger
FormEditingUtil.iterate(component, new FormEditingUtil.ComponentVisitor<RadComponent>() {
public boolean visit(final RadComponent component) {
final Point point = SwingUtilities.convertPoint(component.getDelegee(), 0, 0, rootContainer.getDelegee());
RadButtonGroup group = (RadButtonGroup) FormEditingUtil.findGroupForComponent(rootContainer, component);
if (group != null && !paintedGroups.contains(group) && (component.isSelected() || selectedGroups.contains(group))) {
paintedGroups.add(group);
Painter.paintButtonGroupLines(rootContainer, group, g);
}
g.translate(point.x, point.y);
try {
if (myEditor.isShowComponentTags() && FormEditingUtil.isComponentSwitchedInView(component)) {
Painter.paintComponentTag(component, g);
}
Painter.paintSelectionDecoration(component, g, myEditor.getGlassLayer().isFocusOwner());
// Over selection we have to paint dragger
if (component.hasDragger()) {
final Icon icon = getDragIcon();
icon.paintIcon(PassiveDecorationLayer.this, g, -icon.getIconWidth(), -icon.getIconHeight());
}
} finally {
g.translate(-point.x, -point.y);
}
return true;
}
});
}
Aggregations