diff --git a/plugins/ui-designer-core/src/com/intellij/designer/DesignerEditor.java b/plugins/ui-designer-core/src/com/intellij/designer/DesignerEditor.java index 4aee4999f707..7c73ebe91a37 100644 --- a/plugins/ui-designer-core/src/com/intellij/designer/DesignerEditor.java +++ b/plugins/ui-designer-core/src/com/intellij/designer/DesignerEditor.java @@ -37,7 +37,7 @@ import java.beans.PropertyChangeListener; * @author Alexander Lobas */ public abstract class DesignerEditor extends UserDataHolderBase implements FileEditor { - private final DesignerEditorPanel myDesignerPanel; + protected final DesignerEditorPanel myDesignerPanel; public DesignerEditor(Project project, VirtualFile file) { if (file instanceof LightVirtualFile) { diff --git a/plugins/ui-designer-core/src/com/intellij/designer/DesignerEditorState.java b/plugins/ui-designer-core/src/com/intellij/designer/DesignerEditorState.java index 43e5d64d653e..c57525c8903a 100644 --- a/plugins/ui-designer-core/src/com/intellij/designer/DesignerEditorState.java +++ b/plugins/ui-designer-core/src/com/intellij/designer/DesignerEditorState.java @@ -20,21 +20,33 @@ import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.fileEditor.FileEditorState; import com.intellij.openapi.fileEditor.FileEditorStateLevel; import com.intellij.openapi.vfs.VirtualFile; +import org.jdom.Element; +import org.jetbrains.annotations.NotNull; /** * @author Alexander Lobas */ public class DesignerEditorState implements FileEditorState { - private final long myModificationStamp; + private static final String DESIGNER_ZOOM = "ui-designer-zoom"; - public DesignerEditorState(VirtualFile file) { + private final long myModificationStamp; + private final double myZoom; + + public DesignerEditorState(VirtualFile file, double zoom) { Document document = FileDocumentManager.getInstance().getCachedDocument(file); myModificationStamp = document != null ? document.getModificationStamp() : file.getModificationStamp(); + myZoom = zoom; + } + + public double getZoom() { + return myZoom; } @Override public int hashCode() { - return (int)(myModificationStamp ^ (myModificationStamp >>> 32)); + int A = (int)(myModificationStamp ^ (myModificationStamp >>> 32)); + long B = Double.doubleToLongBits(myZoom); + return 31 * A + (int)(B ^ (B >>> 32)); } @Override @@ -43,7 +55,8 @@ public class DesignerEditorState implements FileEditorState { return true; } if (object instanceof DesignerEditorState) { - return myModificationStamp == ((DesignerEditorState)object).myModificationStamp; + DesignerEditorState state = (DesignerEditorState)object; + return myModificationStamp == state.myModificationStamp && myZoom == state.myZoom; } return false; } @@ -52,4 +65,28 @@ public class DesignerEditorState implements FileEditorState { public boolean canBeMergedWith(FileEditorState otherState, FileEditorStateLevel level) { return otherState instanceof DesignerEditorState; } + + /** + * @see com.intellij.openapi.fileEditor.FileEditorProvider#readState(org.jdom.Element, com.intellij.openapi.project.Project, com.intellij.openapi.vfs.VirtualFile) + */ + @NotNull + public static FileEditorState readState(@NotNull Element sourceElement, @NotNull VirtualFile file, double defaultZoom) { + double zoom = defaultZoom; + + try { + zoom = Double.parseDouble(sourceElement.getAttributeValue(DESIGNER_ZOOM)); + } + catch (Throwable e) { + // ignore + } + + return new DesignerEditorState(file, zoom); + } + + /** + * @see com.intellij.openapi.fileEditor.FileEditorProvider#writeState(com.intellij.openapi.fileEditor.FileEditorState, com.intellij.openapi.project.Project, org.jdom.Element) + */ + public static void writeState(@NotNull FileEditorState state, @NotNull Element targetElement) { + targetElement.setAttribute(DESIGNER_ZOOM, Double.toString(((DesignerEditorState)state).getZoom())); + } } \ No newline at end of file diff --git a/plugins/ui-designer-core/src/com/intellij/designer/designSurface/CaptionPanel.java b/plugins/ui-designer-core/src/com/intellij/designer/designSurface/CaptionPanel.java index e0714063bf12..ae4b898bcfd5 100644 --- a/plugins/ui-designer-core/src/com/intellij/designer/designSurface/CaptionPanel.java +++ b/plugins/ui-designer-core/src/com/intellij/designer/designSurface/CaptionPanel.java @@ -149,7 +149,7 @@ public class CaptionPanel extends JBLayeredPane implements DataProvider, DeleteP myDecorationLayer = new DecorationLayer(designer, myArea); add(myDecorationLayer, DesignerEditorPanel.LAYER_DECORATION); - myFeedbackLayer = new FeedbackLayer(); + myFeedbackLayer = new FeedbackLayer(designer); add(myFeedbackLayer, DesignerEditorPanel.LAYER_FEEDBACK); myActionsProvider = new CommonEditActionsProvider(designer) { diff --git a/plugins/ui-designer-core/src/com/intellij/designer/designSurface/DecorationLayer.java b/plugins/ui-designer-core/src/com/intellij/designer/designSurface/DecorationLayer.java index 91c010fba0f9..b10e3e3bd14e 100644 --- a/plugins/ui-designer-core/src/com/intellij/designer/designSurface/DecorationLayer.java +++ b/plugins/ui-designer-core/src/com/intellij/designer/designSurface/DecorationLayer.java @@ -113,4 +113,8 @@ public class DecorationLayer extends JComponent { } return parent.getLayout().getChildSelectionDecorator(component, selection); } + + public double getZoom() { + return myDesigner.getZoom(); + } } \ No newline at end of file diff --git a/plugins/ui-designer-core/src/com/intellij/designer/designSurface/DesignerEditorPanel.java b/plugins/ui-designer-core/src/com/intellij/designer/designSurface/DesignerEditorPanel.java index 2389daa8c299..f75dad3834c4 100644 --- a/plugins/ui-designer-core/src/com/intellij/designer/designSurface/DesignerEditorPanel.java +++ b/plugins/ui-designer-core/src/com/intellij/designer/designSurface/DesignerEditorPanel.java @@ -182,7 +182,7 @@ public abstract class DesignerEditorPanel extends JPanel implements DataProvider myToolProvider = createToolProvider(); - myGlassLayer = new GlassLayer(myToolProvider, mySurfaceArea); + myGlassLayer = createGlassLayer(myToolProvider, mySurfaceArea); myLayeredPane.add(myGlassLayer, LAYER_GLASS); myDecorationLayer = createDecorationLayer(); @@ -260,12 +260,16 @@ public abstract class DesignerEditorPanel extends JPanel implements DataProvider return new DesignerToolProvider(); } + protected GlassLayer createGlassLayer(ToolProvider provider, EditableArea area) { + return new GlassLayer(provider, area); + } + protected DecorationLayer createDecorationLayer() { return new DecorationLayer(this, mySurfaceArea); } protected FeedbackLayer createFeedbackLayer() { - return new FeedbackLayer(); + return new FeedbackLayer(this); } protected InplaceEditingLayer createInplaceEditingLayer() { @@ -743,7 +747,7 @@ public abstract class DesignerEditorPanel extends JPanel implements DataProvider @NotNull public DesignerEditorState createState() { - return new DesignerEditorState(myFile); + return new DesignerEditorState(myFile, getZoom()); } public boolean isEditorValid() { diff --git a/plugins/ui-designer-core/src/com/intellij/designer/designSurface/FeedbackLayer.java b/plugins/ui-designer-core/src/com/intellij/designer/designSurface/FeedbackLayer.java index f7ad094e039f..5938d312a24e 100644 --- a/plugins/ui-designer-core/src/com/intellij/designer/designSurface/FeedbackLayer.java +++ b/plugins/ui-designer-core/src/com/intellij/designer/designSurface/FeedbackLayer.java @@ -21,4 +21,13 @@ import javax.swing.*; * @author Alexander Lobas */ public class FeedbackLayer extends JComponent { + private final DesignerEditorPanel myDesigner; + + public FeedbackLayer(DesignerEditorPanel designer) { + myDesigner = designer; + } + + public double getZoom() { + return myDesigner.getZoom(); + } } \ No newline at end of file diff --git a/plugins/ui-designer-core/src/com/intellij/designer/designSurface/GlassLayer.java b/plugins/ui-designer-core/src/com/intellij/designer/designSurface/GlassLayer.java index a4d1bbf2b898..7559eca011e7 100644 --- a/plugins/ui-designer-core/src/com/intellij/designer/designSurface/GlassLayer.java +++ b/plugins/ui-designer-core/src/com/intellij/designer/designSurface/GlassLayer.java @@ -29,7 +29,7 @@ import java.awt.event.MouseEvent; /** * @author Alexander Lobas */ -public final class GlassLayer extends JComponent implements DataProvider { +public 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; diff --git a/plugins/ui-designer-core/src/com/intellij/designer/designSurface/tools/ToolProvider.java b/plugins/ui-designer-core/src/com/intellij/designer/designSurface/tools/ToolProvider.java index bcbc4f1aebe4..06ac648d8298 100644 --- a/plugins/ui-designer-core/src/com/intellij/designer/designSurface/tools/ToolProvider.java +++ b/plugins/ui-designer-core/src/com/intellij/designer/designSurface/tools/ToolProvider.java @@ -36,7 +36,7 @@ public abstract class ToolProvider implements ZoomProvider { private MouseEvent myEvent; public void processKeyEvent(KeyEvent event, EditableArea area) { - if (myTool != null) { + if (myTool != null) { try { switch (event.getID()) { case KeyEvent.KEY_PRESSED: diff --git a/python/pluginResources/META-INF/plugin.xml b/python/pluginResources/META-INF/plugin.xml index ebd683978f9c..6ec30aa5fdff 100644 --- a/python/pluginResources/META-INF/plugin.xml +++ b/python/pluginResources/META-INF/plugin.xml @@ -4,7 +4,7 @@ PythonCore Python Community Edition - + Smart editing for Python scripts 3.4.Beta.135.@@BUILD_NUMBER@@ com.intellij.modules.java