1
/*******************************************************************************
2
* Copyright (C) 2003-2007, 2013, Guillaume Brocker
4
* All rights reserved. This program and the accompanying materials
5
* are made available under the terms of the Eclipse Public License v1.0
6
* which accompanies this distribution, and is available at
7
* http://www.eclipse.org/legal/epl-v10.html
10
* Guillaume Brocker - Initial API and implementation
12
******************************************************************************/
14
package eclox.ui.editor.basic;
16
import org.eclipse.swt.widgets.Composite;
17
import org.eclipse.ui.forms.widgets.FormToolkit;
19
import eclox.core.doxyfiles.Doxyfile;
20
import eclox.ui.editor.editors.CheckBoxEditor;
21
import eclox.ui.editor.editors.IEditor;
22
import eclox.ui.editor.editors.IEditorListener;
25
* Implements a art that provides editors for diagram generation controlling.
27
* @author Guillaume Brocker
29
public class DiagramsPart extends Part {
32
* Implements an editor listener that will trigger enabled state updates.
34
private class MyEditorListener implements IEditorListener {
37
* @see eclox.ui.editor.editors.IEditorListener#editorChanged(eclox.ui.editor.editors.IEditor)
39
public void editorChanged(IEditor editor) {
41
assert editor == diagrams;
43
final String selection = diagrams.getSelection();
44
final boolean enabled = selection != null && selection.equals(DIAGRAM_DOT_TOOL);
46
classGraph .setEnabled(enabled && classGraph.hasInput());
47
collaborationGraph.setEnabled(enabled && collaborationGraph.hasInput());
48
includeGraph .setEnabled(enabled && includeGraph.hasInput());
49
includedByGraph .setEnabled(enabled && includedByGraph.hasInput());
50
graphicalHierarcy .setEnabled(enabled && graphicalHierarcy.hasInput());
51
callGraph .setEnabled(enabled && callGraph.hasInput());
57
* symbolic constant for diagram activation's state
59
private static final String DIAGRAM_NONE = "No diagrams";
62
* symbolic constant for diagram activation's state
64
private static final String DIAGRAM_BUILT_IN = "Use built-in diagram generator";
67
* symbolic constant for diagram activation's state
69
private static final String DIAGRAM_DOT_TOOL = "Use dot tool from the GraphViz package to generate:";
72
* the editor for diagram activation
74
private MultiEditor diagrams = new RadioMultiEditor( new String[] {DIAGRAM_NONE, DIAGRAM_BUILT_IN, DIAGRAM_DOT_TOOL} );
77
* the editor for the dot class graph generation
79
private CheckBoxEditor classGraph = new CheckBoxEditor("class diagrams");
82
* the editor for the dot collaboration graph generation
84
private CheckBoxEditor collaborationGraph = new CheckBoxEditor("collaboration diagrams");
87
* the editor for the dot include graph generation
89
private CheckBoxEditor includeGraph = new CheckBoxEditor("include dependency graph");
92
* the editor for the dot included by graph generation
94
private CheckBoxEditor includedByGraph = new CheckBoxEditor("included by dependency graph");
97
* the editor for the dot hierarchy graph generation
99
private CheckBoxEditor graphicalHierarcy = new CheckBoxEditor("overall class hierarchy");
102
* the editor for the dot call graph generation
104
private CheckBoxEditor callGraph = new CheckBoxEditor("call graphs");
110
* @param parent the parent composite
111
* @param toolkit the toolkit to use for control creations
112
* @param doxyfile the doxyfile being edited
114
DiagramsPart( Composite parent, FormToolkit toolkit, Doxyfile doxyfile ) {
115
super( parent, toolkit, "Diagrams to Generate", doxyfile );
117
// Creates all editors.
118
addEditor( diagrams );
119
addEditor( classGraph, 16 );
120
addEditor( collaborationGraph, 16 );
121
addEditor( includeGraph, 16 );
122
addEditor( includedByGraph, 16 );
123
addEditor( graphicalHierarcy, 16 );
124
addEditor( callGraph, 16 );
126
// Setup all editors.
127
if( doxyfile.hasSetting("CLASS_DIAGRAMS")
128
&& doxyfile.hasSetting("HAVE_DOT") ) {
129
diagrams.addListener(new MyEditorListener());
130
diagrams.addSetting(DIAGRAM_BUILT_IN, doxyfile.getSetting("CLASS_DIAGRAMS"));
131
diagrams.addSetting(DIAGRAM_DOT_TOOL, doxyfile.getSetting("HAVE_DOT"));
133
classGraph .setInput(doxyfile.getSetting("CLASS_GRAPH"));
134
collaborationGraph.setInput(doxyfile.getSetting("COLLABORATION_GRAPH"));
135
includeGraph .setInput(doxyfile.getSetting("INCLUDE_GRAPH"));
136
includedByGraph .setInput(doxyfile.getSetting("INCLUDED_BY_GRAPH"));
137
graphicalHierarcy .setInput(doxyfile.getSetting("GRAPHICAL_HIERARCHY"));
138
callGraph .setInput(doxyfile.getSetting("CALL_GRAPH"));
140
classGraph .setEnabled(classGraph.hasInput());
141
collaborationGraph.setEnabled(collaborationGraph.hasInput());
142
includeGraph .setEnabled(includeGraph.hasInput());
143
includedByGraph .setEnabled(includedByGraph.hasInput());
144
graphicalHierarcy .setEnabled(graphicalHierarcy.hasInput());
145
callGraph .setEnabled(callGraph.hasInput());
148
diagrams .setEnabled(false);
149
classGraph .setEnabled(false);
150
collaborationGraph.setEnabled(false);
151
includeGraph .setEnabled(false);
152
includedByGraph .setEnabled(false);
153
graphicalHierarcy .setEnabled(false);
154
callGraph .setEnabled(false);