Lines 81-91
Link Here
|
81 |
import org.openide.explorer.ExplorerUtils; |
81 |
import org.openide.explorer.ExplorerUtils; |
82 |
import org.openide.explorer.view.BeanTreeView; |
82 |
import org.openide.explorer.view.BeanTreeView; |
83 |
import org.openide.filesystems.FileObject; |
83 |
import org.openide.filesystems.FileObject; |
84 |
import org.openide.filesystems.FileStateInvalidException; |
|
|
85 |
import org.openide.filesystems.FileSystem; |
86 |
import org.openide.filesystems.FileUtil; |
84 |
import org.openide.filesystems.FileUtil; |
87 |
import org.openide.filesystems.LocalFileSystem; |
|
|
88 |
import org.openide.filesystems.MultiFileSystem; |
89 |
import org.openide.loaders.DataFilter; |
85 |
import org.openide.loaders.DataFilter; |
90 |
import org.openide.loaders.DataFolder; |
86 |
import org.openide.loaders.DataFolder; |
91 |
import org.openide.loaders.DataObject; |
87 |
import org.openide.loaders.DataObject; |
Lines 99-105
Link Here
|
99 |
import org.openide.nodes.NodeReorderEvent; |
95 |
import org.openide.nodes.NodeReorderEvent; |
100 |
import org.openide.nodes.PropertySupport; |
96 |
import org.openide.nodes.PropertySupport; |
101 |
import org.openide.nodes.Sheet; |
97 |
import org.openide.nodes.Sheet; |
102 |
import org.openide.util.Exceptions; |
|
|
103 |
import org.openide.util.HelpCtx; |
98 |
import org.openide.util.HelpCtx; |
104 |
import org.openide.util.Lookup; |
99 |
import org.openide.util.Lookup; |
105 |
import org.openide.util.NbBundle; |
100 |
import org.openide.util.NbBundle; |
Lines 107-113
Link Here
|
107 |
import org.openide.util.actions.NodeAction; |
102 |
import org.openide.util.actions.NodeAction; |
108 |
import org.openide.util.actions.SystemAction; |
103 |
import org.openide.util.actions.SystemAction; |
109 |
import org.openide.util.lookup.AbstractLookup; |
104 |
import org.openide.util.lookup.AbstractLookup; |
110 |
import org.openide.util.lookup.InstanceContent; |
|
|
111 |
import org.openide.util.lookup.ProxyLookup; |
105 |
import org.openide.util.lookup.ProxyLookup; |
112 |
import org.openide.windows.TopComponent; |
106 |
import org.openide.windows.TopComponent; |
113 |
|
107 |
|
Lines 1188-1194
Link Here
|
1188 |
String name = n.getFileName(); |
1182 |
String name = n.getFileName(); |
1189 |
String displayName = n.getDisplayName(); |
1183 |
String displayName = n.getDisplayName(); |
1190 |
FileObject fo = n.getLookup().lookup(FileObject.class); |
1184 |
FileObject fo = n.getLookup().lookup(FileObject.class); |
1191 |
RenameTemplatePanel editPanel = new RenameTemplatePanel(isUserFile(fo)); |
1185 |
RenameTemplatePanel editPanel = new RenameTemplatePanel(fo.canRevert()); |
1192 |
editPanel.setFileName(name); |
1186 |
editPanel.setFileName(name); |
1193 |
editPanel.setFileDisplayName(displayName); |
1187 |
editPanel.setFileDisplayName(displayName); |
1194 |
String title = org.openide.util.NbBundle.getMessage(TemplatesPanel.class, "RenameTemplatePanel.title.text"); |
1188 |
String title = org.openide.util.NbBundle.getMessage(TemplatesPanel.class, "RenameTemplatePanel.title.text"); |
Lines 1208-1260
Link Here
|
1208 |
} |
1202 |
} |
1209 |
} |
1203 |
} |
1210 |
|
1204 |
|
1211 |
/** Test if the file physically exists on disk and thus was created by user and can be renamed. */ |
|
|
1212 |
private static boolean isUserFile(FileObject fo) { |
1213 |
String path = fo.getPath(); |
1214 |
// Find if this path is on non-local filesystems |
1215 |
FileSystem fs; |
1216 |
try { |
1217 |
fs = fo.getFileSystem(); |
1218 |
} catch (FileStateInvalidException ex) { |
1219 |
return false; |
1220 |
} |
1221 |
return !isOnNonLocalFS(fs, path); |
1222 |
} |
1223 |
|
1224 |
private static boolean isOnNonLocalFS(FileSystem fs, String path) { |
1225 |
if (fs instanceof MultiFileSystem) { |
1226 |
MultiFileSystem mfs = (MultiFileSystem) fs; |
1227 |
try { |
1228 |
java.lang.reflect.Method getDelegatesMethod; |
1229 |
getDelegatesMethod = MultiFileSystem.class.getDeclaredMethod("getDelegates"); // NOI18N |
1230 |
getDelegatesMethod.setAccessible(true); |
1231 |
FileSystem[] delegates = (FileSystem[]) getDelegatesMethod.invoke(mfs); |
1232 |
for (FileSystem fsd : delegates) { |
1233 |
if (isOnNonLocalFS(fsd, path)) { |
1234 |
return true; |
1235 |
} |
1236 |
} |
1237 |
} catch (NoSuchMethodException ex) { |
1238 |
Exceptions.printStackTrace(ex); |
1239 |
} catch (SecurityException ex) { |
1240 |
Exceptions.printStackTrace(ex); |
1241 |
} catch (IllegalAccessException ex) { |
1242 |
Exceptions.printStackTrace(ex); |
1243 |
} catch (IllegalArgumentException ex) { |
1244 |
Exceptions.printStackTrace(ex); |
1245 |
} catch (InvocationTargetException ex) { |
1246 |
Exceptions.printStackTrace(ex); |
1247 |
} |
1248 |
return false; |
1249 |
} else { |
1250 |
if (fs instanceof LocalFileSystem) { |
1251 |
return false; // is local FS |
1252 |
} else { |
1253 |
return fs.findResource(path) != null; |
1254 |
} |
1255 |
} |
1256 |
} |
1257 |
|
1258 |
// action |
1205 |
// action |
1259 |
private static class AddAction extends NodeAction { |
1206 |
private static class AddAction extends NodeAction { |
1260 |
protected void performAction (Node[] activatedNodes) { |
1207 |
protected void performAction (Node[] activatedNodes) { |