~ubuntu-branches/ubuntu/utopic/eclipse-eclox/utopic

« back to all changes in this revision

Viewing changes to eclox.ui/src/eclox/ui/editor/basic/DiagramsPart.java

  • Committer: Package Import Robot
  • Author(s): Graham Inggs
  • Date: 2013-07-07 20:33:10 UTC
  • Revision ID: package-import@ubuntu.com-20130707203310-a44yw80gqtc2s9ob
Tags: upstream-0.10.0
ImportĀ upstreamĀ versionĀ 0.10.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*******************************************************************************
 
2
 * Copyright (C) 2003-2007, 2013, Guillaume Brocker
 
3
 * 
 
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
 
8
 *
 
9
 * Contributors:
 
10
 *     Guillaume Brocker - Initial API and implementation
 
11
 *
 
12
 ******************************************************************************/ 
 
13
 
 
14
package eclox.ui.editor.basic;
 
15
 
 
16
import org.eclipse.swt.widgets.Composite;
 
17
import org.eclipse.ui.forms.widgets.FormToolkit;
 
18
 
 
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;
 
23
 
 
24
/**
 
25
 * Implements a art that provides editors for diagram generation controlling.
 
26
 * 
 
27
 * @author Guillaume Brocker
 
28
 */
 
29
public class DiagramsPart extends Part {
 
30
 
 
31
        /**
 
32
         * Implements an editor listener that will trigger enabled state updates.
 
33
         */
 
34
        private class MyEditorListener implements IEditorListener {
 
35
 
 
36
                /**
 
37
                 * @see eclox.ui.editor.editors.IEditorListener#editorChanged(eclox.ui.editor.editors.IEditor)
 
38
                 */
 
39
                public void editorChanged(IEditor editor) {
 
40
                        // Pre-condition
 
41
                        assert editor == diagrams;
 
42
                        
 
43
                        final String    selection = diagrams.getSelection();
 
44
                        final boolean   enabled = selection != null && selection.equals(DIAGRAM_DOT_TOOL); 
 
45
                        
 
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());
 
52
                }
 
53
                
 
54
        }
 
55
        
 
56
        /**
 
57
         * symbolic constant for diagram activation's state
 
58
         */
 
59
        private static final String DIAGRAM_NONE = "No diagrams";
 
60
 
 
61
        /**
 
62
         * symbolic constant for diagram activation's state
 
63
         */
 
64
        private static final String DIAGRAM_BUILT_IN = "Use built-in diagram generator";
 
65
        
 
66
        /**
 
67
         * symbolic constant for diagram activation's state
 
68
         */
 
69
        private static final String DIAGRAM_DOT_TOOL = "Use dot tool from the GraphViz package to generate:";
 
70
        
 
71
        /**
 
72
         * the editor for diagram activation
 
73
         */
 
74
        private MultiEditor diagrams = new RadioMultiEditor( new String[] {DIAGRAM_NONE, DIAGRAM_BUILT_IN, DIAGRAM_DOT_TOOL} );
 
75
        
 
76
        /**
 
77
         * the editor for the dot class graph generation
 
78
         */
 
79
        private CheckBoxEditor classGraph = new CheckBoxEditor("class diagrams");
 
80
 
 
81
        /**
 
82
         * the editor for the dot collaboration graph generation
 
83
         */
 
84
        private CheckBoxEditor collaborationGraph = new CheckBoxEditor("collaboration diagrams");
 
85
 
 
86
        /**
 
87
         * the editor for the dot include graph generation
 
88
         */
 
89
        private CheckBoxEditor includeGraph = new CheckBoxEditor("include dependency graph");
 
90
 
 
91
        /**
 
92
         * the editor for the dot included by graph generation
 
93
         */
 
94
        private CheckBoxEditor includedByGraph = new CheckBoxEditor("included by dependency graph");
 
95
 
 
96
        /**
 
97
         * the editor for the dot hierarchy graph generation
 
98
         */
 
99
        private CheckBoxEditor graphicalHierarcy = new CheckBoxEditor("overall class hierarchy");
 
100
 
 
101
        /**
 
102
         * the editor for the dot call graph generation
 
103
         */
 
104
        private CheckBoxEditor callGraph = new CheckBoxEditor("call graphs");
 
105
        
 
106
        
 
107
        /**
 
108
         * Constructor
 
109
         * 
 
110
         * @param parent        the parent composite
 
111
         * @param toolkit       the toolkit to use for control creations
 
112
         * @param doxyfile      the doxyfile being edited
 
113
         */
 
114
        DiagramsPart( Composite parent, FormToolkit toolkit, Doxyfile doxyfile ) {
 
115
                super( parent, toolkit, "Diagrams to Generate", doxyfile );
 
116
        
 
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 );
 
125
                
 
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"));
 
132
                        
 
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"));
 
139
                        
 
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());
 
146
                }
 
147
                else {
 
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);
 
155
                }
 
156
        }
 
157
}