mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-86605
This commit is contained in:
+11
-10
@@ -53,8 +53,9 @@ public class CommonEditActionsProvider implements DeleteProvider, CopyProvider,
|
||||
myDesigner = designer;
|
||||
}
|
||||
|
||||
protected EditableArea getArea() {
|
||||
return myDesigner.getActionsArea();
|
||||
protected EditableArea getArea(DataContext dataContext) {
|
||||
EditableArea area = EditableArea.DATA_KEY.getData(dataContext);
|
||||
return area == null ? myDesigner.getSurfaceArea() : area;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -68,7 +69,7 @@ public class CommonEditActionsProvider implements DeleteProvider, CopyProvider,
|
||||
if (myDesigner.getInplaceEditingLayer().isEditing()) {
|
||||
return false;
|
||||
}
|
||||
List<RadComponent> selection = getArea().getSelection();
|
||||
List<RadComponent> selection = getArea(dataContext).getSelection();
|
||||
if (selection.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
@@ -81,11 +82,11 @@ public class CommonEditActionsProvider implements DeleteProvider, CopyProvider,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteElement(@NotNull DataContext dataContext) {
|
||||
public void deleteElement(final @NotNull DataContext dataContext) {
|
||||
myDesigner.getToolProvider().execute(new ThrowableRunnable<Exception>() {
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
EditableArea area = getArea();
|
||||
EditableArea area = getArea(dataContext);
|
||||
List<RadComponent> selection = area.getSelection();
|
||||
|
||||
if (selection.isEmpty()) {
|
||||
@@ -145,20 +146,20 @@ public class CommonEditActionsProvider implements DeleteProvider, CopyProvider,
|
||||
|
||||
@Override
|
||||
public boolean isCopyEnabled(@NotNull DataContext dataContext) {
|
||||
return !myDesigner.getInplaceEditingLayer().isEditing() && !getArea().getSelection().isEmpty();
|
||||
return !myDesigner.getInplaceEditingLayer().isEditing() && !getArea(dataContext).getSelection().isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performCopy(@NotNull DataContext dataContext) {
|
||||
doCopy();
|
||||
doCopy(dataContext);
|
||||
}
|
||||
|
||||
private boolean doCopy() {
|
||||
private boolean doCopy(DataContext dataContext) {
|
||||
try {
|
||||
Element root = new Element("designer");
|
||||
root.setAttribute("target", myDesigner.getPlatformTarget());
|
||||
|
||||
List<RadComponent> components = RadComponent.getPureSelection(getArea().getSelection());
|
||||
List<RadComponent> components = RadComponent.getPureSelection(getArea(dataContext).getSelection());
|
||||
for (RadComponent component : components) {
|
||||
component.copyTo(root);
|
||||
}
|
||||
@@ -243,7 +244,7 @@ public class CommonEditActionsProvider implements DeleteProvider, CopyProvider,
|
||||
|
||||
@Override
|
||||
public void performCut(@NotNull DataContext dataContext) {
|
||||
if (doCopy()) {
|
||||
if (doCopy(dataContext)) {
|
||||
deleteElement(dataContext);
|
||||
}
|
||||
}
|
||||
|
||||
+14
-1
@@ -18,6 +18,7 @@ package com.intellij.designer.componentTree;
|
||||
import com.intellij.designer.actions.DesignerActionPanel;
|
||||
import com.intellij.designer.actions.StartInplaceEditing;
|
||||
import com.intellij.designer.designSurface.DesignerEditorPanel;
|
||||
import com.intellij.designer.designSurface.EditableArea;
|
||||
import com.intellij.designer.designSurface.FeedbackTreeLayer;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.openapi.actionSystem.DataProvider;
|
||||
@@ -40,6 +41,7 @@ public final class ComponentTree extends Tree implements DataProvider {
|
||||
private final StartInplaceEditing myInplaceEditingAction;
|
||||
private TreeComponentDecorator myDecorator;
|
||||
private DesignerActionPanel myActionPanel;
|
||||
private EditableArea myArea;
|
||||
private RadComponent myMarkComponent;
|
||||
private int myMarkFeedback;
|
||||
|
||||
@@ -75,9 +77,14 @@ public final class ComponentTree extends Tree implements DataProvider {
|
||||
myActionPanel = designer.getActionPanel();
|
||||
}
|
||||
myMarkComponent = null;
|
||||
myArea = null;
|
||||
myInplaceEditingAction.setDesignerPanel(designer);
|
||||
}
|
||||
|
||||
public void setArea(@Nullable EditableArea area) {
|
||||
myArea = area;
|
||||
}
|
||||
|
||||
public void mark(RadComponent component, int feedback) {
|
||||
myMarkComponent = component;
|
||||
myMarkFeedback = feedback;
|
||||
@@ -86,7 +93,13 @@ public final class ComponentTree extends Tree implements DataProvider {
|
||||
|
||||
@Override
|
||||
public Object getData(@NonNls String dataId) {
|
||||
return myActionPanel == null ? null : myActionPanel.getData(dataId);
|
||||
if (EditableArea.DATA_KEY.is(dataId)) {
|
||||
return myArea;
|
||||
}
|
||||
if (myActionPanel != null) {
|
||||
return myActionPanel.getData(dataId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+2
@@ -49,6 +49,8 @@ public final class ComponentTreeBuilder extends AbstractTreeBuilder implements C
|
||||
myGlassLayer = new TreeGlassLayer(tree, designer.getToolProvider(), myTreeArea);
|
||||
myExpandStateHandler = new ExpandStateHandler(tree, designer, this);
|
||||
|
||||
tree.setArea(myTreeArea);
|
||||
|
||||
new TreeDropListener(tree, myTreeArea, designer.getToolProvider());
|
||||
|
||||
selectFromSurface();
|
||||
|
||||
+1
-1
@@ -150,7 +150,7 @@ public class CaptionPanel extends JLayeredPane implements DataProvider, DeletePr
|
||||
|
||||
myActionsProvider = new CommonEditActionsProvider(designer) {
|
||||
@Override
|
||||
protected EditableArea getArea() {
|
||||
protected EditableArea getArea(DataContext dataContext) {
|
||||
return myArea;
|
||||
}
|
||||
};
|
||||
|
||||
+3
@@ -18,6 +18,7 @@ package com.intellij.designer.designSurface;
|
||||
import com.intellij.designer.designSurface.tools.InputTool;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.openapi.actionSystem.ActionGroup;
|
||||
import com.intellij.openapi.actionSystem.DataKey;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -29,6 +30,8 @@ import java.util.List;
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public interface EditableArea {
|
||||
DataKey<EditableArea> DATA_KEY = DataKey.create("EditableArea");
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Selection
|
||||
|
||||
+2
-8
@@ -17,7 +17,6 @@ package com.intellij.designer.designSurface;
|
||||
|
||||
import com.intellij.designer.designSurface.tools.ToolProvider;
|
||||
import com.intellij.openapi.actionSystem.DataProvider;
|
||||
import com.intellij.ui.popup.PopupOwner;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -28,7 +27,7 @@ import java.awt.event.MouseEvent;
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public final class GlassLayer extends JComponent implements PopupOwner, DataProvider {
|
||||
public final class GlassLayer extends JComponent implements DataProvider {
|
||||
private static final long EVENT_FLAGS = AWTEvent.KEY_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK;
|
||||
|
||||
private final ToolProvider myToolProvider;
|
||||
@@ -74,13 +73,8 @@ public final class GlassLayer extends JComponent implements PopupOwner, DataProv
|
||||
myToolProvider.processMouseEvent(event, myArea);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getBestPopupPosition() {
|
||||
return null; // TODO: Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getData(@NonNls String dataId) {
|
||||
return null; // TODO: Auto-generated method stub
|
||||
return EditableArea.DATA_KEY.is(dataId) ? myArea : null;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -89,7 +89,7 @@ public class SelectionTool extends InputTool {
|
||||
|
||||
@Override
|
||||
protected void handleDoubleClick(int button) {
|
||||
if (button == MouseEvent.BUTTON1 && myToolProvider != null) {
|
||||
if (button == MouseEvent.BUTTON1 && myToolProvider != null && !myArea.isTree()) {
|
||||
myToolProvider.startInplaceEditing(null);
|
||||
}
|
||||
}
|
||||
@@ -199,7 +199,7 @@ public class SelectionTool extends InputTool {
|
||||
if (myTracker != null) {
|
||||
myTracker.keyTyped(event, area);
|
||||
}
|
||||
else if (myToolProvider != null &&
|
||||
else if (myToolProvider != null && !area.isTree() &&
|
||||
Character.isLetterOrDigit(event.getKeyChar()) &&
|
||||
(event.getModifiers() & (InputEvent.ALT_MASK | InputEvent.CTRL_MASK)) == 0) {
|
||||
myToolProvider.startInplaceEditing(new InplaceContext(event.getKeyChar()));
|
||||
|
||||
@@ -111,6 +111,8 @@ public abstract class RadComponent {
|
||||
if (myLayout != null) {
|
||||
myLayout.removeComponentFromContainer(component);
|
||||
}
|
||||
|
||||
component.setParent(null);
|
||||
}
|
||||
|
||||
public void removeFromParent() {
|
||||
|
||||
Reference in New Issue
Block a user