View | Details | Raw Unified | Return to bug 284452 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mtj/internal/core/project/midp/JADAttributesRegistry.java (-1 / +9 lines)
Lines 129-141 Link Here
129
129
130
    /**
130
    /**
131
     * @param pageID the target page's ID
131
     * @param pageID the target page's ID
132
     * @param device the device user used
133
     * @return the vendor specific JAD descriptors
132
     * @return the vendor specific JAD descriptors
134
     */
133
     */
135
    public static DescriptorPropertyDescription[] getJADAttrDescriptorsByPage(
134
    public static DescriptorPropertyDescription[] getJADAttrDescriptorsByPage(
136
            String pageID) {
135
            String pageID) {
137
        JADAttributesConfigElement[] relatedElements = getRelatedAttrElements(pageID);
136
        JADAttributesConfigElement[] relatedElements = getRelatedAttrElements(pageID);
138
        DescriptorPropertyDescription[] resultAttributes = getDescriptorsFromElements(relatedElements);
137
        DescriptorPropertyDescription[] resultAttributes = getDescriptorsFromElements(relatedElements);
138
        for (DescriptorPropertyDescription descriptorPropertyDescription : resultAttributes) {
139
            if (pageID.contains(".")) { //$NON-NLS-1$
140
                String[] ids = pageID.split("\\."); //$NON-NLS-1$
141
                descriptorPropertyDescription.setPageId(ids[0]);
142
                descriptorPropertyDescription.setSectionId(ids[1]);
143
            } else {
144
                descriptorPropertyDescription.setPageId(pageID);
145
            }
146
        }
139
        return resultAttributes;
147
        return resultAttributes;
140
    }
148
    }
141
149
(-)src/org/eclipse/mtj/core/project/midp/DescriptorPropertyDescription.java (-8 / +43 lines)
Lines 7-15 Link Here
7
 * http://www.eclipse.org/legal/epl-v10.html
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
8
 * 
9
 * Contributors:
9
 * Contributors:
10
 *     Craig Setera (EclipseME) - Initial implementation
10
 *     Craig Setera (EclipseME)         - Initial implementation
11
 *     Diego Sandin (Motorola)  - Refactoring package name to follow eclipse 
11
 *     Diego Sandin (Motorola)          - Refactoring package name to follow eclipse 
12
 *                                standards
12
 *                                        standards
13
 *     Jon Dearden (Research In Motion) - Added support for applying 
14
 *                                        DescriptorPropertyDescription(s) to specific
15
 *                                        page sections [Bug 284452]
13
 */
16
 */
14
package org.eclipse.mtj.core.project.midp;
17
package org.eclipse.mtj.core.project.midp;
15
18
Lines 42-47 Link Here
42
45
43
    /** The name of the underlying property */
46
    /** The name of the underlying property */
44
    private String propertyName;
47
    private String propertyName;
48
    
49
    /** The JAD editor page identifier for which this property is associated */
50
    private String pageId;
51
    
52
    /** The JAD editor page section identifier for which this property is associated */
53
    private String sectionId;
45
54
46
    /**
55
    /**
47
     * Creates a new instance of DescriptorPropertyDescription.
56
     * Creates a new instance of DescriptorPropertyDescription.
Lines 100-105 Link Here
100
    public String getPropertyName() {
109
    public String getPropertyName() {
101
        return propertyName;
110
        return propertyName;
102
    }
111
    }
112
    
113
    /**
114
     * Returns the JAD editor page identifier for which this property is associated
115
     * 
116
     * @return the page identifier.
117
     */
118
    public String getPageId() {
119
        return pageId;
120
    }
121
    
122
    /**
123
     * Returns the JAD editor page section identifier for which this property is associated
124
     * 
125
     * @return the page section identifier.
126
     */
127
    public String getSectionId() {
128
        return sectionId;
129
    }
103
130
104
    /**
131
    /**
105
     * Sets the data type for this property.
132
     * Sets the data type for this property.
Lines 127-138 Link Here
127
    }
154
    }
128
155
129
    /**
156
    /**
130
     * Sets the data type for this property.
157
     * Sets the page ID for this property.
131
     * 
158
     * 
132
     * @param string the property name. This is case-sensitive and must not be
159
     * @param string the page ID.
133
     *            <code>null</code> or an empty String <code>""</code>.
134
     */
160
     */
135
    public void setPropertyName(String string) {
161
    public void setPageId(String string) {
136
        propertyName = string;
162
        pageId = string;
163
    }
164
    
165
    /**
166
     * Sets the page section ID for this property.
167
     * 
168
     * @param string the page section ID.
169
     */
170
    public void setSectionId(String string) {
171
        sectionId = string;
137
    }
172
    }
138
}
173
}
(-)plugin.xml (-8 / +2 lines)
Lines 672-683 Link Here
672
       		class="org.eclipse.mtj.internal.ui.editors.jad.form.pages.JADOptionalPropertiesEditorPage"
672
       		class="org.eclipse.mtj.internal.ui.editors.jad.form.pages.JADOptionalPropertiesEditorPage"
673
       		priority="30"/>
673
       		priority="30"/>
674
       <jadEditorPage 
674
       <jadEditorPage 
675
       		class="org.eclipse.mtj.internal.ui.editors.jad.form.pages.JADOTAPropertiesEditorPage"
676
       		priority="40"/>
677
       <jadEditorPage 
678
       		class="org.eclipse.mtj.internal.ui.editors.jad.form.pages.JADPushRegistryEditorPage"
679
       		priority="50"/>
680
       <jadEditorPage 
681
       		class="org.eclipse.mtj.internal.ui.editors.jad.form.pages.JADUserDefinedPropertiesEditorPage"
675
       		class="org.eclipse.mtj.internal.ui.editors.jad.form.pages.JADUserDefinedPropertiesEditorPage"
682
       		priority="2147483647"/>
676
       		priority="2147483647"/>
683
    </extension>
677
    </extension>
Lines 692-698 Link Here
692
    
686
    
693
    <extension
687
    <extension
694
          point="org.eclipse.mtj.core.jadattributes">
688
          point="org.eclipse.mtj.core.jadattributes">
695
       <jadAttributes pageID="ota">
689
       <jadAttributes pageID="optional.ota">
696
       		<jadDescriptorsProvider
690
       		<jadDescriptorsProvider
697
       			class="org.eclipse.mtj.internal.ui.editors.jad.form.pages.OTAJADDescriptorsProvider"/>
691
       			class="org.eclipse.mtj.internal.ui.editors.jad.form.pages.OTAJADDescriptorsProvider"/>
698
       </jadAttributes>
692
       </jadAttributes>
Lines 700-706 Link Here
700
    
694
    
701
    <extension
695
    <extension
702
          point="org.eclipse.mtj.core.jadattributes">
696
          point="org.eclipse.mtj.core.jadattributes">
703
       <jadAttributes pageID="optional">
697
       <jadAttributes pageID="optional.optional">
704
       		<jadDescriptorsProvider
698
       		<jadDescriptorsProvider
705
       			class="org.eclipse.mtj.internal.ui.editors.jad.form.pages.OptionalJADDescriptorsProvider"/>
699
       			class="org.eclipse.mtj.internal.ui.editors.jad.form.pages.OptionalJADDescriptorsProvider"/>
706
       </jadAttributes>
700
       </jadAttributes>
(-)src/org/eclipse/mtj/internal/ui/editors/jad/form/pages/JADOptionalPropertiesEditorPage.java (-6 / +691 lines)
Lines 1-5 Link Here
1
/**
1
/**
2
 * Copyright (c) 2003,2008 Craig Setera and others.
2
 * Copyright (c) 2003,2009 Craig Setera and others.
3
 * 
3
 * 
4
 * All rights reserved. This program and the accompanying materials
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
5
 * are made available under the terms of the Eclipse Public License v1.0
Lines 11-25 Link Here
11
 *     Diego Sandin (Motorola)  - Refactoring package name to follow eclipse
11
 *     Diego Sandin (Motorola)  - Refactoring package name to follow eclipse
12
 *                                standards
12
 *                                standards
13
 *     Gang Ma      (Sybase)	- Refactoring the page to add expansibilities
13
 *     Gang Ma      (Sybase)	- Refactoring the page to add expansibilities
14
 *     Diego Sandin (Motorola)  - Use Eclipse Message Bundles [Bug 255874]                         
14
 *     Diego Sandin (Motorola)  - Use Eclipse Message Bundles [Bug 255874]
15
 *     Jon Dearden  (Research In Motion) - Move fields from JADOTAPropertiesEditorPage 
16
 *                                         and JADPushRegistryEditorPage onto this page 
17
 *                                         [Bug 284452]                      
15
 */
18
 */
16
package org.eclipse.mtj.internal.ui.editors.jad.form.pages;
19
package org.eclipse.mtj.internal.ui.editors.jad.form.pages;
17
20
21
import java.util.ArrayList;
22
import java.util.Arrays;
23
import java.util.List;
24
25
import org.eclipse.core.runtime.IProgressMonitor;
26
import org.eclipse.core.runtime.IStatus;
27
import org.eclipse.jdt.core.IJavaProject;
28
import org.eclipse.jdt.core.IType;
29
import org.eclipse.jdt.core.JavaModelException;
30
import org.eclipse.jface.action.Action;
31
import org.eclipse.jface.action.IToolBarManager;
32
import org.eclipse.jface.preference.FieldEditor;
33
import org.eclipse.jface.preference.IPreferenceStore;
34
import org.eclipse.jface.util.IPropertyChangeListener;
35
import org.eclipse.jface.viewers.CellEditor;
36
import org.eclipse.jface.viewers.ColumnWeightData;
37
import org.eclipse.jface.viewers.DialogCellEditor;
38
import org.eclipse.jface.viewers.ICellModifier;
39
import org.eclipse.jface.viewers.IStructuredContentProvider;
40
import org.eclipse.jface.viewers.ITableLabelProvider;
41
import org.eclipse.jface.viewers.LabelProvider;
42
import org.eclipse.jface.viewers.TableLayout;
43
import org.eclipse.jface.viewers.TableViewer;
44
import org.eclipse.jface.viewers.TextCellEditor;
45
import org.eclipse.jface.viewers.Viewer;
46
import org.eclipse.jface.window.Window;
47
import org.eclipse.mtj.core.project.midp.DescriptorPropertyDescription;
48
import org.eclipse.mtj.internal.core.project.midp.JADAttributesRegistry;
49
import org.eclipse.mtj.internal.core.util.Utils;
50
import org.eclipse.mtj.internal.core.util.log.MTJLogger;
18
import org.eclipse.mtj.internal.ui.MTJUIMessages;
51
import org.eclipse.mtj.internal.ui.MTJUIMessages;
52
import org.eclipse.mtj.internal.ui.MTJUIPluginImages;
53
import org.eclipse.mtj.internal.ui.editors.FormLayoutFactory;
19
import org.eclipse.mtj.internal.ui.editors.jad.form.JADFormEditor;
54
import org.eclipse.mtj.internal.ui.editors.jad.form.JADFormEditor;
55
import org.eclipse.mtj.internal.ui.util.MidletSelectionDialogCreator;
20
import org.eclipse.mtj.ui.editors.jad.JADPropertiesEditorPage;
56
import org.eclipse.mtj.ui.editors.jad.JADPropertiesEditorPage;
57
import org.eclipse.swt.SWT;
58
import org.eclipse.swt.events.SelectionAdapter;
59
import org.eclipse.swt.events.SelectionEvent;
60
import org.eclipse.swt.graphics.Image;
61
import org.eclipse.swt.layout.FillLayout;
62
import org.eclipse.swt.layout.GridData;
63
import org.eclipse.swt.layout.GridLayout;
64
import org.eclipse.swt.widgets.Button;
65
import org.eclipse.swt.widgets.Combo;
21
import org.eclipse.swt.widgets.Composite;
66
import org.eclipse.swt.widgets.Composite;
67
import org.eclipse.swt.widgets.Control;
68
import org.eclipse.swt.widgets.Label;
69
import org.eclipse.swt.widgets.Table;
70
import org.eclipse.swt.widgets.TableColumn;
71
import org.eclipse.swt.widgets.TableItem;
72
import org.eclipse.ui.IEditorInput;
22
import org.eclipse.ui.PlatformUI;
73
import org.eclipse.ui.PlatformUI;
74
import org.eclipse.ui.dialogs.SelectionDialog;
75
import org.eclipse.ui.forms.IManagedForm;
76
import org.eclipse.ui.forms.widgets.ExpandableComposite;
77
import org.eclipse.ui.forms.widgets.FormToolkit;
78
import org.eclipse.ui.forms.widgets.ScrolledForm;
79
import org.eclipse.ui.forms.widgets.Section;
23
80
24
/**
81
/**
25
 * JAD editor page for handling the optional properties.
82
 * JAD editor page for handling the optional properties.
Lines 27-33 Link Here
27
 * @author Craig Setera
84
 * @author Craig Setera
28
 */
85
 */
29
public class JADOptionalPropertiesEditorPage extends JADPropertiesEditorPage {
86
public class JADOptionalPropertiesEditorPage extends JADPropertiesEditorPage {
30
87
    
31
    /**
88
    /**
32
     * The unique page identifier.
89
     * The unique page identifier.
33
     */
90
     */
Lines 38-43 Link Here
38
     */
95
     */
39
    public JADOptionalPropertiesEditorPage() {
96
    public JADOptionalPropertiesEditorPage() {
40
        super(ID, MTJUIMessages.JADOptionalPropertiesEditorPage_title);
97
        super(ID, MTJUIMessages.JADOptionalPropertiesEditorPage_title);
98
        pushRegEntries = new ArrayList<PushRegEntry>();
41
    }
99
    }
42
100
43
    /**
101
    /**
Lines 47-52 Link Here
47
     */
105
     */
48
    public JADOptionalPropertiesEditorPage(JADFormEditor editor) {
106
    public JADOptionalPropertiesEditorPage(JADFormEditor editor) {
49
        super(editor, ID, MTJUIMessages.JADOptionalPropertiesEditorPage_title);
107
        super(editor, ID, MTJUIMessages.JADOptionalPropertiesEditorPage_title);
108
        pushRegEntries = new ArrayList<PushRegEntry>();
50
    }
109
    }
51
110
52
    /* (non-Javadoc)
111
    /* (non-Javadoc)
Lines 56-62 Link Here
56
    public String getTitle() {
115
    public String getTitle() {
57
        return MTJUIMessages.JADOptionalPropertiesEditorPage_title; 
116
        return MTJUIMessages.JADOptionalPropertiesEditorPage_title; 
58
    }
117
    }
59
118
    
60
    /* (non-Javadoc)
119
    /* (non-Javadoc)
61
     * @see org.eclipse.mtj.ui.editors.jad.JADPropertiesEditorPage#addContextHelp(org.eclipse.swt.widgets.Composite)
120
     * @see org.eclipse.mtj.ui.editors.jad.JADPropertiesEditorPage#addContextHelp(org.eclipse.swt.widgets.Composite)
62
     */
121
     */
Lines 79-85 Link Here
79
     */
138
     */
80
    @Override
139
    @Override
81
    protected String getSectionDescription() {
140
    protected String getSectionDescription() {
82
        return MTJUIMessages.JADOptionalPropertiesEditorPage_description;
141
        return null;
83
    }
142
    }
84
143
85
    /* (non-Javadoc)
144
    /* (non-Javadoc)
Lines 87-92 Link Here
87
     */
146
     */
88
    @Override
147
    @Override
89
    protected String getSectionTitle() {
148
    protected String getSectionTitle() {
90
        return MTJUIMessages.JADOptionalPropertiesEditorPage_SectionTitle;
149
        return null;
150
    }
151
    
152
    @Override
153
    protected void createFormContent( IManagedForm managedForm ) {
154
        final ScrolledForm form = managedForm.getForm();
155
        FormToolkit toolkit = managedForm.getToolkit();
156
        form.setText( getTitle() );
157
        toolkit.decorateFormHeading( form.getForm() );
158
        createErrorMessageHandler( managedForm );
159
        /*
160
         * launch the help system UI, displaying the documentation identified by
161
         * the href parameter.
162
         */
163
        final String href = getHelpResource();
164
        if (href != null) {
165
            IToolBarManager manager = form.getToolBarManager();
166
            Action helpAction = new Action("help") { //$NON-NLS-1$
167
                @Override
168
                public void run() {
169
                    PlatformUI.getWorkbench().getHelpSystem()
170
                    .displayHelpResource(href);
171
                }
172
            };
173
            helpAction.setImageDescriptor(MTJUIPluginImages.DESC_LINKTOHELP);
174
            manager.add(helpAction);
175
        }
176
        form.updateToolBar();
177
        createSectionContent( managedForm, managedForm.getForm().getBody(), this );
178
    }
179
    
180
    @Override
181
    protected void createSectionContent(IManagedForm managedForm,
182
            Composite composite, IPropertyChangeListener propertyChangeListener) {
183
184
        FormToolkit toolkit = managedForm.getToolkit();
185
        Composite body = managedForm.getForm().getBody();
186
        body.setLayoutData(new GridData(GridData.FILL_BOTH));
187
        body.setLayout(new GridLayout(2, true));
188
189
        new Label(body, SWT.NONE);
190
        new Label(body, SWT.NONE);
191
192
        Section optionalSection = createStaticBasicSection(toolkit, body,
193
                MTJUIMessages.JADOptionalPropertiesEditorPage_SectionTitle,
194
                MTJUIMessages.JADOptionalPropertiesEditorPage_description);
195
        Composite optionalSectionClient = createStaticSectionClient(toolkit,
196
                optionalSection, "optional"); //$NON-NLS-1$
197
        optionalSection.setLayoutData(new GridData(
198
                GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL));
199
        optionalSection.setLayout(new GridLayout());
200
201
        Section otaSection = createStaticBasicSection(toolkit, body,
202
                MTJUIMessages.JADOTAPropertiesEditorPage_SectionTitle,
203
                MTJUIMessages.JADOTAPropertiesEditorPage_SectionDescription);
204
        Composite otaSectionClient = createStaticSectionClient(toolkit,
205
                otaSection, "ota"); //$NON-NLS-1$
206
        otaSection.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING
207
                | GridData.FILL_HORIZONTAL));
208
        otaSection.setLayout(new GridLayout());
209
        
210
        Composite[] sectionClients = new Composite[] { optionalSectionClient, otaSectionClient };
211
        createSectionsContent(managedForm, sectionClients, this);
212
213
        optionalSection.setClient(optionalSectionClient);
214
        otaSection.setClient(otaSectionClient);
215
216
        new Label(body, SWT.NONE);
217
        new Label(body, SWT.NONE);
218
219
        Section pushSection = toolkit.createSection(body, Section.DESCRIPTION
220
                | ExpandableComposite.TITLE_BAR);
221
        pushSection.setText(MTJUIMessages.JADPushRegistryEditorPage_sectionTitle);
222
        pushSection.setDescription(MTJUIMessages.JADPushRegistryEditorPage_sectionDescription);
223
224
        GridData gd = new GridData(GridData.FILL_BOTH);
225
        gd.horizontalSpan = 2;
226
        pushSection.setLayoutData(gd);
227
        pushSection.setLayout(new GridLayout());
228
229
        Composite pushSectionClient = toolkit.createComposite(pushSection, SWT.NONE);
230
        pushSectionClient.setLayout(new GridLayout(2, false));
231
        pushSection.setClient(pushSectionClient);
232
233
        createTableViewer(toolkit, pushSectionClient);
234
        createButtons(toolkit, pushSectionClient);
235
        addContextHelp(composite);
236
    }
237
    
238
    /**
239
     * This method creates all sections on the page at one time 
240
     * so that the fieldEditors array is populated only once.
241
     */
242
    private void createSectionsContent(IManagedForm managedForm,
243
            Composite[] sections, IPropertyChangeListener propertyChangeListener) {
244
        
245
        for (int i = 0; i < sections.length; i++) {
246
            sections[i].setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2));
247
            new Label(sections[i], SWT.NONE);
248
            new Label(sections[i], SWT.NONE); 
249
        }
250
        
251
        DescriptorPropertyDescription[] theDescriptors = getDescriptors();
252
        
253
        if (fieldEditors == null) {
254
            fieldEditors = new FieldEditor[theDescriptors.length];
255
        }
256
        
257
        FormToolkit toolkit = managedForm.getToolkit();
258
        Composite sectionComp = null;
259
260
        for (int i = 0; i < theDescriptors.length; i++) {
261
262
            for (int j = 0; j < sections.length; j++) {
263
                if (theDescriptors[i].getSectionId().equals((String) sections[j].getData())) {
264
                    sectionComp = sections[j];
265
                    break;
266
                }
267
            }
268
            
269
            if (sectionComp == null) {
270
                throw new Error("sectionComp should not be null"); //$NON-NLS-1$
271
            }
272
273
            switch (theDescriptors[i].getDataType()) {
274
                case DescriptorPropertyDescription.DATATYPE_INT:
275
                    fieldEditors[i] = createIntegerFieldEditor(toolkit,
276
                            sectionComp, theDescriptors[i]);
277
                    break;
278
                case DescriptorPropertyDescription.DATATYPE_LIST:
279
                    fieldEditors[i] = createComboFieldEditor(toolkit, sectionComp,
280
                            theDescriptors[i]);
281
                    break;
282
                case DescriptorPropertyDescription.DATATYPE_URL:
283
                case DescriptorPropertyDescription.DATATYPE_STRING:
284
                default:
285
                    fieldEditors[i] = createStringFieldEditor(toolkit, sectionComp,
286
                            theDescriptors[i]);
287
                    break;
288
            }
289
290
            Label label = fieldEditors[i].getLabelControl(sectionComp);
291
            toolkit.adapt(label, false, false);
292
293
            // Listen for property change events on the editor
294
            fieldEditors[i].setPropertyChangeListener(propertyChangeListener);
295
        }
296
        
297
        for (int i = 0; i < sections.length; i++) {
298
            // Adapt the Combo instances...
299
            Control[] children = sections[i].getChildren();
300
            for (Control control : children) {
301
                if (control instanceof Combo) {
302
                    toolkit.adapt(control, false, false);
303
                }
304
            }
305
        }
306
        
307
        updateEditComponents();
308
    }
309
    
310
    @Override
311
    protected DescriptorPropertyDescription[] doGetDescriptors() {
312
        DescriptorPropertyDescription[] optionalDescriptors;
313
        optionalDescriptors = JADAttributesRegistry
314
                .getJADAttrDescriptorsByPage(getId() + ".optional"); //$NON-NLS-1$
315
        DescriptorPropertyDescription[] otaDescriptors;
316
        otaDescriptors = JADAttributesRegistry
317
                .getJADAttrDescriptorsByPage(getId() + ".ota"); //$NON-NLS-1$
318
        DescriptorPropertyDescription[] result 
319
            = new DescriptorPropertyDescription[optionalDescriptors.length + otaDescriptors.length];
320
        System.arraycopy(optionalDescriptors, 0, result, 0,
321
                optionalDescriptors.length);
322
        System.arraycopy(otaDescriptors, 0, result, optionalDescriptors.length,
323
                otaDescriptors.length);
324
        return result;
325
    }
326
   
327
    /* (non-Javadoc)
328
     * @see org.eclipse.mtj.ui.editors.jad.AbstractJADEditorPage#isManagingProperty(java.lang.String)
329
     */
330
    @Override
331
    public boolean isManagingProperty(String property) {
332
        boolean manages = property.startsWith(PUSH_REGISTRY_PREFIX);
333
        if (manages) {
334
            String value = property.substring(PUSH_REGISTRY_PREFIX.length());
335
            try {
336
                Integer.parseInt(value);
337
            } catch (NumberFormatException e) {
338
                manages = false;
339
            }
340
        }
341
342
        return manages;
343
    }
344
345
    /* (non-Javadoc)
346
     * @see org.eclipse.ui.forms.editor.FormPage#setFocus()
347
     */
348
    @Override
349
    public void setFocus() {
350
        tableViewer.getTable().setFocus();
351
    }
352
353
    /**
354
     * Add a new item to the table.
355
     */
356
    private void addItem() {
357
        PushRegEntry midletDefinition = new PushRegEntry(
358
                MTJUIMessages.JADPushRegistryEditorPage_new_pushReg,
359
                Utils.EMPTY_STRING, "*"); //$NON-NLS-1$
360
        pushRegEntries.add(midletDefinition);
361
        tableViewer.refresh();
362
        setDirty(true);
363
    }
364
365
    /**
366
     * Create the add and remove buttons to the composite.
367
     * 
368
     * @param toolkit the Eclipse Form's toolkit
369
     * @param parent
370
     */
371
    private void createButtons(FormToolkit toolkit, Composite parent) {
372
        Composite composite = toolkit.createComposite(parent);
373
        FillLayout layout = new FillLayout();
374
        layout.type = SWT.VERTICAL;
375
        composite.setLayout(layout);
376
377
        addButton = toolkit
378
                .createButton(composite,
379
                        MTJUIMessages.JADPushRegistryEditorPage_add_btn_label,
380
                        SWT.PUSH);
381
        addButton.addSelectionListener(new SelectionAdapter() {
382
            @Override
383
            public void widgetSelected(SelectionEvent se) {
384
                addItem();
385
            }
386
        });
387
388
        toolkit.createLabel(composite, Utils.EMPTY_STRING);
389
390
        removeButton = toolkit.createButton(composite,
391
                MTJUIMessages.JADPushRegistryEditorPage_remove_btn_label,
392
                SWT.PUSH);
393
        removeButton.setEnabled(false);
394
        removeButton.addSelectionListener(new SelectionAdapter() {
395
            @Override
396
            public void widgetSelected(SelectionEvent se) {
397
                removeSelectedItems();
398
            }
399
        });
400
    }
401
402
    /**
403
     * Create the table viewer for this editor.
404
     * 
405
     * @param toolkit The Eclipse form's toolkit
406
     * @param parent
407
     */
408
    private void createTableViewer(FormToolkit toolkit, Composite parent) {
409
        
410
        String[] columns = new String[] {
411
                MTJUIMessages.JADPushRegistryEditorPage_connection_column,
412
                MTJUIMessages.JADPushRegistryEditorPage_class_column,
413
                MTJUIMessages.JADPushRegistryEditorPage_sender_column, };
414
415
        // Setup the table
416
        int styles = SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER
417
                | SWT.FULL_SELECTION;
418
        Table table = toolkit.createTable(parent, styles);
419
        table.setHeaderVisible(true);
420
        table.setLinesVisible(true);
421
        
422
        table.setLayoutData(new GridData(GridData.FILL_BOTH));
423
        
424
        table.addSelectionListener(new SelectionAdapter() {
425
            @Override
426
            public void widgetSelected(SelectionEvent e) {
427
                TableItem selected = (TableItem) e.item;
428
                removeButton.setEnabled(selected.getParent()
429
                        .getSelectionCount() > 0);
430
            }
431
        });
432
        tableViewer = new TableViewer(table);
433
434
        // Set the table layout on the table
435
        TableLayout layout = new TableLayout();
436
437
        int width = 100 / columns.length;
438
        for (String element : columns) {
439
            TableColumn column = new TableColumn(table, SWT.NONE);
440
            column.setText(element);
441
            layout.addColumnData(new ColumnWeightData(width));
442
        }
443
        table.setLayout(layout);
444
        
445
        // Set the content providers
446
        tableViewer.setContentProvider(new TableContentProvider());
447
        tableViewer.setLabelProvider(new TableLabelProvider());
448
449
        // Wire up the cell modification handling
450
        tableViewer.setCellModifier(new CellModifier());
451
        tableViewer.setColumnProperties(PROPERTIES);
452
        tableViewer.setCellEditors(new CellEditor[] {
453
                new TextCellEditor(table), new MidletCellEditor(table),
454
                new TextCellEditor(table), });
455
456
        // Get some data into the viewer
457
        tableViewer.setInput(getEditorInput());
458
        tableViewer.refresh();
459
    }
460
461
    /**
462
     * Load the Push Registry Entries from the current preference store.
463
     */
464
    private void loadPushRegistryEntries() {
465
        pushRegEntries.clear();
466
        IPreferenceStore store = getPreferenceStore();
467
468
        // This is sort of ugly, but IPreferenceStore does not
469
        // allow getting the complete list of preference keys
470
        for (int i = 1; i < 1000; i++) {
471
            String propName = PUSH_REGISTRY_PREFIX + i;
472
473
            if (store.contains(propName)) {
474
                String propValue = store.getString(propName);
475
                pushRegEntries.add(new PushRegEntry(propValue));
476
            } else {
477
                break;
478
            }
479
        }
480
481
        storedEntriesCount = pushRegEntries.size();
482
        if (tableViewer != null) {
483
            tableViewer.refresh();
484
        }
485
    }
486
487
    /**
488
     * Remove the items currently selected within the table.
489
     */
490
    private void removeSelectedItems() {
491
        int[] indices = tableViewer.getTable().getSelectionIndices();
492
493
        for (int i = indices.length; i > 0; i--) {
494
            int index = indices[i - 1];
495
            pushRegEntries.remove(index);
496
        }
497
498
        setDirty(true);
499
        tableViewer.refresh();
500
    }    
501
    
502
    /** The prefix of all push registry definition properties */
503
    public static final String PUSH_REGISTRY_PREFIX = "MIDlet-Push-"; //$NON-NLS-1$
504
505
    private static final String PROP_CLASS = "class"; //$NON-NLS-1$
506
507
    // Column property names
508
    private static final String PROP_CONNSTR = "connection string"; //$NON-NLS-1$
509
510
    private static final String PROP_SENDER = "allowed sender"; //$NON-NLS-1$
511
512
    // All of the properties in order
513
    private static final String[] PROPERTIES = new String[] { PROP_CONNSTR,
514
            PROP_CLASS, PROP_SENDER };
515
516
    private static final List<String> PROPERTY_LIST = Arrays.asList(PROPERTIES);
517
518
    // Buttons
519
    private Button addButton;
520
521
    // The collections of entries representing the MIDlets to be registered
522
    private ArrayList<PushRegEntry> pushRegEntries;
523
    private Button removeButton;
524
525
    // The number of MIDlets registered
526
    private int storedEntriesCount;
527
528
    // The table viewer in use
529
    private TableViewer tableViewer;
530
    
531
    /* (non-Javadoc)
532
     * @see org.eclipse.ui.part.EditorPart#setInput(org.eclipse.ui.IEditorInput)
533
     */
534
    @Override
535
    protected void setInput(IEditorInput input) {
536
        super.setInput(input);
537
        if (tableViewer != null) {
538
            tableViewer.setInput(input);
539
        }
540
541
        setDirty(false);
542
        loadPushRegistryEntries();
543
    }
544
    
545
    /* (non-Javadoc)
546
     * @see org.eclipse.ui.forms.editor.FormPage#doSave(org.eclipse.core.runtime.IProgressMonitor)
547
     */
548
    @Override
549
    public void doSave(IProgressMonitor monitor) {
550
        // Save push registry entries
551
        monitor.setTaskName(getTitle());
552
        IPreferenceStore store = getPreferenceStore();
553
        // Add the push registry entries to the store
554
        int i;
555
        int currentEntriesCount = pushRegEntries.size();
556
557
        for (i = 0; i < currentEntriesCount; i++) {
558
            PushRegEntry def = pushRegEntries.get(i);
559
            store.setValue(PUSH_REGISTRY_PREFIX + (i + 1), def.toString());
560
        }
561
        // Removing deleted entries
562
        for (; i < storedEntriesCount; i++) {
563
            store.setToDefault(PUSH_REGISTRY_PREFIX + (i + 1));
564
        }
565
        storedEntriesCount = currentEntriesCount;
566
        // Save other fields
567
        super.doSave(monitor);
568
    }    
569
    
570
    /**
571
     * Implementation of the ICellModifier interface.
572
     */
573
    private class CellModifier implements ICellModifier {
574
575
        /* (non-Javadoc)
576
         * @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object, java.lang.String)
577
         */
578
        public boolean canModify(Object element, String property) {
579
            // All columns are modifiable
580
            return true;
581
        }
582
583
        /* (non-Javadoc)
584
         * @see org.eclipse.jface.viewers.ICellModifier#getValue(java.lang.Object, java.lang.String)
585
         */
586
        public Object getValue(Object element, String property) {
587
            Object value = null;
588
589
            if (element instanceof PushRegEntry) {
590
                PushRegEntry entry = (PushRegEntry) element;
591
592
                int fieldIndex = getFieldIndex(property);
593
                if (fieldIndex != -1) {
594
                    value = entry.fields[fieldIndex];
595
                }
596
            }
597
598
            return value;
599
        }
600
601
        /* (non-Javadoc)
602
         * @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object, java.lang.String, java.lang.Object)
603
         */
604
        public void modify(Object element, String property, Object value) {
605
            if (element instanceof TableItem) {
606
                Object data = ((TableItem) element).getData();
607
                String newValue = (String) value;
608
609
                if (data instanceof PushRegEntry) {
610
                    int fieldIndex = getFieldIndex(property);
611
                    PushRegEntry entry = (PushRegEntry) data;
612
613
                    if (fieldIndex != -1) {
614
                        updateField(entry, property, fieldIndex, newValue);
615
                    }
616
                }
617
            }
618
        }
619
620
        /**
621
         * Return the field index to match the specified property name.
622
         * 
623
         * @param property property name to search for
624
         * @return the index that matchs the specified property name.
625
         *         <code>-1</code> if the property is not recognized.
626
         */
627
        private int getFieldIndex(String property) {
628
            return PROPERTY_LIST.indexOf(property);
629
        }
630
631
        /**
632
         * Update the specified field as necessary.
633
         * 
634
         * @param entry the Push Registry entry to be updated
635
         * @param property property of entry to be updated
636
         * @param fieldIndex the index of the field to be updated in entry
637
         * @param newValue the new value to be set
638
         */
639
        private void updateField(PushRegEntry entry, String property,
640
                int fieldIndex, String newValue) {
641
            if (!entry.fields[fieldIndex].equals(newValue)) {
642
                entry.fields[fieldIndex] = newValue;
643
                setDirty(true);
644
                tableViewer.update(entry, new String[] { property });
645
            }
646
        }
647
    }
648
649
    /**
650
     * A cell editor implementation that allows for selection of a midlet class.
651
     */
652
    private class MidletCellEditor extends DialogCellEditor {
653
        /** Construct a new cell editor */
654
        MidletCellEditor(Composite parent) {
655
            super(parent);
656
        }
657
658
        /* (non-Javadoc)
659
         * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control)
660
         */
661
        @Override
662
        protected Object openDialogBox(Control cellEditorWindow) {
663
            Object value = null;
664
665
            try {
666
                IJavaProject javaProject = getJavaProject();
667
                SelectionDialog dialog = MidletSelectionDialogCreator
668
                        .createMidletSelectionDialog(
669
                                cellEditorWindow.getShell(),
670
                                getSite().getPage().getWorkbenchWindow(),
671
                                javaProject,
672
                                false,
673
                                MTJUIMessages.JADPushRegistryEditorPage_choose_MIDlet);
674
675
                if (dialog.open() == Window.OK) {
676
                    Object[] results = dialog.getResult();
677
                    if ((results != null) && (results.length > 0)) {
678
                        IType type = (IType) results[0];
679
                        if (type != null) {
680
                            value = type.getFullyQualifiedName();
681
                        }
682
                    }
683
                }
684
            } catch (JavaModelException e) {
685
                MTJLogger.log(IStatus.ERROR, "openDialogBox", e); //$NON-NLS-1$
686
            }
687
688
            return value;
689
        }
690
    }
691
692
    /**
693
     * Implementation of the table's content provider.
694
     */
695
    private class TableContentProvider implements IStructuredContentProvider {
696
697
        /* (non-Javadoc)
698
         * @see org.eclipse.jface.viewers.IContentProvider#dispose()
699
         */
700
        public void dispose() {
701
        }
702
703
        /* (non-Javadoc)
704
         * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
705
         */
706
        public Object[] getElements(Object inputElement) {
707
            return pushRegEntries.toArray(new Object[pushRegEntries.size()]);
708
        }
709
710
        /* (non-Javadoc)
711
         * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
712
         */
713
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
714
        }
715
    }
716
717
    /**
718
     * Implementation of the table's label provider.
719
     */
720
    private static class TableLabelProvider extends LabelProvider implements
721
            ITableLabelProvider {
722
723
        /* (non-Javadoc)
724
         * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
725
         */
726
        public Image getColumnImage(Object element, int columnIndex) {
727
            return null;
728
        }
729
730
        /* (non-Javadoc)
731
         * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
732
         */
733
        public String getColumnText(Object element, int columnIndex) {
734
            return ((PushRegEntry) element).fields[columnIndex];
735
        }
736
    }
737
738
    static class PushRegEntry {
739
        public String[] fields;
740
741
        PushRegEntry(String entryString) {
742
            fields = new String[3];
743
            String[] tokens = entryString.split(","); //$NON-NLS-1$
744
745
            for (int i = 0; i < 3; i++) {
746
                fields[i] = (i > tokens.length) ? Utils.EMPTY_STRING
747
                        : tokens[i];
748
            }
749
        }
750
751
        PushRegEntry(String connStr, String className, String allowedSender) {
752
            fields = new String[3];
753
754
            fields[0] = connStr;
755
            fields[1] = className;
756
            fields[2] = allowedSender;
757
        }
758
759
        /* (non-Javadoc)
760
         * @see java.lang.Object#toString()
761
         */
762
        @Override
763
        public String toString() {
764
            StringBuffer sb = new StringBuffer();
765
            if (fields != null) {
766
                for (int i = 0; i < fields.length; i++) {
767
                    if (i != 0) {
768
                        sb.append(","); //$NON-NLS-1$
769
                    }
770
                    sb.append(fields[i]);
771
                }
772
            }
773
            return sb.toString();
774
        }
775
91
    }
776
    }
92
}
777
}
(-)src/org/eclipse/mtj/internal/ui/editors/jad/form/pages/JADOTAPropertiesEditorPage.java (-96 lines)
Lines 1-96 Link Here
1
/**
2
 * Copyright (c) 2003,2008 Craig Setera and others.
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
 *     Craig Setera (EclipseME) - Initial implementation
11
 *     Diego Sandin (Motorola)  - Refactoring package name to follow eclipse
12
 *                                standards
13
 *     Gang Ma      (Sybase)	- Refactoring the page to add expansibilities
14
 *     Diego Sandin (Motorola)  - Use Eclipse Message Bundles [Bug 255874]                                 
15
 */
16
package org.eclipse.mtj.internal.ui.editors.jad.form.pages;
17
18
import org.eclipse.mtj.internal.ui.MTJUIMessages;
19
import org.eclipse.mtj.internal.ui.editors.jad.form.JADFormEditor;
20
import org.eclipse.mtj.ui.editors.jad.JADPropertiesEditorPage;
21
import org.eclipse.swt.widgets.Composite;
22
import org.eclipse.ui.PlatformUI;
23
24
/**
25
 * JAD editor page for handling the over the air properties.
26
 * 
27
 * @author Craig Setera
28
 */
29
public class JADOTAPropertiesEditorPage extends JADPropertiesEditorPage {
30
31
    /**
32
     * The page unique identifier
33
     */
34
    public static final String OTA_PAGEID = "ota"; //$NON-NLS-1$
35
36
    /**
37
     * A constructor that creates the JAD Over the Air (OTA) EditorPage. The
38
     * parent editor need to be passed in the <code>initialize</code> method if
39
     * this constructor is used.
40
     */
41
    public JADOTAPropertiesEditorPage() {
42
        super(OTA_PAGEID, MTJUIMessages.JADOTAPropertiesEditorPage_title);
43
    }
44
45
    /**
46
     * A constructor that creates the JAD Over the Air (OTA) EditorPage and
47
     * initializes it with the editor.
48
     * 
49
     * @param editor the parent editor
50
     */
51
    public JADOTAPropertiesEditorPage(JADFormEditor editor) {
52
        super(editor, OTA_PAGEID,
53
                MTJUIMessages.JADOTAPropertiesEditorPage_title);
54
    }
55
56
    /* (non-Javadoc)
57
     * @see org.eclipse.mtj.ui.editors.jad.AbstractJADEditorPage#getTitle()
58
     */
59
    @Override
60
    public String getTitle() {
61
        return MTJUIMessages.JADOTAPropertiesEditorPage_title;
62
    }
63
64
    /* (non-Javadoc)
65
     * @see org.eclipse.mtj.ui.editors.jad.JADPropertiesEditorPage#addContextHelp(org.eclipse.swt.widgets.Composite)
66
     */
67
    @Override
68
    protected void addContextHelp(Composite c) {
69
        PlatformUI.getWorkbench().getHelpSystem().setHelp(c,
70
                "org.eclipse.mtj.ui.help_JADOTAPropertiesEditorPage"); //$NON-NLS-1$
71
    }
72
73
    /* (non-Javadoc)
74
     * @see org.eclipse.mtj.ui.editors.jad.AbstractJADEditorPage#getHelpResource()
75
     */
76
    @Override
77
    protected String getHelpResource() {
78
        return "/org.eclipse.mtj.doc.user/html/reference/editors/jad_editor/ota.html"; //$NON-NLS-1$
79
    }
80
81
    /* (non-Javadoc)
82
     * @see org.eclipse.mtj.ui.editors.jad.JADPropertiesEditorPage#getSectionDescription()
83
     */
84
    @Override
85
    protected String getSectionDescription() {
86
        return MTJUIMessages.JADOTAPropertiesEditorPage_SectionDescription;
87
    }
88
89
    /* (non-Javadoc)
90
     * @see org.eclipse.mtj.ui.editors.jad.JADPropertiesEditorPage#getSectionTitle()
91
     */
92
    @Override
93
    protected String getSectionTitle() {
94
        return MTJUIMessages.JADOTAPropertiesEditorPage_SectionTitle;
95
    }
96
}
(-)src/org/eclipse/mtj/internal/ui/editors/jad/form/pages/JADPushRegistryEditorPage.java (-600 lines)
Lines 1-600 Link Here
1
/**
2
 * Copyright (c) 2008 Motorola.
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
 *     Hugo Raniere (Motorola) - Initial implementation
11
 *     Gang Ma      (Sybase)	- Refactoring the page to add expansibilities
12
 *     Diego Sandin (Motorola)  - Use Eclipse Message Bundles [Bug 255874]  
13
 */
14
package org.eclipse.mtj.internal.ui.editors.jad.form.pages;
15
16
import java.util.ArrayList;
17
import java.util.Arrays;
18
import java.util.List;
19
20
import org.eclipse.core.runtime.IProgressMonitor;
21
import org.eclipse.core.runtime.IStatus;
22
import org.eclipse.jdt.core.IJavaProject;
23
import org.eclipse.jdt.core.IType;
24
import org.eclipse.jdt.core.JavaModelException;
25
import org.eclipse.jface.preference.IPreferenceStore;
26
import org.eclipse.jface.viewers.CellEditor;
27
import org.eclipse.jface.viewers.ColumnWeightData;
28
import org.eclipse.jface.viewers.DialogCellEditor;
29
import org.eclipse.jface.viewers.ICellModifier;
30
import org.eclipse.jface.viewers.IStructuredContentProvider;
31
import org.eclipse.jface.viewers.ITableLabelProvider;
32
import org.eclipse.jface.viewers.LabelProvider;
33
import org.eclipse.jface.viewers.TableLayout;
34
import org.eclipse.jface.viewers.TableViewer;
35
import org.eclipse.jface.viewers.TextCellEditor;
36
import org.eclipse.jface.viewers.Viewer;
37
import org.eclipse.jface.window.Window;
38
import org.eclipse.mtj.internal.core.util.Utils;
39
import org.eclipse.mtj.internal.core.util.log.MTJLogger;
40
import org.eclipse.mtj.internal.ui.MTJUIMessages;
41
import org.eclipse.mtj.internal.ui.editors.jad.form.JADFormEditor;
42
import org.eclipse.mtj.internal.ui.util.MidletSelectionDialogCreator;
43
import org.eclipse.mtj.ui.editors.jad.AbstractJADEditorPage;
44
import org.eclipse.swt.SWT;
45
import org.eclipse.swt.events.SelectionAdapter;
46
import org.eclipse.swt.events.SelectionEvent;
47
import org.eclipse.swt.graphics.Image;
48
import org.eclipse.swt.layout.FillLayout;
49
import org.eclipse.swt.layout.GridData;
50
import org.eclipse.swt.layout.GridLayout;
51
import org.eclipse.swt.widgets.Button;
52
import org.eclipse.swt.widgets.Composite;
53
import org.eclipse.swt.widgets.Control;
54
import org.eclipse.swt.widgets.Label;
55
import org.eclipse.swt.widgets.Table;
56
import org.eclipse.swt.widgets.TableColumn;
57
import org.eclipse.swt.widgets.TableItem;
58
import org.eclipse.ui.IEditorInput;
59
import org.eclipse.ui.PlatformUI;
60
import org.eclipse.ui.dialogs.SelectionDialog;
61
import org.eclipse.ui.forms.IManagedForm;
62
import org.eclipse.ui.forms.widgets.FormToolkit;
63
64
/**
65
 * A property page editor static registering MIDlets in Push Registry
66
 * 
67
 * @author Hugo Raniere
68
 */
69
public class JADPushRegistryEditorPage extends AbstractJADEditorPage {
70
71
    /**
72
     * Implementation of the ICellModifier interface.
73
     */
74
    private class CellModifier implements ICellModifier {
75
76
        /* (non-Javadoc)
77
         * @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object, java.lang.String)
78
         */
79
        public boolean canModify(Object element, String property) {
80
            // All columns are modifiable
81
            return true;
82
        }
83
84
        /* (non-Javadoc)
85
         * @see org.eclipse.jface.viewers.ICellModifier#getValue(java.lang.Object, java.lang.String)
86
         */
87
        public Object getValue(Object element, String property) {
88
            Object value = null;
89
90
            if (element instanceof PushRegEntry) {
91
                PushRegEntry entry = (PushRegEntry) element;
92
93
                int fieldIndex = getFieldIndex(property);
94
                if (fieldIndex != -1) {
95
                    value = entry.fields[fieldIndex];
96
                }
97
            }
98
99
            return value;
100
        }
101
102
        /* (non-Javadoc)
103
         * @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object, java.lang.String, java.lang.Object)
104
         */
105
        public void modify(Object element, String property, Object value) {
106
            if (element instanceof TableItem) {
107
                Object data = ((TableItem) element).getData();
108
                String newValue = (String) value;
109
110
                if (data instanceof PushRegEntry) {
111
                    int fieldIndex = getFieldIndex(property);
112
                    PushRegEntry entry = (PushRegEntry) data;
113
114
                    if (fieldIndex != -1) {
115
                        updateField(entry, property, fieldIndex, newValue);
116
                    }
117
                }
118
            }
119
        }
120
121
        /**
122
         * Return the field index to match the specified property name.
123
         * 
124
         * @param property property name to search for
125
         * @return the index that matchs the specified property name.
126
         *         <code>-1</code> if the property is not recognized.
127
         */
128
        private int getFieldIndex(String property) {
129
            return PROPERTY_LIST.indexOf(property);
130
        }
131
132
        /**
133
         * Update the specified field as necessary.
134
         * 
135
         * @param entry the Push Registry entry to be updated
136
         * @param property property of entry to be updated
137
         * @param fieldIndex the index of the field to be updated in entry
138
         * @param newValue the new value to be set
139
         */
140
        private void updateField(PushRegEntry entry, String property,
141
                int fieldIndex, String newValue) {
142
            if (!entry.fields[fieldIndex].equals(newValue)) {
143
                entry.fields[fieldIndex] = newValue;
144
                setDirty(true);
145
                tableViewer.update(entry, new String[] { property });
146
            }
147
        }
148
    }
149
150
    /**
151
     * A cell editor implementation that allows for selection of a midlet class.
152
     */
153
    private class MidletCellEditor extends DialogCellEditor {
154
        /** Construct a new cell editor */
155
        MidletCellEditor(Composite parent) {
156
            super(parent);
157
        }
158
159
        /* (non-Javadoc)
160
         * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control)
161
         */
162
        @Override
163
        protected Object openDialogBox(Control cellEditorWindow) {
164
            Object value = null;
165
166
            try {
167
                IJavaProject javaProject = getJavaProject();
168
                SelectionDialog dialog = MidletSelectionDialogCreator
169
                        .createMidletSelectionDialog(
170
                                cellEditorWindow.getShell(),
171
                                getSite().getPage().getWorkbenchWindow(),
172
                                javaProject,
173
                                false,
174
                                MTJUIMessages.JADPushRegistryEditorPage_choose_MIDlet);
175
176
                if (dialog.open() == Window.OK) {
177
                    Object[] results = dialog.getResult();
178
                    if ((results != null) && (results.length > 0)) {
179
                        IType type = (IType) results[0];
180
                        if (type != null) {
181
                            value = type.getFullyQualifiedName();
182
                        }
183
                    }
184
                }
185
            } catch (JavaModelException e) {
186
                MTJLogger.log(IStatus.ERROR, "openDialogBox", e); //$NON-NLS-1$
187
            }
188
189
            return value;
190
        }
191
    }
192
193
    /**
194
     * Implementation of the table's content provider.
195
     */
196
    private class TableContentProvider implements IStructuredContentProvider {
197
198
        /* (non-Javadoc)
199
         * @see org.eclipse.jface.viewers.IContentProvider#dispose()
200
         */
201
        public void dispose() {
202
        }
203
204
        /* (non-Javadoc)
205
         * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
206
         */
207
        public Object[] getElements(Object inputElement) {
208
            return pushRegEntries.toArray(new Object[pushRegEntries.size()]);
209
        }
210
211
        /* (non-Javadoc)
212
         * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
213
         */
214
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
215
        }
216
    }
217
218
    /**
219
     * Implementation of the table's label provider.
220
     */
221
    private static class TableLabelProvider extends LabelProvider implements
222
            ITableLabelProvider {
223
224
        /* (non-Javadoc)
225
         * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
226
         */
227
        public Image getColumnImage(Object element, int columnIndex) {
228
            return null;
229
        }
230
231
        /* (non-Javadoc)
232
         * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
233
         */
234
        public String getColumnText(Object element, int columnIndex) {
235
            return ((PushRegEntry) element).fields[columnIndex];
236
        }
237
    }
238
239
    static class PushRegEntry {
240
        public String[] fields;
241
242
        PushRegEntry(String entryString) {
243
            fields = new String[3];
244
            String[] tokens = entryString.split(","); //$NON-NLS-1$
245
246
            for (int i = 0; i < 3; i++) {
247
                fields[i] = (i > tokens.length) ? Utils.EMPTY_STRING
248
                        : tokens[i];
249
            }
250
        }
251
252
        PushRegEntry(String connStr, String className, String allowedSender) {
253
            fields = new String[3];
254
255
            fields[0] = connStr;
256
            fields[1] = className;
257
            fields[2] = allowedSender;
258
        }
259
260
        /* (non-Javadoc)
261
         * @see java.lang.Object#toString()
262
         */
263
        @Override
264
        public String toString() {
265
            StringBuffer sb = new StringBuffer();
266
            if (fields != null) {
267
                for (int i = 0; i < fields.length; i++) {
268
                    if (i != 0) {
269
                        sb.append(","); //$NON-NLS-1$
270
                    }
271
                    sb.append(fields[i]);
272
                }
273
            }
274
            return sb.toString();
275
        }
276
277
    }
278
279
    public static final String ID = "pushregistry"; //$NON-NLS-1$
280
281
    /** The prefix of all push registry definition properties */
282
    public static final String PUSH_REGISTRY_PREFIX = "MIDlet-Push-"; //$NON-NLS-1$
283
284
    private static final String PROP_CLASS = "class"; //$NON-NLS-1$
285
286
    // Column property names
287
    private static final String PROP_CONNSTR = "connection string"; //$NON-NLS-1$
288
289
    private static final String PROP_SENDER = "allowed sender"; //$NON-NLS-1$
290
291
    // All of the properties in order
292
    private static final String[] PROPERTIES = new String[] { PROP_CONNSTR,
293
            PROP_CLASS, PROP_SENDER };
294
295
    private static final List<String> PROPERTY_LIST = Arrays.asList(PROPERTIES);
296
297
    // Buttons
298
    private Button addButton;
299
300
    // The collections of entries representing the MIDlets to be registered
301
    private ArrayList<PushRegEntry> pushRegEntries;
302
    private Button removeButton;
303
304
    // The number of MIDlets registered
305
    private int storedEntriesCount;
306
307
    // The table viewer in use
308
    private TableViewer tableViewer;
309
310
    /**
311
     * Creates a new JADPushRegistryEditorPage.
312
     */
313
    public JADPushRegistryEditorPage() {
314
        super(ID, MTJUIMessages.JADPushRegistryEditorPage_title);
315
        pushRegEntries = new ArrayList<PushRegEntry>();
316
    }
317
318
    /**
319
     * Creates a new JADPushRegistryEditorPage.
320
     * 
321
     * @param editor the parent editor for this page
322
     * @param title the title of this page
323
     */
324
    public JADPushRegistryEditorPage(JADFormEditor editor, String title) {
325
        super(editor, ID, title);
326
        pushRegEntries = new ArrayList<PushRegEntry>();
327
    }
328
329
    /* (non-Javadoc)
330
     * @see org.eclipse.ui.forms.editor.FormPage#doSave(org.eclipse.core.runtime.IProgressMonitor)
331
     */
332
    @Override
333
    public void doSave(IProgressMonitor monitor) {
334
        IPreferenceStore store = getPreferenceStore();
335
336
        // Add the push registry entries to the store
337
        int i;
338
        int currentEntriesCount = pushRegEntries.size();
339
340
        for (i = 0; i < currentEntriesCount; i++) {
341
            PushRegEntry def = pushRegEntries.get(i);
342
            store.setValue(PUSH_REGISTRY_PREFIX + (i + 1), def.toString());
343
        }
344
345
        // removing deleted entries
346
        for (; i < storedEntriesCount; i++) {
347
            store.setToDefault(PUSH_REGISTRY_PREFIX + (i + 1));
348
        }
349
350
        storedEntriesCount = currentEntriesCount;
351
        setDirty(false);
352
    }
353
354
    /* (non-Javadoc)
355
     * @see org.eclipse.mtj.ui.editors.jad.AbstractJADEditorPage#editorInputChanged()
356
     */
357
    @Override
358
    public void editorInputChanged() {
359
        loadPushRegistryEntries();
360
    }
361
362
    /* (non-Javadoc)
363
     * @see org.eclipse.mtj.ui.editors.jad.AbstractJADEditorPage#getTitle()
364
     */
365
    @Override
366
    public String getTitle() {
367
        return MTJUIMessages.JADPushRegistryEditorPage_title;
368
    }
369
370
    /* (non-Javadoc)
371
     * @see org.eclipse.mtj.ui.editors.jad.AbstractJADEditorPage#isManagingProperty(java.lang.String)
372
     */
373
    @Override
374
    public boolean isManagingProperty(String property) {
375
        boolean manages = property.startsWith(PUSH_REGISTRY_PREFIX);
376
        if (manages) {
377
            String value = property.substring(PUSH_REGISTRY_PREFIX.length());
378
            try {
379
                Integer.parseInt(value);
380
            } catch (NumberFormatException e) {
381
                manages = false;
382
            }
383
        }
384
385
        return manages;
386
    }
387
388
    /* (non-Javadoc)
389
     * @see org.eclipse.ui.forms.editor.FormPage#setFocus()
390
     */
391
    @Override
392
    public void setFocus() {
393
        tableViewer.getTable().setFocus();
394
    }
395
396
    /**
397
     * Add a new item to the table.
398
     */
399
    private void addItem() {
400
        PushRegEntry midletDefinition = new PushRegEntry(
401
                MTJUIMessages.JADPushRegistryEditorPage_new_pushReg,
402
                Utils.EMPTY_STRING, "*"); //$NON-NLS-1$
403
        pushRegEntries.add(midletDefinition);
404
        tableViewer.refresh();
405
        setDirty(true);
406
    }
407
408
    /**
409
     * Create the add and remove buttons to the composite.
410
     * 
411
     * @param toolkit the Eclipse Form's toolkit
412
     * @param parent
413
     */
414
    private void createButtons(FormToolkit toolkit, Composite parent) {
415
        Composite composite = toolkit.createComposite(parent);
416
        FillLayout layout = new FillLayout();
417
        layout.type = SWT.VERTICAL;
418
        composite.setLayout(layout);
419
420
        addButton = toolkit
421
                .createButton(composite,
422
                        MTJUIMessages.JADPushRegistryEditorPage_add_btn_label,
423
                        SWT.PUSH);
424
        addButton.addSelectionListener(new SelectionAdapter() {
425
            @Override
426
            public void widgetSelected(SelectionEvent se) {
427
                addItem();
428
            }
429
        });
430
431
        toolkit.createLabel(composite, Utils.EMPTY_STRING);
432
433
        removeButton = toolkit.createButton(composite,
434
                MTJUIMessages.JADPushRegistryEditorPage_remove_btn_label,
435
                SWT.PUSH);
436
        removeButton.setEnabled(false);
437
        removeButton.addSelectionListener(new SelectionAdapter() {
438
            @Override
439
            public void widgetSelected(SelectionEvent se) {
440
                removeSelectedItems();
441
            }
442
        });
443
    }
444
445
    /**
446
     * Create the table viewer for this editor.
447
     * 
448
     * @param toolkit The Eclipse form's toolkit
449
     * @param parent
450
     */
451
    private void createTableViewer(FormToolkit toolkit, Composite parent) {
452
        String[] columns = new String[] {
453
                MTJUIMessages.JADPushRegistryEditorPage_connection_column,
454
                MTJUIMessages.JADPushRegistryEditorPage_class_column,
455
                MTJUIMessages.JADPushRegistryEditorPage_sender_column, };
456
457
        // Setup the table
458
        int styles = SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER
459
                | SWT.FULL_SELECTION;
460
        Table table = toolkit.createTable(parent, styles);
461
        table.setHeaderVisible(true);
462
        table.setLinesVisible(true);
463
        table.setLayoutData(new GridData(GridData.FILL_BOTH));
464
        table.addSelectionListener(new SelectionAdapter() {
465
            @Override
466
            public void widgetSelected(SelectionEvent e) {
467
                TableItem selected = (TableItem) e.item;
468
                removeButton.setEnabled(selected.getParent()
469
                        .getSelectionCount() > 0);
470
            }
471
        });
472
        tableViewer = new TableViewer(table);
473
474
        // Set the table layout on the table
475
        TableLayout layout = new TableLayout();
476
477
        int width = 100 / columns.length;
478
        for (String element : columns) {
479
            TableColumn column = new TableColumn(table, SWT.NONE);
480
            column.setText(element);
481
            layout.addColumnData(new ColumnWeightData(width));
482
        }
483
        table.setLayout(layout);
484
485
        // Set the content providers
486
        tableViewer.setContentProvider(new TableContentProvider());
487
        tableViewer.setLabelProvider(new TableLabelProvider());
488
489
        // Wire up the cell modification handling
490
        tableViewer.setCellModifier(new CellModifier());
491
        tableViewer.setColumnProperties(PROPERTIES);
492
        tableViewer.setCellEditors(new CellEditor[] {
493
                new TextCellEditor(table), new MidletCellEditor(table),
494
                new TextCellEditor(table), });
495
496
        // Get some data into the viewer
497
        tableViewer.setInput(getEditorInput());
498
        tableViewer.refresh();
499
    }
500
501
    /**
502
     * Load the Push Registry Entries from the current preference store.
503
     */
504
    private void loadPushRegistryEntries() {
505
        pushRegEntries.clear();
506
        IPreferenceStore store = getPreferenceStore();
507
508
        // This is sort of ugly, but IPreferenceStore does not
509
        // allow getting the complete list of preference keys
510
        for (int i = 1; i < 1000; i++) {
511
            String propName = PUSH_REGISTRY_PREFIX + i;
512
513
            if (store.contains(propName)) {
514
                String propValue = store.getString(propName);
515
                pushRegEntries.add(new PushRegEntry(propValue));
516
            } else {
517
                break;
518
            }
519
        }
520
521
        storedEntriesCount = pushRegEntries.size();
522
        if (tableViewer != null) {
523
            tableViewer.refresh();
524
        }
525
    }
526
527
    /**
528
     * Remove the items currently selected within the table.
529
     */
530
    private void removeSelectedItems() {
531
        int[] indices = tableViewer.getTable().getSelectionIndices();
532
533
        for (int i = indices.length; i > 0; i--) {
534
            int index = indices[i - 1];
535
            pushRegEntries.remove(index);
536
        }
537
538
        setDirty(true);
539
        tableViewer.refresh();
540
    }
541
542
    /* (non-Javadoc)
543
     * @see org.eclipse.mtj.ui.editors.jad.AbstractJADEditorPage#createFormContent(org.eclipse.ui.forms.IManagedForm)
544
     */
545
    @Override
546
    protected void createFormContent(IManagedForm managedForm) {
547
        super.createFormContent(managedForm);
548
549
        FormToolkit toolkit = managedForm.getToolkit();
550
551
        // Set the top-level layout
552
        Composite parent = managedForm.getForm().getBody();
553
        parent.setLayoutData(new GridData(GridData.FILL_BOTH));
554
        parent.setLayout(new GridLayout(2, false));
555
        new Label(parent, SWT.NONE);
556
        new Label(parent, SWT.NONE);
557
558
        createTableViewer(toolkit, parent);
559
        createButtons(toolkit, parent);
560
561
        PlatformUI.getWorkbench().getHelpSystem().setHelp(parent,
562
                "eclipseme.ui.help_JADPushRegistryEditorPage"); //$NON-NLS-1$
563
    }
564
565
    /* (non-Javadoc)
566
     * @see org.eclipse.mtj.ui.editors.jad.AbstractJADEditorPage#getHelpResource()
567
     */
568
    @Override
569
    protected String getHelpResource() {
570
        return "/org.eclipse.mtj.doc.user/html/reference/editors/jad_editor/pushregistry.html"; //$NON-NLS-1$
571
    }
572
573
    /**
574
     * @return
575
     */
576
    protected String getSectionDescription() {
577
        return MTJUIMessages.JADPushRegistryEditorPage_sectionDescription;
578
    }
579
580
    /**
581
     * @return
582
     */
583
    protected String getSectionTitle() {
584
        return MTJUIMessages.JADPushRegistryEditorPage_sectionTitle;
585
    }
586
587
    /* (non-Javadoc)
588
     * @see org.eclipse.ui.part.EditorPart#setInput(org.eclipse.ui.IEditorInput)
589
     */
590
    @Override
591
    protected void setInput(IEditorInput input) {
592
        super.setInput(input);
593
        if (tableViewer != null) {
594
            tableViewer.setInput(input);
595
        }
596
597
        setDirty(false);
598
        loadPushRegistryEntries();
599
    }
600
}
(-)src/org/eclipse/mtj/internal/ui/editors/jad/form/pages/OverviewEditorPage.java (-14 / +17 lines)
Lines 1-5 Link Here
1
/**
1
/**
2
 * Copyright (c) 2008 Motorola.
2
 * Copyright (c) 2008,2009 Motorola and others.
3
 * 
3
 * 
4
 * All rights reserved. This program and the accompanying materials
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
5
 * are made available under the terms of the Eclipse Public License v1.0
Lines 7-19 Link Here
7
 * http://www.eclipse.org/legal/epl-v10.html
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
8
 * 
9
 * Contributors:
9
 * Contributors:
10
 *     Diego Sandin (Motorola) - Initial version
10
 *     Diego Sandin (Motorola)  - Initial version
11
 *     Diego Sandin (Motorola) - Added runtime section
11
 *     Diego Sandin (Motorola)  - Added runtime section
12
 *     Feng Wang (Sybase)      - Modify runtime section, replace Device Selector with
12
 *     Feng Wang (Sybase)       - Modify runtime section, replace Device Selector with
13
 *                               Configuration Manager, for Multi-configs support.
13
 *                                Configuration Manager, for Multi-configs support.
14
 *     Diego Sandin (Motorola) - Use Eclipse Message Bundles [Bug 255874]
14
 *     Diego Sandin (Motorola)  - Use Eclipse Message Bundles [Bug 255874]
15
 *     Fernando Rocha(Motorola)- Add validation to JAR URL.
15
 *     Fernando Rocha(Motorola) - Add validation to JAR URL.
16
 *     Fernando Rocha(Motorola)- Problem marker for the description file.
16
 *     Fernando Rocha(Motorola) - Problem marker for the description file.
17
 *     Jon Dearden (Research In Motion) - Move fields from JADOTAPropertiesEditorPage 
18
 *                                        and JADPushRegistryEditorPage onto 
19
 *                                        JADOptionalPropertiesEditorPage [Bug 284452]
17
 */
20
 */
18
package org.eclipse.mtj.internal.ui.editors.jad.form.pages;
21
package org.eclipse.mtj.internal.ui.editors.jad.form.pages;
19
22
Lines 360-366 Link Here
360
363
361
        Section section = createStaticSection(toolkit, parent,
364
        Section section = createStaticSection(toolkit, parent,
362
                MTJUIMessages.OverviewEditorPage_debugging_section_title);
365
                MTJUIMessages.OverviewEditorPage_debugging_section_title);
363
        Composite container = createStaticSectionClient(toolkit, section);
366
        Composite container = createStaticSectionClient(toolkit, section, null);
364
367
365
        FormText text = createClient(container,
368
        FormText text = createClient(container,
366
                MTJUIMessages.overviewPage_launchsection_debuglinks, toolkit,
369
                MTJUIMessages.overviewPage_launchsection_debuglinks, toolkit,
Lines 389-395 Link Here
389
392
390
        Section section = createStaticSection(toolkit, parent,
393
        Section section = createStaticSection(toolkit, parent,
391
                MTJUIMessages.OverviewEditorPage_exporting_section_title);
394
                MTJUIMessages.OverviewEditorPage_exporting_section_title);
392
        Composite container = createStaticSectionClient(toolkit, section);
395
        Composite container = createStaticSectionClient(toolkit, section, null);
393
396
394
        FormText text = createClient(container,
397
        FormText text = createClient(container,
395
                MTJUIMessages.overviewPage_exporting, toolkit, this);
398
                MTJUIMessages.overviewPage_exporting, toolkit, this);
Lines 414-420 Link Here
414
                MTJUIMessages.overviewPage_requiredsection_title,
417
                MTJUIMessages.overviewPage_requiredsection_title,
415
                MTJUIMessages.overviewPage_requiredsection_description);
418
                MTJUIMessages.overviewPage_requiredsection_description);
416
419
417
        Composite sectionClient = createStaticSectionClient(toolkit, section);
420
        Composite sectionClient = createStaticSectionClient(toolkit, section, null);
418
        sectionClient.setLayout(FormLayoutFactory
421
        sectionClient.setLayout(FormLayoutFactory
419
                .createSectionClientTableWrapLayout(false, 1));
422
                .createSectionClientTableWrapLayout(false, 1));
420
423
Lines 436-442 Link Here
436
439
437
        Section section = createStaticSection(toolkit, parent,
440
        Section section = createStaticSection(toolkit, parent,
438
                MTJUIMessages.OverviewEditorPage_packaging_section_title);
441
                MTJUIMessages.OverviewEditorPage_packaging_section_title);
439
        Composite container = createStaticSectionClient(toolkit, section);
442
        Composite container = createStaticSectionClient(toolkit, section, null);
440
443
441
        FormText text = createClient(container,
444
        FormText text = createClient(container,
442
                MTJUIMessages.overviewPage_deploying, toolkit, this);
445
                MTJUIMessages.overviewPage_deploying, toolkit, this);
Lines 462-468 Link Here
462
        // Running links
465
        // Running links
463
        Section section = createStaticSection(toolkit, parent,
466
        Section section = createStaticSection(toolkit, parent,
464
                MTJUIMessages.OverviewEditorPage_running_section_title);
467
                MTJUIMessages.OverviewEditorPage_running_section_title);
465
        Composite container = createStaticSectionClient(toolkit, section);
468
        Composite container = createStaticSectionClient(toolkit, section, null);
466
469
467
        FormText text = createClient(container,
470
        FormText text = createClient(container,
468
                MTJUIMessages.overviewPage_launchsection_runlinks, toolkit,
471
                MTJUIMessages.overviewPage_launchsection_runlinks, toolkit,
Lines 491-497 Link Here
491
                MTJUIMessages.overviewPage_runtimesection_title,
494
                MTJUIMessages.overviewPage_runtimesection_title,
492
                MTJUIMessages.overviewPage_runtimesection_description);
495
                MTJUIMessages.overviewPage_runtimesection_description);
493
496
494
        Composite sectionClient = createStaticSectionClient(toolkit, section);
497
        Composite sectionClient = createStaticSectionClient(toolkit, section, null);
495
        sectionClient.setLayout(FormLayoutFactory
498
        sectionClient.setLayout(FormLayoutFactory
496
                .createSectionClientGridLayout(true, 1));
499
                .createSectionClientGridLayout(true, 1));
497
500
(-)src/org/eclipse/mtj/ui/editors/jad/AbstractJADEditorPage.java (-3 / +10 lines)
Lines 1-5 Link Here
1
/**
1
/**
2
 * Copyright (c) 2003,2008 Craig Setera and others.
2
 * Copyright (c) 2003,2009 Craig Setera and others.
3
 * 
3
 * 
4
 * All rights reserved. This program and the accompanying materials
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
5
 * are made available under the terms of the Eclipse Public License v1.0
Lines 12-18 Link Here
12
 *                                standards
12
 *                                standards
13
 *     Gang Ma      (Sybase)	- Refactoring the page to support extensibility
13
 *     Gang Ma      (Sybase)	- Refactoring the page to support extensibility
14
 *     Diego Sandin (Motorola)  - Use Eclipse Message Bundles [Bug 255874]
14
 *     Diego Sandin (Motorola)  - Use Eclipse Message Bundles [Bug 255874]
15
 *     David Marques (Motorola) - Removing hyperlinks from message manager.                       
15
 *     David Marques (Motorola) - Removing hyperlinks from message manager. 
16
 *     Jon Dearden (Research In Motion) - Added support for applying 
17
 *                                        DescriptorPropertyDescription(s) to specific
18
 *                                        page sections [Bug 284452]                           
16
 */
19
 */
17
package org.eclipse.mtj.ui.editors.jad;
20
package org.eclipse.mtj.ui.editors.jad;
18
21
Lines 405-417 Link Here
405
    /**
408
    /**
406
     * @param toolkit
409
     * @param toolkit
407
     * @param parent
410
     * @param parent
411
     * @param sectionId A String identifer for the section. Used for pages that
412
     *            contain DescriptorPropertyDescription in different sections,
413
     *            otherwise may be null.
408
     * @return
414
     * @return
409
     */
415
     */
410
    protected Composite createStaticSectionClient(FormToolkit toolkit,
416
    protected Composite createStaticSectionClient(FormToolkit toolkit,
411
            Composite parent) {
417
            Composite parent, String sectionId) {
412
        Composite container = toolkit.createComposite(parent, SWT.NONE);
418
        Composite container = toolkit.createComposite(parent, SWT.NONE);
413
        container.setLayout(FormLayoutFactory
419
        container.setLayout(FormLayoutFactory
414
                .createSectionClientTableWrapLayout(false, 1));
420
                .createSectionClientTableWrapLayout(false, 1));
421
        container.setData(sectionId);
415
        TableWrapData data = new TableWrapData(TableWrapData.FILL_GRAB);
422
        TableWrapData data = new TableWrapData(TableWrapData.FILL_GRAB);
416
        container.setLayoutData(data);
423
        container.setLayoutData(data);
417
        return container;
424
        return container;
(-)src/org/eclipse/mtj/ui/editors/jad/JADPropertiesEditorPage.java (-10 / +13 lines)
Lines 1-5 Link Here
1
/**
1
/**
2
 * Copyright (c) 2003,2008 Craig Setera and others.
2
 * Copyright (c) 2003,2009 Craig Setera and others.
3
 * 
3
 * 
4
 * All rights reserved. This program and the accompanying materials
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
5
 * are made available under the terms of the Eclipse Public License v1.0
Lines 7-16 Link Here
7
 * http://www.eclipse.org/legal/epl-v10.html
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
8
 * 
9
 * Contributors:
9
 * Contributors:
10
 *     Craig Setera (EclipseME) - Initial implementation
10
 *     Craig Setera (EclipseME)         - Initial implementation
11
 *     Diego Sandin (Motorola)  - Refactoring package name to follow eclipse
11
 *     Diego Sandin (Motorola)          - Refactoring package name to follow eclipse
12
 *                                standards
12
 *                                        standards
13
 *     Gang Ma      (Sybase)	- Refactoring the page to support extensibility
13
 *     Gang Ma (Sybase)                 - Refactoring the page to support extensibility
14
 *     Jon Dearden (Research In Motion) - Added support for applying 
15
 *                                        DescriptorPropertyDescription(s) to specific
16
 *                                        page sections [Bug 284452]     
14
 */
17
 */
15
package org.eclipse.mtj.ui.editors.jad;
18
package org.eclipse.mtj.ui.editors.jad;
16
19
Lines 181-187 Link Here
181
     * @param description
184
     * @param description
182
     * @return
185
     * @return
183
     */
186
     */
184
    private FieldEditor createComboFieldEditor(FormToolkit toolkit,
187
    protected FieldEditor createComboFieldEditor(FormToolkit toolkit,
185
            Composite composite, DescriptorPropertyDescription description) {
188
            Composite composite, DescriptorPropertyDescription description) {
186
189
187
        if (comboFieldEditorClass == null) {
190
        if (comboFieldEditorClass == null) {
Lines 219-225 Link Here
219
     * @param descriptor
222
     * @param descriptor
220
     * @return
223
     * @return
221
     */
224
     */
222
    private IntegerFieldEditor createIntegerFieldEditor(FormToolkit toolkit,
225
    protected IntegerFieldEditor createIntegerFieldEditor(FormToolkit toolkit,
223
            Composite parent, DescriptorPropertyDescription descriptor) {
226
            Composite parent, DescriptorPropertyDescription descriptor) {
224
227
225
        IntegerFieldEditor integerEditor = new IntegerFieldEditor(descriptor
228
        IntegerFieldEditor integerEditor = new IntegerFieldEditor(descriptor
Lines 237-243 Link Here
237
     * @param descriptor
240
     * @param descriptor
238
     * @return
241
     * @return
239
     */
242
     */
240
    private ExtendedStringFieldEditor createStringFieldEditor(FormToolkit toolkit,
243
    protected ExtendedStringFieldEditor createStringFieldEditor(FormToolkit toolkit,
241
            Composite parent, DescriptorPropertyDescription descriptor) {
244
            Composite parent, DescriptorPropertyDescription descriptor) {
242
        ExtendedStringFieldEditor editor = new ExtendedStringFieldEditor(descriptor
245
        ExtendedStringFieldEditor editor = new ExtendedStringFieldEditor(descriptor
243
                .getPropertyName(), descriptor.getDisplayName(), parent);
246
                .getPropertyName(), descriptor.getDisplayName(), parent);
Lines 271-277 Link Here
271
    /**
274
    /**
272
     * Update the application descriptor the components are handling
275
     * Update the application descriptor the components are handling
273
     */
276
     */
274
    private void updateEditComponents() {
277
    protected void updateEditComponents() {
275
        if (fieldEditors != null) {
278
        if (fieldEditors != null) {
276
            IPreferenceStore store = (IPreferenceStore) getPreferenceStore();
279
            IPreferenceStore store = (IPreferenceStore) getPreferenceStore();
277
            for (FieldEditor fieldEditor : fieldEditors) {
280
            for (FieldEditor fieldEditor : fieldEditors) {
Lines 310-316 Link Here
310
        Section section = createStaticBasicSection(toolkit, center,
313
        Section section = createStaticBasicSection(toolkit, center,
311
                getSectionTitle(), getSectionDescription());
314
                getSectionTitle(), getSectionDescription());
312
315
313
        Composite sectionClient = createStaticSectionClient(toolkit, section);
316
        Composite sectionClient = createStaticSectionClient(toolkit, section, null);
314
        sectionClient.setLayout(FormLayoutFactory
317
        sectionClient.setLayout(FormLayoutFactory
315
                .createSectionClientTableWrapLayout(false, 1));
318
                .createSectionClientTableWrapLayout(false, 1));
316
319

Return to bug 284452