mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ViewAnimator display child over selection
This commit is contained in:
+66
-4
@@ -22,14 +22,12 @@ import com.intellij.android.designer.actions.ProfileAction;
|
||||
import com.intellij.android.designer.componentTree.AndroidTreeDecorator;
|
||||
import com.intellij.android.designer.model.ModelParser;
|
||||
import com.intellij.android.designer.model.PropertyParser;
|
||||
import com.intellij.android.designer.model.RadViewAnimatorLayout;
|
||||
import com.intellij.android.designer.model.RadViewComponent;
|
||||
import com.intellij.android.designer.profile.ProfileManager;
|
||||
import com.intellij.designer.DesignerToolWindowManager;
|
||||
import com.intellij.designer.componentTree.TreeComponentDecorator;
|
||||
import com.intellij.designer.designSurface.ComponentDecorator;
|
||||
import com.intellij.designer.designSurface.DesignerEditorPanel;
|
||||
import com.intellij.designer.designSurface.EditOperation;
|
||||
import com.intellij.designer.designSurface.OperationContext;
|
||||
import com.intellij.designer.designSurface.*;
|
||||
import com.intellij.designer.designSurface.selection.NonResizeSelectionDecorator;
|
||||
import com.intellij.designer.designSurface.tools.ComponentCreationFactory;
|
||||
import com.intellij.designer.designSurface.tools.ComponentPasteFactory;
|
||||
@@ -57,6 +55,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -106,6 +105,69 @@ public final class AndroidDesignerEditorPanel extends DesignerEditorPanel {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTreeArea(EditableArea area) {
|
||||
area.addSelectionListener(new ComponentSelectionListener() {
|
||||
@Override
|
||||
public void selectionChanged(EditableArea area) {
|
||||
List<RadComponent> selection = area.getSelection();
|
||||
if (selection.size() == 1) {
|
||||
final RadComponent component = selection.get(0);
|
||||
final RadComponent parent = component.getParent();
|
||||
if (parent instanceof RadViewComponent && parent.getLayout() instanceof RadViewAnimatorLayout) {
|
||||
ApplicationManager.getApplication().invokeLater(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
int index = parent.getChildren().indexOf(component);
|
||||
Object parentView =
|
||||
((RadViewComponent)parent).getViewInfo().getViewObject();
|
||||
Method method =
|
||||
parentView.getClass().getMethod("setDisplayedChild", int.class);
|
||||
method.invoke(parentView, index);
|
||||
|
||||
Result result = mySession.render();
|
||||
|
||||
if (!result.isSuccess()) {
|
||||
System.out.println(
|
||||
"No re render session: " +
|
||||
result.getErrorMessage() +
|
||||
" : " +
|
||||
result.getStatus() +
|
||||
" : " +
|
||||
result.getData() +
|
||||
" : " +
|
||||
result.getException());
|
||||
}
|
||||
else {
|
||||
RadViewComponent rootComponent = (RadViewComponent)myRootComponent;
|
||||
RootView rootView = (RootView)rootComponent.getNativeComponent();
|
||||
rootView.setImage(mySession.getImage());
|
||||
ModelParser.updateRootComponent(rootComponent, mySession, rootView);
|
||||
|
||||
myLayeredPane.repaint();
|
||||
|
||||
DesignerToolWindowManager.getInstance(getProject()).refresh();
|
||||
}
|
||||
}
|
||||
catch (Throwable e) {
|
||||
showError("reRender error: ", e);
|
||||
}
|
||||
}
|
||||
}, new Condition() {
|
||||
@Override
|
||||
public boolean value(Object o) {
|
||||
return mySession == null;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void reparseFile() {
|
||||
try {
|
||||
myToolProvider.loadDefaultTool();
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ public class DropToOperation implements EditOperation {
|
||||
|
||||
@Override
|
||||
public void execute() throws Exception {
|
||||
if (myContext.isAdd()) {
|
||||
if (myContext.isAdd() || myContext.isMove()) {
|
||||
for (RadComponent component : myComponents) {
|
||||
ModelParser.moveComponent(myContainer, (RadViewComponent)component, null);
|
||||
}
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ public class TreeDropToOperation extends TreeEditOperation {
|
||||
RadViewComponent host = (RadViewComponent)myHost;
|
||||
RadViewComponent before = (RadViewComponent)insertBefore;
|
||||
|
||||
if (myContext.isAdd()) {
|
||||
if (myContext.isAdd() || myContext.isMove()) {
|
||||
for (RadComponent component : myComponents) {
|
||||
ModelParser.moveComponent(host, (RadViewComponent)component, before);
|
||||
}
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ import com.intellij.designer.designSurface.OperationContext;
|
||||
*/
|
||||
public class RadViewAnimatorLayout extends RadViewLayout {
|
||||
public EditOperation processChildOperation(OperationContext context) {
|
||||
if ((context.isCreate() || context.isPaste() || context.isAdd()) && checkChildOperation(context)) {
|
||||
if ((context.isCreate() || context.isPaste() || context.isAdd() || context.isMove()) && checkChildOperation(context)) {
|
||||
if (context.isTree()) {
|
||||
return new TreeDropToOperation(myContainer, context);
|
||||
}
|
||||
|
||||
+1
-1
@@ -23,6 +23,6 @@ import com.intellij.designer.designSurface.OperationContext;
|
||||
public class RadViewSwitcherLayout extends RadViewAnimatorLayout {
|
||||
@Override
|
||||
protected boolean checkChildOperation(OperationContext context) {
|
||||
return myContainer.getChildren().size() < 2;
|
||||
return context.isMove() || myContainer.getChildren().size() < 2;
|
||||
}
|
||||
}
|
||||
+2
@@ -39,6 +39,8 @@ public final class ComponentTreeBuilder extends AbstractTreeBuilder implements C
|
||||
myTreeArea = new TreeEditableArea(tree, this);
|
||||
myGlassLayer = new TreeGlassLayer(tree, designer.getToolProvider(), myTreeArea);
|
||||
|
||||
designer.updateTreeArea(myTreeArea);
|
||||
|
||||
// TODO: restore expanded state
|
||||
select(mySurfaceArea.getSelection().toArray(), null);
|
||||
|
||||
|
||||
+3
@@ -315,6 +315,9 @@ public abstract class DesignerEditorPanel extends JPanel implements DataProvider
|
||||
return treeArea == null ? mySurfaceArea : treeArea;
|
||||
}
|
||||
|
||||
public void updateTreeArea(EditableArea area) {
|
||||
}
|
||||
|
||||
public ToolProvider getToolProvider() {
|
||||
return myToolProvider;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user