use of com.intellij.uiDesigner.radComponents.RadContainer in project intellij-community by JetBrains.
the class IntrospectedProperty method appliesTo.
@Override
public boolean appliesTo(final RadComponent component) {
@NonNls String name = getName();
//noinspection SimplifiableIfStatement
if (name.equals(SwingProperties.PREFERRED_SIZE) || name.equals(SwingProperties.MINIMUM_SIZE) || name.equals(SwingProperties.MAXIMUM_SIZE)) {
// our own properties must be used instead
final RadContainer parent = component.getParent();
return parent != null && !(parent.getLayoutManager() instanceof RadGridLayoutManager);
}
// check if property is available in the JDK used by the module containing the component
final PsiManager psiManager = PsiManager.getInstance(component.getProject());
final GlobalSearchScope scope = component.getModule().getModuleWithDependenciesAndLibrariesScope(true);
PsiClass componentClass = JavaPsiFacade.getInstance(psiManager.getProject()).findClass(component.getComponentClassName(), scope);
if (componentClass == null)
return true;
final PsiMethod[] psiMethods = componentClass.findMethodsByName(myReadMethod.getName(), true);
for (PsiMethod method : psiMethods) {
if (!method.hasModifierProperty(PsiModifier.STATIC) && method.getParameterList().getParametersCount() == 0) {
return true;
}
}
return false;
}
use of com.intellij.uiDesigner.radComponents.RadContainer in project intellij-community by JetBrains.
the class ComponentEditor method collectFilteredComponents.
protected RadComponent[] collectFilteredComponents(final RadComponent component) {
final ArrayList<RadComponent> result = new ArrayList<>();
result.add(null);
RadContainer container = component.getParent();
while (container.getParent() != null) {
container = container.getParent();
}
FormEditingUtil.iterate(container, new FormEditingUtil.ComponentVisitor() {
public boolean visit(final IComponent component) {
RadComponent radComponent = (RadComponent) component;
final JComponent delegee = radComponent.getDelegee();
if (!myPropertyType.isInstance(delegee)) {
return true;
}
if (myFilter == null || myFilter.value(radComponent)) {
result.add(radComponent);
}
return true;
}
});
return result.toArray(new RadComponent[result.size()]);
}
use of com.intellij.uiDesigner.radComponents.RadContainer in project intellij-community by JetBrains.
the class LayoutManagerProperty method getValue.
public String getValue(RadContainer component) {
RadContainer container = component;
while (container != null) {
final RadLayoutManager layoutManager = container.getLayoutManager();
if (layoutManager != null) {
return layoutManager.getName();
}
container = container.getParent();
}
return UIFormXmlConstants.LAYOUT_INTELLIJ;
}
use of com.intellij.uiDesigner.radComponents.RadContainer in project intellij-community by JetBrains.
the class DesignDropTargetListener method processDragEnter.
private void processDragEnter(final DraggedComponentList draggedComponentList, final Point location, final int dropAction) {
final List<RadComponent> dragComponents = draggedComponentList.getComponents();
Rectangle allBounds = null;
if (!draggedComponentList.hasDragDelta() || !myUseDragDelta) {
final RadContainer[] originalParents = draggedComponentList.getOriginalParents();
final Rectangle[] originalBounds = draggedComponentList.getOriginalBounds();
for (int i = 0; i < originalParents.length; i++) {
Rectangle rc = SwingUtilities.convertRectangle(originalParents[i].getDelegee(), originalBounds[i], myEditor.getDragLayer());
if (allBounds == null) {
allBounds = rc;
} else {
allBounds = allBounds.union(rc);
}
}
}
// Place selected components to the drag layer.
myDraggedComponentsCopy = CutCopyPasteSupport.copyComponents(myEditor, dragComponents);
for (int i = 0; i < dragComponents.size(); i++) {
myDraggedComponentsCopy.get(i).setSelected(true);
final JComponent delegee = myDraggedComponentsCopy.get(i).getDelegee();
final Point point = SwingUtilities.convertPoint(draggedComponentList.getOriginalParents()[i].getDelegee(), delegee.getLocation(), myEditor.getDragLayer());
if (draggedComponentList.hasDragDelta() && myUseDragDelta) {
delegee.setLocation((int) point.getX() + draggedComponentList.getDragDeltaX(), (int) point.getY() + draggedComponentList.getDragDeltaY());
} else {
assert allBounds != null;
delegee.setLocation((int) (point.getX() - allBounds.getX() + location.getX()), (int) (point.getY() - allBounds.getY() + location.getY()));
}
//myEditor.getDragLayer().add(delegee);
}
for (final RadComponent c : dragComponents) {
if (dropAction != DnDConstants.ACTION_COPY) {
c.setDragBorder(true);
}
c.setSelected(false);
}
}
use of com.intellij.uiDesigner.radComponents.RadContainer in project intellij-community by JetBrains.
the class MorphAction method morphComponent.
private static boolean morphComponent(final GuiEditor editor, final RadComponent oldComponent, ComponentItem targetItem) {
targetItem = InsertComponentProcessor.replaceAnyComponentItem(editor, targetItem, "Morph to Non-Palette Component");
if (targetItem == null) {
return false;
}
final RadComponent newComponent = InsertComponentProcessor.createInsertedComponent(editor, targetItem);
if (newComponent == null)
return false;
newComponent.setBinding(oldComponent.getBinding());
newComponent.setCustomLayoutConstraints(oldComponent.getCustomLayoutConstraints());
newComponent.getConstraints().restore(oldComponent.getConstraints());
updateBoundFieldType(editor, oldComponent, targetItem);
final IProperty[] oldProperties = oldComponent.getModifiedProperties();
final Palette palette = Palette.getInstance(editor.getProject());
for (IProperty prop : oldProperties) {
IntrospectedProperty newProp = palette.getIntrospectedProperty(newComponent, prop.getName());
if (newProp == null || !prop.getClass().equals(newProp.getClass()))
continue;
Object oldValue = prop.getPropertyValue(oldComponent);
try {
//noinspection unchecked
newProp.setValue(newComponent, oldValue);
} catch (Exception e) {
// ignore
}
}
retargetComponentProperties(editor, oldComponent, newComponent);
final RadContainer parent = oldComponent.getParent();
int index = parent.indexOfComponent(oldComponent);
parent.removeComponent(oldComponent);
parent.addComponent(newComponent, index);
newComponent.setSelected(true);
if (oldComponent.isDefaultBinding()) {
final String text = FormInspectionUtil.getText(newComponent.getModule(), newComponent);
if (text != null) {
String binding = BindingProperty.suggestBindingFromText(newComponent, text);
if (binding != null) {
new BindingProperty(newComponent.getProject()).setValueEx(newComponent, binding);
}
}
newComponent.setDefaultBinding(true);
}
return true;
}
Aggregations