]> gerrit.simantics Code Review - simantics/sysdyn.git/blob
fa60a3e5fd3cb5806df12978983fe3ba3e5e9e65
[simantics/sysdyn.git] /
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2011, 2014 Association for Decentralized Information Management in\r
3  * Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.jfreechart.chart.properties.bar;\r
13 \r
14 import java.util.LinkedHashMap;\r
15 import java.util.Map;\r
16 \r
17 import org.eclipse.jface.layout.GridDataFactory;\r
18 import org.eclipse.jface.layout.GridLayoutFactory;\r
19 import org.eclipse.jface.layout.LayoutConstants;\r
20 import org.eclipse.swt.SWT;\r
21 import org.eclipse.swt.custom.ScrolledComposite;\r
22 import org.eclipse.swt.graphics.Point;\r
23 import org.eclipse.swt.widgets.Composite;\r
24 import org.eclipse.swt.widgets.Group;\r
25 import org.eclipse.swt.widgets.Label;\r
26 import org.eclipse.ui.IWorkbenchSite;\r
27 import org.simantics.browsing.ui.swt.widgets.Button;\r
28 import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory;\r
29 import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier;\r
30 import org.simantics.browsing.ui.swt.widgets.TrackedCombo;\r
31 import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
32 import org.simantics.browsing.ui.swt.widgets.impl.ComboModifyListenerImpl;\r
33 import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl;\r
34 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
35 import org.simantics.db.ReadGraph;\r
36 import org.simantics.db.Resource;\r
37 import org.simantics.db.WriteGraph;\r
38 import org.simantics.db.common.request.PossibleObjectWithType;\r
39 import org.simantics.db.exception.DatabaseException;\r
40 import org.simantics.db.management.ISessionContext;\r
41 import org.simantics.jfreechart.ChartPropertyOptions;\r
42 import org.simantics.jfreechart.chart.properties.AdjustableTab;\r
43 import org.simantics.jfreechart.chart.properties.BooleanPropertyFactory;\r
44 import org.simantics.jfreechart.chart.properties.BooleanSelectionListener;\r
45 import org.simantics.jfreechart.chart.properties.DoublePropertyFactory2;\r
46 import org.simantics.jfreechart.chart.properties.DoublePropertyModifier2;\r
47 import org.simantics.jfreechart.chart.properties.DoubleValidator;\r
48 import org.simantics.jfreechart.chart.properties.JFreeChartPropertyColorProvider;\r
49 import org.simantics.jfreechart.chart.properties.TitleFactory;\r
50 import org.simantics.jfreechart.chart.properties.TitleModifier;\r
51 import org.simantics.layer0.Layer0;\r
52 import org.simantics.layer0.utils.direct.GraphUtils;\r
53 import org.simantics.modeling.ui.chart.property.DoublePropertyFactory;\r
54 import org.simantics.modeling.ui.chart.property.DoublePropertyModifier;\r
55 import org.simantics.sysdyn.JFreeChartResource;\r
56 \r
57 \r
58 /**\r
59  * General properties of a bar chart\r
60  * @author Teemu Lempinen\r
61  * @author Tuomas Miettinen\r
62  *\r
63  */\r
64 public class BarGeneralPropertiesTab extends AdjustableTab {\r
65 \r
66     private ScrolledComposite sc;\r
67     private Button hgrid, htitle, hlegend;\r
68     private TrackedText name, title, time;\r
69     private TrackedCombo type;\r
70     private TrackedCombo orientation;\r
71 \r
72     private boolean showTime = true;\r
73     private boolean showFilter = false;\r
74         private Group general;\r
75         private Composite labelColumn1;\r
76         private Composite propertyColumn1;\r
77         private Composite labelColumn2;\r
78         private Composite propertyColumn2;\r
79         private Label labelName;\r
80         private Label labelTitle;\r
81         private Label labelTime;\r
82         private Label labelType;\r
83         private Group typeGroup;\r
84         private Label labelOrientation;\r
85         private Group hideGroup;\r
86         private Label labelUse;\r
87         private Label labelPercent;\r
88         private Group filteringGroup;\r
89         private Button useFilter;\r
90         private TrackedText fraction;\r
91         private Point size;\r
92     \r
93     public BarGeneralPropertiesTab() {\r
94         \r
95     }\r
96     \r
97     public BarGeneralPropertiesTab(int options) {\r
98         showTime = ((options & ChartPropertyOptions.SHOW_TIME) > 0); \r
99         showFilter = ((options & ChartPropertyOptions.SHOW_FILTER) > 0);\r
100     }\r
101 \r
102     /**\r
103      * \r
104      * @author Teemu Lempinen\r
105      *\r
106      */\r
107     private class TypeSelectionFactory extends ReadFactoryImpl<Resource, String> {\r
108         @Override\r
109         public String perform(ReadGraph graph, Resource chart) throws DatabaseException {\r
110             JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
111             Layer0 l0 = Layer0.getInstance(graph);\r
112 \r
113             Resource plot = graph.syncRequest(new PossibleObjectWithType(chart, l0.ConsistsOf, jfree.CategoryPlot));\r
114             if(plot != null) {\r
115                 Resource dataset = graph.syncRequest(new PossibleObjectWithType(plot, l0.ConsistsOf, jfree.CategoryDataset));\r
116 \r
117                 if(dataset != null) {\r
118                     Resource renderer = graph.syncRequest(new PossibleObjectWithType(dataset, jfree.Dataset_renderer, jfree.Renderer));\r
119 \r
120                     if(renderer != null && graph.isInstanceOf(renderer, jfree.StackedBarRenderer))\r
121                         return "Stacked";\r
122                 }\r
123             }\r
124             return "Normal";\r
125         }\r
126     }\r
127 \r
128     /**\r
129      * RangeItemFactory finds all inexes of a given enumeration \r
130      * and adds "Sum" and "All" to the returned indexes\r
131      * @author Teemu Lempinen\r
132      *\r
133      */\r
134     private class TypeItemFactory extends ReadFactoryImpl<Resource, Map<String, Object>> {\r
135         @Override\r
136         public Map<String, Object> perform(ReadGraph graph, Resource series) throws DatabaseException {\r
137             LinkedHashMap<String, Object> result = new LinkedHashMap<String, Object>();\r
138             result.put("Normal", "Normal");\r
139             result.put("Stacked", "Stacked");\r
140             return result;\r
141         }\r
142     }\r
143 \r
144     /**\r
145      * TypeModifyListener for modifying the type of a bar chart \r
146      * @author Teemu Lempinen\r
147      *\r
148      */\r
149     private class TypeModifyListener  extends ComboModifyListenerImpl<Resource> {\r
150         @Override\r
151         public void applyText(WriteGraph graph, Resource chart, String text) throws DatabaseException {\r
152             JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
153             Layer0 l0 = Layer0.getInstance(graph);\r
154 \r
155             Resource plot = graph.syncRequest(new PossibleObjectWithType(chart, l0.ConsistsOf, jfree.CategoryPlot));\r
156             if(plot == null)\r
157                 return;\r
158 \r
159             Resource dataset = graph.syncRequest(new PossibleObjectWithType(plot, l0.ConsistsOf, jfree.CategoryDataset));\r
160             if(dataset == null)\r
161                 return;\r
162 \r
163             graph.deny(dataset, jfree.Dataset_renderer);\r
164 \r
165             Resource renderer;\r
166             if(text.equals("Stacked"))\r
167                 renderer = GraphUtils.create2(graph, jfree.StackedBarRenderer);\r
168             else\r
169                 renderer = GraphUtils.create2(graph, jfree.BarRenderer);\r
170 \r
171             graph.claim(dataset, jfree.Dataset_renderer, renderer);\r
172         }\r
173     }\r
174     \r
175     /**\r
176      * \r
177      * @author Marko Luukkainen <marko.luukkainen@vtt.fi>\r
178      *\r
179      */\r
180     private class OrientationSelectionFactory extends ReadFactoryImpl<Resource, String> {\r
181         @Override\r
182         public String perform(ReadGraph graph, Resource chart) throws DatabaseException {\r
183             JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
184             Layer0 l0 = Layer0.getInstance(graph);\r
185 \r
186             Resource plot = graph.syncRequest(new PossibleObjectWithType(chart, l0.ConsistsOf, jfree.CategoryPlot));\r
187             if(plot != null) {\r
188                 Boolean orientation = graph.getPossibleRelatedValue(plot, jfree.Plot_orientation);\r
189                 if (orientation != null) {\r
190                         if (orientation)\r
191                                 return "Horizontal";\r
192                         return "Vertical";                      \r
193                 }\r
194                             }\r
195             return "Vertical";\r
196         }\r
197     }\r
198 \r
199    /**\r
200     * \r
201     * @author Marko Luukkainen <marko.luukkainen@vtt.fi>\r
202     *\r
203     */\r
204     private class OrientationItemFactory extends ReadFactoryImpl<Resource, Map<String, Object>> {\r
205         @Override\r
206         public Map<String, Object> perform(ReadGraph graph, Resource series) throws DatabaseException {\r
207             LinkedHashMap<String, Object> result = new LinkedHashMap<String, Object>();\r
208             result.put("Vertical", "Vertical");\r
209             result.put("Horizontal", "Horizontal");\r
210             return result;\r
211         }\r
212     }\r
213 \r
214     /**\r
215      * \r
216      * @author Marko Luukkainen <marko.luukkainen@vtt.fi>\r
217      *\r
218      */\r
219     private class OrientationModifyListener  extends ComboModifyListenerImpl<Resource> {\r
220         @Override\r
221         public void applyText(WriteGraph graph, Resource chart, String text) throws DatabaseException {\r
222             JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
223             Layer0 l0 = Layer0.getInstance(graph);\r
224 \r
225             Resource plot = graph.syncRequest(new PossibleObjectWithType(chart, l0.ConsistsOf, jfree.CategoryPlot));\r
226             if(plot == null)\r
227                 return;\r
228 \r
229            \r
230             if(text.equals("Horizontal"))\r
231                 graph.claimLiteral(plot, jfree.Plot_orientation,true);\r
232             else\r
233                 graph.claimLiteral(plot, jfree.Plot_orientation,false);\r
234 \r
235             \r
236         }\r
237     }\r
238 \r
239         @Override\r
240         protected void createAndAddControls(Composite body, IWorkbenchSite site,\r
241                         ISessionContext context, WidgetSupport support) {\r
242                 // Scrolled composite containing all of the properties in this tab\r
243         sc = new ScrolledComposite(body, SWT.NONE | SWT.H_SCROLL | SWT.V_SCROLL);\r
244         sc.setExpandHorizontal(true);\r
245         sc.setExpandVertical(true);\r
246 \r
247         composite = new Composite(sc, SWT.NONE);\r
248 \r
249         // General properties\r
250         general = new Group(composite, SWT.NONE);\r
251         general.setText("General");\r
252 \r
253         // first column: labels\r
254         labelColumn1 = new Composite(general, SWT.NONE);\r
255         \r
256         // second column: name and title\r
257         propertyColumn1 = new Composite(general, SWT.NONE);\r
258         \r
259         // third column: labels\r
260         labelColumn2 = new Composite(general, SWT.NONE);\r
261         \r
262         // fourth column: type and time\r
263         propertyColumn2 = new Composite(general, SWT.NONE);\r
264         \r
265         // Name\r
266         labelName = new Label(labelColumn1, SWT.NONE);\r
267         labelName.setText("Name:");\r
268 \r
269         name = new org.simantics.browsing.ui.swt.widgets.TrackedText(propertyColumn1, support, SWT.BORDER);\r
270         name.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel));\r
271         name.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel));\r
272         name.setColorProvider(new JFreeChartPropertyColorProvider(name.getResourceManager()));\r
273 \r
274         labelTitle = new Label(labelColumn2, SWT.NONE);\r
275         labelTitle = new Label(propertyColumn2, SWT.NONE);\r
276         \r
277         // Title (Which is different than name)\r
278         labelTitle = new Label(labelColumn1, SWT.NONE);\r
279         labelTitle.setText("Title:");\r
280 \r
281         title = new org.simantics.browsing.ui.swt.widgets.TrackedText(propertyColumn1, support, SWT.BORDER);\r
282         title.setTextFactory(new TitleFactory());\r
283         title.addModifyListener(new TitleModifier());\r
284         title.setColorProvider(new JFreeChartPropertyColorProvider(name.getResourceManager()));\r
285 \r
286         if (showTime) {\r
287                 // Time\r
288                 labelTime = new Label(labelColumn2, SWT.NONE);\r
289                 labelTime.setText("Time:");\r
290                 \r
291                 time = new org.simantics.browsing.ui.swt.widgets.TrackedText(propertyColumn2, support, SWT.BORDER);\r
292                 time.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Chart_time));\r
293                 time.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Chart_time));\r
294                 time.setInputValidator(new DoubleValidator(true));\r
295         time.setColorProvider(new JFreeChartPropertyColorProvider(time.getResourceManager()));\r
296         }\r
297         \r
298         typeGroup = new Group(composite,SWT.NONE);\r
299         typeGroup.setText("Visuals");\r
300         \r
301         labelType = new Label(typeGroup, SWT.NONE);\r
302         labelType.setText("Type:");\r
303 \r
304         type = new TrackedCombo(typeGroup, support, SWT.BORDER | SWT.READ_ONLY);\r
305         type.addModifyListener(new TypeModifyListener());\r
306         type.setItemFactory(new TypeItemFactory());\r
307         type.setSelectionFactory(new TypeSelectionFactory());\r
308         \r
309         labelOrientation = new Label(typeGroup, SWT.NONE);\r
310         labelOrientation.setText("Orientation:");\r
311         \r
312         orientation = new TrackedCombo(typeGroup, support, SWT.BORDER | SWT.READ_ONLY);\r
313         orientation.addModifyListener(new OrientationModifyListener());\r
314         orientation.setItemFactory(new OrientationItemFactory());\r
315         orientation.setSelectionFactory(new OrientationSelectionFactory());\r
316 \r
317         \r
318         // Group for hide options\r
319         hideGroup = new Group(composite, SWT.NONE);\r
320         hideGroup.setText("Hide");\r
321 \r
322         hgrid = new Button(hideGroup, support, SWT.CHECK);\r
323         hgrid.setText("Grid");\r
324         hgrid.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleGrid, true));\r
325         hgrid.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleGrid));\r
326         htitle = new Button(hideGroup, support, SWT.CHECK);\r
327         htitle.setText("Title");\r
328         htitle.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible, true));\r
329         htitle.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible));\r
330         hlegend = new Button(hideGroup, support, SWT.CHECK);\r
331         hlegend.setText("Legend");\r
332         hlegend.setSelectionFactory(new BooleanPropertyFactory(null, JFreeChartResource.URIs.Chart_visibleLegend, true));\r
333         hlegend.addSelectionListener(new BooleanSelectionListener(context, null, JFreeChartResource.URIs.Chart_visibleLegend));\r
334 \r
335         if (showFilter) {\r
336                 filteringGroup = new Group(composite, SWT.NONE);\r
337                 filteringGroup.setText("Filter");\r
338                 labelUse = new Label(filteringGroup, SWT.NONE);\r
339                 labelUse.setText("Use:");\r
340                 useFilter = new Button(filteringGroup, support, SWT.CHECK);\r
341                 useFilter.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_used, false));\r
342                 useFilter.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_used));\r
343                 labelPercent = new Label(filteringGroup, SWT.NONE);\r
344                 labelPercent.setText("Percent:");\r
345                 fraction = new TrackedText(filteringGroup, support, SWT.BORDER);\r
346                 fraction.setTextFactory(new DoublePropertyFactory2(JFreeChartResource.URIs.Plot,JFreeChartResource.URIs.Filter_fraction));\r
347                 fraction.addModifyListener(new DoublePropertyModifier2(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_fraction));\r
348                 fraction.setInputValidator(new DoubleValidator(true));\r
349                 fraction.setColorProvider(new JFreeChartPropertyColorProvider(fraction.getResourceManager()));\r
350         }\r
351         \r
352         // Resize scrolled composite\r
353         sc.setContent(composite);\r
354         \r
355         }\r
356 \r
357         @Override\r
358         protected void createControlLayoutVertical() {\r
359                 // Scrolled composite containing all of the properties in this tab\r
360         GridDataFactory.fillDefaults().grab(true, true).applyTo(sc);\r
361         GridLayoutFactory.fillDefaults().applyTo(sc);\r
362 \r
363         if (showFilter)\r
364                 GridLayoutFactory.fillDefaults().numColumns(1).margins(3, 3).applyTo(composite);\r
365         else\r
366                 GridLayoutFactory.fillDefaults().numColumns(1).margins(3, 3).applyTo(composite);\r
367 \r
368         // General properties\r
369         GridDataFactory.fillDefaults().grab(true, false).applyTo(general);\r
370         GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(general);\r
371 \r
372         // first column: labels\r
373         GridDataFactory.fillDefaults().grab(false, true).applyTo(labelColumn1);\r
374         GridLayoutFactory.fillDefaults().applyTo(labelColumn1);\r
375         \r
376         // second column: name and title\r
377         GridDataFactory.fillDefaults().grab(true, true).applyTo(propertyColumn1);\r
378         GridLayoutFactory.fillDefaults().spacing(0, LayoutConstants.getSpacing().y).applyTo(propertyColumn1);\r
379         \r
380         // third column: labels\r
381         GridDataFactory.fillDefaults().grab(false, true).applyTo(labelColumn2);\r
382         GridLayoutFactory.fillDefaults().spacing(0, LayoutConstants.getSpacing().y).applyTo(labelColumn2);\r
383         \r
384         // fourth column: type and time\r
385         GridDataFactory.fillDefaults().grab(false, true).applyTo(propertyColumn2);\r
386         GridLayoutFactory.fillDefaults().applyTo(propertyColumn2);\r
387         \r
388         // Name\r
389         GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelName);\r
390 \r
391         GridDataFactory.fillDefaults().grab(true, false).applyTo(name.getWidget());\r
392 \r
393         GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelTitle);\r
394 \r
395         GridDataFactory.fillDefaults().grab(true, false).applyTo(title.getWidget());\r
396 \r
397         if (showTime) {\r
398                 // Time\r
399                 GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelTime);\r
400                 \r
401                 GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(time.getWidget());\r
402         }\r
403         \r
404         GridDataFactory.fillDefaults().applyTo(typeGroup);\r
405         GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(typeGroup);\r
406         \r
407         GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelType);\r
408 \r
409         GridDataFactory.fillDefaults().applyTo(type.getWidget());\r
410         \r
411         GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelOrientation);\r
412         \r
413         GridDataFactory.fillDefaults().applyTo(type.getWidget());\r
414 \r
415         // Group for hide options\r
416         GridDataFactory.fillDefaults().applyTo(hideGroup);\r
417         GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(hideGroup);\r
418 \r
419         if (showFilter) {\r
420                 GridDataFactory.fillDefaults().applyTo(filteringGroup);\r
421                 GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(filteringGroup);\r
422                 GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelUse);\r
423                 GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelPercent);\r
424                 GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(fraction.getWidget());\r
425         }\r
426         \r
427         size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);\r
428         sc.setMinSize(size);\r
429         }\r
430 \r
431         @Override\r
432         protected void createControlLayoutHorizontal(boolean wideScreen) {\r
433                 // Scrolled composite containing all of the properties in this tab\r
434         GridDataFactory.fillDefaults().grab(true, true).applyTo(sc);\r
435         GridLayoutFactory.fillDefaults().applyTo(sc);\r
436 \r
437         if (showFilter)\r
438                 GridLayoutFactory.fillDefaults().numColumns(4).margins(3, 3).applyTo(composite);\r
439         else\r
440                 GridLayoutFactory.fillDefaults().numColumns(3).margins(3, 3).applyTo(composite);\r
441 \r
442         // General properties\r
443         GridDataFactory.fillDefaults().grab(true, false).applyTo(general);\r
444         GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(4).applyTo(general);\r
445 \r
446         // first column: labels\r
447         GridDataFactory.fillDefaults().grab(false, true).applyTo(labelColumn1);\r
448         GridLayoutFactory.fillDefaults().applyTo(labelColumn1);\r
449         \r
450         // second column: name and title\r
451         GridDataFactory.fillDefaults().grab(true, true).applyTo(propertyColumn1);\r
452         GridLayoutFactory.fillDefaults().spacing(0, LayoutConstants.getSpacing().y).applyTo(propertyColumn1);\r
453         \r
454         // third column: labels\r
455         GridDataFactory.fillDefaults().grab(false, true).applyTo(labelColumn2);\r
456         GridLayoutFactory.fillDefaults().spacing(0, LayoutConstants.getSpacing().y).applyTo(labelColumn2);\r
457         \r
458         // fourth column: type and time\r
459         GridDataFactory.fillDefaults().grab(false, true).applyTo(propertyColumn2);\r
460         GridLayoutFactory.fillDefaults().applyTo(propertyColumn2);\r
461         \r
462         // Name\r
463         GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelName);\r
464 \r
465         GridDataFactory.fillDefaults().grab(true, false).applyTo(name.getWidget());\r
466 \r
467         GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelTitle);\r
468 \r
469         GridDataFactory.fillDefaults().grab(true, false).applyTo(title.getWidget());\r
470 \r
471         if (showTime) {\r
472                 // Time\r
473                 GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelTime);\r
474                 \r
475                 GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(time.getWidget());\r
476         }\r
477         \r
478         GridDataFactory.fillDefaults().applyTo(typeGroup);\r
479         GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(typeGroup);\r
480         \r
481         GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelType);\r
482 \r
483         GridDataFactory.fillDefaults().applyTo(type.getWidget());\r
484         \r
485         GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelOrientation);\r
486         \r
487         GridDataFactory.fillDefaults().applyTo(type.getWidget());\r
488 \r
489         // Group for hide options\r
490         GridDataFactory.fillDefaults().applyTo(hideGroup);\r
491         GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(hideGroup);\r
492 \r
493         if (showFilter) {\r
494                 GridDataFactory.fillDefaults().applyTo(filteringGroup);\r
495                 GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(filteringGroup);\r
496                 GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelUse);\r
497                 GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(labelPercent);\r
498                 GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(fraction.getWidget());\r
499         }\r
500         \r
501         size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);\r
502         sc.setMinSize(size);\r
503         }\r
504 \r
505 }\r