1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.editors.internal;
\r
14 import java.io.FileInputStream;
\r
15 import java.io.FileNotFoundException;
\r
16 import java.io.InputStream;
\r
17 import java.io.Reader;
\r
18 import java.net.URI;
\r
19 import java.util.Map;
\r
21 import org.eclipse.core.resources.IContainer;
\r
22 import org.eclipse.core.resources.IFile;
\r
23 import org.eclipse.core.resources.IFileState;
\r
24 import org.eclipse.core.resources.IMarker;
\r
25 import org.eclipse.core.resources.IPathVariableManager;
\r
26 import org.eclipse.core.resources.IProject;
\r
27 import org.eclipse.core.resources.IProjectDescription;
\r
28 import org.eclipse.core.resources.IResourceProxy;
\r
29 import org.eclipse.core.resources.IResourceProxyVisitor;
\r
30 import org.eclipse.core.resources.IResourceVisitor;
\r
31 import org.eclipse.core.resources.IWorkspace;
\r
32 import org.eclipse.core.resources.ResourceAttributes;
\r
33 import org.eclipse.core.runtime.CoreException;
\r
34 import org.eclipse.core.runtime.IPath;
\r
35 import org.eclipse.core.runtime.IProgressMonitor;
\r
36 import org.eclipse.core.runtime.Path;
\r
37 import org.eclipse.core.runtime.QualifiedName;
\r
38 import org.eclipse.core.runtime.Status;
\r
39 import org.eclipse.core.runtime.content.IContentDescription;
\r
40 import org.eclipse.core.runtime.jobs.ISchedulingRule;
\r
41 import org.simantics.editors.Activator;
\r
44 * This is an implementation of IFile that can be used to open external editor for any file.
\r
45 * (Original implementation (org.eclipse.core.filesystem.File) doesn't work without project/file structure)
\r
47 * @author Marko Luukkainen <Marko.Luukkainen@vtt.fi>
\r
50 public class SystemFile implements IFile {
\r
51 private java.io.File file;
\r
52 private IWorkspace workspace;
\r
55 public SystemFile(java.io.File file, IWorkspace ws) {
\r
57 this.workspace = ws;
\r
61 public void accept(IResourceProxyVisitor visitor, int memberFlags) throws CoreException {
\r
62 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
66 public void accept(IResourceVisitor visitor) throws CoreException {
\r
67 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
71 public void accept(IResourceVisitor visitor, int depth, boolean includePhantoms) throws CoreException {
\r
72 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
76 public void accept(IResourceVisitor visitor, int depth, int memberFlags) throws CoreException {
\r
77 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
81 * @see org.eclipse.core.resources.IResource#accept(org.eclipse.core.resources.IResourceProxyVisitor, int, int)
\r
84 public void accept(IResourceProxyVisitor visitor, int depth, int memberFlags) throws CoreException {
\r
88 public void clearHistory(IProgressMonitor monitor) throws CoreException {
\r
89 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
93 public void copy(IPath destination, boolean force, IProgressMonitor monitor) throws CoreException {
\r
94 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
99 public void copy(IPath destination, int updateFlags, IProgressMonitor monitor) throws CoreException {
\r
100 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
105 public void copy(IProjectDescription description, boolean force, IProgressMonitor monitor) throws CoreException {
\r
106 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
111 public void copy(IProjectDescription description, int updateFlags, IProgressMonitor monitor) throws CoreException {
\r
112 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
117 public IMarker createMarker(String type) throws CoreException {
\r
118 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
122 public IResourceProxy createProxy() {
\r
127 public void delete(boolean force, IProgressMonitor monitor) throws CoreException {
\r
128 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
132 public void delete(int updateFlags, IProgressMonitor monitor) throws CoreException {
\r
133 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
138 public void deleteMarkers(String type, boolean includeSubtypes, int depth) throws CoreException {
\r
139 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
143 public boolean exists() {
\r
148 public IMarker findMarker(long id) throws CoreException {
\r
153 public IMarker[] findMarkers(String type, boolean includeSubtypes, int depth) throws CoreException {
\r
158 public int findMaxProblemSeverity(String type, boolean includeSubtypes, int depth) throws CoreException {
\r
163 public String getFileExtension() {
\r
164 String name = file.getName();
\r
165 // FIXME : names that do not contain "." won't work
\r
166 return name.substring(name.lastIndexOf("."));
\r
170 public long getLocalTimeStamp() {
\r
175 public IPath getLocation() {
\r
180 public URI getLocationURI() {
\r
181 return file.toURI();
\r
185 public IMarker getMarker(long id) {
\r
190 public long getModificationStamp() {
\r
195 public IContainer getParent() {
\r
200 public String getPersistentProperty(QualifiedName key)throws CoreException {
\r
205 public IProject getProject() {
\r
210 public IPath getProjectRelativePath() {
\r
215 public IPath getRawLocation() {
\r
220 public URI getRawLocationURI() {
\r
221 return file.toURI();
\r
225 public ResourceAttributes getResourceAttributes() {
\r
230 public Object getSessionProperty(QualifiedName key) throws CoreException {
\r
231 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
235 public int getType() {
\r
240 public IWorkspace getWorkspace() {
\r
245 public boolean isAccessible() {
\r
250 public boolean isDerived() {
\r
255 public boolean isLinked() {
\r
260 public boolean isLinked(int options) {
\r
265 public boolean isLocal(int depth) {
\r
270 public boolean isPhantom() {
\r
275 public boolean isSynchronized(int depth) {
\r
280 public boolean isTeamPrivateMember() {
\r
285 public void move(IPath destination, boolean force, IProgressMonitor monitor) throws CoreException {
\r
286 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
290 public void move(IPath destination, int updateFlags, IProgressMonitor monitor) throws CoreException {
\r
291 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
295 public void move(IProjectDescription description, boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException {
\r
296 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
300 public void move(IProjectDescription description, int updateFlags, IProgressMonitor monitor) throws CoreException {
\r
301 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
305 public void refreshLocal(int depth, IProgressMonitor monitor) throws CoreException {
\r
306 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
310 public void revertModificationStamp(long value) throws CoreException {
\r
311 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
315 public void setDerived(boolean isDerived) throws CoreException {
\r
316 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
320 public void setLocal(boolean flag, int depth, IProgressMonitor monitor) throws CoreException {
\r
321 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
325 public long setLocalTimeStamp(long value) throws CoreException {
\r
326 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
330 public void setPersistentProperty(QualifiedName key, String value) throws CoreException {
\r
331 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
335 public void setReadOnly(boolean readOnly) {
\r
340 public void setResourceAttributes(ResourceAttributes attributes) throws CoreException {
\r
341 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
346 public void setSessionProperty(QualifiedName key, Object value) throws CoreException {
\r
347 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
351 public void setTeamPrivateMember(boolean isTeamPrivate) throws CoreException {
\r
352 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
356 public void touch(IProgressMonitor monitor) throws CoreException {
\r
357 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
360 @SuppressWarnings({ "rawtypes" })
\r
362 public Object getAdapter(Class adapter) {
\r
367 public boolean contains(ISchedulingRule rule) {
\r
372 public boolean isConflicting(ISchedulingRule rule) {
\r
377 public void appendContents(InputStream source, boolean force,boolean keepHistory, IProgressMonitor monitor) throws CoreException {
\r
378 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
382 public void appendContents(InputStream source, int updateFlags, IProgressMonitor monitor) throws CoreException {
\r
383 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
387 public void create(InputStream source, boolean force, IProgressMonitor monitor) throws CoreException {
\r
388 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
392 public void create(InputStream source, int updateFlags, IProgressMonitor monitor) throws CoreException {
\r
393 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
398 public void createLink(IPath localLocation, int updateFlags, IProgressMonitor monitor) throws CoreException {
\r
399 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
404 public void createLink(URI location, int updateFlags, IProgressMonitor monitor) throws CoreException {
\r
405 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
409 public void delete(boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException {
\r
410 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
415 public String getCharset() throws CoreException {
\r
416 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
420 public String getCharset(boolean checkImplicit) throws CoreException {
\r
421 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
425 public String getCharsetFor(Reader reader) throws CoreException {
\r
426 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
430 public IContentDescription getContentDescription() throws CoreException {
\r
431 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
435 public InputStream getContents() throws CoreException {
\r
436 return getContents(false);
\r
440 public InputStream getContents(boolean force) throws CoreException {
\r
442 return new FileInputStream(file);
\r
443 } catch (FileNotFoundException e) {
\r
444 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"File " + getName() + " not found"));
\r
449 public int getEncoding() throws CoreException {
\r
454 public IPath getFullPath() {
\r
455 return new Path(file.getAbsolutePath());
\r
459 public IFileState[] getHistory(IProgressMonitor monitor) throws CoreException {
\r
460 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
464 public String getName() {
\r
465 return file.getName();
\r
469 public boolean isReadOnly() {
\r
474 public void move(IPath destination, boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException {
\r
475 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
479 public void setCharset(String newCharset, IProgressMonitor monitor) throws CoreException {
\r
480 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
484 public void setCharset(String newCharset) throws CoreException {
\r
485 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
489 public void setContents(IFileState source, boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException {
\r
490 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
495 public void setContents(IFileState source, int updateFlags,
\r
496 IProgressMonitor monitor) throws CoreException {
\r
497 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
501 public void setContents(InputStream source, boolean force,
\r
502 boolean keepHistory, IProgressMonitor monitor)
\r
503 throws CoreException {
\r
504 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
509 public void setContents(InputStream source, int updateFlags, IProgressMonitor monitor) throws CoreException {
\r
510 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r
513 @SuppressWarnings({ "rawtypes", "unchecked" })
\r
515 public Map getPersistentProperties() throws CoreException {
\r
519 @SuppressWarnings({ "rawtypes", "unchecked" })
\r
521 public Map getSessionProperties() throws CoreException {
\r
526 public boolean isDerived(int options) {
\r
531 public boolean isHidden() {
\r
536 public void setHidden(boolean isHidden) throws CoreException {
\r
541 public boolean isHidden(int options) {
\r
546 public boolean isTeamPrivateMember(int options) {
\r
551 public IPathVariableManager getPathVariableManager() {
\r
556 public boolean isVirtual() {
\r
561 public void setDerived(boolean isDerived, IProgressMonitor monitor)
\r
562 throws CoreException {
\r
563 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
\r