javafx.event.Event Java Examples

The following examples show how to use javafx.event.Event. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FunctionTreeFactory.java    From zest-writer with GNU General Public License v3.0 6 votes vote down vote up
public static void clearContent(ObservableList<Textual> extracts, TabPane editorList, Supplier<Void> doAfter) {

        if (extracts.isEmpty()) {
            doAfter.get();
        }

        for (Textual entry : extracts) {
            Platform.runLater(() -> {
                Tab tab = getTabFromTextual(editorList, entry);
                Event.fireEvent(tab, new Event(Tab.TAB_CLOSE_REQUEST_EVENT));
                if (editorList.getTabs().size() <= 1) {
                    extracts.clear();
                    doAfter.get();
                }
            });
        }
    }
 
Example #2
Source File: TranslateTab.java    From Quelea with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Create a new translate tab.
 * @param name the name of the tab (usually the language.)
 * @param lyrics the translated lyrics (can be blank.)
 */
public TranslateTab(String name, String lyrics) {
    super(name);
    setOnCloseRequest(new EventHandler<Event>() {

        @Override
        public void handle(Event tabEvent) {
            String nameReplace = name;
            if(QueleaProperties.get().getLanguageFile().getName().equalsIgnoreCase("sv.lang")) { //Language names should be in lower case for Swedish
                nameReplace = nameReplace.toLowerCase();
            }
            Dialog.buildConfirmation(LabelGrabber.INSTANCE.getLabel("delete.translation.title"), LabelGrabber.INSTANCE.getLabel("delete.translation.text").replace("$1", nameReplace))
                    .addYesButton((event1) -> {}).addNoButton((ActionEvent buttonEvent) -> {
                        tabEvent.consume();
            }).build().showAndWait();
        }
    });
    this.name = name;
    setClosable(true);
    lyricsArea = new LyricsTextArea();
    lyricsArea.getTextArea().replaceText(lyrics);
    setContent(lyricsArea);
}
 
Example #3
Source File: DockItem.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
/** Tab has been closed */
protected void handleClosed(final Event event)
{
    // If there are callbacks, invoke them
    if (closed_callback != null)
    {
        for (Runnable check : closed_callback)
            check.run();
        closed_callback = null;
    }

    // Remove content to avoid memory leaks
    // because this tab could linger in memory for a while
    setContent(null);
    // Remove "application" entry which otherwise holds on to application data model
    getProperties().remove(KEY_APPLICATION);
}
 
Example #4
Source File: MsSpectrumPlotWindowController.java    From old-mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
public void handleSetMzShiftManually(Event event) {
  DecimalFormat mzFormat = MZmineCore.getConfiguration().getMZFormat();
  String newMzShiftString = "0.0";
  Double newMzShift = (Double) setToMenuItem.getUserData();
  if (newMzShift != null)
    newMzShiftString = mzFormat.format(newMzShift);
  TextInputDialog dialog = new TextInputDialog(newMzShiftString);
  dialog.setTitle("m/z shift");
  dialog.setHeaderText("Set m/z shift value");
  Optional<String> result = dialog.showAndWait();
  result.ifPresent(value -> {
    try {
      double newValue = Double.parseDouble(value);
      mzShift.set(newValue);
    } catch (Exception e) {
      e.printStackTrace();
    }
  });

}
 
Example #5
Source File: MsSpectrumPlotWindowController.java    From old-mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
public void handleNextScan(Event e) {
  for (MsSpectrumDataSet dataset : datasets) {
    MsSpectrum spectrum = dataset.getSpectrum();
    if (!(spectrum instanceof MsScan))
      continue;
    MsScan scan = (MsScan) spectrum;
    RawDataFile rawFile = scan.getRawDataFile();
    if (rawFile == null)
      return;
    int scanIndex = rawFile.getScans().indexOf(scan);
    if (scanIndex == rawFile.getScans().size() - 1)
      return;
    MsScan nextScan = rawFile.getScans().get(scanIndex + 1);
    String title = MsScanUtils.createSingleLineMsScanDescription(nextScan);
    dataset.setSpectrum(nextScan, title);
  }
}
 
Example #6
Source File: MainController.java    From Library-Assistant with Apache License 2.0 6 votes vote down vote up
private void initDrawer() {
    try {
        FXMLLoader loader = new FXMLLoader(getClass().getResource("/library/assistant/ui/main/toolbar/toolbar.fxml"));
        VBox toolbar = loader.load();
        drawer.setSidePane(toolbar);
        ToolbarController controller = loader.getController();
        controller.setBookReturnCallback(this);
    } catch (IOException ex) {
        Logger.getLogger(MainController.class.getName()).log(Level.SEVERE, null, ex);
    }
    HamburgerSlideCloseTransition task = new HamburgerSlideCloseTransition(hamburger);
    task.setRate(-1);
    hamburger.addEventHandler(MouseEvent.MOUSE_CLICKED, (Event event) -> {
        drawer.toggle();
    });
    drawer.setOnDrawerOpening((event) -> {
        task.setRate(task.getRate() * -1);
        task.play();
        drawer.toFront();
    });
    drawer.setOnDrawerClosed((event) -> {
        drawer.toBack();
        task.setRate(task.getRate() * -1);
        task.play();
    });
}
 
Example #7
Source File: EditCell.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void commitEdit(T item) {
    // This block is necessary to support commit on losing focus, because the baked-in mechanism
    // sets our editing state to false before we can intercept the loss of focus.
    // The default commitEdit(...) method simply bails if we are not editing...

    if (!isEditing() && !item.equals(getItem())) {
        TableView<S> table = getTableView();
        if (table != null) {
            TableColumn<S, T> column = getTableColumn();
            CellEditEvent<S, T> event = new CellEditEvent<S, T>(table,
                    new TablePosition<S, T>(table, getIndex(), column),
                    TableColumn.editCommitEvent(), item);
            Event.fireEvent(column, event);
        }
    }
    else {
        super.commitEdit(item);
    }

    setContentDisplay(ContentDisplay.TEXT_ONLY);
}
 
Example #8
Source File: MainMenuController.java    From mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
public void handleShowLogFile(Event event) {

    /*
     * There doesn't seem to be any way to obtain the log file name from the logging FileHandler, so
     * it is hard-coded here for now
     */
    final Path logFilePath =
        Paths.get(System.getProperty("java.io.tmpdir") + File.separator + "mzmine.log");

    try {
      Desktop gui = MZmineCore.getDesktop();
      gui.openWebPage(logFilePath.toUri().toURL());
    } catch (MalformedURLException e) {
      e.printStackTrace();
    }


  }
 
Example #9
Source File: ConsoleOutputControl.java    From chvote-1-0 with GNU Affero General Public License v3.0 5 votes vote down vote up
@FXML
public void initialize() throws IOException {
    TableColumn<LogMessage, GlyphIcon> logLevelColumn = new TableColumn<>();
    logLevelColumn.setCellValueFactory(new PropertyValueFactory<>("glyphIcon"));
    logLevelColumn.setMinWidth(50.0);
    logLevelColumn.setPrefWidth(50.0);
    logLevelColumn.setMaxWidth(50.0);

    TableColumn<LogMessage, String> messageColumn = new TableColumn<>();
    messageColumn.setCellValueFactory(new PropertyValueFactory<>("message"));

    logTable.setItems(logMessages);
    ObservableList<TableColumn<LogMessage, ?>> tableColumns = logTable.getColumns();
    tableColumns.add(logLevelColumn);
    tableColumns.add(messageColumn);

    logTable.setEditable(false);
    // Prevent cell selection
    logTable.addEventFilter(MouseEvent.ANY, Event::consume);
    // Do not display a placeholder
    logTable.setPlaceholder(new Label(""));
    // Hide the header row
    logTable.widthProperty().addListener((observable, oldValue, newValue) -> {
        Pane header = (Pane) logTable.lookup("TableHeaderRow");
        if (header.isVisible()) {
            header.setMaxHeight(0);
            header.setMinHeight(0);
            header.setPrefHeight(0);
            header.setVisible(false);
        }
    });
    progressBar.setProgress(0f);
}
 
Example #10
Source File: TabController.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
private void configureTab(Tab tab, String title, String iconPath, AnchorPane containerPane, URL resourceURL, EventHandler<Event> onSelectionChangedEvent) {
    double imageWidth = 40.0;

    ImageView imageView = new ImageView(new Image(iconPath));
    imageView.setFitHeight(imageWidth);
    imageView.setFitWidth(imageWidth);

    Label label = new Label(title);
    label.setMaxWidth(tabWidth - 20);
    label.setPadding(new Insets(5, 0, 0, 0));
    label.setStyle("-fx-text-fill: black; -fx-font-size: 10pt; -fx-font-weight: bold;");
    label.setTextAlignment(TextAlignment.CENTER);

    BorderPane tabPane = new BorderPane();
    tabPane.setRotate(90.0);
    tabPane.setMaxWidth(tabWidth);
    tabPane.setCenter(imageView);
    tabPane.setBottom(label);

    tab.setText("");
    tab.setGraphic(tabPane);

    tab.setOnSelectionChanged(onSelectionChangedEvent);

    if (containerPane != null && resourceURL != null) {
        try {
            Parent contentView = FXMLLoader.load(resourceURL);
            containerPane.getChildren().add(contentView);
            AnchorPane.setTopAnchor(contentView, 0.0);
            AnchorPane.setBottomAnchor(contentView, 0.0);
            AnchorPane.setRightAnchor(contentView, 0.0);
            AnchorPane.setLeftAnchor(contentView, 0.0);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 
Example #11
Source File: TestTarget.java    From ShootOFF with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testDownArrowKeyMoveTarget() {
	double oldX = pepperPopper.getPosition().getX();
	double oldY = pepperPopper.getPosition().getY();

	KeyEvent downArrowEvent = new KeyEvent(null, pepperPopper.getTargetGroup(), KeyEvent.KEY_PRESSED, "down",
			"down", KeyCode.DOWN, false, false, false, false);
	Event.fireEvent(pepperPopper.getTargetGroup(), downArrowEvent);

	assertEquals(oldX, pepperPopper.getPosition().getX(), .001);
	assertEquals(oldY + TargetView.MOVEMENT_DELTA, pepperPopper.getPosition().getY(), .001);
}
 
Example #12
Source File: MainMenuController.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
public void fillRecentProjects(Event event) {

    recentProjectsMenu.getItems().clear();

    var recentProjects = MZmineCore.getConfiguration().getLastProjectsParameter().getValue();

    if ((recentProjects == null) || (recentProjects.isEmpty())) {
      recentProjectsMenu.setDisable(true);
      return;
    }

    recentProjectsMenu.setDisable(false);

    // add items to load last used projects directly
    recentProjects.stream().map(File::getAbsolutePath).forEach(name -> {
      MenuItem item = new MenuItem(name);

      item.setOnAction(e -> {
        MenuItem c = (MenuItem) e.getSource();
        if (c == null)
          return;
        File f = new File(c.getText());
        if (f.exists()) {
          // load file
          ProjectOpeningTask newTask = new ProjectOpeningTask(f);
          MZmineCore.getTaskController().addTask(newTask);
        }
      });
      recentProjectsMenu.getItems().add(item);
    });
  }
 
Example #13
Source File: MainWindowController.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
@FXML
public void handleCancelTask(Event event) {
  var selectedTasks = tasksView.getSelectionModel().getSelectedItems();
  for (WrappedTask t : selectedTasks) {
    t.getActualTask().cancel();
  }
}
 
Example #14
Source File: LabelSourceStateIdSelectorHandler.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
public EventHandler<Event> viewerHandler(
		final PainteraBaseView paintera,
		final KeyAndMouseBindings labelSourceStateBindings,
		final KeyTracker keyTracker,
		final String bindingKeySelectAll,
		final String bindingKeySelectAllInCurrentView,
		final String bindingKeyLockSegment,
		final String bindingKeyNextId) {
	return event -> {
		final EventTarget target = event.getTarget();
		if (!(target instanceof Node))
			return;
		Node node = (Node) target;
		LOG.trace("Handling event {} in target {}", event, target);
		// kind of hacky way to accomplish this:
		while (node != null) {
			if (node instanceof ViewerPanelFX) {
				handlers.computeIfAbsent((ViewerPanelFX) node, k -> this.makeHandler(
						paintera,
						labelSourceStateBindings,
						keyTracker,
						k,
						bindingKeySelectAll,
						bindingKeySelectAllInCurrentView,
						bindingKeyLockSegment,
						bindingKeyNextId)).handle(event);
				return;
			}
			node = node.getParent();
		}
	};
}
 
Example #15
Source File: LabelSourceStateMergeDetachHandler.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
private EventHandler<Event> makeHandler(
		final PainteraBaseView paintera,
		final KeyAndMouseBindings bindings,
		final KeyTracker keyTracker,
		final ViewerPanelFX vp,
		final String bindingKeyMergeAllSelected) {
	final DelegateEventHandlers.AnyHandler handler = DelegateEventHandlers.handleAny();
	handler.addOnMousePressed(EventFX.MOUSE_PRESSED(
			"merge fragments",
			new MergeFragments(vp),
			e -> paintera.allowedActionsProperty().get().isAllowed(LabelActionType.Merge) && e.isPrimaryButtonDown() && keyTracker.areOnlyTheseKeysDown(KeyCode.SHIFT)));
	handler.addOnMousePressed(EventFX.MOUSE_PRESSED(
			"detach fragment",
			new DetachFragment(vp),
			e -> paintera.allowedActionsProperty().get().isAllowed(LabelActionType.Split) && e.isSecondaryButtonDown() && keyTracker.areOnlyTheseKeysDown(KeyCode.SHIFT)));
	handler.addOnMousePressed(EventFX.MOUSE_PRESSED(
			"detach fragment",
			new ConfirmSelection(vp),
			e -> paintera.allowedActionsProperty().get().isAllowed(LabelActionType.Split) && e.isSecondaryButtonDown() && keyTracker.areOnlyTheseKeysDown(KeyCode.SHIFT, KeyCode.CONTROL)));

	final NamedKeyCombination.CombinationMap keyBindings = bindings.getKeyCombinations();

	handler.addOnKeyPressed(EventFX.KEY_PRESSED(
			bindingKeyMergeAllSelected,
			e -> mergeAllSelected(),
			e -> paintera.allowedActionsProperty().get().isAllowed(LabelActionType.Merge) && keyBindings.get(bindingKeyMergeAllSelected).getPrimaryCombination().match(e)));

	return handler;
}
 
Example #16
Source File: MainWindowController.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
public void handleShow3DPlot(Event event) {
  logger.finest("Activated Show 3D plot menu item");
  var selectedFiles = MZmineGUI.getSelectedRawDataFiles();
  ParameterSet parameters =
      MZmineCore.getConfiguration().getModuleParameters(Fx3DVisualizerModule.class);
  parameters.getParameter(Fx3DVisualizerParameters.dataFiles).setValue(
      RawDataFilesSelectionType.SPECIFIC_FILES, selectedFiles.toArray(new RawDataFile[0]));
  ExitCode exitCode = parameters.showSetupDialog(true);
  if (exitCode == ExitCode.OK)
    MZmineCore.runMZmineModule(Fx3DVisualizerModule.class, parameters);
}
 
Example #17
Source File: EventStreams.java    From ReactFX with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static <T extends Event> EventStream<T> eventsOf(
        MenuItem menuItem, EventType<T> eventType) {
    return new EventStreamBase<T>() {
        @Override
        protected Subscription observeInputs() {
            EventHandler<T> handler = this::emit;
            menuItem.addEventHandler(eventType, handler);
            return () -> menuItem.removeEventHandler(eventType, handler);
        }
    };
}
 
Example #18
Source File: FaceDetectionController.java    From ExoVisix with MIT License 5 votes vote down vote up
@FXML
protected void haarSelected(Event event)
{
	// check whether the lpb checkbox is selected and deselect it
	if (this.lbpClassifier.isSelected())
		this.lbpClassifier.setSelected(false);
		
	this.checkboxSelection("resources/haarcascades/haarcascade_frontalcatface.xml");
}
 
Example #19
Source File: MainWindowController.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
@FXML
public void handleMemoryBarClick(Event e) {
  // Run garbage collector on a new thread, so it doesn't block the GUI
  new Thread(() -> {
    logger.info("Freeing unused memory");
    System.gc();
  }).start();
}
 
Example #20
Source File: SwordController.java    From Sword_emulator with GNU General Public License v3.0 5 votes vote down vote up
public void onExecute(Event actionEvent) {
    if (machine.loop()) {
        debugSingleMenu.setDisable(true);
        debugSingleWithoutJalMenu.setDisable(true);
        debugStopMenu.setDisable(false);
        debugExecuteMenu.setDisable(true);
        singleButton.setDisable(true);
        pauseButton.setDisable(false);
        executeButton.setDisable(true);
    }
}
 
Example #21
Source File: RFXComponent.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public void handleRawRecording(IJSONRecorder recorder, Event event) {
    if (event instanceof MouseEvent && event.getEventType() == MouseEvent.MOUSE_PRESSED) {
        recorder.recordRawMouseEvent(this, (MouseEvent) event);
    }
    if (event instanceof KeyEvent && event.getEventType() != KeyEvent.KEY_RELEASED) {
        recorder.recordRawKeyEvent(this, (KeyEvent) event);
    }
}
 
Example #22
Source File: JFXDrawer.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
/**
 * this method is only used in drawers stack component
 *
 * @param callback
 */
void bringToFront(Callback<Void, Void> callback) {
    EventHandler<? super MouseEvent> eventFilter = Event::consume;
    final boolean fillSize = prefSizeProperty.get() == USE_COMPUTED_SIZE;
    // disable mouse events
    this.addEventFilter(MouseEvent.ANY, eventFilter);

    Runnable onFinished = () -> {
        callback.call(null);
        translateTo = 0;
        translateTimer.setOnFinished(() -> {
            if (fillSize) {
                prefSizeProperty.set(USE_COMPUTED_SIZE);
                maxSizeProperty.set(USE_COMPUTED_SIZE);
            }
            // enable mouse events
            this.removeEventFilter(MouseEvent.ANY, eventFilter);
        });
        getCachePolicy().cache(contentHolder);
        translateTimer.start();
    };

    if (sizeProperty.get() > getDefaultDrawerSize()) {
        tempDrawerSize = sizeProperty.get();
    } else {
        tempDrawerSize = getDefaultDrawerSize();
    }
    translateTo = initTranslate.get();
    translateTimer.setOnFinished(onFinished);
    getCachePolicy().cache(contentHolder);
    translateTimer.start();
}
 
Example #23
Source File: JFXNodeUtils.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
public static <T extends Event> EventHandler<? super T> addDelayedEventHandler(Node control, Duration delayTime,
                                                                               final EventType<T> eventType,
                                                                               final EventHandler<? super T> eventHandler) {
    Wrapper<T> eventWrapper = new Wrapper<>();
    PauseTransition holdTimer = new PauseTransition(delayTime);
    holdTimer.setOnFinished(finish -> eventHandler.handle(eventWrapper.content));
    final EventHandler<? super T> eventEventHandler = event -> {
        eventWrapper.content = event;
        holdTimer.playFromStart();
    };
    control.addEventHandler(eventType, eventEventHandler);
    return eventEventHandler;
}
 
Example #24
Source File: WebEventDispatcher.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Event dispatchEvent(Event event, EventDispatchChain tail) {

	if (event instanceof MouseEvent){
        MouseEvent m = (MouseEvent)event;
        if (event.getEventType().equals(MouseEvent.MOUSE_CLICKED) ||
            event.getEventType().equals(MouseEvent.MOUSE_PRESSED)) {
            Point2D origin = new Point2D(m.getX(),m.getY());
            if (limit != null)
            	allowDrag = !(origin.getX() < limit.getX() && origin.getY() < limit.getY());
        }

        // avoid selection with mouse dragging, allowing dragging the scrollbars
        if (event.getEventType().equals(MouseEvent.MOUSE_DRAGGED)) {
            if(!allowDrag){
                event.consume();
            }
        }
        // Avoid selection of word, line, paragraph with mouse click
        if(m.getClickCount() > 1){
            event.consume();
        }
    }

    if (event instanceof KeyEvent && event.getEventType().equals(KeyEvent.KEY_PRESSED)){
        KeyEvent k = (KeyEvent)event;
        // Avoid copy with Ctrl+C or Ctrl+Insert
        if((k.getCode().equals(KeyCode.C) || k.getCode().equals(KeyCode.INSERT)) && k.isControlDown()){
            event.consume();
        }
        // Avoid selection with shift+Arrow
        if(k.isShiftDown() && (k.getCode().equals(KeyCode.RIGHT) || k.getCode().equals(KeyCode.LEFT) ||
            k.getCode().equals(KeyCode.UP) || k.getCode().equals(KeyCode.DOWN))){
            event.consume();
        }
    }
    return oldDispatcher.dispatchEvent(event, tail);
}
 
Example #25
Source File: Controller.java    From game-of-life-java with MIT License 5 votes vote down vote up
@FXML
private void onRun(Event evt) {
    toggleButtons(false);

    loop = new Timeline(new KeyFrame(Duration.millis(300), e -> {
        board.update();
        display.displayBoard(board);
    }));

    loop.setCycleCount(100);
    loop.play();
}
 
Example #26
Source File: ShowPanelFrame.java    From oim-fx with MIT License 5 votes vote down vote up
private void init() {
	this.setBackground("Resources/Images/Wallpaper/18.jpg");
	this.setTitle("登录");
	this.setWidth(440);
	this.setHeight(360);
	this.setCenter(box);

	box.setStyle("-fx-background-color:rgba(255, 255, 255, 0.2)");

	box.getChildren().add(button);
	box.getChildren().add(webView);

	File file = new File("Resources/Images/Head/User/90_100.gif");
	//
	String fullPath = file.getAbsolutePath();
	String htmlText = "<html><body> <lable id=\"show_text\">666</label>" + "<img src=\"file:/" + fullPath + "\" />"
			+ "</body></html> ";

	// WebPage webPage=new WebPage();
	// WebEngine we = webView.getEngine();
	// // we.loadContent(htmlText);
	webPage = Accessor.getPageFor(webView.getEngine());
	webPage.setEditable(false);
	webPage.load(webPage.getMainFrame(), htmlText, "text/html");
	//webPage.setUserAgent(userAgent);
	//webView.
	//webView.setContextMenuEnabled(false);
	webPage.setLocalStorageEnabled(false);
	webView.setOnContextMenuRequested(new  EventHandler<Event>(){

		@Override
		public void handle(Event event) {
			Object o=event.getSource();
			System.out.println(o.getClass());
		}});

}
 
Example #27
Source File: AbstractSceneFileEditor.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
@FxThread
private boolean isVisibleOnEditor(@NotNull final Spatial spatial) {

    final MA editor3DPart = getEditor3DPart();
    final Camera camera = editor3DPart.getCamera();

    final Vector3f position = spatial.getWorldTranslation();
    final Vector3f coordinates = camera.getScreenCoordinates(position, new Vector3f());

    boolean invisible = coordinates.getZ() < 0F || coordinates.getZ() > 1F;
    invisible = invisible || !isInside(coordinates.getX(), camera.getHeight() - coordinates.getY(), Event.class);

    return !invisible;
}
 
Example #28
Source File: GroupResource.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public Resource rename(String text) {
    group.setName(text);
    try {
        Group.updateFile(group);
        Event.fireEvent(this, new ResourceModificationEvent(ResourceModificationEvent.UPDATE, this));
    } catch (IOException e) {
        e.printStackTrace();
    }
    return this;
}
 
Example #29
Source File: MenuEditorController.java    From tcMenu with Apache License 2.0 5 votes vote down vote up
public void onShowEditMenu(Event event) {
    currentEditor.ifPresentOrElse((uiItem)-> {
        menuCopy.setDisable(!uiItem.canCopy());
        menuCut.setDisable(!uiItem.canCopy());
        menuPaste.setDisable(!uiItem.canPaste());
    }, ()-> {
        menuCopy.setDisable(true);
        menuCut.setDisable(true);
        menuPaste.setDisable(true);
    });
    menuRedo.setDisable(!editorProject.canRedo());
    menuUndo.setDisable(!editorProject.canUndo());
}
 
Example #30
Source File: DashboardController.java    From Everest with Apache License 2.0 5 votes vote down vote up
private void onFailed(Event event) {
    showLayer(ResponseLayer.ERROR);
    Throwable throwable = requestManager.getException();
    Exception exception = (Exception) throwable;
    LoggingService.logWarning(httpMethodBox.getValue() + " request could not be processed.", exception, LocalDateTime.now());

    if (throwable.getClass() == NullResponseException.class) {
        NullResponseException URE = (NullResponseException) throwable;
        errorTitle.setText(URE.getExceptionTitle());
        errorDetails.setText(URE.getExceptionDetails());
    } else if (throwable.getClass() == ProcessingException.class) {
        errorTitle.setText("Everest couldn't connect.");
        errorDetails.setText("Either you are not connected to the Internet or the server is offline.");
    } else if (throwable.getClass() == RedirectException.class) {
        RedirectException redirect = (RedirectException) throwable;
        addressField.setText(redirect.getNewLocation());
        snackbar.show("Resource moved permanently. Redirecting...", 3000);
        requestManager = null;
        sendRequest();
        return;
    }

    if (requestManager.getRequest().getClass().equals(DataRequest.class)) {
        if (throwable.getClass() == FileNotFoundException.class) {
            errorTitle.setText("File(s) not found:");
            errorDetails.setText(throwable.getMessage());
        }
    }

    requestManager.reset();
}