use of com.intellij.designer.model.RadComponent in project intellij-community by JetBrains.
the class AbstractCreationTool method updateTargetUnderMouse.
private void updateTargetUnderMouse() {
ContainerTargetFilter filter = new ContainerTargetFilter();
RadComponent target = myArea.findTarget(myCurrentScreenX, myCurrentScreenY, filter);
setTarget(target, filter);
if (target != null) {
updateTarget();
}
}
use of com.intellij.designer.model.RadComponent in project intellij-community by JetBrains.
the class TreeDropListener method updateTargetUnderMouse.
private void updateTargetUnderMouse() {
if (myContext.getComponents().isEmpty()) {
return;
}
final List<RadComponent> excludeComponents = new ArrayList<>(myContext.getComponents());
if (!myContext.isCreate()) {
for (RadComponent component : myContext.getComponents()) {
component.accept(new RadComponentVisitor() {
@Override
public void endVisit(RadComponent component) {
excludeComponents.add(component);
}
}, true);
}
}
final EditOperation[] operation = new EditOperation[1];
ComponentTargetFilter filter = new ComponentTargetFilter() {
@Override
public boolean preFilter(RadComponent component) {
return myContext.isCreate() || !excludeComponents.contains(component);
}
@Override
public boolean resultFilter(RadComponent target) {
if (!myContext.isCreate()) {
if (myContext.getComponents().get(0).getParent() == target) {
myContext.setType(OperationContext.MOVE);
} else {
myContext.setType(OperationContext.ADD);
}
}
if (myTarget == target) {
return true;
}
RadLayout layout = target.getLayout();
if (layout != null) {
operation[0] = layout.processChildOperation(myContext);
}
return operation[0] != null;
}
};
Point location = getLocation();
RadComponent target = myArea.findTarget(location.x, location.y, filter);
if (target != myTarget) {
if (myTargetOperation != null) {
eraseFeedback();
}
myTarget = target;
myTargetOperation = operation[0];
}
if (target == null) {
if (!myContext.isCreate()) {
myContext.setType(null);
}
} else {
myTargetOperation.setComponents(myContext.getComponents());
}
}
use of com.intellij.designer.model.RadComponent in project intellij-community by JetBrains.
the class TreeDropListener method updateContext.
private void updateContext() {
myContext.setLocation(getLocation());
if (myContext.getComponents() == null) {
if (!ArrayUtil.contains(SimpleTransferable.getData(myEvent.getTransferable(), Class.class), myDragTargets)) {
myContext.setComponents(Collections.<RadComponent>emptyList());
return;
}
if (myToolProvider.getActiveTool() instanceof CreationTool) {
myContext.setType(OperationContext.CREATE);
CreationTool tool = (CreationTool) myToolProvider.getActiveTool();
try {
myContext.setComponents(Collections.singletonList(tool.getFactory().create()));
} catch (Throwable e) {
myContext.setComponents(Collections.<RadComponent>emptyList());
myToolProvider.loadDefaultTool();
}
return;
}
List<RadComponent> components = RadComponent.getPureSelection(myArea.getSelection());
RadComponent parent = null;
for (RadComponent component : components) {
if (parent == null) {
parent = component.getParent();
} else if (parent != component.getParent()) {
components = Collections.emptyList();
break;
}
}
myContext.setComponents(components);
myContext.resetMoveAddEnabled();
for (RadComponent component : components) {
component.processDropOperation(myContext);
}
}
}
Aggregations