Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2015-02-13 15:04:34 +0000
committerTom Schindl2015-02-13 15:04:34 +0000
commit7a3769cdaa293fe151480c0cd92e6e70fca01528 (patch)
tree2ed838177ca4cfcb865494a201751c0df1350af0
parent754de0a3969032f0716aebecf9540233f01eb48c (diff)
downloadorg.eclipse.efxclipse-7a3769cdaa293fe151480c0cd92e6e70fca01528.tar.gz
org.eclipse.efxclipse-7a3769cdaa293fe151480c0cd92e6e70fca01528.tar.xz
org.eclipse.efxclipse-7a3769cdaa293fe151480c0cd92e6e70fca01528.zip
Bug 459868 - Add sample for syntax highlighting
-rw-r--r--demos/CodeEditor/src/application/Main.java39
1 files changed, 17 insertions, 22 deletions
diff --git a/demos/CodeEditor/src/application/Main.java b/demos/CodeEditor/src/application/Main.java
index 8b9f7ca21..0a7f72e1c 100644
--- a/demos/CodeEditor/src/application/Main.java
+++ b/demos/CodeEditor/src/application/Main.java
@@ -43,12 +43,12 @@ public class Main extends Application {
MenuItem item = new MenuItem("Open ...");
m.getItems().add(item);
b.getMenus().add(m);
-
+
{
Menu themes = new Menu("Themes");
-
+
ToggleGroup g = new ToggleGroup();
-
+
RadioMenuItem defaultTheme = new RadioMenuItem("Default");
defaultTheme.setSelected(true);
defaultTheme.setOnAction(e -> {
@@ -58,7 +58,7 @@ public class Main extends Application {
scene.getStylesheets().add(Main.class.getResource("highlight.css").toExternalForm());
});
-
+
RadioMenuItem dark = new RadioMenuItem("Dark");
dark.setOnAction(e -> {
Scene scene = primaryStage.getScene();
@@ -67,36 +67,36 @@ public class Main extends Application {
scene.getStylesheets().add(Main.class.getResource("dark-highlight.css").toExternalForm());
});
- themes.getItems().addAll(defaultTheme,dark);
-
+ themes.getItems().addAll(defaultTheme, dark);
+
m.getItems().add(themes);
- g.getToggles().addAll(defaultTheme,dark);
+ g.getToggles().addAll(defaultTheme, dark);
}
-
+
root.setTop(b);
-
+
TabPane tabPane = new TabPane();
root.setCenter(tabPane);
-
+
m.setOnAction(e -> {
FileChooser c = new FileChooser();
c.getExtensionFilters().add(new ExtensionFilter("Java Source Files", Collections.singletonList("*.java")));
c.setSelectedExtensionFilter(c.getExtensionFilters().get(0));
List<File> showOpenMultipleDialog = c.showOpenMultipleDialog(primaryStage);
- if( showOpenMultipleDialog != null ) {
- for( File f : showOpenMultipleDialog ) {
+ if (showOpenMultipleDialog != null) {
+ for (File f : showOpenMultipleDialog) {
Path path = Paths.get(f.toURI());
Tab t = new Tab(path.getFileName().toString());
t.setContent(createViewer(path).getTextWidget());
tabPane.getTabs().add(t);
- }
+ }
}
});
Scene scene = new Scene(root, 400, 400);
scene.getStylesheets().add(getClass().getResource("default.css").toExternalForm());
scene.getStylesheets().add(Main.class.getResource("highlight.css").toExternalForm());
-
+
primaryStage.setScene(scene);
primaryStage.show();
}
@@ -107,12 +107,8 @@ public class Main extends Application {
Document document = createDocument(p);
IDocumentPartitioner partitioner = createPartitioner();
- if (document instanceof IDocumentExtension3) {
- ((IDocumentExtension3) document).setDocumentPartitioner(
- configuration.getConfiguredDocumentPartitioning(viewer), partitioner);
- } else {
- document.setDocumentPartitioner(partitioner);
- }
+ document.setDocumentPartitioner(configuration.getConfiguredDocumentPartitioning(viewer), partitioner);
+
document.setDocumentPartitioner(partitioner);
partitioner.connect(document);
@@ -141,8 +137,7 @@ public class Main extends Application {
StringBuilder b = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
- // FIXME We need to replace TABs for now
- b.append(line.replaceAll("\t", " ") + "\n");
+ b.append(line + "\n");
}
reader.close();
return b.toString();

Back to the top