Пример #1
0
  public void onClose() {
    container.removeComponentListener(componentListener);
    editor.getDocument().removeDocumentListener(documentListener);
    configService.remove(configChangeListener);
    editor.getScrollingModel().removeVisibleAreaListener(this);
    editor.getSelectionModel().removeSelectionListener(selectionListener);
    removeMouseWheelListener(mouseWheelListener);
    removeMouseListener(mouseListener);
    removeMouseMotionListener(mouseListener);

    componentListener = null;
    documentListener = null;
    configChangeListener = null;
    mouseListener = null;
  }
Пример #2
0
  public GlancePanel(Project project, FileEditor fileEditor, JPanel container, TaskRunner runner) {
    this.runner = runner;
    this.editor = ((TextEditor) fileEditor).getEditor();
    this.container = container;
    this.project = project;

    container.addComponentListener(
        componentListener =
            new ComponentAdapter() {
              @Override
              public void componentResized(ComponentEvent componentEvent) {
                updateSize();
                GlancePanel.this.revalidate();
                GlancePanel.this.repaint();
              }
            });

    editor
        .getDocument()
        .addDocumentListener(
            documentListener =
                new DocumentAdapter() {
                  @Override
                  public void documentChanged(DocumentEvent documentEvent) {
                    updateImage();
                  }
                });

    configService.add(
        configChangeListener =
            new ConfigChangeListener() {
              @Override
              public void configChanged() {
                readConfig();
                updateImage();
                updateSize();
                GlancePanel.this.revalidate();
                GlancePanel.this.repaint();
              }
            });

    addMouseWheelListener(mouseWheelListener);

    readConfig();

    editor.getScrollingModel().addVisibleAreaListener(this);

    editor
        .getSelectionModel()
        .addSelectionListener(
            selectionListener =
                new SelectionListener() {
                  @Override
                  public void selectionChanged(SelectionEvent selectionEvent) {
                    repaint();
                  }
                });

    addMouseListener(mouseListener);
    addMouseMotionListener(mouseListener);

    updateSize();
    for (int i = 0; i < Array.getLength(minimaps); i++) {
      minimaps[i] = new Minimap(configService.getState());
    }
    updateImage();
  }
Пример #3
0
  private void readConfig() {
    config = configService.getState();

    coords.setPixelsPerLine(config.pixelsPerLine);
    viewportColor = Color.decode("#" + config.viewportColor);
  }