1 11 package org.eclipse.pde.internal.ui.editor.schema; 12 import org.eclipse.pde.internal.core.ischema.ISchema; 13 import org.eclipse.pde.internal.core.schema.Schema; 14 import org.eclipse.pde.internal.ui.PDEUIMessages; 15 import org.eclipse.pde.internal.ui.editor.FormEntryAdapter; 16 import org.eclipse.pde.internal.ui.editor.FormLayoutFactory; 17 import org.eclipse.pde.internal.ui.editor.PDESection; 18 import org.eclipse.pde.internal.ui.parts.FormEntry; 19 import org.eclipse.swt.dnd.Clipboard; 20 import org.eclipse.swt.layout.GridData; 21 import org.eclipse.swt.widgets.Composite; 22 import org.eclipse.ui.forms.widgets.FormToolkit; 23 import org.eclipse.ui.forms.widgets.Section; 24 25 public class SchemaSpecSection extends PDESection { 26 27 private FormEntry fPluginText; 28 private FormEntry fPointText; 29 private FormEntry fNameText; 30 31 public SchemaSpecSection(SchemaOverviewPage page, Composite parent) { 32 super(page, parent, Section.DESCRIPTION); 33 getSection().setText(PDEUIMessages.SchemaEditor_SpecSection_title); 34 getSection().setDescription(PDEUIMessages.SchemaEditor_SpecSection_desc); 35 createClient(getSection(), page.getManagedForm().getToolkit()); 36 } 37 38 public void commit(boolean onSave) { 39 fPluginText.commit(); 40 fPointText.commit(); 41 fNameText.commit(); 42 super.commit(onSave); 43 } 44 45 public void cancelEdit() { 46 fPluginText.cancelEdit(); 47 fPointText.cancelEdit(); 48 fNameText.cancelEdit(); 49 super.cancelEdit(); 50 } 51 52 public void createClient(Section section, FormToolkit toolkit) { 53 Composite container = toolkit.createComposite(section); 54 container.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2)); 55 GridData data = new GridData(GridData.FILL_BOTH); 56 section.setLayoutData(data); 57 58 final Schema schema = (Schema) getPage().getModel(); 59 fPluginText = new FormEntry(container, toolkit, PDEUIMessages.SchemaEditor_SpecSection_plugin, null, false); 60 fPluginText.setFormEntryListener(new FormEntryAdapter(this) { 61 public void textValueChanged(FormEntry text) { 62 schema.setPluginId(text.getValue()); 63 } 64 }); 65 fPointText = new FormEntry(container, toolkit, PDEUIMessages.SchemaEditor_SpecSection_point, null, false); 66 fPointText.setFormEntryListener(new FormEntryAdapter(this) { 67 public void textValueChanged(FormEntry text) { 68 schema.setPointId(text.getValue()); 69 } 70 }); 71 fNameText = new FormEntry(container, toolkit, PDEUIMessages.SchemaEditor_SpecSection_name, null, false); 72 fNameText.setFormEntryListener(new FormEntryAdapter(this) { 73 public void textValueChanged(FormEntry text) { 74 schema.setName(text.getValue()); 75 getPage().getManagedForm().getForm().setText(schema.getName()); 76 } 77 }); 78 79 toolkit.paintBordersFor(container); 80 section.setClient(container); 81 initialize(); 82 } 83 84 public void dispose() { 85 ISchema schema = (ISchema) getPage().getModel(); 86 if (schema != null) 87 schema.removeModelChangedListener(this); 88 super.dispose(); 89 } 90 91 public void initialize() { 92 ISchema schema = (ISchema) getPage().getModel(); 93 refresh(); 94 fPluginText.setEditable(isEditable()); 95 fPointText.setEditable(isEditable()); 96 fNameText.setEditable(isEditable()); 97 schema.addModelChangedListener(this); 98 } 99 100 103 public void setFocus() { 104 if (fPluginText != null) { 105 fPluginText.getText().setFocus(); 106 } 107 } 108 109 public void refresh() { 110 ISchema schema = (ISchema)getPage().getModel(); 111 fPluginText.setValue(schema.getPluginId(), true); 112 fPointText.setValue(schema.getPointId(), true); 113 fNameText.setValue(schema.getName(), true); 114 getPage().getManagedForm().getForm().setText(schema.getName()); 115 super.refresh(); 116 } 117 118 public boolean canPaste(Clipboard clipboard) { 119 return isEditable(); 120 } 121 } 122 | Popular Tags |