use of com.intellij.uiDesigner.radComponents.RadComponent in project intellij-community by JetBrains.
the class AbstractGuiEditorAction method actionPerformed.
public final void actionPerformed(final AnActionEvent e) {
final GuiEditor editor = FormEditingUtil.getEditorFromContext(e.getDataContext());
if (editor != null) {
final ArrayList<RadComponent> selection = FormEditingUtil.getSelectedComponents(editor);
if (myModifying) {
if (!editor.ensureEditable())
return;
}
InplaceEditingLayer editingLayer = editor.getInplaceEditingLayer();
if (editingLayer.isEditing()) {
editingLayer.finishInplaceEditing();
}
Runnable runnable = () -> {
actionPerformed(editor, selection, e);
if (myModifying) {
editor.refreshAndSave(true);
}
};
if (getCommandName() != null) {
CommandProcessor.getInstance().executeCommand(editor.getProject(), runnable, getCommandName(), null);
} else {
runnable.run();
}
}
}
use of com.intellij.uiDesigner.radComponents.RadComponent in project intellij-community by JetBrains.
the class AbstractMoveSelectionAction method actionPerformed.
public final void actionPerformed(final AnActionEvent e) {
final ArrayList<RadComponent> selectedComponents = FormEditingUtil.getSelectedComponents(myEditor);
final JComponent rootContainerDelegee = myEditor.getRootContainer().getDelegee();
if (selectedComponents.size() == 0) {
moveToFirstComponent(rootContainerDelegee);
return;
}
RadComponent selectedComponent = myEditor.getSelectionLead();
if (selectedComponent == null || !selectedComponents.contains(selectedComponent)) {
selectedComponent = selectedComponents.get(0);
}
if (moveSelectionByGrid(selectedComponent) || myMoveToLast) {
return;
}
// 1. We need to get coordinates of all editor's component in the same
// coordinate system. For example, in the RadRootContainer rootContainerDelegee's coordinate system.
final ArrayList<RadComponent> components = new ArrayList<>();
final ArrayList<Point> points = new ArrayList<>();
final RadComponent selectedComponent1 = selectedComponent;
FormEditingUtil.iterate(myEditor.getRootContainer(), new FormEditingUtil.ComponentVisitor<RadComponent>() {
public boolean visit(final RadComponent component) {
if (component instanceof RadAtomicComponent) {
if (selectedComponent1.equals(component)) {
return true;
}
if (!FormEditingUtil.isComponentSwitchedInView(component)) {
return true;
}
components.add(component);
final JComponent _delegee = component.getDelegee();
final Point p = SwingUtilities.convertPoint(_delegee, new Point(0, 0), rootContainerDelegee);
p.x += _delegee.getWidth() / 2;
p.y += _delegee.getHeight() / 2;
points.add(p);
}
return true;
}
});
if (components.size() == 0) {
return;
}
// 2.
final Point source = SwingUtilities.convertPoint(selectedComponent.getDelegee(), new Point(0, 0), rootContainerDelegee);
source.x += selectedComponent.getDelegee().getWidth() / 2;
source.y += selectedComponent.getDelegee().getHeight() / 2;
int min = Integer.MAX_VALUE;
int nextSelectedIndex = -1;
for (int i = points.size() - 1; i >= 0; i--) {
final int distance = calcDistance(source, points.get(i));
if (distance < min) {
min = distance;
nextSelectedIndex = i;
}
}
if (min == Integer.MAX_VALUE) {
return;
}
LOG.assertTrue(nextSelectedIndex != -1);
final RadComponent component = components.get(nextSelectedIndex);
selectOrExtend(component);
}
use of com.intellij.uiDesigner.radComponents.RadComponent in project intellij-community by JetBrains.
the class AddTabAction method actionPerformed.
protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
RadTabbedPane tabbedPane = (RadTabbedPane) selection.get(0);
Palette palette = Palette.getInstance(editor.getProject());
final RadComponent radComponent = InsertComponentProcessor.createPanelComponent(editor);
final ComponentDropLocation dropLocation = tabbedPane.getDropLocation(null);
dropLocation.processDrop(editor, new RadComponent[] { radComponent }, null, new ComponentItemDragObject(palette.getPanelItem()));
}
use of com.intellij.uiDesigner.radComponents.RadComponent in project intellij-community by JetBrains.
the class SelectionState method getSelection.
public static ComponentPtr[] getSelection(final GuiEditor editor) {
final ArrayList<RadComponent> selection = FormEditingUtil.getAllSelectedComponents(editor);
final ComponentPtr[] ptrs = new ComponentPtr[selection.size()];
for (int i = selection.size() - 1; i >= 0; i--) {
ptrs[i] = new ComponentPtr(editor, selection.get(i));
}
return ptrs;
}
use of com.intellij.uiDesigner.radComponents.RadComponent 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);
}
}
}
}
Aggregations