KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > editor > product > SplashConfigurationSection


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.ui.editor.product;
12
13 import org.eclipse.jface.fieldassist.ControlDecoration;
14 import org.eclipse.jface.fieldassist.FieldDecoration;
15 import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
16 import org.eclipse.jface.preference.ColorSelector;
17 import org.eclipse.jface.util.IPropertyChangeListener;
18 import org.eclipse.jface.util.PropertyChangeEvent;
19 import org.eclipse.pde.core.IModelChangedEvent;
20 import org.eclipse.pde.internal.core.iproduct.IProduct;
21 import org.eclipse.pde.internal.core.iproduct.IProductModel;
22 import org.eclipse.pde.internal.core.iproduct.IProductObject;
23 import org.eclipse.pde.internal.core.iproduct.ISplashInfo;
24 import org.eclipse.pde.internal.core.product.SplashInfo;
25 import org.eclipse.pde.internal.core.util.PDETextHelper;
26 import org.eclipse.pde.internal.ui.PDEUIMessages;
27 import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
28 import org.eclipse.pde.internal.ui.editor.PDEFormPage;
29 import org.eclipse.pde.internal.ui.editor.PDESection;
30 import org.eclipse.pde.internal.ui.parts.ComboPart;
31 import org.eclipse.pde.internal.ui.wizards.product.ISplashHandlerConstants;
32 import org.eclipse.swt.SWT;
33 import org.eclipse.swt.dnd.Clipboard;
34 import org.eclipse.swt.events.ModifyEvent;
35 import org.eclipse.swt.events.ModifyListener;
36 import org.eclipse.swt.events.SelectionAdapter;
37 import org.eclipse.swt.events.SelectionEvent;
38 import org.eclipse.swt.graphics.Color;
39 import org.eclipse.swt.graphics.RGB;
40 import org.eclipse.swt.layout.GridData;
41 import org.eclipse.swt.layout.GridLayout;
42 import org.eclipse.swt.widgets.Button;
43 import org.eclipse.swt.widgets.Composite;
44 import org.eclipse.swt.widgets.Control;
45 import org.eclipse.swt.widgets.Display;
46 import org.eclipse.swt.widgets.Label;
47 import org.eclipse.swt.widgets.Spinner;
48 import org.eclipse.swt.widgets.Text;
49 import org.eclipse.ui.forms.IFormColors;
50 import org.eclipse.ui.forms.widgets.FormToolkit;
51 import org.eclipse.ui.forms.widgets.Section;
52
53
54 public class SplashConfigurationSection extends PDESection {
55
56     private static final int F_NUM_COLUMNS = 10;
57     
58     private ColorSelector fColorSelector;
59     private boolean fBlockNotification;
60     
61     private Button fAddBarButton;
62     // spinners controlling the progress bar geometry
63
private Spinner[] fBarSpinners = new Spinner[4];
64     // all swt controls under the progress bar checkbox
65
private Control[] fBarControls = new Control[8];
66     
67     private Button fAddMessageButton;
68     // spinners controlling the progress message geometry
69
private Spinner[] fMessageSpinners = new Spinner[4];
70     // all swt controls under the progress message checkbox
71
private Control[] fMessageControls = new Control[10];
72     
73     private Section fSection;
74     
75     private FormToolkit fToolkit;
76     
77     private ComboPart fFieldTemplateCombo;
78     
79     public SplashConfigurationSection(PDEFormPage page, Composite parent) {
80         super(page, parent, Section.DESCRIPTION);
81         fFieldTemplateCombo = null;
82         createClient(getSection(), page.getEditor().getToolkit());
83     }
84
85     /* (non-Javadoc)
86      * @see org.eclipse.pde.internal.ui.editor.PDESection#createClient(org.eclipse.ui.forms.widgets.Section, org.eclipse.ui.forms.widgets.FormToolkit)
87      */

88     protected void createClient(Section section, FormToolkit toolkit) {
89         // Set globals
90
fSection = section;
91         fToolkit = toolkit;
92         // Configure the section
93
configureUISection();
94         // Create the UI
95
createUI();
96         // Create listener for the combo box
97
createUIListenerFieldTemplateCombo();
98         // Note: Rely on refresh method to update the UI
99
}
100     
101     /**
102      *
103      */

104     private void createUIListenerFieldTemplateCombo() {
105         fFieldTemplateCombo.addSelectionListener(new SelectionAdapter() {
106             public void widgetSelected(SelectionEvent e) {
107                 handleTemplateComboWidgetSelected();
108             }
109         });
110     }
111     
112     /**
113      *
114      */

115     private void handleTemplateComboWidgetSelected() {
116         // Ignore event if notifications are blocked
117
if (fBlockNotification) {
118             return;
119         }
120         // Set the splash handler type in the model
121
String JavaDoc template = getSelectedTemplate();
122         getSplashInfo().setFieldSplashHandlerType(template, false);
123         // Update this sections enablement
124
updateFieldEnablement();
125     }
126     
127     /**
128      * @return the associated key of the item selected in the combo box
129      */

130     private String JavaDoc getSelectedTemplate() {
131         int index = fFieldTemplateCombo.getSelectionIndex();
132         int position = index - 1;
133         if ((index <= 0) ||
134                 (index > ISplashHandlerConstants.F_SPLASH_SCREEN_TYPE_CHOICES.length)) {
135             return null;
136         }
137         return ISplashHandlerConstants.F_SPLASH_SCREEN_TYPE_CHOICES[position][0];
138     }
139     
140     /**
141      *
142      */

143     private void createUI() {
144         // Create the container
145
Composite container = createUISectionContainer(fSection);
146         // Create the template field label
147
createUILabelType(container);
148         // Create the template field
149
createUIFieldTemplateCombo(container);
150         // Create the template field decoration
151
createUIFieldDecorationTemplate();
152         // Create the progress field label
153
createUILabelProgress(container);
154         // Create the progress bar fields
155
createProgressBarConfig(container);
156         // Create the message bar fields
157
createProgressMessageConfig(container);
158         // Paint the borders for the container
159
fToolkit.paintBordersFor(container);
160         // Set the container as the section client
161
fSection.setClient(container);
162         // Register to be notified when the model changes
163
getModel().addModelChangedListener(this);
164     }
165     
166     /**
167      *
168      */

169     private void createUIFieldDecorationTemplate() {
170         // Decorate the combo with the info image
171
int bits = SWT.TOP | SWT.LEFT;
172         ControlDecoration controlDecoration =
173             new ControlDecoration(fFieldTemplateCombo.getControl(), bits);
174         // Configure decoration
175
// No margin
176
controlDecoration.setMarginWidth(0);
177         // Custom hover tip text
178
controlDecoration.setDescriptionText(
179                 PDEUIMessages.SplashConfigurationSection_msgDecorationTemplateSupport);
180         // Custom hover properties
181
controlDecoration.setShowHover(true);
182         controlDecoration.setShowOnlyOnFocus(true);
183         // Hover image to use
184
FieldDecoration contentProposalImage =
185             FieldDecorationRegistry.getDefault().getFieldDecoration(
186                 FieldDecorationRegistry.DEC_INFORMATION);
187         controlDecoration.setImage(contentProposalImage.getImage());
188     }
189
190     /**
191      * @param parent
192      */

193     private void createUILabelType(Composite parent) {
194         Color foreground = fToolkit.getColors().getColor(IFormColors.TITLE);
195         Label label = fToolkit.createLabel(parent,
196                 PDEUIMessages.SplashTemplatesSection_typeName, SWT.WRAP);
197         label.setForeground(foreground);
198     }
199     
200     /**
201      * @param parent
202      */

203     private void createUILabelProgress(Composite parent) {
204         Label label = fToolkit.createLabel(parent,
205                 PDEUIMessages.SplashConfigurationSection_sectionDescCustomization, SWT.WRAP);
206         GridData data = new GridData(GridData.FILL_HORIZONTAL);
207         data.horizontalSpan = F_NUM_COLUMNS;
208         data.verticalIndent = 5;
209         label.setLayoutData(data);
210     }
211     
212     /**
213      * @param parent
214      */

215     private void createUIFieldTemplateCombo(Composite parent) {
216         int style = SWT.READ_ONLY | SWT.BORDER;
217         fFieldTemplateCombo = new ComboPart();
218         fFieldTemplateCombo.createControl(parent, fToolkit, style);
219         GridData data = new GridData(GridData.FILL_HORIZONTAL);
220         data.horizontalSpan = F_NUM_COLUMNS - 1;
221         fFieldTemplateCombo.getControl().setLayoutData(data);
222         // Add "none" element
223
fFieldTemplateCombo.add(PDEUIMessages.SimpleCSCommandDetails_6, 0);
224         // Add all splash screen types in exact order found
225
for (int i = 0; i < ISplashHandlerConstants.F_SPLASH_SCREEN_TYPE_CHOICES.length; i++) {
226             int position = i + 1;
227             fFieldTemplateCombo.add(
228                     ISplashHandlerConstants.F_SPLASH_SCREEN_TYPE_CHOICES[i][1],
229                     position);
230         }
231     }
232     
233     /**
234      * @param parent
235      * @return
236      */

237     private Composite createUISectionContainer(Composite parent) {
238         Composite client = fToolkit.createComposite(fSection);
239         client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, F_NUM_COLUMNS));
240         client.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
241         return client;
242     }
243     
244     /**
245      *
246      */

247     private void configureUISection() {
248         fSection.setLayout(FormLayoutFactory.createClearGridLayout(false, 1));
249         GridData data = new GridData(GridData.FILL_HORIZONTAL);
250         fSection.setLayoutData(data);
251         fSection.setText(PDEUIMessages.SplashProgressSection_progressName);
252         fSection.setDescription(PDEUIMessages.SplashProgressSection_progressSectionDesc);
253     }
254     
255     private void createProgressBarConfig(Composite parent) {
256         fAddBarButton = createButton(parent, fToolkit, PDEUIMessages.SplashSection_progressBar);
257         fAddBarButton.addSelectionListener(new SelectionAdapter() {
258             public void widgetSelected(SelectionEvent e) {
259                 boolean enable = fAddBarButton.getSelection();
260                 getSplashInfo().addProgressBar(enable, false);
261                 updateFieldEnablement();
262             }
263         });
264         GridData data = new GridData(GridData.FILL_HORIZONTAL);
265         data.verticalIndent = 5;
266         data.horizontalSpan = F_NUM_COLUMNS;
267         fAddBarButton.setLayoutData(data);
268         
269         Color foreground = fToolkit.getColors().getColor(IFormColors.TITLE);
270         
271         fBarControls[0] = createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_progressX);
272         fBarControls[1] = fBarSpinners[0] = createSpinner(parent, fToolkit);
273         fBarControls[2] = createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_progressY);
274         fBarControls[3] = fBarSpinners[1] = createSpinner(parent, fToolkit);
275         fBarControls[4] = createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_progressWidth);
276         fBarControls[5] = fBarSpinners[2] = createSpinner(parent, fToolkit);
277         fBarControls[6] = createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_progressHeight);
278         fBarControls[7] = fBarSpinners[3] = createSpinner(parent, fToolkit);
279         // Add tooltips to coordinate controls
280
addOffsetTooltips(fBarControls);
281         
282         for (int i = 0; i < fBarSpinners.length; i++) {
283             fBarSpinners[i].addModifyListener(new ModifyListener() {
284                 public void modifyText(ModifyEvent e) {
285                     applySpinners(true);
286                 }
287             });
288         }
289         
290         Composite filler = fToolkit.createComposite(parent);
291         filler.setLayout(new GridLayout());
292         GridData gd = new GridData();
293         gd.horizontalSpan = 2;
294         filler.setLayoutData(gd);
295     }
296     
297     private void createProgressMessageConfig(Composite parent) {
298         fAddMessageButton = createButton(parent, fToolkit, PDEUIMessages.SplashSection_progressMessage);
299         fAddMessageButton.addSelectionListener(new SelectionAdapter() {
300             public void widgetSelected(SelectionEvent e) {
301                 boolean enable = fAddMessageButton.getSelection();
302                 getSplashInfo().addProgressMessage(enable, false);
303                 updateFieldEnablement();
304             }
305         });
306         
307         Color foreground = fToolkit.getColors().getColor(IFormColors.TITLE);
308         
309         fMessageControls[0] = createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_messageX);
310         fMessageControls[1] = fMessageSpinners[0] = createSpinner(parent, fToolkit);
311         fMessageControls[2] = createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_messageY);
312         fMessageControls[3] = fMessageSpinners[1] = createSpinner(parent, fToolkit);
313         
314         fMessageControls[4] = createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_messageWidth);
315         fMessageControls[5] = fMessageSpinners[2] = createSpinner(parent, fToolkit);
316         fMessageControls[6] = createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_messageHeight);
317         fMessageControls[7] = fMessageSpinners[3] = createSpinner(parent, fToolkit);
318
319         fMessageControls[8] = createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_messageColor);
320         fColorSelector = new ColorSelector(parent);
321         fColorSelector.addListener(new IPropertyChangeListener() {
322             public void propertyChange(PropertyChangeEvent event) {
323                 if (!event.getNewValue().equals(event.getOldValue()))
324                     applyColor();
325             }
326         });
327         fToolkit.adapt(fColorSelector.getButton(), true, true);
328         fMessageControls[9] = fColorSelector.getButton();
329         // Add tooltips to coordinate controls
330
addOffsetTooltips(fMessageControls);
331         
332         for (int i = 0; i < fMessageSpinners.length; i++) {
333             fMessageSpinners[i].addModifyListener(new ModifyListener() {
334                 public void modifyText(ModifyEvent e) {
335                     applySpinners(false);
336                 }
337             });
338         }
339     }
340     
341     private void applyColor() {
342         if (fBlockNotification)
343             return;
344         RGB rgb = fColorSelector.getColorValue();
345         getSplashInfo().setForegroundColor(rgbToHEX(rgb), false);
346     }
347     
348     private void applySpinners(boolean bar) {
349         if (fBlockNotification)
350             return;
351         Spinner[] spinners = bar ? fBarSpinners : fMessageSpinners;
352         int[] geo = new int[] {
353                 spinners[0].getSelection(),
354                 spinners[1].getSelection(),
355                 spinners[2].getSelection(),
356                 spinners[3].getSelection()
357         };
358         if (bar)
359             getSplashInfo().setProgressGeometry(geo, false);
360         else
361             getSplashInfo().setMessageGeometry(geo, false);
362     }
363     
364     private Label createLabel(Composite parent, FormToolkit toolkit, Color color, String JavaDoc labelName) {
365         Label label = toolkit.createLabel(parent, labelName);
366         label.setForeground(color);
367         GridData gd = new GridData();
368         gd.horizontalIndent = 10;
369         label.setLayoutData(gd);
370         return label;
371     }
372     
373     private Button createButton(Composite parent, FormToolkit toolkit, String JavaDoc label) {
374         Button button = toolkit.createButton(parent, label, SWT.CHECK);
375         GridData gd = new GridData();
376         gd.horizontalSpan = F_NUM_COLUMNS;
377         button.setLayoutData(gd);
378         return button;
379     }
380     
381     private Spinner createSpinner(Composite parent, FormToolkit toolkit) {
382         Spinner spinner = new Spinner(parent, SWT.BORDER);
383         spinner.setMinimum(0);
384         spinner.setMaximum(9999);
385         toolkit.adapt(spinner, false, false);
386         return spinner;
387     }
388     
389     /**
390      *
391      */

392     private void resetProgressBarGeometry() {
393         // X Offset
394
fBarSpinners[0].setSelection(SplashInfo.F_DEFAULT_BAR_X_OFFSET);
395         // Y Offset
396
fBarSpinners[1].setSelection(SplashInfo.F_DEFAULT_BAR_Y_OFFSET);
397         // Width
398
fBarSpinners[2].setSelection(SplashInfo.F_DEFAULT_BAR_WIDTH);
399         // Height
400
fBarSpinners[3].setSelection(SplashInfo.F_DEFAULT_BAR_HEIGHT);
401     }
402     
403     /**
404      *
405      */

406     private void resetProgressMessageGeometry() {
407         // X Offset
408
fMessageSpinners[0].setSelection(SplashInfo.F_DEFAULT_MESSAGE_X_OFFSET);
409         // Y Offset
410
fMessageSpinners[1].setSelection(SplashInfo.F_DEFAULT_MESSAGE_Y_OFFSET);
411         // Width
412
fMessageSpinners[2].setSelection(SplashInfo.F_DEFAULT_MESSAGE_WIDTH);
413         // Height
414
fMessageSpinners[3].setSelection(SplashInfo.F_DEFAULT_MESSAGE_HEIGHT);
415     }
416     
417     /* (non-Javadoc)
418      * @see org.eclipse.ui.forms.AbstractFormPart#refresh()
419      */

420     public void refresh() {
421         ISplashInfo info = getSplashInfo();
422         fBlockNotification = true;
423         
424         fColorSelector.setColorValue(hexToRGB(info.getForegroundColor()));
425         
426         int[] pgeo = info.getProgressGeometry();
427         boolean addProgress = pgeo != null;
428         info.addProgressBar(addProgress, fBlockNotification);
429         if (addProgress) {
430             for (int i = 0; i < pgeo.length; i++) {
431                 fBarSpinners[i].setSelection(pgeo[i]);
432             }
433         } else {
434             resetProgressBarGeometry();
435         }
436         
437         fAddBarButton.setSelection(addProgress);
438         
439         int[] mgeo = info.getMessageGeometry();
440         boolean addMessage = mgeo != null;
441         info.addProgressMessage(addMessage, fBlockNotification);
442         if (addMessage) {
443             for (int i = 0; i < mgeo.length; i++) {
444                 fMessageSpinners[i].setSelection(mgeo[i]);
445             }
446         } else {
447             resetProgressMessageGeometry();
448         }
449         fColorSelector.setColorValue(
450                 addMessage ?
451                         hexToRGB(info.getForegroundColor()) :
452                         new RGB(0,0,0));
453         
454         fAddMessageButton.setSelection(addMessage);
455         
456         // Update the UI
457
updateUIFieldTemplateCombo();
458         fBlockNotification = false;
459         super.refresh();
460         // Update this sections enablement
461
updateFieldEnablement();
462     }
463
464     /**
465      *
466      */

467     private void updateUIFieldTemplateCombo() {
468         // Update this sections enablement
469
updateFieldEnablement();
470         // Get the splash info if any
471
ISplashInfo info = getSplashInfo();
472         if (info.isDefinedSplashHandlerType() == false) {
473             // No splash handler type defined, set "none" in combo box
474
fFieldTemplateCombo.setText(PDEUIMessages.SimpleCSCommandDetails_6);
475             return;
476         }
477         String JavaDoc splashHandlerType = info.getFieldSplashHandlerType();
478         // Update the splash handler type in the combo box
479
for (int i = 0; i < ISplashHandlerConstants.F_SPLASH_SCREEN_TYPE_CHOICES.length; i++) {
480             String JavaDoc key = ISplashHandlerConstants.F_SPLASH_SCREEN_TYPE_CHOICES[i][0];
481             if (splashHandlerType.equals(key)) {
482                 String JavaDoc displayName = ISplashHandlerConstants.F_SPLASH_SCREEN_TYPE_CHOICES[i][1];
483                 fFieldTemplateCombo.setText(displayName);
484             }
485         }
486     }
487     
488     private ISplashInfo getSplashInfo() {
489         ISplashInfo info = getProduct().getSplashInfo();
490         if (info == null) {
491             info = getModel().getFactory().createSplashInfo();
492             getProduct().setSplashInfo(info);
493         }
494         return info;
495     }
496     
497     private IProduct getProduct() {
498         return getModel().getProduct();
499     }
500     
501     private IProductModel getModel() {
502         return (IProductModel)getPage().getPDEEditor().getAggregateModel();
503     }
504
505     public boolean canPaste(Clipboard clipboard) {
506         Display d = getSection().getDisplay();
507         Control c = d.getFocusControl();
508         if (c instanceof Text)
509             return true;
510         return false;
511     }
512
513     private String JavaDoc rgbToHEX(RGB rgb) {
514         if (rgb == null)
515             return null;
516         return rgbToHex(rgb.red) + rgbToHex(rgb.green) + rgbToHex(rgb.blue);
517     }
518     
519     private String JavaDoc rgbToHex(int value) {
520         value = Math.max(0, value);
521         value = Math.min(value, 255);
522         String JavaDoc hex = Integer.toHexString(value).toUpperCase();
523         if (hex.length() == 1)
524             hex = '0' + hex;
525         return hex;
526     }
527     
528     private RGB hexToRGB(String JavaDoc hexValue) {
529         if (hexValue == null || hexValue.length() < 6)
530             return new RGB(0,0,0);
531         return new RGB(
532                 Integer.parseInt(hexValue.substring(0,2),16),
533                 Integer.parseInt(hexValue.substring(2,4),16),
534                 Integer.parseInt(hexValue.substring(4,6),16)
535             );
536     }
537
538     /* (non-Javadoc)
539      * @see org.eclipse.pde.internal.ui.editor.PDESection#modelChanged(org.eclipse.pde.core.IModelChangedEvent)
540      */

541     public void modelChanged(IModelChangedEvent e) {
542         // No need to call super, handling world changed event here
543
if (e.getChangeType() == IModelChangedEvent.WORLD_CHANGED) {
544             handleModelEventWorldChanged(e);
545         } else if (e.getChangeType() == IModelChangedEvent.CHANGE) {
546             handleModelEventChange(e);
547         }
548     }
549
550     /**
551      * @param e
552      */

553     private void handleModelEventChange(IModelChangedEvent event) {
554         // Change event
555
Object JavaDoc[] objects = event.getChangedObjects();
556         IProductObject object = (IProductObject) objects[0];
557         if (object == null) {
558             // Ignore
559
} else if ((object instanceof IProduct) &&
560                 (event.getChangedProperty() == IProduct.P_ID)) {
561             updateFieldEnablement();
562         }
563     }
564
565     /**
566      * @param event
567      */

568     private void handleModelEventWorldChanged(IModelChangedEvent event) {
569         refresh();
570     }
571     
572     /* (non-Javadoc)
573      * @see org.eclipse.ui.forms.AbstractFormPart#dispose()
574      */

575     public void dispose() {
576         IProductModel model = getModel();
577         if (model != null) {
578             model.removeModelChangedListener(this);
579         }
580         super.dispose();
581     }
582
583     /**
584      *
585      */

586     private void updateFieldEnablement() {
587         // Enable / disable progress and message bar fields
588
updateFieldProgressEnablement();
589         // Enable / disable template field
590
updateFieldTemplateEnablement();
591     }
592     
593     /**
594      *
595      */

596     private void updateFieldProgressEnablement() {
597         // Get the splash info if any
598
ISplashInfo info = getSplashInfo();
599         // Enable section under the following conditions:
600
// (1) Product ID is defined
601
// (2) Progress geometry is defined
602
// (3) Splash handler type is NOT defined
603
if ((PDETextHelper.isDefined(getProduct().getId()) == false) ||
604                 ((info.isDefinedGeometry() == false) &&
605                 (info.isDefinedSplashHandlerType() == true))) {
606             fAddBarButton.setEnabled(false);
607             fAddMessageButton.setEnabled(false);
608             updateFieldProgressBarEnablement(false);
609             updateFieldProgressMessageEnablement(false);
610         } else {
611             fAddBarButton.setEnabled(true);
612             fAddMessageButton.setEnabled(true);
613             updateFieldProgressBarEnablement(true);
614             updateFieldProgressMessageEnablement(true);
615         }
616     }
617
618     /**
619      * @param buttonEnabled
620      */

621     private void updateFieldProgressBarEnablement(boolean buttonEnabled) {
622         boolean enable = (fAddBarButton.getSelection() && buttonEnabled);
623         for (int i = 0; i < fBarControls.length; i++) {
624             fBarControls[i].setEnabled(enable);
625         }
626     }
627     
628     /**
629      * @param buttonEnabled
630      */

631     private void updateFieldProgressMessageEnablement(boolean buttonEnabled) {
632         boolean enable = (fAddMessageButton.getSelection() && buttonEnabled);
633         for (int i = 0; i < fMessageControls.length; i++) {
634             fMessageControls[i].setEnabled(enable);
635         }
636     }
637     
638     /**
639      *
640      */

641     private void updateFieldTemplateEnablement() {
642         // Get the splash info if any
643
ISplashInfo info = getSplashInfo();
644         // Enable section under the following conditions:
645
// (1) Product ID is defined
646
// (2) Progress geometry is NOT defined
647
// (3) Progress geometry is defined and splash handler type is defined
648
if ((PDETextHelper.isDefined(getProduct().getId()) == false) ||
649                 ((info.isDefinedGeometry() == true) &&
650                 (info.isDefinedSplashHandlerType() == false))) {
651             fFieldTemplateCombo.setEnabled(false);
652         } else {
653             fFieldTemplateCombo.setEnabled(true);
654         }
655     }
656     
657     /**
658      * @param controls
659      */

660     private void addOffsetTooltips(Control[] controls) {
661         // Limit includes X, Y spinners and labels
662
int limit = 4;
663         // Ensure we have that many controls
664
if (controls.length < limit) {
665             // Something seriously wrong
666
return;
667         }
668         // Set the tooltips
669
for (int i = 0; i < limit; i++) {
670             controls[i].setToolTipText(PDEUIMessages.SplashConfigurationSection_msgTooltipOffsetRelative);
671         }
672     }
673     
674 }
675
Popular Tags