mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Until build moved forward.
This commit is contained in:
committed by
Dmitry Trofimov
parent
0f15b6d28a
commit
ce4bafa64b
@@ -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) {
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
@@ -113,4 +113,8 @@ public class DecorationLayer extends JComponent {
|
||||
}
|
||||
return parent.getLayout().getChildSelectionDecorator(component, selection);
|
||||
}
|
||||
|
||||
public double getZoom() {
|
||||
return myDesigner.getZoom();
|
||||
}
|
||||
}
|
||||
+7
-3
@@ -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() {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
+1
-1
@@ -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:
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<id>PythonCore</id>
|
||||
<name>Python Community Edition</name>
|
||||
<idea-version since-build="135.406" until-build="136.*"/>
|
||||
<idea-version since-build="135.406" until-build="138.*"/>
|
||||
<description>Smart editing for Python scripts</description>
|
||||
<version>3.4.Beta.135.@@BUILD_NUMBER@@</version>
|
||||
<depends>com.intellij.modules.java</depends>
|
||||
|
||||
Reference in New Issue
Block a user