author | Eugene Ostroukhov <eugeneo@symbian.org> |
Mon, 07 Jun 2010 16:51:19 -0700 | |
changeset 355 | 8726e95bcbba |
parent 2 | e4420d2515f1 |
permissions | -rw-r--r-- |
2 | 1 |
// Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 |
// Use of this source code is governed by a BSD-style license that can be |
|
3 |
// found in the LICENSE file. |
|
4 |
||
5 |
package org.chromium.debug.ui.editors; |
|
6 |
||
355
8726e95bcbba
Initial commit of updated Chrome Java SDK
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
2
diff
changeset
|
7 |
import org.eclipse.core.resources.IProject; |
2 | 8 |
import org.eclipse.core.runtime.CoreException; |
9 |
import org.eclipse.jface.text.IDocument; |
|
10 |
import org.eclipse.jface.text.IDocumentPartitioner; |
|
11 |
import org.eclipse.jface.text.rules.FastPartitioner; |
|
355
8726e95bcbba
Initial commit of updated Chrome Java SDK
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
2
diff
changeset
|
12 |
import org.eclipse.ui.IFileEditorInput; |
2 | 13 |
import org.eclipse.ui.editors.text.FileDocumentProvider; |
14 |
||
15 |
/** |
|
16 |
* Provides JavaScript content and sets up the document partitioner. |
|
17 |
*/ |
|
18 |
public class JsDocumentProvider extends FileDocumentProvider { |
|
19 |
||
20 |
@Override |
|
21 |
protected IDocument createDocument(Object element) throws CoreException { |
|
22 |
IDocument doc = super.createDocument(element); |
|
23 |
if (doc != null) { |
|
24 |
IDocumentPartitioner partitioner = new FastPartitioner( |
|
25 |
new JsPartitionScanner(), JsPartitionScanner.PARTITION_TYPES); |
|
26 |
partitioner.connect(doc); |
|
27 |
doc.setDocumentPartitioner(partitioner); |
|
28 |
} |
|
29 |
return doc; |
|
30 |
} |
|
31 |
||
355
8726e95bcbba
Initial commit of updated Chrome Java SDK
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
2
diff
changeset
|
32 |
/** |
8726e95bcbba
Initial commit of updated Chrome Java SDK
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
2
diff
changeset
|
33 |
* Alternative implementation of the method that does not require file to be a physical file. |
8726e95bcbba
Initial commit of updated Chrome Java SDK
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
2
diff
changeset
|
34 |
*/ |
8726e95bcbba
Initial commit of updated Chrome Java SDK
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
2
diff
changeset
|
35 |
@Override |
8726e95bcbba
Initial commit of updated Chrome Java SDK
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
2
diff
changeset
|
36 |
public boolean isDeleted(Object element) { |
8726e95bcbba
Initial commit of updated Chrome Java SDK
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
2
diff
changeset
|
37 |
if (element instanceof IFileEditorInput) { |
8726e95bcbba
Initial commit of updated Chrome Java SDK
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
2
diff
changeset
|
38 |
IFileEditorInput input= (IFileEditorInput) element; |
8726e95bcbba
Initial commit of updated Chrome Java SDK
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
2
diff
changeset
|
39 |
|
8726e95bcbba
Initial commit of updated Chrome Java SDK
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
2
diff
changeset
|
40 |
IProject project = input.getFile().getProject(); |
8726e95bcbba
Initial commit of updated Chrome Java SDK
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
2
diff
changeset
|
41 |
if (project != null && !project.exists()) { |
8726e95bcbba
Initial commit of updated Chrome Java SDK
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
2
diff
changeset
|
42 |
return true; |
8726e95bcbba
Initial commit of updated Chrome Java SDK
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
2
diff
changeset
|
43 |
} |
8726e95bcbba
Initial commit of updated Chrome Java SDK
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
2
diff
changeset
|
44 |
|
8726e95bcbba
Initial commit of updated Chrome Java SDK
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
2
diff
changeset
|
45 |
return !input.getFile().exists(); |
8726e95bcbba
Initial commit of updated Chrome Java SDK
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
2
diff
changeset
|
46 |
} |
8726e95bcbba
Initial commit of updated Chrome Java SDK
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
2
diff
changeset
|
47 |
return super.isDeleted(element); |
8726e95bcbba
Initial commit of updated Chrome Java SDK
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
2
diff
changeset
|
48 |
} |
8726e95bcbba
Initial commit of updated Chrome Java SDK
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
2
diff
changeset
|
49 |
|
2 | 50 |
} |