void handleErrorEvent(final ProgramError error) {
   if (error.getLevel() == ErrorLevel.FATAL) {
     eventBus.publish(new FatalProgramErrorEvent(error));
   } else {
     eventBus.publish(new NonFatalProgramErrorEvent(error));
   }
 }
Exemple #2
0
  /**
   * Adds a window to the frame container.
   *
   * @param parent Parent node
   * @param window Window to add
   */
  public void addWindow(final MutableTreeNode parent, final TextFrame window) {
    UIUtilities.invokeAndWait(
        () -> {
          final NodeLabel label = new NodeLabel(window, iconManager);
          eventBus.subscribe(label);
          swingEventBus.subscribe(label);
          final TreeViewNode node = new TreeViewNode(label, window);
          synchronized (nodes) {
            nodes.put(window, node);
          }
          if (parent == null) {
            model.insertNodeInto(node, model.getRootNode());
          } else {
            model.insertNodeInto(node, parent);
          }
          tree.expandPath(new TreePath(node.getPath()).getParentPath());
          final Rectangle view =
              tree.getRowBounds(tree.getRowForPath(new TreePath(node.getPath())));
          if (view != null) {
            tree.scrollRectToVisible(new Rectangle(0, (int) view.getY(), 0, 0));
          }

          node.getLabel()
              .unreadStatusChanged(
                  new UnreadStatusChangedEvent(
                      window.getContainer(),
                      window.getContainer().getUnreadStatusManager(),
                      window.getContainer().getUnreadStatusManager().getNotificationColour(),
                      window.getContainer().getUnreadStatusManager().getUnreadLines()));
          node.getLabel()
              .iconChanged(
                  new FrameIconChangedEvent(
                      window.getContainer(), window.getContainer().getIcon()));
        });
  }
Exemple #3
0
  /**
   * Creates a new feedback nag.
   *
   * @param iconManager The icon manager to use to find the feedback nag icon.
   * @param feedbackDialogProvider Provider of feedback dialogs.
   * @param eventBus The event bus to post messages to
   */
  @Inject
  public FeedbackNag(
      final IconManager iconManager,
      final DialogProvider<FeedbackDialog> feedbackDialogProvider,
      final EventBus eventBus) {
    this.feedbackDialogProvider = feedbackDialogProvider;
    this.eventBus = eventBus;

    menu = new JPopupMenu();
    show = new JMenuItem("Open");
    final JMenuItem dismiss = new JMenuItem("Dismiss");

    setIcon(iconManager.getIcon("feedback"));
    setBorder(BorderFactory.createEtchedBorder());
    setToolTipText("We would appreciate any feedback you may have about " + "DMDirc.");

    menu.add(show);
    menu.add(dismiss);

    show.addActionListener(this);
    dismiss.addActionListener(this);
    addMouseListener(this);
    // TODO: There should be some other class which adds the nag to the status bar
    eventBus.publishAsync(new StatusBarComponentAddedEvent(this));
  }
Exemple #4
0
 @Override
 public void actionPerformed(final ActionEvent e) {
   if (e.getSource() == show) {
     feedbackDialogProvider.displayOrRequestFocus();
   }
   eventBus.publishAsync(new StatusBarComponentRemovedEvent(this));
 }
Exemple #5
0
 @Override
 public void mouseReleased(final MouseEvent e) {
   if (e.getButton() == 1) {
     feedbackDialogProvider.displayOrRequestFocus();
     eventBus.publishAsync(new StatusBarComponentRemovedEvent(this));
   }
   checkMouseEvent(e);
 }
Exemple #6
0
  @Override
  public void setParent(final JComponent parent) {
    SwingUtilities.invokeLater(
        () -> {
          final JScrollPane scrollPane = new JScrollPane(tree);
          scrollPane.setAutoscrolls(true);
          scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

          parent.setVisible(false);
          parent.setLayout(new MigLayout("ins 0, fill"));
          parent.add(scrollPane, "grow");
          parent.setFocusable(false);
          parent.setVisible(true);

          setColours();

          eventBus.subscribe(this);
          swingEventBus.subscribe(this);
          redoTreeView();
        });
  }
Exemple #7
0
 @Handler
 public void doDeleteWindow(final SwingWindowDeletedEvent event) {
   final TextFrame window = event.getChildWindow();
   UIUtilities.invokeAndWait(
       () -> {
         if (nodes.get(window) == null) {
           return;
         }
         final DefaultMutableTreeNode node = nodes.get(window);
         if (node.getLevel() == 0) {
           LOG.warn(
               LogUtils.USER_ERROR,
               "delServer triggered for root node {}",
               node,
               new IllegalArgumentException());
         } else {
           model.removeNodeFromParent(nodes.get(window));
         }
         synchronized (nodes) {
           eventBus.unsubscribe(nodes.get(window).getLabel());
           nodes.remove(window);
         }
       });
 }
 /** Initialises the error manager. Must be called before logging will start. */
 public void initialise() {
   eventBus.subscribe(this);
 }
 /**
  * Called when an error needs to be deleted from the list.
  *
  * @param error ProgramError that changed
  */
 public void deleteError(final ProgramError error) {
   errors.remove(error);
   eventBus.publishAsync(new ProgramErrorDeletedEvent(error));
 }