]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.editors/src/org/simantics/editors/internal/SystemFile.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.editors / src / org / simantics / editors / internal / SystemFile.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.editors.internal;
13
14 import java.io.FileInputStream;
15 import java.io.FileNotFoundException;
16 import java.io.InputStream;
17 import java.io.Reader;
18 import java.net.URI;
19 import java.util.Map;
20
21 import org.eclipse.core.resources.IContainer;
22 import org.eclipse.core.resources.IFile;
23 import org.eclipse.core.resources.IFileState;
24 import org.eclipse.core.resources.IMarker;
25 import org.eclipse.core.resources.IPathVariableManager;
26 import org.eclipse.core.resources.IProject;
27 import org.eclipse.core.resources.IProjectDescription;
28 import org.eclipse.core.resources.IResourceProxy;
29 import org.eclipse.core.resources.IResourceProxyVisitor;
30 import org.eclipse.core.resources.IResourceVisitor;
31 import org.eclipse.core.resources.IWorkspace;
32 import org.eclipse.core.resources.ResourceAttributes;
33 import org.eclipse.core.runtime.CoreException;
34 import org.eclipse.core.runtime.IPath;
35 import org.eclipse.core.runtime.IProgressMonitor;
36 import org.eclipse.core.runtime.Path;
37 import org.eclipse.core.runtime.QualifiedName;
38 import org.eclipse.core.runtime.Status;
39 import org.eclipse.core.runtime.content.IContentDescription;
40 import org.eclipse.core.runtime.jobs.ISchedulingRule;
41 import org.simantics.editors.Activator;
42
43 /**
44  * This is an implementation of IFile that can be used to open external editor for any file.
45  * (Original implementation (org.eclipse.core.filesystem.File) doesn't work without project/file structure) 
46  * 
47  * @author Marko Luukkainen <Marko.Luukkainen@vtt.fi>
48  *
49  */
50 public class SystemFile implements IFile {
51         private java.io.File file;
52         private IWorkspace workspace;
53         
54         
55         public SystemFile(java.io.File file, IWorkspace ws) {
56                 this.file = file;
57                 this.workspace = ws;
58         }
59
60         @Override
61         public void accept(IResourceProxyVisitor visitor, int memberFlags) throws CoreException {
62                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
63         }
64         
65         @Override
66         public void accept(IResourceVisitor visitor) throws CoreException {
67                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
68         }
69         
70         @Override
71         public void accept(IResourceVisitor visitor, int depth, boolean includePhantoms) throws CoreException {
72                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
73         }
74         
75         @Override
76         public void accept(IResourceVisitor visitor, int depth, int memberFlags) throws CoreException {
77                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
78         }
79
80         /* (non-Javadoc)
81          * @see org.eclipse.core.resources.IResource#accept(org.eclipse.core.resources.IResourceProxyVisitor, int, int)
82          * @since 3.8
83          */
84         public void accept(IResourceProxyVisitor visitor, int depth, int memberFlags) throws CoreException {
85         }
86
87         @Override
88         public void clearHistory(IProgressMonitor monitor) throws CoreException {
89                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
90         }
91
92         @Override
93         public void copy(IPath destination, boolean force, IProgressMonitor monitor) throws CoreException {
94                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
95                 
96         }
97
98         @Override
99         public void copy(IPath destination, int updateFlags, IProgressMonitor monitor) throws CoreException {
100                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
101                 
102         }
103
104         @Override
105         public void copy(IProjectDescription description, boolean force, IProgressMonitor monitor) throws CoreException {
106                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
107                 
108         }
109
110         @Override
111         public void copy(IProjectDescription description, int updateFlags, IProgressMonitor monitor) throws CoreException {
112                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
113                 
114         }
115
116         @Override
117         public IMarker createMarker(String type) throws CoreException {
118                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
119         }
120
121         @Override
122         public IResourceProxy createProxy() {
123                 return null;
124         }
125
126         @Override
127         public void delete(boolean force, IProgressMonitor monitor) throws CoreException {
128                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
129         }
130
131         @Override
132         public void delete(int updateFlags, IProgressMonitor monitor) throws CoreException {
133                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
134                 
135         }
136
137         @Override
138         public void deleteMarkers(String type, boolean includeSubtypes, int depth) throws CoreException {
139                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
140         }
141
142         @Override
143         public boolean exists() {
144                 return false;
145         }
146
147         @Override
148         public IMarker findMarker(long id) throws CoreException {
149                 return null;
150         }
151
152         @Override
153         public IMarker[] findMarkers(String type, boolean includeSubtypes, int depth) throws CoreException {
154                 return null;
155         }
156
157         @Override
158         public int findMaxProblemSeverity(String type, boolean includeSubtypes, int depth) throws CoreException {
159                 return 0;
160         }
161
162         @Override
163         public String getFileExtension() {
164                 String name = file.getName();
165                 // FIXME : names that do not contain "." won't work
166                 return name.substring(name.lastIndexOf("."));
167         }
168
169         @Override
170         public long getLocalTimeStamp() {
171                 return 0;
172         }
173
174         @Override
175         public IPath getLocation() {
176                 return null;
177         }
178
179         @Override
180         public URI getLocationURI() {
181                 return file.toURI();
182         }
183
184         @Override
185         public IMarker getMarker(long id) {
186                 return null;
187         }
188
189         @Override
190         public long getModificationStamp() {
191                 return 0;
192         }
193
194         @Override
195         public IContainer getParent() {
196                 return null;
197         }
198
199         @Override
200         public String getPersistentProperty(QualifiedName key)throws CoreException {
201                 return null;
202         }
203
204         @Override
205         public IProject getProject() {
206                 return null;
207         }
208
209         @Override
210         public IPath getProjectRelativePath() {
211                 return null;
212         }
213
214         @Override
215         public IPath getRawLocation() {
216                 return null;
217         }
218
219         @Override
220         public URI getRawLocationURI() {
221                 return file.toURI();
222         }
223
224         @Override
225         public ResourceAttributes getResourceAttributes() {
226                 return null;
227         }
228
229         @Override
230         public Object getSessionProperty(QualifiedName key) throws CoreException {
231                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
232         }
233
234         @Override
235         public int getType() {
236                 return IFile.FILE;
237         }
238
239         @Override
240         public IWorkspace getWorkspace() {
241                 return workspace;
242         }
243
244         @Override
245         public boolean isAccessible() {
246                 return false;
247         }
248
249         @Override
250         public boolean isDerived() {
251                 return false;
252         }
253
254         @Override
255         public boolean isLinked() {
256                 return false;
257         }
258
259         @Override
260         public boolean isLinked(int options) {
261                 return false;
262         }
263
264         @Override
265         public boolean isLocal(int depth) {
266                 return false;
267         }
268
269         @Override
270         public boolean isPhantom() {
271                 return false;
272         }
273
274         @Override
275         public boolean isSynchronized(int depth) {
276                 return false;
277         }
278
279         @Override
280         public boolean isTeamPrivateMember() {
281                 return false;
282         }
283
284         @Override
285         public void move(IPath destination, boolean force, IProgressMonitor monitor) throws CoreException {
286                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
287         }
288
289         @Override
290         public void move(IPath destination, int updateFlags, IProgressMonitor monitor) throws CoreException {
291                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
292         }
293
294         @Override
295         public void move(IProjectDescription description, boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException {
296                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
297         }
298
299         @Override
300         public void move(IProjectDescription description, int updateFlags, IProgressMonitor monitor) throws CoreException {
301                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
302         }
303
304         @Override
305         public void refreshLocal(int depth, IProgressMonitor monitor) throws CoreException {
306                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
307         }
308
309         @Override
310         public void revertModificationStamp(long value) throws CoreException {
311                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
312         }
313
314         @Override
315         public void setDerived(boolean isDerived) throws CoreException {
316                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
317         }
318
319         @Override
320         public void setLocal(boolean flag, int depth, IProgressMonitor monitor) throws CoreException {
321                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
322         }
323
324         @Override
325         public long setLocalTimeStamp(long value) throws CoreException {
326                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
327         }
328
329         @Override
330         public void setPersistentProperty(QualifiedName key, String value) throws CoreException {
331                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
332         }
333
334         @Override
335         public void setReadOnly(boolean readOnly) {
336
337         }
338
339         @Override
340         public void setResourceAttributes(ResourceAttributes attributes) throws CoreException {
341                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
342                 
343         }
344
345         @Override
346         public void setSessionProperty(QualifiedName key, Object value) throws CoreException {
347                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));  
348         }
349
350         @Override
351         public void setTeamPrivateMember(boolean isTeamPrivate) throws CoreException {
352                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
353         }
354
355         @Override
356         public void touch(IProgressMonitor monitor) throws CoreException {
357                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));  
358         }
359
360         @SuppressWarnings({ "rawtypes" })
361         @Override
362         public Object getAdapter(Class adapter) {
363                 return null;
364         }
365
366         @Override
367         public boolean contains(ISchedulingRule rule) {
368                 return false;
369         }
370
371         @Override
372         public boolean isConflicting(ISchedulingRule rule) {
373                 return false;
374         }
375
376         @Override
377         public void appendContents(InputStream source, boolean force,boolean keepHistory, IProgressMonitor monitor) throws CoreException {
378                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
379         }
380
381         @Override
382         public void appendContents(InputStream source, int updateFlags, IProgressMonitor monitor) throws CoreException {
383                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));  
384         }
385
386         @Override
387         public void create(InputStream source, boolean force, IProgressMonitor monitor) throws CoreException {
388                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
389         }
390
391         @Override
392         public void create(InputStream source, int updateFlags, IProgressMonitor monitor) throws CoreException {
393                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
394                 
395         }
396
397         @Override
398         public void createLink(IPath localLocation, int updateFlags, IProgressMonitor monitor) throws CoreException {
399                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
400                 
401         }
402
403         @Override
404         public void createLink(URI location, int updateFlags, IProgressMonitor monitor) throws CoreException {
405                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
406         }
407
408         @Override
409         public void delete(boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException {
410                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
411                 
412         }
413
414         @Override
415         public String getCharset() throws CoreException {
416                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
417         }
418
419         @Override
420         public String getCharset(boolean checkImplicit) throws CoreException {
421                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
422         }
423
424         @Override
425         public String getCharsetFor(Reader reader) throws CoreException {
426                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
427         }
428
429         @Override
430         public IContentDescription getContentDescription() throws CoreException {
431                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
432         }
433
434         @Override
435         public InputStream getContents() throws CoreException {
436                 return getContents(false);
437         }
438
439         @Override
440         public InputStream getContents(boolean force) throws CoreException {
441                 try {
442                         return new FileInputStream(file);
443                 } catch (FileNotFoundException e) {
444                         throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"File " + getName() + " not found"));
445                 }
446         }
447
448         @Override
449         public int getEncoding() throws CoreException {
450                 return 0;
451         }
452
453         @Override
454         public IPath getFullPath() {
455                 return new Path(file.getAbsolutePath());
456         }
457
458         @Override
459         public IFileState[] getHistory(IProgressMonitor monitor) throws CoreException {
460                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
461         }
462
463         @Override
464         public String getName() {
465                 return file.getName();
466         }
467
468         @Override
469         public boolean isReadOnly() {
470                 return true;
471         }
472
473         @Override
474         public void move(IPath destination, boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException {
475                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
476         }
477
478         @Override
479         public void setCharset(String newCharset, IProgressMonitor monitor) throws CoreException {
480                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
481         }
482
483         @Override
484         public void setCharset(String newCharset) throws CoreException {
485                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
486         }
487
488         @Override
489         public void setContents(IFileState source, boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException {
490                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
491                 
492         }
493
494         @Override
495         public void setContents(IFileState source, int updateFlags,
496                         IProgressMonitor monitor) throws CoreException {
497                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
498         }
499
500         @Override
501         public void setContents(InputStream source, boolean force,
502                         boolean keepHistory, IProgressMonitor monitor)
503                         throws CoreException {
504                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
505                 
506         }
507
508         @Override
509         public void setContents(InputStream source, int updateFlags, IProgressMonitor monitor) throws CoreException {
510                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));
511         }
512
513         @SuppressWarnings({ "rawtypes", "unchecked" })
514         @Override
515         public Map getPersistentProperties() throws CoreException {
516                 return null;
517         }
518
519         @SuppressWarnings({ "rawtypes", "unchecked" })
520         @Override
521         public Map getSessionProperties() throws CoreException {
522                 return null;
523         }
524
525         //@Override
526         public boolean isDerived(int options) {
527                 return false;
528         }
529
530         //@Override
531         public boolean isHidden() {
532                 return false;
533         }
534
535         //@Override
536         public void setHidden(boolean isHidden) throws CoreException {
537
538         }
539
540         //@Override
541         public boolean isHidden(int options) {
542                 return false;
543         }
544
545         //@Override
546         public boolean isTeamPrivateMember(int options) {
547                 return false;
548         }
549         
550         //@Override
551         public IPathVariableManager getPathVariableManager() {
552                 return null;
553         }
554         
555         //@Override
556         public boolean isVirtual() {
557                 return false;
558         }
559         
560         //@Override
561         public void setDerived(boolean isDerived, IProgressMonitor monitor)
562                         throws CoreException {
563                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));          
564         }
565
566 }