use of com.intellij.designer.model.RadComponent in project intellij-community by JetBrains.
the class AbstractFlowBaseOperation method getSideChildTarget.
private RadComponent getSideChildTarget() {
Point location = myContext.getLocation();
List<RadComponent> children = getChildren();
RadComponent lastChild = children.get(children.size() - 1);
Rectangle childBounds = lastChild.getBounds(myContext.getArea().getFeedbackLayer());
if (myHorizontal) {
if (location.x >= childBounds.getMaxX()) {
return lastChild;
}
return children.get(0);
}
if (location.y >= childBounds.getMaxY()) {
return lastChild;
}
return children.get(0);
}
use of com.intellij.designer.model.RadComponent in project intellij-community by JetBrains.
the class CommonEditActionsProvider method handleDeletion.
private static void handleDeletion(@NotNull List<RadComponent> components) throws Exception {
// Segment the deleted components into lists of siblings
Map<RadComponent, List<RadComponent>> siblingLists = RadComponent.groupSiblings(components);
// Notify parent components about children getting deleted
for (Map.Entry<RadComponent, List<RadComponent>> entry : siblingLists.entrySet()) {
RadComponent parent = entry.getKey();
List<RadComponent> children = entry.getValue();
boolean finished = false;
if (parent instanceof IComponentDeletionParticipant) {
IComponentDeletionParticipant handler = (IComponentDeletionParticipant) parent;
finished = handler.deleteChildren(parent, children);
} else if (parent != null && /*check root*/
parent.getLayout() instanceof IComponentDeletionParticipant) {
IComponentDeletionParticipant handler = (IComponentDeletionParticipant) parent.getLayout();
finished = handler.deleteChildren(parent, children);
}
if (!finished) {
deleteComponents(children);
}
}
}
use of com.intellij.designer.model.RadComponent in project intellij-community by JetBrains.
the class CommonEditActionsProvider method doCopy.
private boolean doCopy(DataContext dataContext) {
try {
Element root = new Element("designer");
root.setAttribute("target", myDesigner.getPlatformTarget());
List<RadComponent> components = RadComponent.getPureSelection(getArea(dataContext).getSelection());
RadComponent rootComponent = myDesigner.getRootComponent();
if (rootComponent instanceof IComponentCopyProvider) {
IComponentCopyProvider copyProvider = (IComponentCopyProvider) rootComponent;
copyProvider.copyTo(root, components);
} else {
for (RadComponent component : components) {
component.copyTo(root);
}
}
SerializedComponentData data = new SerializedComponentData(new XMLOutputter().outputString(root));
CopyPasteManager.getInstance().setContents(new SimpleTransferable(data, DATA_FLAVOR));
return true;
} catch (Throwable e) {
myDesigner.showError("Copy error", e);
return false;
}
}
use of com.intellij.designer.model.RadComponent in project intellij-community by JetBrains.
the class CommonEditActionsProvider method getNewSelection.
@Nullable
private static RadComponent getNewSelection(RadComponent component, List<RadComponent> excludes) {
RadComponent parent = component.getParent();
if (parent == null) {
return null;
}
List<RadComponent> children = parent.getChildren();
int size = children.size();
for (int i = children.indexOf(component) + 1; i < size; i++) {
RadComponent next = children.get(i);
if (!excludes.contains(next)) {
return next;
}
}
return parent;
}
use of com.intellij.designer.model.RadComponent in project intellij-community by JetBrains.
the class CommonEditActionsProvider method deleteElement.
@Override
public void deleteElement(@NotNull final DataContext dataContext) {
myDesigner.getToolProvider().execute(() -> {
EditableArea area = getArea(dataContext);
List<RadComponent> selection = area.getSelection();
if (selection.isEmpty()) {
return;
}
myDesigner.getToolProvider().loadDefaultTool();
List<RadComponent> components = RadComponent.getPureSelection(selection);
updateSelectionBeforeDelete(area, components.get(0), selection);
handleDeletion(components);
}, DesignerBundle.message("command.delete.selection"), true);
}
Aggregations