Пример #1
0
  public EditorView<T> getView(String viewId) {
    for (EditorView<T> view : views) {
      if (view.getViewId().equals(viewId)) return view;
    }

    return null;
  }
Пример #2
0
  public final void setDocument(T document) {
    if (this.document != null) this.document.release();

    this.document = document;

    for (EditorView<T> view : views) {
      view.setDocument(document);
    }
  }
Пример #3
0
    @SuppressWarnings("unchecked")
    public void stateChanged(ChangeEvent e) {
      int currentViewIndex = views.indexOf(currentView);

      if (currentView != null) {
        if (inputTabs.getSelectedIndex() == currentViewIndex) return;

        if (!currentView.deactivate()) {
          inputTabs.setSelectedIndex(currentViewIndex);
          return;
        }
      }

      EditorView<T> previousView = currentView;
      int selectedIndex = inputTabs.getSelectedIndex();
      if (selectedIndex == -1) {
        currentView = null;
        return;
      }

      currentView = views.get(selectedIndex);

      if (currentView != null
          && !currentView.activate(
              previousView == null ? null : previousView.getEditorLocation())) {
        inputTabs.setSelectedIndex(currentViewIndex);
        if (currentViewIndex == -1) return;
      }

      EditorInspector<T> currentInspector =
          (EditorInspector<T>) inspectorPanel.getCurrentInspector();

      if (currentInspector != null) {
        lastDividerLocation = inspectorPanel.getDividerLocation();
      }

      for (Inspector inspector : inspectorPanel.getInspectors()) {
        inspectorPanel.setInspectorVisible(
            inspector, ((EditorInspector<T>) inspector).isEnabledFor(currentView));
      }

      if (currentInspector != null
          && ((EditorInspector<T>) currentInspector).isEnabledFor(currentView)) {
        if (lastDividerLocation == 0) inspectorPanel.setResetDividerLocation();
        else inspectorPanel.setDividerLocation(lastDividerLocation);
      } else currentInspector = null;

      SwingUtilities.invokeLater(
          new Runnable() {

            public void run() {
              if (currentView != null) currentView.getComponent().requestFocus();
            }
          });
    }
Пример #4
0
  public void addEditorView(EditorView<T> editorView) {
    views.add(editorView);

    inputTabs.addTab(
        null,
        new VTextIcon(inputTabs, editorView.getTitle(), VTextIcon.ROTATE_LEFT),
        editorView.getComponent());

    editorView.addPropertyChangeListener(this);
    editorView.addLocationListener(this);

    editorView.setDocument(document);
  }
Пример #5
0
  public void release() {
    for (EditorView<T> view : views) {
      view.release();
      view.removePropertyChangeListener(this);
    }

    views.clear();

    inputTabs.removeChangeListener(inputTabsChangeListener);
    inputTabs.removeAll();

    inspectorPanel.release();
    document.release();
  }
Пример #6
0
 public void setEditable(boolean enabled) {
   for (EditorView<T> view : views) {
     view.setEditable(enabled);
   }
 }
Пример #7
0
 public boolean hasFocus() {
   return currentView == null ? false : currentView.getComponent().hasFocus();
 }
Пример #8
0
 public void requestFocus() {
   if (currentView != null) currentView.getComponent().requestFocus();
 }