List of usage examples for javafx.scene.control MenuItem MenuItem
public MenuItem(String text)
From source file:org.sleuthkit.autopsy.imageanalyzer.gui.GroupPane.java
/** * called automatically during constructor by FXMLConstructor. * * checks that FXML loading went ok and performs additional setup *//*from w w w . j a va 2 s. com*/ @FXML void initialize() { assert gridView != null : "fx:id=\"tilePane\" was not injected: check your FXML file 'GroupPane.fxml'."; assert grpCatSplitMenu != null : "fx:id=\"grpCatSplitMenu\" was not injected: check your FXML file 'GroupHeader.fxml'."; assert grpTagSplitMenu != null : "fx:id=\"grpTagSplitMenu\" was not injected: check your FXML file 'GroupHeader.fxml'."; assert headerToolBar != null : "fx:id=\"headerToolBar\" was not injected: check your FXML file 'GroupHeader.fxml'."; assert segButton != null : "fx:id=\"previewList\" was not injected: check your FXML file 'GroupHeader.fxml'."; assert slideShowToggle != null : "fx:id=\"segButton\" was not injected: check your FXML file 'GroupHeader.fxml'."; assert tileToggle != null : "fx:id=\"tileToggle\" was not injected: check your FXML file 'GroupHeader.fxml'."; grouping.addListener(new InvalidationListener() { private void updateFiles() { final ObservableList<Long> fileIds = grouping.get().fileIds(); Platform.runLater(() -> { gridView.setItems(FXCollections.observableArrayList(fileIds)); }); resetHeaderString(); } @Override public void invalidated(Observable o) { getScrollBar().ifPresent((scrollBar) -> { scrollBar.setValue(0); }); //set the embeded header resetHeaderString(); //and assign fileIDs to gridView if (grouping.get() == null) { Platform.runLater(gridView.getItems()::clear); } else { grouping.get().fileIds().addListener((Observable observable) -> { updateFiles(); }); updateFiles(); } } }); //configure flashing glow animation on next unseen group button flashAnimation.setCycleCount(Timeline.INDEFINITE); flashAnimation.setAutoReverse(true); //configure gridView cell properties gridView.cellHeightProperty().bind(Toolbar.getDefault().sizeSliderValue().add(75)); gridView.cellWidthProperty().bind(Toolbar.getDefault().sizeSliderValue().add(75)); gridView.setCellFactory((GridView<Long> param) -> new DrawableCell()); //configure toolbar properties HBox.setHgrow(spacer, Priority.ALWAYS); spacer.setMinWidth(Region.USE_PREF_SIZE); ArrayList<MenuItem> grpTagMenues = new ArrayList<>(); for (final TagName tn : TagUtils.getNonCategoryTagNames()) { MenuItem menuItem = createGrpTagMenuItem(tn); grpTagMenues.add(menuItem); } try { grpTagSplitMenu.setText(TagUtils.getFollowUpTagName().getDisplayName()); grpTagSplitMenu.setOnAction(createGrpTagMenuItem(TagUtils.getFollowUpTagName()).getOnAction()); } catch (TskCoreException tskCoreException) { LOGGER.log(Level.WARNING, "failed to load FollowUpTagName", tskCoreException); } grpTagSplitMenu.setGraphic(new ImageView(DrawableAttribute.TAGS.getIcon())); grpTagSplitMenu.getItems().setAll(grpTagMenues); ArrayList<MenuItem> grpCategoryMenues = new ArrayList<>(); for (final Category cat : Category.values()) { MenuItem menuItem = createGrpCatMenuItem(cat); grpCategoryMenues.add(menuItem); } grpCatSplitMenu.setText(Category.FIVE.getDisplayName()); grpCatSplitMenu.setGraphic(new ImageView(DrawableAttribute.CATEGORY.getIcon())); grpCatSplitMenu.getItems().setAll(grpCategoryMenues); grpCatSplitMenu.setOnAction(createGrpCatMenuItem(Category.FIVE).getOnAction()); Runnable syncMode = () -> { switch (groupViewMode.get()) { case SLIDE_SHOW: slideShowToggle.setSelected(true); break; case TILE: tileToggle.setSelected(true); break; } }; syncMode.run(); //make togle states match view state groupViewMode.addListener((o) -> { syncMode.run(); }); slideShowToggle.toggleGroupProperty().addListener((o) -> { slideShowToggle.getToggleGroup().selectedToggleProperty() .addListener((observable, oldToggle, newToggle) -> { if (newToggle == null) { oldToggle.setSelected(true); } }); }); //listen to toggles and update view state slideShowToggle.setOnAction((ActionEvent t) -> { activateSlideShowViewer(globalSelectionModel.lastSelectedProperty().get()); }); tileToggle.setOnAction((ActionEvent t) -> { activateTileViewer(); }); controller.viewState().addListener((ObservableValue<? extends GroupViewState> observable, GroupViewState oldValue, GroupViewState newValue) -> { setViewState(newValue); }); addEventFilter(KeyEvent.KEY_PRESSED, tileKeyboardNavigationHandler); gridView.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() { private ContextMenu buildContextMenu() { ArrayList<MenuItem> menuItems = new ArrayList<>(); menuItems.add(CategorizeAction.getPopupMenu()); menuItems.add(AddDrawableTagAction.getInstance().getPopupMenu()); Collection<? extends ContextMenuActionsProvider> menuProviders = Lookup.getDefault() .lookupAll(ContextMenuActionsProvider.class); for (ContextMenuActionsProvider provider : menuProviders) { for (final Action act : provider.getActions()) { if (act instanceof Presenter.Popup) { Presenter.Popup aact = (Presenter.Popup) act; menuItems.add(SwingMenuItemAdapter.create(aact.getPopupPresenter())); } } } final MenuItem extractMenuItem = new MenuItem("Extract File(s)"); extractMenuItem.setOnAction((ActionEvent t) -> { SwingUtilities.invokeLater(() -> { TopComponent etc = WindowManager.getDefault() .findTopComponent(ImageAnalyzerTopComponent.PREFERRED_ID); ExtractAction.getInstance().actionPerformed(new java.awt.event.ActionEvent(etc, 0, null)); }); }); menuItems.add(extractMenuItem); ContextMenu contextMenu = new ContextMenu(menuItems.toArray(new MenuItem[] {})); contextMenu.setAutoHide(true); return contextMenu; } @Override public void handle(MouseEvent t) { switch (t.getButton()) { case PRIMARY: if (t.getClickCount() == 1) { globalSelectionModel.clearSelection(); if (contextMenu != null) { contextMenu.hide(); } } t.consume(); break; case SECONDARY: if (t.getClickCount() == 1) { selectAllFiles(); } if (contextMenu == null) { contextMenu = buildContextMenu(); } contextMenu.hide(); contextMenu.show(GroupPane.this, t.getScreenX(), t.getScreenY()); t.consume(); break; } } }); // Platform.runLater(() -> { ActionUtils.configureButton(nextGroupAction, nextButton); final EventHandler<ActionEvent> onAction = nextButton.getOnAction(); nextButton.setOnAction((ActionEvent event) -> { flashAnimation.stop(); nextButton.setEffect(null); onAction.handle(event); }); ActionUtils.configureButton(forwardAction, forwardButton); ActionUtils.configureButton(backAction, backButton); // }); nextGroupAction.disabledProperty().addListener( (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> { nextButton.setEffect(newValue ? null : DROP_SHADOW); if (newValue == false) { flashAnimation.play(); } else { flashAnimation.stop(); } }); //listen to tile selection and make sure it is visible in scroll area //TODO: make sure we are testing complete visability not just bounds intersection globalSelectionModel.lastSelectedProperty().addListener((observable, oldFileID, newFileId) -> { if (groupViewMode.get() == GroupViewMode.SLIDE_SHOW) { slideShowPane.setFile(newFileId); } else { scrollToFileID(newFileId); } }); setViewState(controller.viewState().get()); }
From source file:com.chart.SwingChart.java
/** * /* w ww . j a va2s. c o m*/ * @param name Chart name * @param parent Skeleton parent * @param axes Configuration of axes * @param abcissaName Abcissa name */ public SwingChart(String name, final Skeleton parent, List<AxisChart> axes, String abcissaName) { this.skeleton = parent; this.axes = axes; this.name = name; this.abcissaFormat = NumberFormat.getInstance(Locale.getDefault()); this.ordinateFormat = NumberFormat.getInstance(Locale.getDefault()); plot = new XYPlot(); plot.setBackgroundPaint(scene2awtColor(javafx.scene.paint.Color.web(strChartBackgroundColor))); plot.setDomainGridlinePaint(scene2awtColor(javafx.scene.paint.Color.web(strGridlineColor))); plot.setRangeGridlinePaint(scene2awtColor(javafx.scene.paint.Color.web(strGridlineColor))); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); abcissaAxis = new NumberAxis(abcissaName); ((NumberAxis) abcissaAxis).setAutoRangeIncludesZero(false); abcissaAxis.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12)); abcissaAxis.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); abcissaAxis.setLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor))); abcissaAxis.setTickLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor))); abcissaAxis.setAutoRange(true); abcissaAxis.setLowerMargin(0.0); abcissaAxis.setUpperMargin(0.0); abcissaAxis.setTickLabelsVisible(true); abcissaAxis.setLabelFont(abcissaAxis.getLabelFont().deriveFont(fontSize)); abcissaAxis.setTickLabelFont(abcissaAxis.getLabelFont().deriveFont(fontSize)); plot.setDomainAxis(abcissaAxis); for (int i = 0; i < axes.size(); i++) { AxisChart categoria = axes.get(i); addAxis(categoria.getName()); for (int j = 0; j < categoria.configSerieList.size(); j++) { SimpleSeriesConfiguration cs = categoria.configSerieList.get(j); addSeries(categoria.getName(), cs); } } chart = new JFreeChart("", new Font("SansSerif", Font.BOLD, 16), plot, false); chart.setBackgroundPaint(scene2awtColor(javafx.scene.paint.Color.web(strBackgroundColor))); chartPanel = new ChartPanel(chart); chartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), BorderFactory.createLineBorder(scene2awtColor(javafx.scene.paint.Color.web(strBackgroundColor))))); chartPanel.getInputMap().put(KeyStroke.getKeyStroke("ESCAPE"), "escape"); chartPanel.getActionMap().put("escape", new AbstractAction() { @Override public void actionPerformed(java.awt.event.ActionEvent e) { for (int i = 0; i < plot.getDatasetCount(); i++) { XYDataset test = plot.getDataset(i); XYItemRenderer r = plot.getRenderer(i); r.removeAnnotations(); } } }); chartPanel.addChartMouseListener(cml = new ChartMouseListener() { @Override public void chartMouseClicked(ChartMouseEvent event) { } @Override public void chartMouseMoved(ChartMouseEvent event) { try { XYItemEntity xyitem = (XYItemEntity) event.getEntity(); // get clicked entity XYDataset dataset = (XYDataset) xyitem.getDataset(); // get data set double x = dataset.getXValue(xyitem.getSeriesIndex(), xyitem.getItem()); double y = dataset.getYValue(xyitem.getSeriesIndex(), xyitem.getItem()); final XYPlot plot = chart.getXYPlot(); for (int i = 0; i < plot.getDatasetCount(); i++) { XYDataset test = plot.getDataset(i); XYItemRenderer r = plot.getRenderer(i); r.removeAnnotations(); if (test == dataset) { NumberAxis ejeOrdenada = AxesList.get(i); double y_max = ejeOrdenada.getUpperBound(); double y_min = ejeOrdenada.getLowerBound(); double x_max = abcissaAxis.getUpperBound(); double x_min = abcissaAxis.getLowerBound(); double angulo; if (y > (y_max + y_min) / 2 && x > (x_max + x_min) / 2) { angulo = 3.0 * Math.PI / 4.0; } else if (y > (y_max + y_min) / 2 && x < (x_max + x_min) / 2) { angulo = 1.0 * Math.PI / 4.0; } else if (y < (y_max + y_min) / 2 && x < (x_max + x_min) / 2) { angulo = 7.0 * Math.PI / 4.0; } else { angulo = 5.0 * Math.PI / 4.0; } CircleDrawer cd = new CircleDrawer((Color) r.getSeriesPaint(xyitem.getSeriesIndex()), new BasicStroke(2.0f), null); //XYAnnotation bestBid = new XYDrawableAnnotation(dataset.getXValue(xyitem.getSeriesIndex(), xyitem.getItem()), dataset.getYValue(xyitem.getSeriesIndex(), xyitem.getItem()), 11, 11, cd); String txt = "X:" + abcissaFormat.format(x) + ", Y:" + ordinateFormat.format(y); XYPointerAnnotation anotacion = new XYPointerAnnotation(txt, dataset.getXValue(xyitem.getSeriesIndex(), xyitem.getItem()), dataset.getYValue(xyitem.getSeriesIndex(), xyitem.getItem()), angulo); anotacion.setTipRadius(10.0); anotacion.setBaseRadius(35.0); anotacion.setFont(new Font("SansSerif", Font.PLAIN, 10)); if (Long.parseLong((strChartBackgroundColor.replace("#", "")), 16) > 0xffffff / 2) { anotacion.setPaint(Color.black); anotacion.setArrowPaint(Color.black); } else { anotacion.setPaint(Color.white); anotacion.setArrowPaint(Color.white); } //bestBid.setPaint((Color) r.getSeriesPaint(xyitem.getSeriesIndex())); r.addAnnotation(anotacion); } } //LabelValorVariable.setSize(LabelValorVariable.getPreferredSize()); } catch (NullPointerException | ClassCastException ex) { } } }); chartPanel.setPopupMenu(null); chartPanel.setBackground(scene2awtColor(javafx.scene.paint.Color.web(strBackgroundColor))); SwingNode sn = new SwingNode(); sn.setContent(chartPanel); chartFrame = new VBox(); chartFrame.getChildren().addAll(sn, legendFrame); VBox.setVgrow(sn, Priority.ALWAYS); VBox.setVgrow(legendFrame, Priority.NEVER); chartFrame.getStylesheets().addAll(SwingChart.class.getResource("overlay-chart.css").toExternalForm()); legendFrame.setStyle("marco: " + strBackgroundColor + ";-fx-background-color: marco;"); MenuItem mi; mi = new MenuItem("Print"); mi.setOnAction((ActionEvent t) -> { print(chartFrame); }); contextMenuList.add(mi); sn.setOnMouseClicked((MouseEvent t) -> { if (menu != null) { menu.hide(); } if (t.getClickCount() == 2) { backgroundEdition(); } }); mi = new MenuItem("Copy to clipboard"); mi.setOnAction((ActionEvent t) -> { copyClipboard(chartFrame); }); contextMenuList.add(mi); mi = new MenuItem("Export values"); mi.setOnAction((ActionEvent t) -> { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Export to file"); fileChooser.getExtensionFilters() .addAll(new FileChooser.ExtensionFilter("Comma Separated Values", "*.csv")); Window w = null; try { w = parent.getScene().getWindow(); } catch (NullPointerException e) { } File file = fileChooser.showSaveDialog(w); if (file != null) { export(file); } }); contextMenuList.add(mi); chartFrame.setOnContextMenuRequested((ContextMenuEvent t) -> { if (menu != null) { menu.hide(); } menu = new ContextMenu(); menu.getItems().addAll(contextMenuList); menu.show(chartFrame, t.getScreenX(), t.getScreenY()); }); }
From source file:snpviewer.SnpViewer.java
@Override public void initialize(URL url, ResourceBundle rb) { labelSplitPane.setDividerPositions(); chromSplitPane.setDividerPositions(); Pane lpane = (Pane) horizontalSplit.getItems().get(0); SplitPane.setResizableWithParent(lpane, false); //mnemonics/shortcuts for menus mainMenu.useSystemMenuBarProperty().set(true); fileMenu.setMnemonicParsing(true);/* w w w . j av a 2 s. c o m*/ sampleMenu.setMnemonicParsing(true); goMenu.setMnemonicParsing(true); helpMenu.setMnemonicParsing(true); newProjectMenu.setAccelerator(new KeyCodeCombination(KeyCode.N, KeyCombination.SHORTCUT_DOWN)); loadProjectMenu.setAccelerator(new KeyCodeCombination(KeyCode.L, KeyCombination.SHORTCUT_DOWN)); addAffSampleMenu.setAccelerator( new KeyCodeCombination(KeyCode.A, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)); addUnSampleMenu.setAccelerator( new KeyCodeCombination(KeyCode.U, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)); nextChromMenu.setAccelerator(new KeyCodeCombination(KeyCode.EQUALS, KeyCombination.SHORTCUT_DOWN)); prevChromMenu.setAccelerator(new KeyCodeCombination(KeyCode.MINUS, KeyCombination.SHORTCUT_DOWN)); firstChromMenu.setAccelerator(new KeyCodeCombination(KeyCode.DIGIT1, KeyCombination.SHORTCUT_DOWN)); lastChromMenu.setAccelerator(new KeyCodeCombination(KeyCode.DIGIT0, KeyCombination.SHORTCUT_DOWN)); redrawMenu.setAccelerator(new KeyCodeCombination(KeyCode.R, KeyCombination.SHORTCUT_DOWN)); cacheChromsMenu.setAccelerator( new KeyCodeCombination(KeyCode.C, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)); saveToPngMenu.setAccelerator( new KeyCodeCombination(KeyCode.S, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)); autoFindRegions.setAccelerator(new KeyCodeCombination(KeyCode.F, KeyCombination.SHORTCUT_DOWN)); //need to disable hideSavedRegionsMenu accelerator for linux - doesn't work for check menus hideSavedRegionsMenu.setAccelerator( new KeyCodeCombination(KeyCode.H, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)); clearSavedRegionsMenu.setAccelerator( new KeyCodeCombination(KeyCode.X, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)); displaySavedsRegionsMenu.setAccelerator(new KeyCodeCombination(KeyCode.T, KeyCombination.SHORTCUT_DOWN)); outputSavedRegionsMenu.setAccelerator(new KeyCodeCombination(KeyCode.O, KeyCombination.SHORTCUT_DOWN)); removeSampleMenu.setAccelerator( new KeyCodeCombination(KeyCode.R, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)); //set radio menu item toggle group ArrayList<RadioMenuItem> callQualityRadios = new ArrayList<>( Arrays.asList(noFilteringRadio, filter99, filter95, filter90, filter85)); ToggleGroup callQualityToggle = new ToggleGroup(); for (RadioMenuItem r : callQualityRadios) { r.setToggleGroup(callQualityToggle); } noFilteringRadio.setOnAction(new EventHandler() { @Override public void handle(Event ev) { setQualityFilter(null); } }); filter99.setOnAction(new EventHandler() { @Override public void handle(Event ev) { setQualityFilter(0.01); } }); filter95.setOnAction(new EventHandler() { @Override public void handle(Event ev) { setQualityFilter(0.05); } }); filter90.setOnAction(new EventHandler() { @Override public void handle(Event ev) { setQualityFilter(0.10); } }); filter85.setOnAction(new EventHandler() { @Override public void handle(Event ev) { setQualityFilter(0.15); } }); nextChromMenu.setOnAction(new EventHandler() { @Override public void handle(Event ev) { selectNextChromosome(true); } }); prevChromMenu.setOnAction(new EventHandler() { @Override public void handle(Event ev) { selectNextChromosome(false); } }); firstChromMenu.setOnAction(new EventHandler() { @Override public void handle(Event ev) { if (!cancelButton.isDisabled()) { cancelButton.fire(); } if (!chromosomeSelector.isDisabled()) { chromosomeSelector.getSelectionModel().selectFirst(); } } }); lastChromMenu.setOnAction(new EventHandler() { @Override public void handle(Event ev) { if (!cancelButton.isDisabled()) { cancelButton.fire(); } if (!chromosomeSelector.isDisabled()) { chromosomeSelector.getSelectionModel().selectLast(); } } }); hideSavedRegionsMenu.setOnAction(new EventHandler() { @Override public void handle(Event ev) { showHideSavedRegions(); } }); colorComp.addAll(Arrays.asList(colorComponants)); //selection context menu final ContextMenu scm = new ContextMenu(); final MenuItem scmItem1 = new MenuItem("Display Flanking SNP IDs"); scmItem1.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { /* get coordinates of selection and report back * flanking snp ids and coordinates */ displayFlankingSnpIDs(dragSelectRectangle); } }); final MenuItem scmItem2 = new MenuItem("Write Selected Region to File"); scmItem2.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { Platform.runLater(new Runnable() { @Override public void run() { /* get coordinates of selection and report back * write SNPs in region to file */ writeRegionToFile(dragSelectRectangle); } }); } }); final MenuItem scmItem3 = new MenuItem("Add To Saved Regions"); scmItem3.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { /* get coordinates of selection and report back * write SNPs in region to file */ saveSelection(); } }); final MenuItem scmItem4 = new MenuItem("Show/Hide Saved Regions"); scmItem4.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { /* get coordinates of selection and report back * write SNPs in region to file */ hideSavedRegionsMenu.selectedProperty().setValue(!hideSavedRegionsMenu.isSelected()); hideSavedRegionsMenu.fire(); } }); final MenuItem scmItem5 = new MenuItem("Zoom Region"); scmItem5.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { Platform.runLater(new Runnable() { @Override public void run() { /* get coordinates of selection and report back * write SNPs in region to file */ zoomRegion(dragSelectRectangle); } }); } }); final MenuItem scmItem6 = new MenuItem("Write Saved Regions to File"); scmItem6.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { Platform.runLater(new Runnable() { @Override public void run() { /* get coordinates of selection and report back * write SNPs in region to file */ writeSavedRegionsToFile(); } }); } }); scm.getItems().add(scmItem1); scm.getItems().add(scmItem2); scm.getItems().add(scmItem3); scm.getItems().add(scmItem4); scm.getItems().add(scmItem5); scm.getItems().add(scmItem6); //overlayPane context menu ocm = new ContextMenu(); final MenuItem ocmItem1 = new MenuItem("Save Image to File"); ocmItem1.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { Platform.runLater(new Runnable() { @Override public void run() { drawPaneToPng(); } }); } }); ocm.getItems().add(ocmItem1); ocm.getItems().add(scmItem4); ocm.getItems().add(scmItem6); //color selections colorComponantSelector.getItems().clear(); colorComponantSelector.getItems().add("AA"); colorComponantSelector.getItems().add("BB"); colorComponantSelector.getItems().add("AB"); colorComponantSelector.getItems().add("Selection Outline"); colorComponantSelector.getItems().add("Selection Fill"); colorComponantSelector.getItems().add("Saved Region Outline"); colorComponantSelector.getItems().add("Saved Region Fill"); colorComponantSelector.getSelectionModel().selectFirst(); colorPicker.setValue(colorComponants[0]); colorComponantSelector.getSelectionModel().selectedIndexProperty() .addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue ov, Number value, Number new_value) { colorPicker.setValue(colorComp.get(new_value.intValue())); colorPicker.fireEvent(new ActionEvent()); } }); colorPicker.setOnAction(new EventHandler() { @Override public void handle(Event t) { if (!colorComp.get(colorComponantSelector.getSelectionModel().getSelectedIndex()) .equals(colorPicker.getValue())) { colorComp.set(colorComponantSelector.getSelectionModel().getSelectedIndex(), colorPicker.getValue()); saveProject(); //colorComponants[colorComponantSelector.getSelectionModel().getSelectedIndex()] = colorPicker.getValue(); if (colorComponantSelector.getSelectionModel().getSelectedIndex() == Colors.fill.value) { dragSelectRectangle.setFill(colorPicker.getValue()); } else if (colorComponantSelector.getSelectionModel().getSelectedIndex() == Colors.line.value) { dragSelectRectangle.setStroke(colorPicker.getValue()); } else if (colorComponantSelector.getSelectionModel() .getSelectedIndex() == Colors.saveLine.value) { for (Rectangle r : savedRegionsDisplay) { r.setStroke(colorPicker.getValue()); } } else if (colorComponantSelector.getSelectionModel() .getSelectedIndex() == Colors.saveFill.value) { for (Rectangle r : savedRegionsDisplay) { r.setFill(colorPicker.getValue()); } } else { removeSavedChromosomeImages(); if (redrawCheckBox.isSelected()) { refreshView(null, true); } } } } }); /*perform appropriate action when user selects a chromosome * from the chromosome choice box */ chromosomeSelector.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue ov, Number value, Number new_value) { chromosomeBoxList = chromosomeSelector.getItems().toArray(); if (new_value.intValue() > -1) { chromosomeSelected((String) chromosomeBoxList[new_value.intValue()]); } } }); chromosomeSelector.addEventFilter(KeyEvent.ANY, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent ke) { if (ke.getCode() == KeyCode.UP) { ke.consume(); chromosomeSelector.show(); } } }); selectionOverlayPane.heightProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number oldSceneWidth, Number newSceneWidth) { windowResized(new ActionEvent()); } }); selectionOverlayPane.widthProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number oldSceneWidth, Number newSceneWidth) { windowResized(new ActionEvent()); } }); /*upon addition of a new affected file adjust components accordingly * i.e. ensure appropriate chromosomes are in the choice box * adjust the split panes to fit all files and redisplay */ affObserve.addListener(new ListChangeListener() { @Override public void onChanged(ListChangeListener.Change change) { change.next();/*from the javadoc * 'Go to the next change. In initial state is invalid a require * a call to next() before calling other methods. The first * next() call will make this object represent the first change. */ if (change.getRemovedSize() > 0) { List<SnpFile> both = new ArrayList<>(unFiles); both.addAll(affFiles); recheckChromosomeSelector(both);//need to check all files again, not just affFiles } else if (change.getAddedSize() > 0) { addToChromosomeSelector(affFiles); } } }); /*as above * but for unaffected files */ unObserve.addListener(new ListChangeListener() { @Override public void onChanged(ListChangeListener.Change change) { change.next(); if (change.getRemovedSize() > 0) { List<SnpFile> both = new ArrayList<>(unFiles); both.addAll(affFiles); recheckChromosomeSelector(both);//need to check all files again, not just unFiles } else if (change.getAddedSize() > 0) { addToChromosomeSelector(unFiles); } } }); selectionOverlayPane.addEventHandler(MouseEvent.MOUSE_MOVED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { if (!genomeVersion.equals("") && chromosomeSelector.getSelectionModel().getSelectedIndex() > -1) { try { ChromosomeLength chromLength = new ChromosomeLength(genomeVersion); String currentChrom = (String) chromosomeBoxList[chromosomeSelector.getSelectionModel() .getSelectedIndex()]; double coordinate = chromLength.getLength(currentChrom) / chromSplitPane.getWidth() * e.getX(); positionIndicator.setText(nf.format(coordinate)); } catch (Exception ex) { positionIndicator.setText("Build Error!"); } } } }); /*handle mouse dragging and effect on dragSelectRectangle * */ dragSelectRectangle.widthProperty().bind(dragSelectRectX.subtract(dragSelectRectInitX)); dragSelectRectangle.heightProperty().bind(selectionOverlayPane.heightProperty()); //dragSelectRectangle.strokeProperty().set(colorComponants[Colors.line.value]); dragSelectRectangle.setStrokeWidth(4.0); //dragSelectRectangle.setBlendMode(BlendMode.SCREEN); dragSelectRectangle.setOpacity(0.45); dragSelectRectangle.setVisible(false); selectionOverlayPane.getChildren().add(dragSelectRectangle); selectionOverlayPane.addEventHandler(MouseEvent.MOUSE_PRESSED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { if (scm.isShowing()) { scm.hide(); } if (!e.isPrimaryButtonDown()) { if (e.isSecondaryButtonDown()) { //check we're not overlapping selection if (e.getX() >= dragSelectRectangle.getX() && e.getX() <= (dragSelectRectangle.getX() + dragSelectRectangle.getWidth())) { return; } //check we're not overlapping saved regions for (Rectangle r : savedRegionsDisplay) { if (r.isVisible() && e.getX() >= r.getX() && e.getX() <= r.getX() + r.getWidth()) { return; } } if (chromosomeSelector.getSelectionModel().isEmpty()) { ocmItem1.setDisable(true); } else { ocmItem1.setDisable(false); } ocm.show(selectionOverlayPane, e.getScreenX(), e.getScreenY()); return; } } if (ocm.isShowing()) { ocm.hide(); } dragSelectRectangle.strokeProperty().set(colorComp.get(Colors.line.value)); dragSelectRectangle.fillProperty().set(colorComp.get(Colors.fill.value)); dragSelectRectX.set(0); dragSelectRectangle.setVisible(true); dragSelectRectangle.setX(e.getX()); dragSelectRectangle.setY(0); dragSelectRectInitX.set(e.getX()); anchorInitX.set(e.getX()); } }); selectionOverlayPane.addEventHandler(MouseEvent.MOUSE_DRAGGED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { if (!e.isPrimaryButtonDown()) { return; } dragSelectRectangle.setVisible(true); if (e.getX() > anchorInitX.doubleValue()) {//dragging to the right if (e.getX() <= selectionOverlayPane.getLayoutX() + selectionOverlayPane.getWidth()) { //mouse is before the edge of the pane dragSelectRectInitX.set(anchorInitX.doubleValue()); dragSelectRectX.set(e.getX()); } else { //mouse is over the edge dragSelectRectX.set(selectionOverlayPane.getWidth()); } } else { if (e.getX() > selectionOverlayPane.getLayoutX()) { dragSelectRectInitX.set(e.getX()); dragSelectRectangle.setX(e.getX()); dragSelectRectX.set(anchorInitX.doubleValue()); } else { dragSelectRectInitX.set(0); dragSelectRectangle.setX(0); /* the two lines below are just to trigger * dragSelectRectangle.widthProperty listener * so that start coordinate changes to 1 */ dragSelectRectX.set(anchorInitX.doubleValue() + 1); dragSelectRectX.set(anchorInitX.doubleValue() + 1); } } } }); selectionOverlayPane.addEventHandler(MouseEvent.MOUSE_RELEASED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { //dragSelectRectX.set(e.getX()); if (!e.isPrimaryButtonDown()) { return; } dragSelectRectangle.setVisible(true); if (dragSelectRectangle.getWidth() == 0) { clearDragSelectRectangle(); } } }); dragSelectRectangle.widthProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observableValue, Object oldValue, Object newRectWidth) { if (!genomeVersion.equals("") && chromosomeSelector.getSelectionModel().getSelectedIndex() > -1 && dragSelectRectangle.getWidth() > 0) { try { ChromosomeLength chromLength = new ChromosomeLength(genomeVersion); String currentChrom = (String) chromosomeBoxList[chromosomeSelector.getSelectionModel() .getSelectedIndex()]; double startCoordinate = chromLength.getLength(currentChrom) / selectionOverlayPane.getWidth() * dragSelectRectangle.getX(); double selectionWidth = chromLength.getLength(currentChrom) / selectionOverlayPane.getWidth() * dragSelectRectangle.getWidth(); if (dragSelectRectangle.getX() == 0) { startCoordinate = 1; } selectionIndicator.setText("chr" + currentChrom + ":" + nf.format(startCoordinate) + "-" + nf.format(startCoordinate + selectionWidth)); } catch (Exception ex) { selectionIndicator.setText("Build Error!"); } } else { selectionIndicator.setText(""); } } }); dragSelectRectangle.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { if (e.getButton() == MouseButton.SECONDARY) { if (chromosomeSelector.getSelectionModel().isEmpty()) { scmItem1.setDisable(true); scmItem2.setDisable(true); } else { scmItem1.setDisable(false); scmItem2.setDisable(false); } if (ocm.isShowing()) { ocm.hide(); } scm.show(selectionOverlayPane, e.getScreenX(), e.getScreenY()); } } }); }
From source file:com.ggvaidya.scinames.dataset.BinomialChangesSceneController.java
private MenuItem createMenuItem(String name, EventHandler<ActionEvent> handler) { MenuItem mi = new MenuItem(name); mi.onActionProperty().set(handler);//from w w w .j a v a2 s. c o m return mi; }
From source file:pl.baczkowicz.mqttspy.ui.controllers.NewPublicationController.java
/** * Refreshes the list of recent messages shown in the publish button's context menu. *//* w w w . j av a 2 s . c om*/ private void refreshRecentMessages() { // Remove all elements while (recentMessagesMenu.getItems().size() > 0) { recentMessagesMenu.getItems().remove(0); } while (saveRecentMessagesMenu.getItems().size() > 0) { saveRecentMessagesMenu.getItems().remove(0); } // Add all elements for (final BaseMqttMessage message : recentMessages) { final String topic = message.getTopic(); final String payload = message.getPayload().length() > 10 ? message.getPayload().substring(0, 10) + "..." : message.getPayload(); final String time = TimeUtils.DATE_WITH_SECONDS_SDF.format(message.getDate()); final String messageText = "Topic = '" + topic + "', payload = '" + payload + "', published at " + time; final MenuItem recentMessageItem = new MenuItem(messageText); recentMessageItem.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { displayMessage(message); } }); recentMessagesMenu.getItems().add(recentMessageItem); final MenuItem saveMessageItem = new MenuItem(messageText); saveMessageItem.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { saveAsScript(message); } }); saveRecentMessagesMenu.getItems().add(saveMessageItem); } recentMessagesMenu.setDisable(recentMessagesMenu.getItems().size() == 0); saveRecentMessagesMenu.setDisable(saveRecentMessagesMenu.getItems().size() == 0); }
From source file:io.github.mzmine.modules.plots.msspectrum.MsSpectrumPlotWindowController.java
public void handleContextMenuShowing(ContextMenuEvent event) { // Calculate the m/z value of the clicked point final double clickedX = event.getX(); XYPlot plot = chartNode.getChart().getXYPlot(); Rectangle2D chartArea = chartNode.getRenderingInfo().getPlotInfo().getDataArea(); RectangleEdge axisEdge = plot.getDomainAxisEdge(); ValueAxis domainAxis = plot.getDomainAxis(); final double clickedMz = domainAxis.java2DToValue(clickedX, chartArea, axisEdge); final double clickedMzWithShift = Math.abs(clickedMz - mzShift.get()); // Update the m/z shift menu item DecimalFormat mzFormat = MZmineCore.getConfiguration().getMZFormat(); setToMenuItem.setText("Set to " + mzFormat.format(clickedMz) + " m/z"); setToMenuItem.setUserData(clickedMz); // Update the Show XIC menu item showXICMenuItem.setText("Show XIC of " + mzFormat.format(clickedMzWithShift) + " m/z"); showXICMenuItem.setUserData(clickedMzWithShift); // Update the MS/MS menu findMSMSMenu.setText("Find MS/MS of " + mzFormat.format(clickedMzWithShift) + " m/z"); final ObservableList<MenuItem> msmsItems = findMSMSMenu.getItems(); msmsItems.clear();//from ww w .ja v a2s.c o m MZmineProject project = MZmineCore.getCurrentProject(); for (RawDataFile file : project.getRawDataFiles()) { scans: for (MsScan scan : file.getScans()) { if (scan.getMsFunction().getMsLevel() == 1) continue; for (IsolationInfo isolation : scan.getIsolations()) { if (!isolation.getIsolationMzRange().contains(clickedMzWithShift)) continue; String menuLabel = MsScanUtils.createSingleLineMsScanDescription(scan, isolation); MenuItem msmsItem = new MenuItem(menuLabel); msmsItem.setOnAction(e -> MsSpectrumPlotModule.showNewSpectrumWindow(scan)); msmsItems.add(msmsItem); continue scans; } } } if (msmsItems.isEmpty()) { MenuItem noneItem = new MenuItem("None"); noneItem.setDisable(true); msmsItems.add(noneItem); } // Update the Remove... menu final ObservableList<MenuItem> rmItems = removeDatasetMenu.getItems(); rmItems.clear(); for (MsSpectrumDataSet dataset : datasets) { MenuItem msmsItem = new MenuItem(dataset.getName()); msmsItem.setOnAction(e -> datasets.remove(dataset)); rmItems.add(msmsItem); } removeDatasetMenu.setDisable(rmItems.isEmpty()); }
From source file:com.github.drbookings.ui.controller.MainController.java
private void initTableViewContextMenus() { final ContextMenu menu = new ContextMenu(); final MenuItem mi1 = new MenuItem("Delete"); final MenuItem mi2 = new MenuItem("Add"); final MenuItem mi3 = new MenuItem("Modify"); mi1.setOnAction(event -> {/*from www . ja va2s . c o m*/ Platform.runLater(() -> deleteSelected()); }); mi2.setOnAction(event -> { Platform.runLater(() -> addBooking()); }); mi3.setOnAction(event -> { Platform.runLater(() -> showModifyBookingDialog()); }); menu.getItems().addAll(mi2, mi1, mi3); tableView.setContextMenu(menu); tableView.addEventHandler(MouseEvent.MOUSE_CLICKED, t -> { if (t.getButton() == MouseButton.SECONDARY) { menu.show(tableView, t.getScreenX(), t.getScreenY()); } }); }
From source file:ninja.javafx.smartcsv.fx.SmartCSVController.java
private ContextMenu contextMenuForColumn(String header) { ContextMenu contextMenu = new ContextMenu(); MenuItem editColumnRulesMenuItem = new MenuItem(resourceBundle.getString("context.menu.edit.column.rules")); bindMenuItemsToContentExistence(currentConfigFile, editColumnRulesMenuItem); editColumnRulesMenuItem.setOnAction(e -> showValidationEditor(header)); contextMenu.getItems().addAll(editColumnRulesMenuItem); return contextMenu; }
From source file:com.exalttech.trex.ui.views.PacketTableView.java
/** * Add menu item to table rightclickMenu * * @param action//from w ww. j a v a 2 s . c o m */ private void addMenuItem(StreamTableAction action) { MenuItem item = new MenuItem(action.getTitle()); item.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { handleStreamTableAction(action); } }); rightClickMenu.getItems().add(item); }
From source file:patientmanagerv1.HomeController.java
@Override public void initialize(URL url, ResourceBundle rb) { //start with the forum and the common questions page, add-on the profile page and private messaging features //passLoaded = false; //sets the current Patient try {/*from w w w.j a v a 2 s . co m*/ String entireFileText = new Scanner(new File(installationPath + "/currentpatient.txt")) .useDelimiter("//A").next(); String[] nameArray = entireFileText.split(","); firstName = nameArray[0].toLowerCase(); lastName = nameArray[1].toLowerCase(); dob = nameArray[2]; } catch (Exception e) { } //checks the signed status try { FileReader reader = new FileReader( installationPath + "/userdata/" + firstName + lastName + dob + "/EvaluationForm/signed.txt"); //+ "/userdata/" + get.currentPatientFirstName + get.currentPatientLastName + "/EvaluationForm/first.txt"); BufferedReader br = new BufferedReader(reader); String signedStatus = br.readLine(); br.close(); reader.close(); if (signedStatus.equalsIgnoreCase("true")) { dccSigned = true; } else { dccSigned = false; } FileReader reader2 = new FileReader(installationPath + "/userdata/" + firstName + lastName + dob + "/EvaluationForm/assistantsigned.txt"); //+ "/userdata/" + get.currentPatientFirstName + get.currentPatientLastName + "/EvaluationForm/first.txt"); BufferedReader br2 = new BufferedReader(reader2); String assistantSigned = br2.readLine(); br2.close(); reader2.close(); if (assistantSigned.equalsIgnoreCase("true")) { partnerSigned = true; } else { partnerSigned = false; } /*saveButton.setDisable(false); sign.setVisible(true); sign.setDisable(true); signature.setVisible(false);*/ if (signedStatus.equalsIgnoreCase("false") && (assistantSigned.equalsIgnoreCase("false"))) { saveButton.setDisable(false); sign.setVisible(true); sign.setDisable(false); assistantsign.setVisible(true); assistantsign.setDisable(false); assistantsignature.setVisible(false); signature.setVisible(false); signature2.setVisible(false); ap.setDisable(false); } else if (signedStatus.equalsIgnoreCase("true") && (assistantSigned.equalsIgnoreCase("false"))) { saveButton.setDisable(true); sign.setVisible(false); assistantsign.setVisible(true); assistantsign.setDisable(false); assistantsignature.setVisible(false); signature.setVisible(true); signature2.setVisible(true); signature.setText("This document has been digitally signed by David Zhvikov MD"); ap.setDisable(true); } else if (signedStatus.equalsIgnoreCase("false") && (assistantSigned.equalsIgnoreCase("true"))) { saveButton.setDisable(true); sign.setVisible(true); assistantsign.setVisible(false); assistantsign.setDisable(true); assistantsignature.setVisible(true); signature.setVisible(false); signature2.setVisible(false); signature.setText("This document has been digitally signed by David Zhvikov MD"); ap.setDisable(true); } else { saveButton.setDisable(true); sign.setVisible(false); assistantsign.setVisible(false); assistantsign.setDisable(true); assistantsignature.setVisible(true); signature.setVisible(true); signature2.setVisible(true); signature.setText("This document has been digitally signed by David Zhvikov MD"); ap.setDisable(true); } } catch (Exception e) { } //loads the ListView try { FileReader r2 = new FileReader( installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressReports.txt"); BufferedReader b2 = new BufferedReader(r2); String s; ArrayList progressNotes = new ArrayList(); while ((s = b2.readLine()) != null) { //System.out.println(s); progressNotes.add(s); } b2.close(); r2.close(); //Adds the Progress Notes to the ListView ObservableList<String> items = FXCollections.observableArrayList("Single", "Double"); items.clear(); for (int counter = 0; counter < progressNotes.size(); counter++) { items.add(progressNotes.get(counter).toString()); } listOfProgressReports.setItems(items); //String[] ethnicityArray = ethnicity.split(","); } catch (Exception e) { //System.out.println("file not found"); } //initializes the evaluation form [with the new patient's name] for the current patient fillName(); fillDOB(); fillAge(loaded); fillGender(); fillMaritalStatus(); fillEthnicity(); fillReferredBy(); fillReasonForReferral(); fillSourceOfInformation(); fillReliabilityOfInformation(); fillHistoryOfPresentIllness(); fillSignsSymptoms(); fillCurrentMedications(); fillPastPsychiatricHistory(); fillPastHistoryOf(); fillHistoryOfMedicationTrialsInThePast(); fillSubstanceUseHistory(); fillDeniesHistoryOf(); fillSocialHistory(); fillParentsSiblingsChildren(); fillFamilyHistoryOfMentalIllness(); fillEducation(); fillEmployment(); fillLegalHistory(); fillPastMedicalHistory(); fillAllergies(); fillAppearance(); fillEyeContact(); fillAttitude(); fillMotorActivity(); fillAffect(); fillMood(); fillSpeech(); fillThoughtProcess(); fillThoughtContent(); fillPerception(); fillSuicidality(); fillHomicidality(); fillOrientation(); fillShortTermMemory(); fillLongTermMemory(); fillGeneralFundOfKnowledge(); fillIntellect(); fillAbstraction(); fillJudgementAndInsight(); fillClinicalNotes(); fillTreatmentPlan(); fillSideEffects(); fillLabs(); fillEnd(); fillSignatureZone(); // currentPatientFirstName = get.currentPatientFirstName; // currentPatientLastName = get.currentPatientLastName; //sets the current patient /*try { String entireFileText = new Scanner(new File(installationPath + "/Patients.txt")).useDelimiter("//A").next(); String[] arrayOfNames = entireFileText.split(";"); System.out.println("Patient Name: " + arrayOfNames[arrayOfNames.length - 1]); String nameWithComma = arrayOfNames[arrayOfNames.length - 1]; String[] nameArray = nameWithComma.split(","); firstName = nameArray[0].toLowerCase(); lastName = nameArray[1].toLowerCase(); } catch(Exception e) {}*/ /*ArrayList progressNotes = new ArrayList(); for(int i = 0; i < listOfProgressReports.getItems().size(); i++) { progressNotes.add(listOfProgressReports.getItems().get(i)); }*/ //broken and betrayed //of the ecsts's you've shown me. //...for me, italicsmaster, she put emphasis/lingered on the word. "M" menu.getMenus().removeAll(); Menu file = new Menu("File"); Menu edit = new Menu("Edit"); Menu view = new Menu("View"); Menu help = new Menu("About"); Menu speech = new Menu("Speech Options"); MenuItem save = new MenuItem("Save"); MenuItem print = new MenuItem("Print"); MenuItem printWithSettings = new MenuItem("Print With Settings"); MenuItem export = new MenuItem("Export to"); MenuItem logout = new MenuItem("Return to Patient Selection"); MenuItem deleteThisPatient = new MenuItem("Delete This Patient"); MenuItem exit = new MenuItem("Exit"); MenuItem undo = new MenuItem("Undo (ctrl+z)"); MenuItem redo = new MenuItem("Redo (ctrl+y)"); MenuItem selectAll = new MenuItem("Select All (ctrl+A)"); MenuItem cut = new MenuItem("Cut (ctrl+x)"); MenuItem copy = new MenuItem("Copy (ctrl+c)"); MenuItem paste = new MenuItem("Paste (ctrl+v)"); MenuItem enableBackdoorModifications = new MenuItem("Enable Modification of this Evaluation Post-Signing"); Menu submenu1 = new Menu("Create"); Menu submenu2 = new Menu("Load"); Menu submenu3 = new Menu("New"); MenuItem createProgressReport = new MenuItem("Progress Report"); MenuItem loadProgressReport = new MenuItem("Progress Report"); MenuItem deleteProgressReport = new MenuItem("Delete selected progress report"); submenu1.getItems().add(submenu3); submenu3.getItems().add(createProgressReport); submenu2.getItems().add(loadProgressReport); MenuItem howToUse = new MenuItem("How to use patient manager"); MenuItem versionInfo = new MenuItem("About Patient Manager/Version Info"); /*MenuItem read = new MenuItem("Read to me"); MenuItem launch = new MenuItem("Launch Dictation");*/ //read to me menu, dictation menu- select a document to read aloud, read this passage aloud, launch windows in-built dictation, download brainac dictation online Menu read = new Menu("Read to me"); Menu launch = new Menu("Dictation"); Menu readPassageOrFormStartStop = new Menu("Read this passage/read this form"); MenuItem startReading1 = new MenuItem("Start"); MenuItem stopReading1 = new MenuItem("Stop"); MenuItem startReading2 = new MenuItem("Start"); MenuItem stopReading2 = new MenuItem("Stop"); Menu readUploadedDocument = new Menu("Select a document to read"); MenuItem launchWindowsDictation = new MenuItem("Launch Windows' Built-In Dictation"); MenuItem launchBrainacDictation = new MenuItem("Download Brainac Dictation"); startReading1.setDisable(true); stopReading1.setDisable(true); startReading2.setDisable(true); stopReading2.setDisable(true); readPassageOrFormStartStop.getItems().add(startReading1); readPassageOrFormStartStop.getItems().add(stopReading1); readUploadedDocument.getItems().add(startReading2); readUploadedDocument.getItems().add(stopReading2); readPassageOrFormStartStop.setDisable(true); readUploadedDocument.setDisable(true); launchBrainacDictation.setDisable(true); read.getItems().add(readPassageOrFormStartStop); read.getItems().add(readUploadedDocument); launch.getItems().add(launchWindowsDictation); launch.getItems().add(launchBrainacDictation); file.getItems().add(save); file.getItems().add(print); file.getItems().add(printWithSettings); file.getItems().add(export); file.getItems().add(logout); file.getItems().add(deleteThisPatient); file.getItems().add(exit); edit.getItems().add(undo); edit.getItems().add(redo); edit.getItems().add(selectAll); edit.getItems().add(cut); edit.getItems().add(copy); edit.getItems().add(paste); edit.getItems().add(enableBackdoorModifications); view.getItems().add(submenu1); view.getItems().add(submenu2); view.getItems().add(deleteProgressReport); help.getItems().add(howToUse); help.getItems().add(versionInfo); speech.getItems().add(read); speech.getItems().add(launch); menu.prefWidthProperty().bind(masterPane.widthProperty()); //menu.setStyle("-fx-padding: 0 20 0 20;"); //menu.getMenus().addAll(file, edit, view, help, speech); menu.getMenus().add(file); menu.getMenus().add(edit); menu.getMenus().add(view); menu.getMenus().add(speech); menu.getMenus().add(help); undo.setDisable(true); redo.setDisable(true); cut.setDisable(true); copy.setDisable(true); paste.setDisable(true); selectAll.setDisable(true); deleteThisPatient.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { int result = JOptionPane.showConfirmDialog(null, "Are you sure you want to delete this patient?", "Warning", JOptionPane.OK_CANCEL_OPTION); if (result == 2) { } if (result == 0) { int result2 = JOptionPane.showConfirmDialog(null, "Are you ABSOLUTELY sure you want to delete this patient?", "Warning", JOptionPane.OK_CANCEL_OPTION); if (result2 == 2) { } if (result2 == 0) { String patientToDelete = firstName + "," + lastName + "," + dob; //listOfProgressReports.getSelectionModel().getSelectedItem().toString(); // String currRepNoColons = currRep.replace(":", ""); // currRepNoColons = currRepNoColons.trim(); //1) removes the report from the list in the file try { FileReader r2 = new FileReader(installationPath + "/patients.txt"); BufferedReader b2 = new BufferedReader(r2); String s = b2.readLine(); String[] patients = s.split(";"); //String[] ssArray = ss.split(","); /*for(int i = 0; i < patients.size(); i++) { }*/ /*while((s = b2.readLine()) != null) { //System.out.println(s); if(!s.equalsIgnoreCase(patientToDelete)) {patients.add(s);} }*/ b2.close(); r2.close(); File fff = new File(installationPath + "/patients.txt"); FileWriter ddd = new FileWriter(fff, false); BufferedWriter bw = new BufferedWriter(ddd); ddd.append(""); bw.close(); ddd.close(); for (int i = 0; i < patients.length; i++) { File openProgressReportsList = new File(installationPath + "/patients.txt"); FileWriter fw = new FileWriter(openProgressReportsList, true); BufferedWriter bufferedwriter = new BufferedWriter(fw); if (!(patients[i].equalsIgnoreCase(patientToDelete))) { fw.append(patients[i].toLowerCase() + ";"); } bufferedwriter.close(); fw.close(); } } catch (Exception ex) { } /*try{ FileReader reader = new FileReader(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressReports.txt"); BufferedReader br = new BufferedReader(reader); String fileContents = br.readLine(); br.close(); reader.close(); fileContents = fileContents.replace(currRep, ""); //System.out.println("fc:" + fileContents); //writes the new contents to the file: //writes the new report to the list File openProgressReportsList = new File(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressReports.txt"); FileWriter fw = new FileWriter(openProgressReportsList, false); BufferedWriter bufferedwriter = new BufferedWriter(fw); fw.append(fileContents); bufferedwriter.close(); fw.close(); } catch(Exception e) { }*/ //2) Deletes the folder for that progress report try { File directory = new File(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressNotes"); File[] subdirs = directory.listFiles((FileFilter) DirectoryFileFilter.DIRECTORY); for (File dir : subdirs) { File deleteThis = new File(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressNotes/" + dir.getName()); //System.out.println("Directory: " + dir.getName()); File[] filez = deleteThis.listFiles(); for (int i = 0; i < filez.length; i++) { filez[i].delete(); } //the wedding nightmare: red, red, dark purple-brown; big-ol red wrap/red jacket deleteThis.delete(); } File path3 = new File(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressNotes"); File[] files3 = path3.listFiles(); for (int i = 0; i < files3.length; i++) { files3[i].delete(); } //the wedding nightmare: red, red, dark purple-brown; big-ol red wrap/red jacket path3.delete(); File path2 = new File(installationPath + "/userdata/" + firstName + lastName + dob + "/EvaluationForm"); File[] files2 = path2.listFiles(); for (int i = 0; i < files2.length; i++) { files2[i].delete(); } //the wedding nightmare: red, red, dark purple-brown; big-ol red wrap/red jacket path2.delete(); File path = new File(installationPath + "/userdata/" + firstName + lastName + dob); File[] files = path.listFiles(); for (int i = 0; i < files.length; i++) { files[i].delete(); } //the wedding nightmare: red, red, dark purple-brown; big-ol red wrap/red jacket path.delete(); //deleteDirectory(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressNotes/" + currRepNoColons); //Files.delete(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressNotes/" + currRepNoColons); //PUT A MESSAGE SAYING "DELETED" HERE JOptionPane.showMessageDialog(null, "Deleted!"); toPatientSelectionNoDialog.fire(); } catch (Exception exception) { } } } } }); save.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { save(); } }); versionInfo.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { JOptionPane.showMessageDialog(null, "Patient Manager Version 5.0.6 \n Compatible with: Windows 7"); } }); howToUse.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { JOptionPane.showMessageDialog(null, "Help: \n\n\n Print- sends the document to the default printer. Requires no passwords. \n\n Print with Settings- opens the evaluation or progress report in word so that the document can be printed using word's built-in dialog. Because the word document will be open to modification, 'print with settings' requires the physician's password. \n\n Export to- save an evaluation or progress note to the location of your choice, rather than to the default location. Requires the physician/admin's password. \n\n Enable Backdoor Modifications- allows the physician or physician's assistant(s) to reopen the forms for modification post-signing. If the physician's password is used, only his signature will become undone. If the physician's assistant(s)' password is used, both the physician's signature (if relevant) and the assitant's signature will become undone (since the physician will need to review the new modifications before re-signing his approval). \n\n Create/Load/Delete a progress note- the create & load functions are accessible directly from the interface. Deletion can only be accessed from the drop-down menu. Select a progress report prior to clicking 'load' or 'delete' \n\n Speech Options- most speech options are still a WIP, HOWEVER, you can click 'launch windows 7 native dictation' from either the interface OR the menu bar, in order to quickly access Windows' built-in dictation capabilities. \n\n Version info can be found in 'About' in the 'Help' drop-down menu on the main menu bar."); } }); launchWindowsDictation.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { launchSpeechRecognition(); } }); exit.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { int result = JOptionPane.showConfirmDialog(null, "Do you want to save any unsaved changes before exiting?", "Save changes?", JOptionPane.YES_NO_CANCEL_OPTION); if (result == 0) { saveEval(); //some idiocy goes here /*try { Audio audio = Audio.getInstance(); InputStream sound = audio.getAudio("Have a nice day!", Language.ENGLISH); audio.play(sound); } catch(Exception excep) {System.out.println(excep);}*/ System.exit(0); } if (result == 1) { //some idiocy goes here /*try { Audio audio = Audio.getInstance(); InputStream sound = audio.getAudio("Have a nice day!", Language.ENGLISH); audio.play(sound); } catch(Exception excep) {System.out.println(excep);}*/ System.exit(0); } if (result == 2) { } } }); enableBackdoorModifications.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { enableBackdoorModifications(); } }); deleteProgressReport.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { deleteProgressReport(); } }); //<MenuItem fx:id="loadProgressReport" onAction="#loadProgressReport" /> loadProgressReport.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { load.fire(); } }); createProgressReport.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { createPN.fire(); } }); //read to me menu, dictation menu- select a document to read aloud, read this passage aloud, launch windows in-built dictation, download brainac dictation online export.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { final Stage dialog = new Stage(); dialog.initModality(Modality.APPLICATION_MODAL); final TextField textField = new TextField(); Button submit = new Button(); Button cancel = new Button(); final Label label = new Label(); cancel.setText("Cancel"); cancel.setAlignment(Pos.CENTER); submit.setText("Submit"); submit.setAlignment(Pos.BOTTOM_RIGHT); final VBox dialogVbox = new VBox(20); dialogVbox.getChildren().add(new Text("Enter the master password: ")); dialogVbox.getChildren().add(textField); dialogVbox.getChildren().add(submit); dialogVbox.getChildren().add(cancel); dialogVbox.getChildren().add(label); Scene dialogScene = new Scene(dialogVbox, 300, 200); dialog.setScene(dialogScene); dialog.setTitle("Security/Physician Authentication"); dialog.show(); submit.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent anEvent) { String password = textField.getText(); if (password.equalsIgnoreCase("protooncogene")) { dialog.close(); export(); } else { label.setText("The password you entered is incorrect. Please try again."); } } }); cancel.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent anEvent) { dialog.close(); //close the window here } }); } }); print.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { print(); } }); printWithSettings.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { printAdv(); } }); logout.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { toPatientSelection.fire(); } }); ///"sometime during s-y lol." }