### Eclipse Workspace Patch 1.0
#P org.eclipse.mtj.core
Index: src/org/eclipse/mtj/internal/core/project/midp/JADAttributesRegistry.java
===================================================================
--- src/org/eclipse/mtj/internal/core/project/midp/JADAttributesRegistry.java (revision 1401)
+++ src/org/eclipse/mtj/internal/core/project/midp/JADAttributesRegistry.java (working copy)
@@ -129,13 +129,21 @@
/**
* @param pageID the target page's ID
- * @param device the device user used
* @return the vendor specific JAD descriptors
*/
public static DescriptorPropertyDescription[] getJADAttrDescriptorsByPage(
String pageID) {
JADAttributesConfigElement[] relatedElements = getRelatedAttrElements(pageID);
DescriptorPropertyDescription[] resultAttributes = getDescriptorsFromElements(relatedElements);
+ for (DescriptorPropertyDescription descriptorPropertyDescription : resultAttributes) {
+ if (pageID.contains(".")) { //$NON-NLS-1$
+ String[] ids = pageID.split("\\."); //$NON-NLS-1$
+ descriptorPropertyDescription.setPageId(ids[0]);
+ descriptorPropertyDescription.setSectionId(ids[1]);
+ } else {
+ descriptorPropertyDescription.setPageId(pageID);
+ }
+ }
return resultAttributes;
}
Index: src/org/eclipse/mtj/core/project/midp/DescriptorPropertyDescription.java
===================================================================
--- src/org/eclipse/mtj/core/project/midp/DescriptorPropertyDescription.java (revision 1401)
+++ src/org/eclipse/mtj/core/project/midp/DescriptorPropertyDescription.java (working copy)
@@ -7,9 +7,12 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Craig Setera (EclipseME) - Initial implementation
- * Diego Sandin (Motorola) - Refactoring package name to follow eclipse
- * standards
+ * Craig Setera (EclipseME) - Initial implementation
+ * Diego Sandin (Motorola) - Refactoring package name to follow eclipse
+ * standards
+ * Jon Dearden (Research In Motion) - Added support for applying
+ * DescriptorPropertyDescription(s) to specific
+ * page sections [Bug 284452]
*/
package org.eclipse.mtj.core.project.midp;
@@ -42,6 +45,12 @@
/** The name of the underlying property */
private String propertyName;
+
+ /** The JAD editor page identifier for which this property is associated */
+ private String pageId;
+
+ /** The JAD editor page section identifier for which this property is associated */
+ private String sectionId;
/**
* Creates a new instance of DescriptorPropertyDescription.
@@ -100,6 +109,24 @@
public String getPropertyName() {
return propertyName;
}
+
+ /**
+ * Returns the JAD editor page identifier for which this property is associated
+ *
+ * @return the page identifier.
+ */
+ public String getPageId() {
+ return pageId;
+ }
+
+ /**
+ * Returns the JAD editor page section identifier for which this property is associated
+ *
+ * @return the page section identifier.
+ */
+ public String getSectionId() {
+ return sectionId;
+ }
/**
* Sets the data type for this property.
@@ -127,12 +154,20 @@
}
/**
- * Sets the data type for this property.
+ * Sets the page ID for this property.
*
- * @param string the property name. This is case-sensitive and must not be
- * null
or an empty String ""
.
+ * @param string the page ID.
*/
- public void setPropertyName(String string) {
- propertyName = string;
+ public void setPageId(String string) {
+ pageId = string;
+ }
+
+ /**
+ * Sets the page section ID for this property.
+ *
+ * @param string the page section ID.
+ */
+ public void setSectionId(String string) {
+ sectionId = string;
}
}
#P org.eclipse.mtj.ui
Index: plugin.xml
===================================================================
--- plugin.xml (revision 1401)
+++ plugin.xml (working copy)
@@ -672,12 +672,6 @@
class="org.eclipse.mtj.internal.ui.editors.jad.form.pages.JADOptionalPropertiesEditorPage"
priority="30"/>
-
-
@@ -692,7 +686,7 @@
-
+
@@ -700,7 +694,7 @@
-
+
Index: src/org/eclipse/mtj/internal/ui/editors/jad/form/pages/JADOptionalPropertiesEditorPage.java
===================================================================
--- src/org/eclipse/mtj/internal/ui/editors/jad/form/pages/JADOptionalPropertiesEditorPage.java (revision 1401)
+++ src/org/eclipse/mtj/internal/ui/editors/jad/form/pages/JADOptionalPropertiesEditorPage.java (working copy)
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2003,2008 Craig Setera and others.
+ * Copyright (c) 2003,2009 Craig Setera and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -11,15 +11,72 @@
* Diego Sandin (Motorola) - Refactoring package name to follow eclipse
* standards
* Gang Ma (Sybase) - Refactoring the page to add expansibilities
- * Diego Sandin (Motorola) - Use Eclipse Message Bundles [Bug 255874]
+ * Diego Sandin (Motorola) - Use Eclipse Message Bundles [Bug 255874]
+ * Jon Dearden (Research In Motion) - Move fields from JADOTAPropertiesEditorPage
+ * and JADPushRegistryEditorPage onto this page
+ * [Bug 284452]
*/
package org.eclipse.mtj.internal.ui.editors.jad.form.pages;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.preference.FieldEditor;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.DialogCellEditor;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.mtj.core.project.midp.DescriptorPropertyDescription;
+import org.eclipse.mtj.internal.core.project.midp.JADAttributesRegistry;
+import org.eclipse.mtj.internal.core.util.Utils;
+import org.eclipse.mtj.internal.core.util.log.MTJLogger;
import org.eclipse.mtj.internal.ui.MTJUIMessages;
+import org.eclipse.mtj.internal.ui.MTJUIPluginImages;
+import org.eclipse.mtj.internal.ui.editors.FormLayoutFactory;
import org.eclipse.mtj.internal.ui.editors.jad.form.JADFormEditor;
+import org.eclipse.mtj.internal.ui.util.MidletSelectionDialogCreator;
import org.eclipse.mtj.ui.editors.jad.JADPropertiesEditorPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.SelectionDialog;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.Section;
/**
* JAD editor page for handling the optional properties.
@@ -27,7 +84,7 @@
* @author Craig Setera
*/
public class JADOptionalPropertiesEditorPage extends JADPropertiesEditorPage {
-
+
/**
* The unique page identifier.
*/
@@ -38,6 +95,7 @@
*/
public JADOptionalPropertiesEditorPage() {
super(ID, MTJUIMessages.JADOptionalPropertiesEditorPage_title);
+ pushRegEntries = new ArrayList();
}
/**
@@ -47,6 +105,7 @@
*/
public JADOptionalPropertiesEditorPage(JADFormEditor editor) {
super(editor, ID, MTJUIMessages.JADOptionalPropertiesEditorPage_title);
+ pushRegEntries = new ArrayList();
}
/* (non-Javadoc)
@@ -56,7 +115,7 @@
public String getTitle() {
return MTJUIMessages.JADOptionalPropertiesEditorPage_title;
}
-
+
/* (non-Javadoc)
* @see org.eclipse.mtj.ui.editors.jad.JADPropertiesEditorPage#addContextHelp(org.eclipse.swt.widgets.Composite)
*/
@@ -79,7 +138,7 @@
*/
@Override
protected String getSectionDescription() {
- return MTJUIMessages.JADOptionalPropertiesEditorPage_description;
+ return null;
}
/* (non-Javadoc)
@@ -87,6 +146,632 @@
*/
@Override
protected String getSectionTitle() {
- return MTJUIMessages.JADOptionalPropertiesEditorPage_SectionTitle;
+ return null;
+ }
+
+ @Override
+ protected void createFormContent( IManagedForm managedForm ) {
+ final ScrolledForm form = managedForm.getForm();
+ FormToolkit toolkit = managedForm.getToolkit();
+ form.setText( getTitle() );
+ toolkit.decorateFormHeading( form.getForm() );
+ createErrorMessageHandler( managedForm );
+ /*
+ * launch the help system UI, displaying the documentation identified by
+ * the href parameter.
+ */
+ final String href = getHelpResource();
+ if (href != null) {
+ IToolBarManager manager = form.getToolBarManager();
+ Action helpAction = new Action("help") { //$NON-NLS-1$
+ @Override
+ public void run() {
+ PlatformUI.getWorkbench().getHelpSystem()
+ .displayHelpResource(href);
+ }
+ };
+ helpAction.setImageDescriptor(MTJUIPluginImages.DESC_LINKTOHELP);
+ manager.add(helpAction);
+ }
+ form.updateToolBar();
+ createSectionContent( managedForm, managedForm.getForm().getBody(), this );
+ }
+
+ @Override
+ protected void createSectionContent(IManagedForm managedForm,
+ Composite composite, IPropertyChangeListener propertyChangeListener) {
+
+ FormToolkit toolkit = managedForm.getToolkit();
+ Composite body = managedForm.getForm().getBody();
+ body.setLayoutData(new GridData(GridData.FILL_BOTH));
+ body.setLayout(new GridLayout(2, true));
+
+ new Label(body, SWT.NONE);
+ new Label(body, SWT.NONE);
+
+ Section optionalSection = createStaticBasicSection(toolkit, body,
+ MTJUIMessages.JADOptionalPropertiesEditorPage_SectionTitle,
+ MTJUIMessages.JADOptionalPropertiesEditorPage_description);
+ Composite optionalSectionClient = createStaticSectionClient(toolkit,
+ optionalSection, "optional"); //$NON-NLS-1$
+ optionalSection.setLayoutData(new GridData(
+ GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL));
+ optionalSection.setLayout(new GridLayout());
+
+ Section otaSection = createStaticBasicSection(toolkit, body,
+ MTJUIMessages.JADOTAPropertiesEditorPage_SectionTitle,
+ MTJUIMessages.JADOTAPropertiesEditorPage_SectionDescription);
+ Composite otaSectionClient = createStaticSectionClient(toolkit,
+ otaSection, "ota"); //$NON-NLS-1$
+ otaSection.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING
+ | GridData.FILL_HORIZONTAL));
+ otaSection.setLayout(new GridLayout());
+
+ Composite[] sectionClients = new Composite[] { optionalSectionClient, otaSectionClient };
+ createSectionsContent(managedForm, sectionClients, this);
+
+ optionalSection.setClient(optionalSectionClient);
+ otaSection.setClient(otaSectionClient);
+
+ new Label(body, SWT.NONE);
+ new Label(body, SWT.NONE);
+
+ Section pushSection = toolkit.createSection(body, Section.DESCRIPTION
+ | ExpandableComposite.TITLE_BAR);
+ pushSection.setText(MTJUIMessages.JADPushRegistryEditorPage_sectionTitle);
+ pushSection.setDescription(MTJUIMessages.JADPushRegistryEditorPage_sectionDescription);
+
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalSpan = 2;
+ pushSection.setLayoutData(gd);
+ pushSection.setLayout(new GridLayout());
+
+ Composite pushSectionClient = toolkit.createComposite(pushSection, SWT.NONE);
+ pushSectionClient.setLayout(new GridLayout(2, false));
+ pushSection.setClient(pushSectionClient);
+
+ createTableViewer(toolkit, pushSectionClient);
+ createButtons(toolkit, pushSectionClient);
+ addContextHelp(composite);
+ }
+
+ /**
+ * This method creates all sections on the page at one time
+ * so that the fieldEditors array is populated only once.
+ */
+ private void createSectionsContent(IManagedForm managedForm,
+ Composite[] sections, IPropertyChangeListener propertyChangeListener) {
+
+ for (int i = 0; i < sections.length; i++) {
+ sections[i].setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2));
+ new Label(sections[i], SWT.NONE);
+ new Label(sections[i], SWT.NONE);
+ }
+
+ DescriptorPropertyDescription[] theDescriptors = getDescriptors();
+
+ if (fieldEditors == null) {
+ fieldEditors = new FieldEditor[theDescriptors.length];
+ }
+
+ FormToolkit toolkit = managedForm.getToolkit();
+ Composite sectionComp = null;
+
+ for (int i = 0; i < theDescriptors.length; i++) {
+
+ for (int j = 0; j < sections.length; j++) {
+ if (theDescriptors[i].getSectionId().equals((String) sections[j].getData())) {
+ sectionComp = sections[j];
+ break;
+ }
+ }
+
+ if (sectionComp == null) {
+ throw new Error("sectionComp should not be null"); //$NON-NLS-1$
+ }
+
+ switch (theDescriptors[i].getDataType()) {
+ case DescriptorPropertyDescription.DATATYPE_INT:
+ fieldEditors[i] = createIntegerFieldEditor(toolkit,
+ sectionComp, theDescriptors[i]);
+ break;
+ case DescriptorPropertyDescription.DATATYPE_LIST:
+ fieldEditors[i] = createComboFieldEditor(toolkit, sectionComp,
+ theDescriptors[i]);
+ break;
+ case DescriptorPropertyDescription.DATATYPE_URL:
+ case DescriptorPropertyDescription.DATATYPE_STRING:
+ default:
+ fieldEditors[i] = createStringFieldEditor(toolkit, sectionComp,
+ theDescriptors[i]);
+ break;
+ }
+
+ Label label = fieldEditors[i].getLabelControl(sectionComp);
+ toolkit.adapt(label, false, false);
+
+ // Listen for property change events on the editor
+ fieldEditors[i].setPropertyChangeListener(propertyChangeListener);
+ }
+
+ for (int i = 0; i < sections.length; i++) {
+ // Adapt the Combo instances...
+ Control[] children = sections[i].getChildren();
+ for (Control control : children) {
+ if (control instanceof Combo) {
+ toolkit.adapt(control, false, false);
+ }
+ }
+ }
+
+ updateEditComponents();
+ }
+
+ @Override
+ protected DescriptorPropertyDescription[] doGetDescriptors() {
+ DescriptorPropertyDescription[] optionalDescriptors;
+ optionalDescriptors = JADAttributesRegistry
+ .getJADAttrDescriptorsByPage(getId() + ".optional"); //$NON-NLS-1$
+ DescriptorPropertyDescription[] otaDescriptors;
+ otaDescriptors = JADAttributesRegistry
+ .getJADAttrDescriptorsByPage(getId() + ".ota"); //$NON-NLS-1$
+ DescriptorPropertyDescription[] result
+ = new DescriptorPropertyDescription[optionalDescriptors.length + otaDescriptors.length];
+ System.arraycopy(optionalDescriptors, 0, result, 0,
+ optionalDescriptors.length);
+ System.arraycopy(otaDescriptors, 0, result, optionalDescriptors.length,
+ otaDescriptors.length);
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.mtj.ui.editors.jad.AbstractJADEditorPage#isManagingProperty(java.lang.String)
+ */
+ @Override
+ public boolean isManagingProperty(String property) {
+ boolean manages = property.startsWith(PUSH_REGISTRY_PREFIX);
+ if (manages) {
+ String value = property.substring(PUSH_REGISTRY_PREFIX.length());
+ try {
+ Integer.parseInt(value);
+ } catch (NumberFormatException e) {
+ manages = false;
+ }
+ }
+
+ return manages;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.editor.FormPage#setFocus()
+ */
+ @Override
+ public void setFocus() {
+ tableViewer.getTable().setFocus();
+ }
+
+ /**
+ * Add a new item to the table.
+ */
+ private void addItem() {
+ PushRegEntry midletDefinition = new PushRegEntry(
+ MTJUIMessages.JADPushRegistryEditorPage_new_pushReg,
+ Utils.EMPTY_STRING, "*"); //$NON-NLS-1$
+ pushRegEntries.add(midletDefinition);
+ tableViewer.refresh();
+ setDirty(true);
+ }
+
+ /**
+ * Create the add and remove buttons to the composite.
+ *
+ * @param toolkit the Eclipse Form's toolkit
+ * @param parent
+ */
+ private void createButtons(FormToolkit toolkit, Composite parent) {
+ Composite composite = toolkit.createComposite(parent);
+ FillLayout layout = new FillLayout();
+ layout.type = SWT.VERTICAL;
+ composite.setLayout(layout);
+
+ addButton = toolkit
+ .createButton(composite,
+ MTJUIMessages.JADPushRegistryEditorPage_add_btn_label,
+ SWT.PUSH);
+ addButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent se) {
+ addItem();
+ }
+ });
+
+ toolkit.createLabel(composite, Utils.EMPTY_STRING);
+
+ removeButton = toolkit.createButton(composite,
+ MTJUIMessages.JADPushRegistryEditorPage_remove_btn_label,
+ SWT.PUSH);
+ removeButton.setEnabled(false);
+ removeButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent se) {
+ removeSelectedItems();
+ }
+ });
+ }
+
+ /**
+ * Create the table viewer for this editor.
+ *
+ * @param toolkit The Eclipse form's toolkit
+ * @param parent
+ */
+ private void createTableViewer(FormToolkit toolkit, Composite parent) {
+
+ String[] columns = new String[] {
+ MTJUIMessages.JADPushRegistryEditorPage_connection_column,
+ MTJUIMessages.JADPushRegistryEditorPage_class_column,
+ MTJUIMessages.JADPushRegistryEditorPage_sender_column, };
+
+ // Setup the table
+ int styles = SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER
+ | SWT.FULL_SELECTION;
+ Table table = toolkit.createTable(parent, styles);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ table.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ table.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ TableItem selected = (TableItem) e.item;
+ removeButton.setEnabled(selected.getParent()
+ .getSelectionCount() > 0);
+ }
+ });
+ tableViewer = new TableViewer(table);
+
+ // Set the table layout on the table
+ TableLayout layout = new TableLayout();
+
+ int width = 100 / columns.length;
+ for (String element : columns) {
+ TableColumn column = new TableColumn(table, SWT.NONE);
+ column.setText(element);
+ layout.addColumnData(new ColumnWeightData(width));
+ }
+ table.setLayout(layout);
+
+ // Set the content providers
+ tableViewer.setContentProvider(new TableContentProvider());
+ tableViewer.setLabelProvider(new TableLabelProvider());
+
+ // Wire up the cell modification handling
+ tableViewer.setCellModifier(new CellModifier());
+ tableViewer.setColumnProperties(PROPERTIES);
+ tableViewer.setCellEditors(new CellEditor[] {
+ new TextCellEditor(table), new MidletCellEditor(table),
+ new TextCellEditor(table), });
+
+ // Get some data into the viewer
+ tableViewer.setInput(getEditorInput());
+ tableViewer.refresh();
+ }
+
+ /**
+ * Load the Push Registry Entries from the current preference store.
+ */
+ private void loadPushRegistryEntries() {
+ pushRegEntries.clear();
+ IPreferenceStore store = getPreferenceStore();
+
+ // This is sort of ugly, but IPreferenceStore does not
+ // allow getting the complete list of preference keys
+ for (int i = 1; i < 1000; i++) {
+ String propName = PUSH_REGISTRY_PREFIX + i;
+
+ if (store.contains(propName)) {
+ String propValue = store.getString(propName);
+ pushRegEntries.add(new PushRegEntry(propValue));
+ } else {
+ break;
+ }
+ }
+
+ storedEntriesCount = pushRegEntries.size();
+ if (tableViewer != null) {
+ tableViewer.refresh();
+ }
+ }
+
+ /**
+ * Remove the items currently selected within the table.
+ */
+ private void removeSelectedItems() {
+ int[] indices = tableViewer.getTable().getSelectionIndices();
+
+ for (int i = indices.length; i > 0; i--) {
+ int index = indices[i - 1];
+ pushRegEntries.remove(index);
+ }
+
+ setDirty(true);
+ tableViewer.refresh();
+ }
+
+ /** The prefix of all push registry definition properties */
+ public static final String PUSH_REGISTRY_PREFIX = "MIDlet-Push-"; //$NON-NLS-1$
+
+ private static final String PROP_CLASS = "class"; //$NON-NLS-1$
+
+ // Column property names
+ private static final String PROP_CONNSTR = "connection string"; //$NON-NLS-1$
+
+ private static final String PROP_SENDER = "allowed sender"; //$NON-NLS-1$
+
+ // All of the properties in order
+ private static final String[] PROPERTIES = new String[] { PROP_CONNSTR,
+ PROP_CLASS, PROP_SENDER };
+
+ private static final List PROPERTY_LIST = Arrays.asList(PROPERTIES);
+
+ // Buttons
+ private Button addButton;
+
+ // The collections of entries representing the MIDlets to be registered
+ private ArrayList pushRegEntries;
+ private Button removeButton;
+
+ // The number of MIDlets registered
+ private int storedEntriesCount;
+
+ // The table viewer in use
+ private TableViewer tableViewer;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.EditorPart#setInput(org.eclipse.ui.IEditorInput)
+ */
+ @Override
+ protected void setInput(IEditorInput input) {
+ super.setInput(input);
+ if (tableViewer != null) {
+ tableViewer.setInput(input);
+ }
+
+ setDirty(false);
+ loadPushRegistryEntries();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.editor.FormPage#doSave(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void doSave(IProgressMonitor monitor) {
+ // Save push registry entries
+ monitor.setTaskName(getTitle());
+ IPreferenceStore store = getPreferenceStore();
+ // Add the push registry entries to the store
+ int i;
+ int currentEntriesCount = pushRegEntries.size();
+
+ for (i = 0; i < currentEntriesCount; i++) {
+ PushRegEntry def = pushRegEntries.get(i);
+ store.setValue(PUSH_REGISTRY_PREFIX + (i + 1), def.toString());
+ }
+ // Removing deleted entries
+ for (; i < storedEntriesCount; i++) {
+ store.setToDefault(PUSH_REGISTRY_PREFIX + (i + 1));
+ }
+ storedEntriesCount = currentEntriesCount;
+ // Save other fields
+ super.doSave(monitor);
+ }
+
+ /**
+ * Implementation of the ICellModifier interface.
+ */
+ private class CellModifier implements ICellModifier {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object, java.lang.String)
+ */
+ public boolean canModify(Object element, String property) {
+ // All columns are modifiable
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ICellModifier#getValue(java.lang.Object, java.lang.String)
+ */
+ public Object getValue(Object element, String property) {
+ Object value = null;
+
+ if (element instanceof PushRegEntry) {
+ PushRegEntry entry = (PushRegEntry) element;
+
+ int fieldIndex = getFieldIndex(property);
+ if (fieldIndex != -1) {
+ value = entry.fields[fieldIndex];
+ }
+ }
+
+ return value;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object, java.lang.String, java.lang.Object)
+ */
+ public void modify(Object element, String property, Object value) {
+ if (element instanceof TableItem) {
+ Object data = ((TableItem) element).getData();
+ String newValue = (String) value;
+
+ if (data instanceof PushRegEntry) {
+ int fieldIndex = getFieldIndex(property);
+ PushRegEntry entry = (PushRegEntry) data;
+
+ if (fieldIndex != -1) {
+ updateField(entry, property, fieldIndex, newValue);
+ }
+ }
+ }
+ }
+
+ /**
+ * Return the field index to match the specified property name.
+ *
+ * @param property property name to search for
+ * @return the index that matchs the specified property name.
+ * -1
if the property is not recognized.
+ */
+ private int getFieldIndex(String property) {
+ return PROPERTY_LIST.indexOf(property);
+ }
+
+ /**
+ * Update the specified field as necessary.
+ *
+ * @param entry the Push Registry entry to be updated
+ * @param property property of entry to be updated
+ * @param fieldIndex the index of the field to be updated in entry
+ * @param newValue the new value to be set
+ */
+ private void updateField(PushRegEntry entry, String property,
+ int fieldIndex, String newValue) {
+ if (!entry.fields[fieldIndex].equals(newValue)) {
+ entry.fields[fieldIndex] = newValue;
+ setDirty(true);
+ tableViewer.update(entry, new String[] { property });
+ }
+ }
+ }
+
+ /**
+ * A cell editor implementation that allows for selection of a midlet class.
+ */
+ private class MidletCellEditor extends DialogCellEditor {
+ /** Construct a new cell editor */
+ MidletCellEditor(Composite parent) {
+ super(parent);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control)
+ */
+ @Override
+ protected Object openDialogBox(Control cellEditorWindow) {
+ Object value = null;
+
+ try {
+ IJavaProject javaProject = getJavaProject();
+ SelectionDialog dialog = MidletSelectionDialogCreator
+ .createMidletSelectionDialog(
+ cellEditorWindow.getShell(),
+ getSite().getPage().getWorkbenchWindow(),
+ javaProject,
+ false,
+ MTJUIMessages.JADPushRegistryEditorPage_choose_MIDlet);
+
+ if (dialog.open() == Window.OK) {
+ Object[] results = dialog.getResult();
+ if ((results != null) && (results.length > 0)) {
+ IType type = (IType) results[0];
+ if (type != null) {
+ value = type.getFullyQualifiedName();
+ }
+ }
+ }
+ } catch (JavaModelException e) {
+ MTJLogger.log(IStatus.ERROR, "openDialogBox", e); //$NON-NLS-1$
+ }
+
+ return value;
+ }
+ }
+
+ /**
+ * Implementation of the table's content provider.
+ */
+ private class TableContentProvider implements IStructuredContentProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ public void dispose() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ public Object[] getElements(Object inputElement) {
+ return pushRegEntries.toArray(new Object[pushRegEntries.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ }
+
+ /**
+ * Implementation of the table's label provider.
+ */
+ private static class TableLabelProvider extends LabelProvider implements
+ ITableLabelProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
+ */
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
+ */
+ public String getColumnText(Object element, int columnIndex) {
+ return ((PushRegEntry) element).fields[columnIndex];
+ }
+ }
+
+ static class PushRegEntry {
+ public String[] fields;
+
+ PushRegEntry(String entryString) {
+ fields = new String[3];
+ String[] tokens = entryString.split(","); //$NON-NLS-1$
+
+ for (int i = 0; i < 3; i++) {
+ fields[i] = (i > tokens.length) ? Utils.EMPTY_STRING
+ : tokens[i];
+ }
+ }
+
+ PushRegEntry(String connStr, String className, String allowedSender) {
+ fields = new String[3];
+
+ fields[0] = connStr;
+ fields[1] = className;
+ fields[2] = allowedSender;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ if (fields != null) {
+ for (int i = 0; i < fields.length; i++) {
+ if (i != 0) {
+ sb.append(","); //$NON-NLS-1$
+ }
+ sb.append(fields[i]);
+ }
+ }
+ return sb.toString();
+ }
+
}
}
Index: src/org/eclipse/mtj/internal/ui/editors/jad/form/pages/JADOTAPropertiesEditorPage.java
===================================================================
--- src/org/eclipse/mtj/internal/ui/editors/jad/form/pages/JADOTAPropertiesEditorPage.java (revision 1401)
+++ src/org/eclipse/mtj/internal/ui/editors/jad/form/pages/JADOTAPropertiesEditorPage.java (working copy)
@@ -1,96 +0,0 @@
-/**
- * Copyright (c) 2003,2008 Craig Setera and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Craig Setera (EclipseME) - Initial implementation
- * Diego Sandin (Motorola) - Refactoring package name to follow eclipse
- * standards
- * Gang Ma (Sybase) - Refactoring the page to add expansibilities
- * Diego Sandin (Motorola) - Use Eclipse Message Bundles [Bug 255874]
- */
-package org.eclipse.mtj.internal.ui.editors.jad.form.pages;
-
-import org.eclipse.mtj.internal.ui.MTJUIMessages;
-import org.eclipse.mtj.internal.ui.editors.jad.form.JADFormEditor;
-import org.eclipse.mtj.ui.editors.jad.JADPropertiesEditorPage;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * JAD editor page for handling the over the air properties.
- *
- * @author Craig Setera
- */
-public class JADOTAPropertiesEditorPage extends JADPropertiesEditorPage {
-
- /**
- * The page unique identifier
- */
- public static final String OTA_PAGEID = "ota"; //$NON-NLS-1$
-
- /**
- * A constructor that creates the JAD Over the Air (OTA) EditorPage. The
- * parent editor need to be passed in the initialize
method if
- * this constructor is used.
- */
- public JADOTAPropertiesEditorPage() {
- super(OTA_PAGEID, MTJUIMessages.JADOTAPropertiesEditorPage_title);
- }
-
- /**
- * A constructor that creates the JAD Over the Air (OTA) EditorPage and
- * initializes it with the editor.
- *
- * @param editor the parent editor
- */
- public JADOTAPropertiesEditorPage(JADFormEditor editor) {
- super(editor, OTA_PAGEID,
- MTJUIMessages.JADOTAPropertiesEditorPage_title);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.mtj.ui.editors.jad.AbstractJADEditorPage#getTitle()
- */
- @Override
- public String getTitle() {
- return MTJUIMessages.JADOTAPropertiesEditorPage_title;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.mtj.ui.editors.jad.JADPropertiesEditorPage#addContextHelp(org.eclipse.swt.widgets.Composite)
- */
- @Override
- protected void addContextHelp(Composite c) {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(c,
- "org.eclipse.mtj.ui.help_JADOTAPropertiesEditorPage"); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.mtj.ui.editors.jad.AbstractJADEditorPage#getHelpResource()
- */
- @Override
- protected String getHelpResource() {
- return "/org.eclipse.mtj.doc.user/html/reference/editors/jad_editor/ota.html"; //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.mtj.ui.editors.jad.JADPropertiesEditorPage#getSectionDescription()
- */
- @Override
- protected String getSectionDescription() {
- return MTJUIMessages.JADOTAPropertiesEditorPage_SectionDescription;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.mtj.ui.editors.jad.JADPropertiesEditorPage#getSectionTitle()
- */
- @Override
- protected String getSectionTitle() {
- return MTJUIMessages.JADOTAPropertiesEditorPage_SectionTitle;
- }
-}
Index: src/org/eclipse/mtj/internal/ui/editors/jad/form/pages/JADPushRegistryEditorPage.java
===================================================================
--- src/org/eclipse/mtj/internal/ui/editors/jad/form/pages/JADPushRegistryEditorPage.java (revision 1401)
+++ src/org/eclipse/mtj/internal/ui/editors/jad/form/pages/JADPushRegistryEditorPage.java (working copy)
@@ -1,600 +0,0 @@
-/**
- * Copyright (c) 2008 Motorola.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Hugo Raniere (Motorola) - Initial implementation
- * Gang Ma (Sybase) - Refactoring the page to add expansibilities
- * Diego Sandin (Motorola) - Use Eclipse Message Bundles [Bug 255874]
- */
-package org.eclipse.mtj.internal.ui.editors.jad.form.pages;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.DialogCellEditor;
-import org.eclipse.jface.viewers.ICellModifier;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TextCellEditor;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.window.Window;
-import org.eclipse.mtj.internal.core.util.Utils;
-import org.eclipse.mtj.internal.core.util.log.MTJLogger;
-import org.eclipse.mtj.internal.ui.MTJUIMessages;
-import org.eclipse.mtj.internal.ui.editors.jad.form.JADFormEditor;
-import org.eclipse.mtj.internal.ui.util.MidletSelectionDialogCreator;
-import org.eclipse.mtj.ui.editors.jad.AbstractJADEditorPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.SelectionDialog;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-
-/**
- * A property page editor static registering MIDlets in Push Registry
- *
- * @author Hugo Raniere
- */
-public class JADPushRegistryEditorPage extends AbstractJADEditorPage {
-
- /**
- * Implementation of the ICellModifier interface.
- */
- private class CellModifier implements ICellModifier {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object, java.lang.String)
- */
- public boolean canModify(Object element, String property) {
- // All columns are modifiable
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ICellModifier#getValue(java.lang.Object, java.lang.String)
- */
- public Object getValue(Object element, String property) {
- Object value = null;
-
- if (element instanceof PushRegEntry) {
- PushRegEntry entry = (PushRegEntry) element;
-
- int fieldIndex = getFieldIndex(property);
- if (fieldIndex != -1) {
- value = entry.fields[fieldIndex];
- }
- }
-
- return value;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object, java.lang.String, java.lang.Object)
- */
- public void modify(Object element, String property, Object value) {
- if (element instanceof TableItem) {
- Object data = ((TableItem) element).getData();
- String newValue = (String) value;
-
- if (data instanceof PushRegEntry) {
- int fieldIndex = getFieldIndex(property);
- PushRegEntry entry = (PushRegEntry) data;
-
- if (fieldIndex != -1) {
- updateField(entry, property, fieldIndex, newValue);
- }
- }
- }
- }
-
- /**
- * Return the field index to match the specified property name.
- *
- * @param property property name to search for
- * @return the index that matchs the specified property name.
- * -1
if the property is not recognized.
- */
- private int getFieldIndex(String property) {
- return PROPERTY_LIST.indexOf(property);
- }
-
- /**
- * Update the specified field as necessary.
- *
- * @param entry the Push Registry entry to be updated
- * @param property property of entry to be updated
- * @param fieldIndex the index of the field to be updated in entry
- * @param newValue the new value to be set
- */
- private void updateField(PushRegEntry entry, String property,
- int fieldIndex, String newValue) {
- if (!entry.fields[fieldIndex].equals(newValue)) {
- entry.fields[fieldIndex] = newValue;
- setDirty(true);
- tableViewer.update(entry, new String[] { property });
- }
- }
- }
-
- /**
- * A cell editor implementation that allows for selection of a midlet class.
- */
- private class MidletCellEditor extends DialogCellEditor {
- /** Construct a new cell editor */
- MidletCellEditor(Composite parent) {
- super(parent);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control)
- */
- @Override
- protected Object openDialogBox(Control cellEditorWindow) {
- Object value = null;
-
- try {
- IJavaProject javaProject = getJavaProject();
- SelectionDialog dialog = MidletSelectionDialogCreator
- .createMidletSelectionDialog(
- cellEditorWindow.getShell(),
- getSite().getPage().getWorkbenchWindow(),
- javaProject,
- false,
- MTJUIMessages.JADPushRegistryEditorPage_choose_MIDlet);
-
- if (dialog.open() == Window.OK) {
- Object[] results = dialog.getResult();
- if ((results != null) && (results.length > 0)) {
- IType type = (IType) results[0];
- if (type != null) {
- value = type.getFullyQualifiedName();
- }
- }
- }
- } catch (JavaModelException e) {
- MTJLogger.log(IStatus.ERROR, "openDialogBox", e); //$NON-NLS-1$
- }
-
- return value;
- }
- }
-
- /**
- * Implementation of the table's content provider.
- */
- private class TableContentProvider implements IStructuredContentProvider {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- */
- public void dispose() {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- */
- public Object[] getElements(Object inputElement) {
- return pushRegEntries.toArray(new Object[pushRegEntries.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
- }
-
- /**
- * Implementation of the table's label provider.
- */
- private static class TableLabelProvider extends LabelProvider implements
- ITableLabelProvider {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
- */
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
- */
- public String getColumnText(Object element, int columnIndex) {
- return ((PushRegEntry) element).fields[columnIndex];
- }
- }
-
- static class PushRegEntry {
- public String[] fields;
-
- PushRegEntry(String entryString) {
- fields = new String[3];
- String[] tokens = entryString.split(","); //$NON-NLS-1$
-
- for (int i = 0; i < 3; i++) {
- fields[i] = (i > tokens.length) ? Utils.EMPTY_STRING
- : tokens[i];
- }
- }
-
- PushRegEntry(String connStr, String className, String allowedSender) {
- fields = new String[3];
-
- fields[0] = connStr;
- fields[1] = className;
- fields[2] = allowedSender;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- StringBuffer sb = new StringBuffer();
- if (fields != null) {
- for (int i = 0; i < fields.length; i++) {
- if (i != 0) {
- sb.append(","); //$NON-NLS-1$
- }
- sb.append(fields[i]);
- }
- }
- return sb.toString();
- }
-
- }
-
- public static final String ID = "pushregistry"; //$NON-NLS-1$
-
- /** The prefix of all push registry definition properties */
- public static final String PUSH_REGISTRY_PREFIX = "MIDlet-Push-"; //$NON-NLS-1$
-
- private static final String PROP_CLASS = "class"; //$NON-NLS-1$
-
- // Column property names
- private static final String PROP_CONNSTR = "connection string"; //$NON-NLS-1$
-
- private static final String PROP_SENDER = "allowed sender"; //$NON-NLS-1$
-
- // All of the properties in order
- private static final String[] PROPERTIES = new String[] { PROP_CONNSTR,
- PROP_CLASS, PROP_SENDER };
-
- private static final List PROPERTY_LIST = Arrays.asList(PROPERTIES);
-
- // Buttons
- private Button addButton;
-
- // The collections of entries representing the MIDlets to be registered
- private ArrayList pushRegEntries;
- private Button removeButton;
-
- // The number of MIDlets registered
- private int storedEntriesCount;
-
- // The table viewer in use
- private TableViewer tableViewer;
-
- /**
- * Creates a new JADPushRegistryEditorPage.
- */
- public JADPushRegistryEditorPage() {
- super(ID, MTJUIMessages.JADPushRegistryEditorPage_title);
- pushRegEntries = new ArrayList();
- }
-
- /**
- * Creates a new JADPushRegistryEditorPage.
- *
- * @param editor the parent editor for this page
- * @param title the title of this page
- */
- public JADPushRegistryEditorPage(JADFormEditor editor, String title) {
- super(editor, ID, title);
- pushRegEntries = new ArrayList();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.forms.editor.FormPage#doSave(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void doSave(IProgressMonitor monitor) {
- IPreferenceStore store = getPreferenceStore();
-
- // Add the push registry entries to the store
- int i;
- int currentEntriesCount = pushRegEntries.size();
-
- for (i = 0; i < currentEntriesCount; i++) {
- PushRegEntry def = pushRegEntries.get(i);
- store.setValue(PUSH_REGISTRY_PREFIX + (i + 1), def.toString());
- }
-
- // removing deleted entries
- for (; i < storedEntriesCount; i++) {
- store.setToDefault(PUSH_REGISTRY_PREFIX + (i + 1));
- }
-
- storedEntriesCount = currentEntriesCount;
- setDirty(false);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.mtj.ui.editors.jad.AbstractJADEditorPage#editorInputChanged()
- */
- @Override
- public void editorInputChanged() {
- loadPushRegistryEntries();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.mtj.ui.editors.jad.AbstractJADEditorPage#getTitle()
- */
- @Override
- public String getTitle() {
- return MTJUIMessages.JADPushRegistryEditorPage_title;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.mtj.ui.editors.jad.AbstractJADEditorPage#isManagingProperty(java.lang.String)
- */
- @Override
- public boolean isManagingProperty(String property) {
- boolean manages = property.startsWith(PUSH_REGISTRY_PREFIX);
- if (manages) {
- String value = property.substring(PUSH_REGISTRY_PREFIX.length());
- try {
- Integer.parseInt(value);
- } catch (NumberFormatException e) {
- manages = false;
- }
- }
-
- return manages;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.forms.editor.FormPage#setFocus()
- */
- @Override
- public void setFocus() {
- tableViewer.getTable().setFocus();
- }
-
- /**
- * Add a new item to the table.
- */
- private void addItem() {
- PushRegEntry midletDefinition = new PushRegEntry(
- MTJUIMessages.JADPushRegistryEditorPage_new_pushReg,
- Utils.EMPTY_STRING, "*"); //$NON-NLS-1$
- pushRegEntries.add(midletDefinition);
- tableViewer.refresh();
- setDirty(true);
- }
-
- /**
- * Create the add and remove buttons to the composite.
- *
- * @param toolkit the Eclipse Form's toolkit
- * @param parent
- */
- private void createButtons(FormToolkit toolkit, Composite parent) {
- Composite composite = toolkit.createComposite(parent);
- FillLayout layout = new FillLayout();
- layout.type = SWT.VERTICAL;
- composite.setLayout(layout);
-
- addButton = toolkit
- .createButton(composite,
- MTJUIMessages.JADPushRegistryEditorPage_add_btn_label,
- SWT.PUSH);
- addButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent se) {
- addItem();
- }
- });
-
- toolkit.createLabel(composite, Utils.EMPTY_STRING);
-
- removeButton = toolkit.createButton(composite,
- MTJUIMessages.JADPushRegistryEditorPage_remove_btn_label,
- SWT.PUSH);
- removeButton.setEnabled(false);
- removeButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent se) {
- removeSelectedItems();
- }
- });
- }
-
- /**
- * Create the table viewer for this editor.
- *
- * @param toolkit The Eclipse form's toolkit
- * @param parent
- */
- private void createTableViewer(FormToolkit toolkit, Composite parent) {
- String[] columns = new String[] {
- MTJUIMessages.JADPushRegistryEditorPage_connection_column,
- MTJUIMessages.JADPushRegistryEditorPage_class_column,
- MTJUIMessages.JADPushRegistryEditorPage_sender_column, };
-
- // Setup the table
- int styles = SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER
- | SWT.FULL_SELECTION;
- Table table = toolkit.createTable(parent, styles);
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
- table.setLayoutData(new GridData(GridData.FILL_BOTH));
- table.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- TableItem selected = (TableItem) e.item;
- removeButton.setEnabled(selected.getParent()
- .getSelectionCount() > 0);
- }
- });
- tableViewer = new TableViewer(table);
-
- // Set the table layout on the table
- TableLayout layout = new TableLayout();
-
- int width = 100 / columns.length;
- for (String element : columns) {
- TableColumn column = new TableColumn(table, SWT.NONE);
- column.setText(element);
- layout.addColumnData(new ColumnWeightData(width));
- }
- table.setLayout(layout);
-
- // Set the content providers
- tableViewer.setContentProvider(new TableContentProvider());
- tableViewer.setLabelProvider(new TableLabelProvider());
-
- // Wire up the cell modification handling
- tableViewer.setCellModifier(new CellModifier());
- tableViewer.setColumnProperties(PROPERTIES);
- tableViewer.setCellEditors(new CellEditor[] {
- new TextCellEditor(table), new MidletCellEditor(table),
- new TextCellEditor(table), });
-
- // Get some data into the viewer
- tableViewer.setInput(getEditorInput());
- tableViewer.refresh();
- }
-
- /**
- * Load the Push Registry Entries from the current preference store.
- */
- private void loadPushRegistryEntries() {
- pushRegEntries.clear();
- IPreferenceStore store = getPreferenceStore();
-
- // This is sort of ugly, but IPreferenceStore does not
- // allow getting the complete list of preference keys
- for (int i = 1; i < 1000; i++) {
- String propName = PUSH_REGISTRY_PREFIX + i;
-
- if (store.contains(propName)) {
- String propValue = store.getString(propName);
- pushRegEntries.add(new PushRegEntry(propValue));
- } else {
- break;
- }
- }
-
- storedEntriesCount = pushRegEntries.size();
- if (tableViewer != null) {
- tableViewer.refresh();
- }
- }
-
- /**
- * Remove the items currently selected within the table.
- */
- private void removeSelectedItems() {
- int[] indices = tableViewer.getTable().getSelectionIndices();
-
- for (int i = indices.length; i > 0; i--) {
- int index = indices[i - 1];
- pushRegEntries.remove(index);
- }
-
- setDirty(true);
- tableViewer.refresh();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.mtj.ui.editors.jad.AbstractJADEditorPage#createFormContent(org.eclipse.ui.forms.IManagedForm)
- */
- @Override
- protected void createFormContent(IManagedForm managedForm) {
- super.createFormContent(managedForm);
-
- FormToolkit toolkit = managedForm.getToolkit();
-
- // Set the top-level layout
- Composite parent = managedForm.getForm().getBody();
- parent.setLayoutData(new GridData(GridData.FILL_BOTH));
- parent.setLayout(new GridLayout(2, false));
- new Label(parent, SWT.NONE);
- new Label(parent, SWT.NONE);
-
- createTableViewer(toolkit, parent);
- createButtons(toolkit, parent);
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(parent,
- "eclipseme.ui.help_JADPushRegistryEditorPage"); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.mtj.ui.editors.jad.AbstractJADEditorPage#getHelpResource()
- */
- @Override
- protected String getHelpResource() {
- return "/org.eclipse.mtj.doc.user/html/reference/editors/jad_editor/pushregistry.html"; //$NON-NLS-1$
- }
-
- /**
- * @return
- */
- protected String getSectionDescription() {
- return MTJUIMessages.JADPushRegistryEditorPage_sectionDescription;
- }
-
- /**
- * @return
- */
- protected String getSectionTitle() {
- return MTJUIMessages.JADPushRegistryEditorPage_sectionTitle;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.EditorPart#setInput(org.eclipse.ui.IEditorInput)
- */
- @Override
- protected void setInput(IEditorInput input) {
- super.setInput(input);
- if (tableViewer != null) {
- tableViewer.setInput(input);
- }
-
- setDirty(false);
- loadPushRegistryEntries();
- }
-}
Index: src/org/eclipse/mtj/internal/ui/editors/jad/form/pages/OverviewEditorPage.java
===================================================================
--- src/org/eclipse/mtj/internal/ui/editors/jad/form/pages/OverviewEditorPage.java (revision 1401)
+++ src/org/eclipse/mtj/internal/ui/editors/jad/form/pages/OverviewEditorPage.java (working copy)
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2008 Motorola.
+ * Copyright (c) 2008,2009 Motorola and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -7,13 +7,16 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Diego Sandin (Motorola) - Initial version
- * Diego Sandin (Motorola) - Added runtime section
- * Feng Wang (Sybase) - Modify runtime section, replace Device Selector with
- * Configuration Manager, for Multi-configs support.
- * Diego Sandin (Motorola) - Use Eclipse Message Bundles [Bug 255874]
- * Fernando Rocha(Motorola)- Add validation to JAR URL.
- * Fernando Rocha(Motorola)- Problem marker for the description file.
+ * Diego Sandin (Motorola) - Initial version
+ * Diego Sandin (Motorola) - Added runtime section
+ * Feng Wang (Sybase) - Modify runtime section, replace Device Selector with
+ * Configuration Manager, for Multi-configs support.
+ * Diego Sandin (Motorola) - Use Eclipse Message Bundles [Bug 255874]
+ * Fernando Rocha(Motorola) - Add validation to JAR URL.
+ * Fernando Rocha(Motorola) - Problem marker for the description file.
+ * Jon Dearden (Research In Motion) - Move fields from JADOTAPropertiesEditorPage
+ * and JADPushRegistryEditorPage onto
+ * JADOptionalPropertiesEditorPage [Bug 284452]
*/
package org.eclipse.mtj.internal.ui.editors.jad.form.pages;
@@ -360,7 +363,7 @@
Section section = createStaticSection(toolkit, parent,
MTJUIMessages.OverviewEditorPage_debugging_section_title);
- Composite container = createStaticSectionClient(toolkit, section);
+ Composite container = createStaticSectionClient(toolkit, section, null);
FormText text = createClient(container,
MTJUIMessages.overviewPage_launchsection_debuglinks, toolkit,
@@ -389,7 +392,7 @@
Section section = createStaticSection(toolkit, parent,
MTJUIMessages.OverviewEditorPage_exporting_section_title);
- Composite container = createStaticSectionClient(toolkit, section);
+ Composite container = createStaticSectionClient(toolkit, section, null);
FormText text = createClient(container,
MTJUIMessages.overviewPage_exporting, toolkit, this);
@@ -414,7 +417,7 @@
MTJUIMessages.overviewPage_requiredsection_title,
MTJUIMessages.overviewPage_requiredsection_description);
- Composite sectionClient = createStaticSectionClient(toolkit, section);
+ Composite sectionClient = createStaticSectionClient(toolkit, section, null);
sectionClient.setLayout(FormLayoutFactory
.createSectionClientTableWrapLayout(false, 1));
@@ -436,7 +439,7 @@
Section section = createStaticSection(toolkit, parent,
MTJUIMessages.OverviewEditorPage_packaging_section_title);
- Composite container = createStaticSectionClient(toolkit, section);
+ Composite container = createStaticSectionClient(toolkit, section, null);
FormText text = createClient(container,
MTJUIMessages.overviewPage_deploying, toolkit, this);
@@ -462,7 +465,7 @@
// Running links
Section section = createStaticSection(toolkit, parent,
MTJUIMessages.OverviewEditorPage_running_section_title);
- Composite container = createStaticSectionClient(toolkit, section);
+ Composite container = createStaticSectionClient(toolkit, section, null);
FormText text = createClient(container,
MTJUIMessages.overviewPage_launchsection_runlinks, toolkit,
@@ -491,7 +494,7 @@
MTJUIMessages.overviewPage_runtimesection_title,
MTJUIMessages.overviewPage_runtimesection_description);
- Composite sectionClient = createStaticSectionClient(toolkit, section);
+ Composite sectionClient = createStaticSectionClient(toolkit, section, null);
sectionClient.setLayout(FormLayoutFactory
.createSectionClientGridLayout(true, 1));
Index: src/org/eclipse/mtj/ui/editors/jad/AbstractJADEditorPage.java
===================================================================
--- src/org/eclipse/mtj/ui/editors/jad/AbstractJADEditorPage.java (revision 1401)
+++ src/org/eclipse/mtj/ui/editors/jad/AbstractJADEditorPage.java (working copy)
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2003,2008 Craig Setera and others.
+ * Copyright (c) 2003,2009 Craig Setera and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -12,7 +12,10 @@
* standards
* Gang Ma (Sybase) - Refactoring the page to support extensibility
* Diego Sandin (Motorola) - Use Eclipse Message Bundles [Bug 255874]
- * David Marques (Motorola) - Removing hyperlinks from message manager.
+ * David Marques (Motorola) - Removing hyperlinks from message manager.
+ * Jon Dearden (Research In Motion) - Added support for applying
+ * DescriptorPropertyDescription(s) to specific
+ * page sections [Bug 284452]
*/
package org.eclipse.mtj.ui.editors.jad;
@@ -405,13 +408,17 @@
/**
* @param toolkit
* @param parent
+ * @param sectionId A String identifer for the section. Used for pages that
+ * contain DescriptorPropertyDescription in different sections,
+ * otherwise may be null.
* @return
*/
protected Composite createStaticSectionClient(FormToolkit toolkit,
- Composite parent) {
+ Composite parent, String sectionId) {
Composite container = toolkit.createComposite(parent, SWT.NONE);
container.setLayout(FormLayoutFactory
.createSectionClientTableWrapLayout(false, 1));
+ container.setData(sectionId);
TableWrapData data = new TableWrapData(TableWrapData.FILL_GRAB);
container.setLayoutData(data);
return container;
Index: src/org/eclipse/mtj/ui/editors/jad/JADPropertiesEditorPage.java
===================================================================
--- src/org/eclipse/mtj/ui/editors/jad/JADPropertiesEditorPage.java (revision 1401)
+++ src/org/eclipse/mtj/ui/editors/jad/JADPropertiesEditorPage.java (working copy)
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2003,2008 Craig Setera and others.
+ * Copyright (c) 2003,2009 Craig Setera and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -7,10 +7,13 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Craig Setera (EclipseME) - Initial implementation
- * Diego Sandin (Motorola) - Refactoring package name to follow eclipse
- * standards
- * Gang Ma (Sybase) - Refactoring the page to support extensibility
+ * Craig Setera (EclipseME) - Initial implementation
+ * Diego Sandin (Motorola) - Refactoring package name to follow eclipse
+ * standards
+ * Gang Ma (Sybase) - Refactoring the page to support extensibility
+ * Jon Dearden (Research In Motion) - Added support for applying
+ * DescriptorPropertyDescription(s) to specific
+ * page sections [Bug 284452]
*/
package org.eclipse.mtj.ui.editors.jad;
@@ -181,7 +184,7 @@
* @param description
* @return
*/
- private FieldEditor createComboFieldEditor(FormToolkit toolkit,
+ protected FieldEditor createComboFieldEditor(FormToolkit toolkit,
Composite composite, DescriptorPropertyDescription description) {
if (comboFieldEditorClass == null) {
@@ -219,7 +222,7 @@
* @param descriptor
* @return
*/
- private IntegerFieldEditor createIntegerFieldEditor(FormToolkit toolkit,
+ protected IntegerFieldEditor createIntegerFieldEditor(FormToolkit toolkit,
Composite parent, DescriptorPropertyDescription descriptor) {
IntegerFieldEditor integerEditor = new IntegerFieldEditor(descriptor
@@ -237,7 +240,7 @@
* @param descriptor
* @return
*/
- private ExtendedStringFieldEditor createStringFieldEditor(FormToolkit toolkit,
+ protected ExtendedStringFieldEditor createStringFieldEditor(FormToolkit toolkit,
Composite parent, DescriptorPropertyDescription descriptor) {
ExtendedStringFieldEditor editor = new ExtendedStringFieldEditor(descriptor
.getPropertyName(), descriptor.getDisplayName(), parent);
@@ -271,7 +274,7 @@
/**
* Update the application descriptor the components are handling
*/
- private void updateEditComponents() {
+ protected void updateEditComponents() {
if (fieldEditors != null) {
IPreferenceStore store = (IPreferenceStore) getPreferenceStore();
for (FieldEditor fieldEditor : fieldEditors) {
@@ -310,7 +313,7 @@
Section section = createStaticBasicSection(toolkit, center,
getSectionTitle(), getSectionDescription());
- Composite sectionClient = createStaticSectionClient(toolkit, section);
+ Composite sectionClient = createStaticSectionClient(toolkit, section, null);
sectionClient.setLayout(FormLayoutFactory
.createSectionClientTableWrapLayout(false, 1));