21
21
// USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
package phasereditor .chains .ui .views ;
23
23
24
+ import java .io .IOException ;
25
+ import java .nio .file .Files ;
24
26
import java .nio .file .Path ;
25
27
import java .util .List ;
26
28
27
- import org .eclipse .core .filesystem .EFS ;
28
- import org .eclipse .core .filesystem .IFileStore ;
29
29
import org .eclipse .core .runtime .CoreException ;
30
30
import org .eclipse .core .runtime .IProgressMonitor ;
31
31
import org .eclipse .core .runtime .IStatus ;
72
72
import org .eclipse .swt .widgets .TableColumn ;
73
73
import org .eclipse .swt .widgets .Text ;
74
74
import org .eclipse .ui .IWorkbenchPage ;
75
- import org .eclipse .ui .ide .FileStoreEditorInput ;
76
75
import org .eclipse .ui .part .ViewPart ;
77
76
import org .eclipse .wb .swt .SWTResourceManager ;
78
77
import org .eclipse .wst .jsdt .internal .ui .javaeditor .CompilationUnitEditor ;
91
90
import phasereditor .ui .EditorSharedImages ;
92
91
import phasereditor .ui .IEditorSharedImages ;
93
92
import phasereditor .ui .WebkitBrowser ;
93
+ import phasereditor .ui .editors .StringEditorInput ;
94
94
95
95
@ SuppressWarnings ("restriction" )
96
96
public class ChainsView extends ViewPart {
97
-
98
97
protected Text _queryText ;
99
98
private TableViewer _chainsViewer ;
100
99
protected ChainsModel _chainsModel ;
@@ -171,6 +170,7 @@ public void update(ViewerCell cell) {
171
170
}
172
171
173
172
class ExamplesLineLabelProvider extends StyledCellLabelProvider {
173
+
174
174
private Font _font ;
175
175
private Font _italic ;
176
176
@@ -418,12 +418,17 @@ private void openJSEditor(int linenum, int offset, Path filePath) {
418
418
419
419
String editorId = "org.eclipse.wst.jsdt.ui.CompilationUnitEditor" ;
420
420
421
- IFileStore store = EFS .getStore (filePath .toUri ());
422
- FileStoreEditorInput input = new FileStoreEditorInput (store );
421
+ byte [] bytes = Files .readAllBytes (filePath );
423
422
424
423
IWorkbenchPage activePage = getViewSite ().getWorkbenchWindow ().getActivePage ();
425
424
425
+ StringEditorInput input = new StringEditorInput (filePath .getFileName ().toString (), new String (bytes ));
426
426
CompilationUnitEditor editor = (CompilationUnitEditor ) activePage .openEditor (input , editorId );
427
+ try {
428
+ editor .updatedTitleImage (EditorSharedImages .getImage (IEditorSharedImages .IMG_JCU_OBJ ));
429
+ } catch (Exception e ) {
430
+ // ignore it
431
+ }
427
432
ISourceViewer viewer = editor .getViewer ();
428
433
StyledText textWidget = viewer .getTextWidget ();
429
434
textWidget .setEditable (false );
@@ -440,7 +445,7 @@ private void openJSEditor(int linenum, int offset, Path filePath) {
440
445
e .printStackTrace ();
441
446
}
442
447
443
- } catch (CoreException e ) {
448
+ } catch (CoreException | IOException e ) {
444
449
throw new RuntimeException (e );
445
450
}
446
451
}
0 commit comments