Exemplo n.º 1
0
 public void markAsUnread(Preferences prefs) {
   setMarkedReadAt(Optional.empty());
   prefs.clearMarkedReadAt(getRepoId(), getId());
 }
Exemplo n.º 2
0
  private void setupKeyboardShortcuts() {
    filterTextField.addEventHandler(
        KeyEvent.KEY_RELEASED,
        event -> {
          if (KeyboardShortcuts.BOX_TO_LIST.match(event)) {
            event.consume();
            listView.selectFirstItem();
          }
          if (event.getCode() == KeyboardShortcuts.DOUBLE_PRESS) {
            event.consume();
          }
          if (KeyPress.isDoublePress(KeyboardShortcuts.DOUBLE_PRESS, event.getCode())) {
            event.consume();
            listView.selectFirstItem();
          }
          if (KeyboardShortcuts.MAXIMIZE_WINDOW.match(event)) {
            ui.maximizeWindow();
          }
          if (KeyboardShortcuts.MINIMIZE_WINDOW.match(event)) {
            ui.minimizeWindow();
          }
          if (KeyboardShortcuts.DEFAULT_SIZE_WINDOW.match(event)) {
            ui.setDefaultWidth();
          }
          if (KeyboardShortcuts.SWITCH_DEFAULT_REPO.match(event)) {
            ui.switchDefaultRepo();
          }
        });

    addEventHandler(
        KeyEvent.KEY_RELEASED,
        event -> {
          if (event.getCode() == KeyboardShortcuts.markAsRead) {
            Optional<TurboIssue> item = listView.getSelectedItem();
            if (!item.isPresent()) {
              return;
            }
            TurboIssue issue = item.get();
            LocalDateTime now = LocalDateTime.now();
            ui.prefs.setMarkedReadAt(issue.getRepoId(), issue.getId(), now);
            issue.setMarkedReadAt(Optional.of(now));
            issue.setIsCurrentlyRead(true);
            parentPanelControl.refresh();
            listView.selectNextItem();
          }
          if (event.getCode() == KeyboardShortcuts.markAsUnread) {
            Optional<TurboIssue> item = listView.getSelectedItem();
            if (!item.isPresent()) {
              return;
            }
            TurboIssue issue = item.get();
            ui.prefs.clearMarkedReadAt(issue.getRepoId(), issue.getId());
            issue.setMarkedReadAt(Optional.empty());
            issue.setIsCurrentlyRead(false);
            parentPanelControl.refresh();
          }
          if (event.getCode() == KeyboardShortcuts.SHOW_DOCS) {
            ui.getBrowserComponent().showDocs();
          }
          if (KeyboardShortcuts.LIST_TO_BOX.match(event)) {
            setFocusToFilterBox();
          }
          if (event.getCode() == KeyboardShortcuts.DOUBLE_PRESS
              && KeyPress.isDoublePress(KeyboardShortcuts.DOUBLE_PRESS, event.getCode())) {

            setFocusToFilterBox();
          }
          if (event.getCode() == KeyboardShortcuts.SHOW_ISSUES) {
            if (KeyPress.isValidKeyCombination(KeyboardShortcuts.GOTO_MODIFIER, event.getCode())) {
              ui.getBrowserComponent().showIssues();
            }
          }
          if (event.getCode() == KeyboardShortcuts.SHOW_PULL_REQUESTS) {
            if (KeyPress.isValidKeyCombination(KeyboardShortcuts.GOTO_MODIFIER, event.getCode())) {
              ui.getBrowserComponent().showPullRequests();
            }
          }
          if (event.getCode() == KeyboardShortcuts.SHOW_HELP) {
            if (KeyPress.isValidKeyCombination(KeyboardShortcuts.GOTO_MODIFIER, event.getCode())) {
              ui.getBrowserComponent().showDocs();
            }
          }
          if (event.getCode() == KeyboardShortcuts.SHOW_KEYBOARD_SHORTCUTS) {
            if (KeyPress.isValidKeyCombination(KeyboardShortcuts.GOTO_MODIFIER, event.getCode())) {
              ui.getBrowserComponent().showKeyboardShortcuts();
            }
          }
          if (event.getCode() == KeyboardShortcuts.SHOW_CONTRIBUTORS) {
            if (KeyPress.isValidKeyCombination(KeyboardShortcuts.GOTO_MODIFIER, event.getCode())) {
              ui.getBrowserComponent().showContributors();
              event.consume();
            }
          }
          if (event.getCode() == KeyboardShortcuts.scrollToTop) {
            ui.getBrowserComponent().scrollToTop();
          }
          if (event.getCode() == KeyboardShortcuts.scrollToBottom) {
            if (!KeyboardShortcuts.MINIMIZE_WINDOW.match(event)) {
              ui.getBrowserComponent().scrollToBottom();
            }
          }
          if (event.getCode() == KeyboardShortcuts.scrollUp
              || event.getCode() == KeyboardShortcuts.scrollDown) {
            ui.getBrowserComponent().scrollPage(event.getCode() == KeyboardShortcuts.scrollDown);
          }
          if (event.getCode() == KeyboardShortcuts.GOTO_MODIFIER) {
            KeyPress.setLastKeyPressedCodeAndTime(event.getCode());
          }
          if (event.getCode() == KeyboardShortcuts.NEW_COMMENT
              && ui.getBrowserComponent().isCurrentUrlIssue()) {
            ui.getBrowserComponent().jumpToComment();
          }
          if (event.getCode() == KeyboardShortcuts.SHOW_LABELS) {
            if (KeyPress.isValidKeyCombination(KeyboardShortcuts.GOTO_MODIFIER, event.getCode())) {
              ui.getBrowserComponent().newLabel();
            } else {
              ui.triggerEvent(new ShowLabelPickerEvent(getSelectedIssue()));
            }
          }
          if (event.getCode() == KeyboardShortcuts.MANAGE_ASSIGNEES
              && ui.getBrowserComponent().isCurrentUrlIssue()) {
            ui.getBrowserComponent().manageAssignees(event.getCode().toString());
          }
          if (event.getCode() == KeyboardShortcuts.SHOW_MILESTONES) {
            if (KeyPress.isValidKeyCombination(KeyboardShortcuts.GOTO_MODIFIER, event.getCode())) {
              ui.getBrowserComponent().showMilestones();
            } else if (ui.getBrowserComponent().isCurrentUrlIssue()) {
              ui.getBrowserComponent().manageMilestones(event.getCode().toString());
            }
          }
          if (KeyboardShortcuts.MAXIMIZE_WINDOW.match(event)) {
            ui.maximizeWindow();
          }
          if (KeyboardShortcuts.MINIMIZE_WINDOW.match(event)) {
            ui.minimizeWindow();
          }
          if (KeyboardShortcuts.DEFAULT_SIZE_WINDOW.match(event)) {
            ui.setDefaultWidth();
          }
          if (KeyboardShortcuts.SWITCH_DEFAULT_REPO.match(event)) {
            ui.switchDefaultRepo();
          }
        });
  }
Exemplo n.º 3
0
 public void markAsRead(Preferences prefs) {
   LocalDateTime now = LocalDateTime.now();
   setMarkedReadAt(Optional.of(now));
   prefs.setMarkedReadAt(getRepoId(), getId(), getMarkedReadAt().get());
 }