This commit is contained in:
Roman Shevchenko
2012-04-04 14:22:31 +02:00
parent 50b937c072
commit d76a38b660
6 changed files with 49 additions and 71 deletions
@@ -229,12 +229,6 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica
return false;
}
/** @deprecated use {@linkplain #getCanonicalFile()} (to remove in IDEA 12) */
@Nullable
public VirtualFile getRealFile() {
return isSymLink() ? getCanonicalFile() : this;
}
/**
* Resolves all symbolic links containing in a path to this file and returns a path to a link target.
*
@@ -64,12 +64,6 @@ public abstract class LocalFileSystem extends NewVirtualFileSystem {
return false;
}
/** @deprecated use {@linkplain com.intellij.openapi.vfs.VirtualFile#getCanonicalFile()} (to remove in IDEA 12) */
@Nullable
public VirtualFile getRealFile(@NotNull final VirtualFile file) {
return file;
}
@Nullable
public abstract VirtualFile findFileByIoFile(@NotNull File file);
@@ -102,29 +96,34 @@ public abstract class LocalFileSystem extends NewVirtualFileSystem {
public abstract void refreshFiles(@NotNull Iterable<VirtualFile> files, boolean async, boolean recursive, @Nullable Runnable onFinish);
public abstract byte[] physicalContentsToByteArray(@NotNull VirtualFile virtualFile) throws IOException;
/** @deprecated use {@linkplain com.intellij.openapi.vfs.VirtualFile#contentsToByteArray()} (to remove in IDEA 13) */
@SuppressWarnings({"MethodMayBeStatic", "UnusedDeclaration"})
public byte[] physicalContentsToByteArray(@NotNull VirtualFile virtualFile) throws IOException{
return virtualFile.contentsToByteArray();
}
public abstract long physicalLength(@NotNull VirtualFile virtualFile) throws IOException;
/** @deprecated use {@linkplain VirtualFile#getLength()} (to remove in IDEA 13) */
@SuppressWarnings({"MethodMayBeStatic", "UnusedDeclaration"})
public long physicalLength(@NotNull VirtualFile virtualFile) throws IOException{
return virtualFile.getLength();
}
public interface WatchRequest {
@NotNull
String getRootPath();
boolean isToWatchRecursively();
/** @deprecated implementation details (to remove in IDEA 13) */
@SuppressWarnings({"UnusedDeclaration"})
@NotNull
String getFileSystemRootPath();
boolean isToWatchRecursively();
/** @deprecated implementation details (to remove in IDEA 13) */
@SuppressWarnings({"UnusedDeclaration"})
boolean dominates(@NotNull WatchRequest other);
}
/**
* Adds this rootFile as the watch root for file system.
*
* @param rootPath path to watch.
* @param toWatchRecursively whether the whole subtree should be monitored.
* @return request handle or null if rootFile does not belong to this file system.
*/
@Nullable
public abstract WatchRequest addRootToWatch(@NotNull final String rootPath, final boolean toWatchRecursively);
@@ -1,27 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.internal.encodings.EncodingViewer">
<grid id="cb3c8" binding="myPanel" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="cb3c8" binding="myPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="31" y="65" width="267" height="160"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="c1bfc" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="c1bfc" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="0" y="0" width="267" height="25"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="25e1d" class="javax.swing.JButton" binding="myLoadFile">
<constraints>
<xy x="0" y="0" width="79" height="25"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/CommonBundle" key="button.load.file"/>
@@ -29,24 +26,30 @@
</component>
<component id="e614" class="javax.swing.JComboBox" binding="myEncoding">
<constraints>
<xy x="89" y="1" width="178" height="22"/>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1"/>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
</children>
</grid>
<scrollpane class="com.intellij.ui.components.JBScrollPane" id="e9f31">
<scrollpane id="e9f31" class="com.intellij.ui.components.JBScrollPane">
<constraints>
<xy x="0" y="30" width="267" height="130"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<properties>
<verticalScrollBarPolicy value="22"/>
</properties>
<border type="none"/>
<children>
<component id="588d1" class="javax.swing.JTextField" binding="myText">
<component id="4dc45" class="javax.swing.JTextArea" binding="myText">
<constraints/>
<properties/>
<properties>
<editable value="false"/>
<rows value="20"/>
</properties>
<clientProperties>
<caretAspectRatio class="java.lang.Float" value="0.04"/>
</clientProperties>
</component>
</children>
</scrollpane>
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,6 @@ import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.vfs.CharsetToolkit;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.LocalFileSystem;
import javax.swing.*;
import java.awt.event.ActionEvent;
@@ -35,8 +34,9 @@ import java.util.Arrays;
public class EncodingViewer extends DialogWrapper {
private static final Logger LOG = Logger.getInstance("#com.intellij.internal.encodings.EncodingViewer");
private JPanel myPanel;
private JTextField myText;
private JTextArea myText;
private JComboBox myEncoding;
private JButton myLoadFile;
private byte[] myBytes;
@@ -61,8 +61,9 @@ public class EncodingViewer extends DialogWrapper {
private void loadFrom(VirtualFile virtualFile) {
try {
myBytes = LocalFileSystem.getInstance().physicalContentsToByteArray(virtualFile);
} catch (IOException e) {
myBytes = virtualFile.contentsToByteArray();
}
catch (IOException e) {
LOG.error(e);
return;
}
@@ -74,7 +75,8 @@ public class EncodingViewer extends DialogWrapper {
if (myBytes == null || selectedCharset == null) return;
try {
myText.setText(new String(myBytes, selectedCharset));
} catch (UnsupportedEncodingException e) {
}
catch (UnsupportedEncodingException e) {
LOG.error(e);
}
}
@@ -90,8 +92,9 @@ public class EncodingViewer extends DialogWrapper {
myEncoding.setSelectedIndex(defaultIndex);
myEncoding.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() != ItemEvent.SELECTED) return;
refreshText();
if (e.getStateChange() == ItemEvent.SELECTED) {
refreshText();
}
}
});
}
@@ -99,5 +102,4 @@ public class EncodingViewer extends DialogWrapper {
protected JComponent createCenterPanel() {
return myPanel;
}
}
@@ -238,10 +238,10 @@ public abstract class LocalFileSystemBase extends LocalFileSystem {
protected static boolean isInvalidSymLink(@NotNull final VirtualFile file) {
if (!file.isSymLink()) return false;
final VirtualFile realFile = file.getRealFile();
return realFile == null ||
realFile == file ||
FileUtil.isAncestor(convertToIOFile(realFile), convertToIOFile(file), true);
final VirtualFile target = file.getCanonicalFile();
return target == null ||
target == file ||
FileUtil.isAncestor(convertToIOFile(target), convertToIOFile(file), true);
}
@Override
@@ -316,16 +316,6 @@ public abstract class LocalFileSystemBase extends LocalFileSystem {
RefreshQueue.getInstance().refresh(async, recursive, onFinish, VfsUtil.toVirtualFileArray(list));
}
@Override
public byte[] physicalContentsToByteArray(@NotNull final VirtualFile virtualFile) throws IOException {
return virtualFile.contentsToByteArray();
}
@Override
public long physicalLength(@NotNull final VirtualFile virtualFile) {
return virtualFile.getLength();
}
@Override
public void registerAuxiliaryFileOperationsHandler(@NotNull LocalFileOperationsHandler handler) {
if (myHandlers.contains(handler)) {
@@ -81,16 +81,6 @@ public class MockLocalFileSystem extends LocalFileSystem {
public void refreshFiles(@NotNull Iterable<VirtualFile> files, boolean async, boolean recursive, @Nullable Runnable onFinish) {
}
@Override
public byte[] physicalContentsToByteArray(@NotNull final VirtualFile virtualFile) throws IOException {
throw new UnsupportedOperationException("'physicalContentsToByteArray' not implemented in " + getClass().getName());
}
@Override
public long physicalLength(@NotNull final VirtualFile virtualFile) throws IOException {
throw new UnsupportedOperationException("'physicalLength' not implemented in " + getClass().getName());
}
@Override
@Nullable
public WatchRequest addRootToWatch(@NotNull final String rootPath, final boolean toWatchRecursively) {