author | Eugene Ostroukhov <eugeneo@symbian.org> |
Mon, 23 Aug 2010 09:55:57 -0700 | |
changeset 471 | 06589bf52fa7 |
child 484 | f5df819c1852 |
permissions | -rw-r--r-- |
471
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1 |
package org.symbian.tools.tmw.debug.internal.model; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
2 |
|
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
3 |
import java.util.Collection; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
4 |
|
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
5 |
import org.chromium.debug.core.model.Value; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
6 |
import org.chromium.sdk.JsValue; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
7 |
import org.chromium.sdk.JsVariable; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
8 |
import org.eclipse.core.filesystem.IFileStore; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
9 |
import org.eclipse.core.resources.IFile; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
10 |
import org.eclipse.core.resources.IResource; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
11 |
import org.eclipse.core.resources.IStorage; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
12 |
import org.eclipse.debug.core.model.IBreakpoint; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
13 |
import org.eclipse.debug.core.model.ILineBreakpoint; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
14 |
import org.eclipse.debug.core.model.IValue; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
15 |
import org.eclipse.debug.ui.IDebugModelPresentation; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
16 |
import org.eclipse.debug.ui.IValueDetailListener; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
17 |
import org.eclipse.jface.viewers.LabelProvider; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
18 |
import org.eclipse.swt.graphics.Image; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
19 |
import org.eclipse.ui.IEditorInput; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
20 |
import org.eclipse.ui.IFileEditorInput; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
21 |
import org.eclipse.ui.PartInitException; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
22 |
import org.eclipse.ui.ide.FileStoreEditorInput; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
23 |
import org.eclipse.ui.ide.IDE; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
24 |
import org.eclipse.ui.part.FileEditorInput; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
25 |
import org.eclipse.wst.jsdt.core.JavaScriptCore; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
26 |
import org.eclipse.wst.jsdt.internal.ui.javaeditor.JarEntryEditorInput; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
27 |
import org.eclipse.wst.jsdt.ui.JavaScriptUI; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
28 |
|
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
29 |
@SuppressWarnings("restriction") |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
30 |
public class SymbianDebugModelPresentation extends LabelProvider implements |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
31 |
IDebugModelPresentation { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
32 |
private static final int DETAILS_DEPTH = 2; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
33 |
|
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
34 |
public void setAttribute(String attribute, Object value) { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
35 |
} |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
36 |
|
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
37 |
@Override |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
38 |
public Image getImage(Object element) { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
39 |
// use default image |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
40 |
return null; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
41 |
} |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
42 |
|
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
43 |
@Override |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
44 |
public String getText(Object element) { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
45 |
// use default label text |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
46 |
return null; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
47 |
} |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
48 |
|
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
49 |
public void computeDetail(IValue value, IValueDetailListener listener) { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
50 |
String detail = ""; //$NON-NLS-1$ |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
51 |
if (value instanceof Value) { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
52 |
// Avoid quoting string JavaScript values by getting the value |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
53 |
// string |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
54 |
// from the underlying JsValue. |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
55 |
final JsValue jsValue = ((Value) value).getJsValue(); |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
56 |
detail = printJSON(jsValue, 0); |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
57 |
} |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
58 |
|
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
59 |
listener.detailComputed(value, detail); |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
60 |
} |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
61 |
|
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
62 |
private String printJSON(final JsValue value, int depth) { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
63 |
if (depth < DETAILS_DEPTH) { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
64 |
switch (value.getType()) { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
65 |
case TYPE_OBJECT: |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
66 |
return printObject(value, depth); |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
67 |
case TYPE_ARRAY: |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
68 |
return printArray(value, depth); |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
69 |
} |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
70 |
} |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
71 |
if (depth > 0) { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
72 |
if (value.getType() == JsValue.Type.TYPE_STRING) { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
73 |
return "\"" + value.getValueString() + "\""; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
74 |
} |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
75 |
} |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
76 |
return value.getValueString(); |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
77 |
} |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
78 |
|
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
79 |
private String printArray(JsValue value, int depth) { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
80 |
final StringBuilder builder = new StringBuilder("{ "); |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
81 |
String sep = ""; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
82 |
|
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
83 |
Collection<? extends JsVariable> properties = value.asObject().asArray().toSparseArray().values(); |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
84 |
|
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
85 |
for (JsVariable jsVariable : properties) { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
86 |
builder.append(sep).append(printJSON(jsVariable.getValue(), depth + 1)); |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
87 |
sep = ", "; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
88 |
} |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
89 |
|
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
90 |
builder.append(" }"); |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
91 |
return builder.toString(); |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
92 |
} |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
93 |
|
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
94 |
private String printObject(final JsValue value, final int depth) { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
95 |
final StringBuilder builder = new StringBuilder("{ "); |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
96 |
|
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
97 |
String sep = ""; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
98 |
|
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
99 |
Collection<? extends JsVariable> properties = value.asObject().getProperties(); |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
100 |
for (JsVariable jsVariable : properties) { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
101 |
builder.append(sep).append(jsVariable.getName()).append(" : "); |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
102 |
builder.append(printJSON(jsVariable.getValue(), depth + 1)); |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
103 |
sep = ", "; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
104 |
} |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
105 |
|
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
106 |
builder.append(" }"); |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
107 |
return builder.toString(); |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
108 |
} |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
109 |
|
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
110 |
public IEditorInput getEditorInput(Object element) { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
111 |
return toEditorInput(element); |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
112 |
} |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
113 |
|
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
114 |
public static IEditorInput toEditorInput(Object element) { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
115 |
if (element instanceof IFile) { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
116 |
return new FileEditorInput((IFile) element); |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
117 |
} |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
118 |
if (element instanceof IFileStore) { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
119 |
return new FileStoreEditorInput((IFileStore) element); |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
120 |
} |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
121 |
if (element instanceof IStorage) { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
122 |
return new JarEntryEditorInput((IStorage) element); |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
123 |
} |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
124 |
|
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
125 |
if (element instanceof ILineBreakpoint) { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
126 |
return new FileEditorInput((IFile) ((ILineBreakpoint) element) |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
127 |
.getMarker().getResource()); |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
128 |
} |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
129 |
|
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
130 |
return null; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
131 |
} |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
132 |
|
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
133 |
public String getEditorId(IEditorInput input, Object element) { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
134 |
if (input instanceof IFileEditorInput) { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
135 |
IFile file; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
136 |
if (element instanceof IFile) { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
137 |
file = (IFile) element; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
138 |
} else if (element instanceof IBreakpoint) { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
139 |
IBreakpoint breakpoint = (IBreakpoint) element; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
140 |
IResource resource = breakpoint.getMarker().getResource(); |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
141 |
// Can the breakpoint resource be folder or project? Better |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
142 |
// check for it. |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
143 |
if (resource instanceof IFile == false) { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
144 |
return null; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
145 |
} |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
146 |
file = (IFile) resource; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
147 |
} else { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
148 |
return null; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
149 |
} |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
150 |
|
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
151 |
// Pick the editor based on the file extension, taking user |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
152 |
// preferences into account. |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
153 |
try { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
154 |
return IDE.getEditorDescriptor(file).getId(); |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
155 |
} catch (PartInitException e) { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
156 |
// TODO(peter.rybin): should it really be the default case? |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
157 |
// There might be no virtual project. |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
158 |
return null; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
159 |
} |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
160 |
} else { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
161 |
if (element instanceof IStorage) { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
162 |
IStorage store = (IStorage) element; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
163 |
if (JavaScriptCore.isJavaScriptLikeFileName(store.getName())) { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
164 |
return JavaScriptUI.ID_CU_EDITOR; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
165 |
} else { |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
166 |
return "org.eclipse.wst.html.core.htmlsource.source"; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
167 |
} |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
168 |
} |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
169 |
} |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
170 |
return null; |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
171 |
} |
06589bf52fa7
Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
172 |
} |