mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
do not overwrite ipython file if cell content is identical
This commit is contained in:
@@ -105,6 +105,7 @@ public class IpnbFilePanel extends JPanel implements Scrollable, DataProvider, D
|
||||
try {
|
||||
IpnbFile file = IpnbParser.parseIpnbFile(myDocument, myVirtualFile);
|
||||
if (file.equals(myIpnbFile)) return;
|
||||
removeAll();
|
||||
myIpnbFile = file;
|
||||
myIpnbPanels.clear();
|
||||
mySelectedCell = null;
|
||||
@@ -348,7 +349,6 @@ public class IpnbFilePanel extends JPanel implements Scrollable, DataProvider, D
|
||||
final IpnbEditablePanel selectedCell = getSelectedCell();
|
||||
final int index = myIpnbPanels.indexOf(selectedCell);
|
||||
myInitialSelection = index >= 0 && index < myIpnbPanels.size() ? index : myIpnbPanels.size() - 1;
|
||||
removeAll();
|
||||
readFromFile(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@ public class IpnbFile {
|
||||
private final Map<String, Object> myMetadata;
|
||||
private final int myNbformat;
|
||||
private final List<IpnbCell> myCells;
|
||||
private final String myPath;
|
||||
@NotNull private final String myPath;
|
||||
|
||||
public IpnbFile(Map<String, Object> metadata, int nbformat, List<IpnbCell> cells, String path) {
|
||||
public IpnbFile(Map<String, Object> metadata, int nbformat, List<IpnbCell> cells, @NotNull String path) {
|
||||
myMetadata = metadata;
|
||||
myNbformat = nbformat;
|
||||
myCells = cells;
|
||||
@@ -31,6 +31,7 @@ public class IpnbFile {
|
||||
myCells.remove(index);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getPath() {
|
||||
return myPath;
|
||||
}
|
||||
@@ -43,4 +44,27 @@ public class IpnbFile {
|
||||
return myNbformat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
IpnbFile file = (IpnbFile)o;
|
||||
|
||||
if (myNbformat != file.myNbformat) return false;
|
||||
if (myMetadata != null ? !myMetadata.equals(file.myMetadata) : file.myMetadata != null) return false;
|
||||
if (myCells != null ? !myCells.equals(file.myCells) : file.myCells != null) return false;
|
||||
if (!myPath.equals(file.myPath)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = myMetadata != null ? myMetadata.hashCode() : 0;
|
||||
result = 31 * result + myNbformat;
|
||||
result = 31 * result + (myCells != null ? myCells.hashCode() : 0);
|
||||
result = 31 * result + (myPath.hashCode());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -34,4 +34,24 @@ public abstract class IpnbEditableCell implements IpnbCell {
|
||||
public Map<String, Object> getMetadata() {
|
||||
return myMetadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
IpnbEditableCell cell = (IpnbEditableCell)o;
|
||||
|
||||
if (!mySource.equals(cell.mySource)) return false;
|
||||
if (myMetadata != null ? !myMetadata.equals(cell.myMetadata) : cell.myMetadata != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = mySource.hashCode();
|
||||
result = 31 * result + (myMetadata != null ? myMetadata.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,4 +37,26 @@ public class IpnbOutputCell implements IpnbCell {
|
||||
public Map<String, Object> getMetadata() {
|
||||
return myMetadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
IpnbOutputCell cell = (IpnbOutputCell)o;
|
||||
|
||||
if (myPromptNumber != null ? !myPromptNumber.equals(cell.myPromptNumber) : cell.myPromptNumber != null) return false;
|
||||
if (myText != null ? !myText.equals(cell.myText) : cell.myText != null) return false;
|
||||
if (myMetadata != null ? !myMetadata.equals(cell.myMetadata) : cell.myMetadata != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = myPromptNumber != null ? myPromptNumber.hashCode() : 0;
|
||||
result = 31 * result + (myText != null ? myText.hashCode() : 0);
|
||||
result = 31 * result + (myMetadata != null ? myMetadata.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user