当前位置: 首页>>代码示例>>Java>>正文


Java CodeArea.replaceText方法代码示例

本文整理汇总了Java中org.fxmisc.richtext.CodeArea.replaceText方法的典型用法代码示例。如果您正苦于以下问题:Java CodeArea.replaceText方法的具体用法?Java CodeArea.replaceText怎么用?Java CodeArea.replaceText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.fxmisc.richtext.CodeArea的用法示例。


在下文中一共展示了CodeArea.replaceText方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fillCodeArea

import org.fxmisc.richtext.CodeArea; //导入方法依赖的package包/类
protected void fillCodeArea(CodeArea area, String fileName) throws IOException {
    area.richChanges()
            .filter(ch -> !ch.getInserted().equals(ch.getRemoved())) // XXX
            .subscribe(change -> {
                        area.setStyleSpans(
                                0,
                                HighlightProvider.computeHighlighting(
                                        area.getText(),
                                        HighlightProvider.resolvePattern(fileName)
                                )
                        );
                    }
            );

    area.replaceText(0, 0, new String(
                    Files.readAllBytes((new File(fileName)).toPath()),
                    "UTF-8"
            )
    );

}
 
开发者ID:iazarny,项目名称:gitember,代码行数:22,代码来源:BaseFileViewController.java

示例2: setupEditorArea

import org.fxmisc.richtext.CodeArea; //导入方法依赖的package包/类
private CodeArea setupEditorArea(String formattedJson, Dialog<String> dialog, int cursorPosition) {
  URL url = getClass().getResource("/ui/Editor.fxml");
  final FXMLLoader loader = createLoader(url);
  BorderPane root = load(url, loader);
  EditorController editorController = loader.getController();
  CodeArea codeArea = editorController.getCodeArea();
  codeArea.setPrefSize(500, 400);
  codeArea.replaceText(formattedJson);
  codeArea.getUndoManager().forgetHistory();

  // stackpane is workaround https://github.com/TomasMikula/RichTextFX/issues/196
  dialog.getDialogPane().setContent(new StackPane(root));
  Platform.runLater(() -> {
    codeArea.selectRange(cursorPosition, cursorPosition);
    codeArea.requestFocus();
  });
  return codeArea;
}
 
开发者ID:daa84,项目名称:mongofx,代码行数:19,代码来源:UIBuilder.java

示例3: start

import org.fxmisc.richtext.CodeArea; //导入方法依赖的package包/类
@Override
  public void start(Stage primaryStage) {
      CodeArea codeArea = new CodeArea();
      codeArea.setParagraphGraphicFactory(LineNumberFactory.get(codeArea));

      codeArea.textProperty().addListener((obs, oldText, newText) -> {
          codeArea.setStyleSpans(0, computeHighlighting(newText));
      });
      codeArea.replaceText(0, 0, sampleCode);

Scene scene = new Scene(new StackPane(new VirtualizedScrollPane<>(codeArea)), 600, 400);
      scene.getStylesheets().add(XMLEditor.class.getResource("xml-highlighting.css").toExternalForm());
      primaryStage.setScene(scene);
      primaryStage.setTitle("XML Editor Demo");
      primaryStage.show();
  }
 
开发者ID:FXMisc,项目名称:RichTextFX,代码行数:17,代码来源:XMLEditor.java

示例4: start

import org.fxmisc.richtext.CodeArea; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) {
    CodeArea codeArea = new CodeArea();

    IntFunction<Node> numberFactory = LineNumberFactory.get(codeArea);
    IntFunction<Node> arrowFactory = new ArrowFactory(codeArea.currentParagraphProperty());
    IntFunction<Node> graphicFactory = line -> {
        HBox hbox = new HBox(
                numberFactory.apply(line),
                arrowFactory.apply(line));
        hbox.setAlignment(Pos.CENTER_LEFT);
        return hbox;
    };
    codeArea.setParagraphGraphicFactory(graphicFactory);
    codeArea.replaceText("The green arrow will only be on the line where the caret appears.\n\nTry it.");
    codeArea.moveTo(0, 0);

    primaryStage.setScene(new Scene(new StackPane(codeArea), 600, 400));
    primaryStage.show();
}
 
开发者ID:FXMisc,项目名称:RichTextFX,代码行数:21,代码来源:LineIndicatorDemo.java

示例5: start

import org.fxmisc.richtext.CodeArea; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) {
    CodeArea codeArea = new CodeArea();
    codeArea.setParagraphGraphicFactory(LineNumberFactory.get(codeArea));

    codeArea.richChanges()
            .filter(ch -> !ch.getInserted().equals(ch.getRemoved())) // XXX
            .subscribe(change -> {
                codeArea.setStyleSpans(0, computeHighlighting(codeArea.getText()));
            });
    codeArea.replaceText(0, 0, sampleCode);

    Scene scene = new Scene(new StackPane(new VirtualizedScrollPane<>(codeArea)), 600, 400);
    scene.getStylesheets().add(JavaKeywordsAsync.class.getResource("java-keywords.css").toExternalForm());
    primaryStage.setScene(scene);
    primaryStage.setTitle("Java Keywords Demo");
    primaryStage.show();
}
 
开发者ID:FXMisc,项目名称:RichTextFX,代码行数:19,代码来源:JavaKeywords.java

示例6: setContent

import org.fxmisc.richtext.CodeArea; //导入方法依赖的package包/类
public void setContent(String content) {
	SimpleTextView currentPageView = this.view.getCurrentPageView();
	if (currentPageView != null) {
		CodeArea codeArea = currentPageView.getCodeArea();
		codeArea.getUndoManager().mark();
		codeArea.clear();
		codeArea.replaceText(0, 0, content);
		codeArea.getUndoManager().mark();
	}

}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:12,代码来源:PagedCodeAreaFindAndReplaceHelper.java

示例7: initialize

import org.fxmisc.richtext.CodeArea; //导入方法依赖的package包/类
@Override
    public void initialize(URL location, ResourceBundle resources) {
        executor = Executors.newSingleThreadExecutor();
        codeArea = new CodeArea();
        codeArea.setParagraphGraphicFactory(LineNumberFactory.get(codeArea));
        OkButton.disableProperty().bind(Val.map(codeArea.lengthProperty(), n -> n == 0));
        EventStream<?> richChanges = codeArea.richChanges();
        richChanges
                .successionEnds(Duration.ofMillis(500))
                .supplyTask(this::computeHighlightingAsync)
                .awaitLatest(richChanges)
                .filterMap(t -> {
                    if (t.isSuccess()) {
                        return Optional.of(t.get());
                    } else {
                        t.getFailure().printStackTrace();
                        return Optional.empty();
                    }
                })
                .subscribe(this::applyHighlighting);
        codeArea.replaceText(0, 0, getSampleCode());
        borderPane.setCenter(codeArea);
        borderPane.getStylesheets().add(getClass().getResource("/styles/JavaKeywords.css").toExternalForm());
        JdkFolderLocation.setOnMouseClicked((event) -> {
            if (event.getClickCount() == 2) {
                DirectoryChooser directoryChooser = new DirectoryChooser();
                directoryChooser.setTitle("Select JDK installation folder");
                File file = new File("C:\\Program Files\\Java");
                if (file.isDirectory()) { //check if it exists and a folder
                    directoryChooser.setInitialDirectory(file);
                }
                File directory = directoryChooser.showDialog(primaryStage);
                if (directory != null) {
                    JdkFolderLocation.setText(directory.getAbsolutePath());
                }
            }
        });
//        borderPane.setCenter(new VirtualizedScrollPane<>(codeArea));
    }
 
开发者ID:EMostafaAli,项目名称:HlaListener,代码行数:40,代码来源:ScriptWindowController.java

示例8: start

import org.fxmisc.richtext.CodeArea; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) {
    executor = Executors.newSingleThreadExecutor();
    codeArea = new CodeArea();
    codeArea.setParagraphGraphicFactory(LineNumberFactory.get(codeArea));
    codeArea.richChanges()
            .filter(ch -> !ch.getInserted().equals(ch.getRemoved())) // XXX
            .successionEnds(Duration.ofMillis(500))
            .supplyTask(this::computeHighlightingAsync)
            .awaitLatest(codeArea.richChanges())
            .filterMap(t -> {
                if(t.isSuccess()) {
                    return Optional.of(t.get());
                } else {
                    t.getFailure().printStackTrace();
                    return Optional.empty();
                }
            })
            .subscribe(this::applyHighlighting);
    codeArea.replaceText(0, 0, sampleCode);

    Scene scene = new Scene(new StackPane(new VirtualizedScrollPane<>(codeArea)), 600, 400);
    scene.getStylesheets().add(JavaKeywordsAsync.class.getResource("java-keywords.css").toExternalForm());
    primaryStage.setScene(scene);
    primaryStage.setTitle("Java Keywords Async Demo");
    primaryStage.show();
}
 
开发者ID:FXMisc,项目名称:RichTextFX,代码行数:28,代码来源:JavaKeywordsAsync.java

示例9: createResourceView

import org.fxmisc.richtext.CodeArea; //导入方法依赖的package包/类
@Override
public ResourceView<Map<String, Object>> createResourceView() {
	ConnectionSupplier connectionSupplier = getConnectionSupplier();

	MssqlTableOpenResourceView tableOpenResourceView = new MssqlTableOpenResourceView(connectionSupplier, new Stage()) {

		/*
		 * (non-Javadoc)
		 * 
		 * @see
		 * com.kyj.fx.voeditor.visual.component.popup.TableOpenResourceView#
		 * close()
		 */
		@Override
		public void close() {
			CodeArea codeArea = getCodeArea();
			codeArea.getPopupWindow().hide();

			ResultDialog<Map<String, Object>> result = getResult();

			if (result.getStatus() == ResultDialog.SELECT) {
				Map<String, Object> data = result.getData();
				if (data == null)
					return;

				String tableName = getTableName(data);
				if (tableName == null)
					return;
				
				Object _tbCat = data.get("TABLE_CAT");
				if(ValueUtil.isNotEmpty(_tbCat))
				{
					tableName = String.format("%s.%s", _tbCat.toString(), tableName);
				}
				
				// Object object = data.get("table_name");
				// if (object == null)
				// return;

				String string = currentPragraph(codeArea);
				int markTextColumnIndex = getIndexOfValideWhiteSpace(string);

				if (markTextColumnIndex == -1) {
					codeArea.getUndoManager().mark();
					codeArea.appendText(tableName);
				} else {

					int anchor = codeArea.getAnchor();
					int start = anchor - string.length() + markTextColumnIndex;

					IndexRange normalize = IndexRange.normalize(start, anchor);
					codeArea.getUndoManager().mark();
					codeArea.replaceText(normalize, tableName);
				}
			}

		}

	};

	return tableOpenResourceView.getView();
}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:63,代码来源:MssqlASTSqlCodeAreaHelper.java


注:本文中的org.fxmisc.richtext.CodeArea.replaceText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。