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 MorphAction method actionPerformed.
protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
Processor<ComponentItem> processor = selectedValue -> {
Runnable runnable = () -> {
for (RadComponent c : selection) {
if (!morphComponent(editor, c, selectedValue))
break;
}
editor.refreshAndSave(true);
};
CommandProcessor.getInstance().executeCommand(editor.getProject(), runnable, UIDesignerBundle.message("morph.component.command"), null);
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
IdeFocusManager.getGlobalInstance().requestFocus(editor.getGlassLayer(), true);
});
return true;
};
PaletteListPopupStep step = new PaletteListPopupStep(editor, myLastMorphComponent, processor, UIDesignerBundle.message("morph.component.title"));
step.hideNonAtomic();
if (selection.size() == 1) {
step.hideComponentClass(selection.get(0).getComponentClassName());
}
final ListPopup listPopup = JBPopupFactory.getInstance().createListPopup(step);
FormEditingUtil.showPopupUnderComponent(listPopup, selection.get(0));
}
use of com.intellij.uiDesigner.radComponents.RadComponent in project intellij-community by JetBrains.
the class CreateListenerAction method canCreateListener.
private static boolean canCreateListener(final ArrayList<RadComponent> selection) {
if (selection.size() == 0)
return false;
final RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(selection.get(0));
if (root.getClassToBind() == null)
return false;
String componentClass = selection.get(0).getComponentClassName();
for (RadComponent c : selection) {
if (!c.getComponentClassName().equals(componentClass) || c.getBinding() == null)
return false;
if (BindingProperty.findBoundField(root, c.getBinding()) == null)
return false;
}
return true;
}
use of com.intellij.uiDesigner.radComponents.RadComponent in project intellij-community by JetBrains.
the class DuplicateComponentsAction method actionPerformed.
protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
FormEditingUtil.remapToActionTargets(selection);
RadContainer parent = FormEditingUtil.getSelectionParent(selection);
assert parent != null;
List<RadComponent> duplicates = new ArrayList<>();
Map<RadComponent, RadComponent> duplicateMap = new HashMap<>();
TIntHashSet insertedRows = new TIntHashSet();
boolean incrementRow = true;
if (selection.size() > 1 && canDuplicate(selection, false) && FormEditingUtil.getSelectionBounds(selection).width == 1) {
incrementRow = false;
}
for (RadComponent c : selection) {
final int row = c.getConstraints().getCell(incrementRow);
int rowSpan = c.getConstraints().getSpan(incrementRow);
int insertIndex = parent.indexOfComponent(c);
if (parent.getLayoutManager().isGrid()) {
if (!insertedRows.contains(row) && !isSpaceBelowEmpty(c, incrementRow)) {
insertedRows.add(row);
parent.getGridLayoutManager().copyGridCells(parent, parent, incrementRow, row, rowSpan, row + rowSpan);
}
}
List<RadComponent> copyList = CutCopyPasteSupport.copyComponents(editor, Collections.singletonList(c));
if (copyList != null) {
RadComponent copy = copyList.get(0);
if (parent.getLayoutManager().isGrid()) {
copy.getConstraints().setCell(incrementRow, row + rowSpan + parent.getGridLayoutManager().getGapCellCount());
copy.getConstraints().setSpan(incrementRow, rowSpan);
}
parent.addComponent(copy, insertIndex + 1);
fillDuplicateMap(duplicateMap, c, copy);
duplicates.add(copy);
}
}
adjustDuplicates(duplicateMap);
FormEditingUtil.selectComponents(editor, duplicates);
}
Aggregations