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