List of usage examples for javafx.scene.input Clipboard getSystemClipboard
public static Clipboard getSystemClipboard()
From source file:com.bekwam.mavenpomupdater.MenuBarDelegate.java
public void showingEditMenu() { if (log.isDebugEnabled()) { log.debug("[SHOWING EDIT MENU]"); }/*from w w w. j av a2 s . co m*/ // // Controls the enabling and disabling of edit menu items by consulting // the clipboard prior to showing the menu // if (systemClipboard == null) { systemClipboard = Clipboard.getSystemClipboard(); } if (systemClipboard.hasString()) { if (log.isDebugEnabled()) { log.debug("[SHOWING EDIT MENU] there is content in clipboard"); } adjustForClipboardContents(); } else { if (log.isDebugEnabled()) { log.debug("[SHOWING EDIT MENU] there is NO content in clipboard"); } adjustForEmptyClipboard(); } if (anythingSelected()) { if (log.isDebugEnabled()) { log.debug("[SHOWING EDIT MENU] there is a selection"); } adjustForSelection(); } else { if (log.isDebugEnabled()) { log.debug("[SHOWING EDIT MENU] there is a DE-selection"); } adjustForDeselection(); } }
From source file:org.pdfsam.ui.dashboard.about.AboutDashboardPaneTest.java
@Test public void clickCopy() throws Exception { FXTestUtils.invokeAndWait(() -> { Clipboard.getSystemClipboard().clear(); assertTrue(isBlank(Clipboard.getSystemClipboard().getString())); }, 2);// w w w . ja va2 s .co m click("#copyEnvDetails"); FXTestUtils.invokeAndWait(() -> assertTrue(Clipboard.getSystemClipboard().getString().contains("PDFsam")), 1); }
From source file:bear.main.FXConf.java
public String pasteFromClipboard() { return Clipboard.getSystemClipboard().getString(); }
From source file:de.ks.idnadrev.information.chart.ChartDataEditor.java
private TextField createCategoryEditor(ChartRow chartRow, int rowNum) { TextField categoryEditor = new TextField(); categoryEditor.textProperty().bindBidirectional(chartRow.getCategory()); categoryEditor.focusedProperty().addListener(getEditorFocusListener(rowNum, categoryEditor)); categoryEditor.textProperty().addListener((p, o, n) -> { categoryEditor.setUserData(true); });/*from w w w . ja va2 s .co m*/ BiFunction<Integer, Integer, TextField> nextCategoryField = (row, column) -> { if (categoryEditors.size() > row) { return categoryEditors.get(row); } else { return null; } }; BiConsumer<Integer, Integer> clipBoardHandler = (row, col) -> { String string = Clipboard.getSystemClipboard().getString(); if (StringUtils.containsWhitespace(string)) { List<String> datas = Arrays.asList(StringUtils.split(string, "\n")); int missingRows = (row + datas.size()) - rows.size(); if (missingRows > 0) { for (int i = 0; i < missingRows; i++) { rows.add(new ChartRow()); } } for (int i = row; i < row + datas.size(); i++) { ChartRow currentChartRow = rows.get(i); String data = datas.get(i - row); currentChartRow.setCategory(data); } } }; categoryEditor.setOnKeyReleased(getInputKeyHandler(rowNum, -1, nextCategoryField, clipBoardHandler)); validationRegistry.registerValidator(categoryEditor, (control, value) -> { if (value != null) { Set<String> values = categoryEditors.stream()// .filter(e -> e != categoryEditor)// .map(e -> e.textProperty().getValueSafe())// .filter(v -> !v.isEmpty())// .collect(Collectors.toSet()); if (values.contains(value)) { ValidationMessage message = new ValidationMessage("validation.noDuplicates", control, value); return ValidationResult.fromMessages(message); } } return null; }); categoryEditors.add(categoryEditor); return categoryEditor; }
From source file:bear.main.FXConf.java
public void copyToClipboard(String text) { HashMap<DataFormat, Object> map = new HashMap<DataFormat, Object>(); map.put(DataFormat.PLAIN_TEXT, text); Clipboard.getSystemClipboard().setContent(map); }
From source file:com.cdd.bao.editor.endpoint.BrowseEndpoint.java
public void actionCopy() { Branch branch = currentBranchValue(); if (branch == null || branch.assay == null) return;//from w ww. ja va 2 s . co m JSONObject json = ClipboardSchema.composeAssay(branch.assay); String serial = null; try { serial = json.toString(2); } catch (JSONException ex) { return; } ClipboardContent content = new ClipboardContent(); content.putString(serial); if (!Clipboard.getSystemClipboard().setContent(content)) { Util.informWarning("Clipboard Copy", "Unable to copy to the clipboard."); return; } }
From source file:io.bitsquare.common.util.Utilities.java
public static void copyToClipboard(String content) { try {// w w w . j av a2 s . c om if (content != null && content.length() > 0) { Clipboard clipboard = Clipboard.getSystemClipboard(); ClipboardContent clipboardContent = new ClipboardContent(); clipboardContent.putString(content); clipboard.setContent(clipboardContent); } } catch (Throwable e) { log.error("copyToClipboard failed " + e.getMessage()); e.printStackTrace(); } }
From source file:com.ggvaidya.scinames.complexquery.ComplexQueryViewController.java
@FXML private void copyToClipboard(ActionEvent evt) { try {/*from w ww.j av a 2s.c o m*/ StringWriter writer = new StringWriter(); List<List<String>> dataAsTable = getDataAsTable(); fillCSVFormat(CSVFormat.TDF, writer, getDataAsTable()); Clipboard clipboard = Clipboard.getSystemClipboard(); HashMap<DataFormat, Object> content = new HashMap<>(); content.put(DataFormat.PLAIN_TEXT, writer.getBuffer().toString()); clipboard.setContent(content); Alert window = new Alert(Alert.AlertType.CONFIRMATION, (dataAsTable.get(0).size() - 1) + " rows written to clipboard."); window.showAndWait(); } catch (IOException e) { Alert window = new Alert(Alert.AlertType.ERROR, "Could not save CSV to the clipboard: " + e); window.showAndWait(); } }
From source file:Main.java
@Override public void start(Stage stage) { stage.setTitle("Menu Sample"); Scene scene = new Scene(new VBox(), 400, 350); scene.setFill(Color.OLDLACE); name.setFont(new Font("Verdana Bold", 22)); binName.setFont(new Font("Arial Italic", 10)); pic.setFitHeight(150);//from www . j a v a2 s. co m pic.setPreserveRatio(true); description.setWrapText(true); description.setTextAlignment(TextAlignment.JUSTIFY); shuffle(); MenuBar menuBar = new MenuBar(); // --- Graphical elements final VBox vbox = new VBox(); vbox.setAlignment(Pos.CENTER); vbox.setSpacing(10); vbox.setPadding(new Insets(0, 10, 0, 10)); vbox.getChildren().addAll(name, binName, pic, description); // --- Menu File Menu menuFile = new Menu("File"); MenuItem add = new MenuItem("Shuffle", new ImageView(new Image("src/menusample/new.png"))); add.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent t) { shuffle(); vbox.setVisible(true); } }); MenuItem clear = new MenuItem("Clear"); clear.setAccelerator(KeyCombination.keyCombination("Ctrl+X")); clear.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent t) { vbox.setVisible(false); } }); MenuItem exit = new MenuItem("Exit"); exit.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent t) { System.exit(0); } }); menuFile.getItems().addAll(add, clear, new SeparatorMenuItem(), exit); // --- Menu Edit Menu menuEdit = new Menu("Edit"); Menu menuEffect = new Menu("Picture Effect"); final ToggleGroup groupEffect = new ToggleGroup(); for (Entry effect : effects) { RadioMenuItem itemEffect = new RadioMenuItem((String) effect.getKey()); itemEffect.setUserData(effect.getValue()); itemEffect.setToggleGroup(groupEffect); menuEffect.getItems().add(itemEffect); } final MenuItem noEffects = new MenuItem("No Effects"); noEffects.setDisable(true); noEffects.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent t) { pic.setEffect(null); groupEffect.getSelectedToggle().setSelected(false); noEffects.setDisable(true); } }); groupEffect.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { public void changed(ObservableValue ov, Toggle old_toggle, Toggle new_toggle) { if (groupEffect.getSelectedToggle() != null) { Effect effect = (Effect) groupEffect.getSelectedToggle().getUserData(); pic.setEffect(effect); noEffects.setDisable(false); } else { noEffects.setDisable(true); } } }); menuEdit.getItems().addAll(menuEffect, noEffects); // --- Menu View Menu menuView = new Menu("View"); CheckMenuItem titleView = createMenuItem("Title", name); CheckMenuItem binNameView = createMenuItem("Binomial name", binName); CheckMenuItem picView = createMenuItem("Picture", pic); CheckMenuItem descriptionView = createMenuItem("Decsription", description); menuView.getItems().addAll(titleView, binNameView, picView, descriptionView); menuBar.getMenus().addAll(menuFile, menuEdit, menuView); // --- Context Menu final ContextMenu cm = new ContextMenu(); MenuItem cmItem1 = new MenuItem("Copy Image"); cmItem1.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent e) { Clipboard clipboard = Clipboard.getSystemClipboard(); ClipboardContent content = new ClipboardContent(); content.putImage(pic.getImage()); clipboard.setContent(content); } }); cm.getItems().add(cmItem1); pic.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { if (e.getButton() == MouseButton.SECONDARY) cm.show(pic, e.getScreenX(), e.getScreenY()); } }); ((VBox) scene.getRoot()).getChildren().addAll(menuBar, vbox); stage.setScene(scene); stage.show(); }
From source file:de.ks.idnadrev.information.chart.ChartDataEditor.java
protected TextField createValueEditor(ChartRow chartRow, int rowNum, int column) { TextField editor = new TextField(); valueEditors.put(rowNum, column, editor); validationRegistry.registerValidator(editor, new DoubleValidator()); dataContainer.add(editor, column + COLUMN_OFFSET, rowNum + ROW_OFFSET); editor.focusedProperty().addListener(getEditorFocusListener(rowNum, editor)); editor.textProperty().addListener((p, o, n) -> { editor.setUserData(true);//from w ww .j ava 2s . co m }); BiFunction<Integer, Integer, TextField> nextTextField = (row, col) -> valueEditors.row(row).get(col); BiConsumer<Integer, Integer> clipBoardHandler = (row, col) -> { String string = Clipboard.getSystemClipboard().getString(); if (StringUtils.containsWhitespace(string)) { List<String> datas = Arrays.asList(StringUtils.split(string)); int missingRows = (row + datas.size()) - rows.size(); if (missingRows > 0) { for (int i = 0; i < missingRows; i++) { rows.add(new ChartRow()); } } for (int i = row; i < row + datas.size(); i++) { ChartRow currentChartRow = rows.get(i); String data = datas.get(i - row); currentChartRow.setValue(column, data); } } }; editor.setOnKeyReleased(getInputKeyHandler(rowNum, column, nextTextField, clipBoardHandler)); return editor; }