public EditorView<T> getView(String viewId) { for (EditorView<T> view : views) { if (view.getViewId().equals(viewId)) return view; } return null; }
public final void setDocument(T document) { if (this.document != null) this.document.release(); this.document = document; for (EditorView<T> view : views) { view.setDocument(document); } }
@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(); } }); }
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); }
public void release() { for (EditorView<T> view : views) { view.release(); view.removePropertyChangeListener(this); } views.clear(); inputTabs.removeChangeListener(inputTabsChangeListener); inputTabs.removeAll(); inspectorPanel.release(); document.release(); }
public void setEditable(boolean enabled) { for (EditorView<T> view : views) { view.setEditable(enabled); } }
public boolean hasFocus() { return currentView == null ? false : currentView.getComponent().hasFocus(); }
public void requestFocus() { if (currentView != null) currentView.getComponent().requestFocus(); }