1 11 12 package org.eclipse.pde.internal.ui.wizards.feature; 13 14 import org.eclipse.pde.internal.core.util.IdUtil; 15 import org.eclipse.pde.internal.ui.IHelpContextIds; 16 import org.eclipse.pde.internal.ui.PDEUIMessages; 17 import org.eclipse.swt.SWT; 18 import org.eclipse.swt.events.ModifyListener; 19 import org.eclipse.swt.layout.GridData; 20 import org.eclipse.swt.layout.GridLayout; 21 import org.eclipse.swt.widgets.Composite; 22 import org.eclipse.swt.widgets.Group; 23 import org.eclipse.swt.widgets.Label; 24 import org.eclipse.swt.widgets.Text; 25 26 public class FeatureSpecPage extends AbstractFeatureSpecPage { 27 28 private Text fFeatureProviderText; 29 private Text fFeatureIdText; 30 31 public FeatureSpecPage() { 32 super(); 33 setTitle(PDEUIMessages.NewFeatureWizard_SpecPage_title); 34 setDescription(PDEUIMessages.NewFeatureWizard_SpecPage_desc); 35 } 36 37 protected void initialize() { 38 String projectName = getProjectName(); 39 if (fInitialId == null) 40 fFeatureIdText.setText(IdUtil.getValidId(projectName)); 41 if (fInitialName == null) 42 fFeatureNameText.setText(projectName); 43 fFeatureVersionText.setText("1.0.0"); setMessage(PDEUIMessages.NewFeatureWizard_MainPage_desc); 45 } 46 47 public FeatureData getFeatureData() { 48 FeatureData data = new FeatureData(); 49 data.id = fFeatureIdText.getText(); 50 data.version = fFeatureVersionText.getText(); 51 data.provider = fFeatureProviderText.getText(); 52 data.name = fFeatureNameText.getText(); 53 data.library = getInstallHandlerLibrary(); 54 return data; 55 } 56 57 protected String validateContent() { 58 setMessage(null); 59 return null; 60 } 61 62 protected String getHelpId() { 63 return IHelpContextIds.NEW_FEATURE_DATA; 64 } 65 66 protected void createContents(Composite container) { 67 Group group = new Group(container, SWT.NULL); 68 group.setLayout(new GridLayout(2, false)); 69 GridData gd = new GridData(GridData.FILL_HORIZONTAL); 70 gd.verticalIndent = 10; 71 group.setLayoutData(gd); 72 group.setText(PDEUIMessages.BaseFeatureSpecPage_featurePropertiesGroup_title); 73 74 Label label = new Label(group, SWT.NULL); 75 label.setText(PDEUIMessages.NewFeatureWizard_SpecPage_id); 76 fFeatureIdText = new Text(group, SWT.BORDER); 77 fFeatureIdText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 78 79 createCommonInput(group); 80 81 label = new Label(group, SWT.NULL); 82 label.setText(PDEUIMessages.NewFeatureWizard_SpecPage_provider); 83 fFeatureProviderText = new Text(group, SWT.BORDER); 84 fFeatureProviderText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 85 86 createInstallHandlerText(group); 87 } 88 89 protected void attachListeners(ModifyListener listener) { 90 fFeatureProviderText.addModifyListener(listener); 91 fFeatureIdText.addModifyListener(listener); 92 } 93 94 protected String getFeatureId() { 95 return fFeatureIdText.getText(); 96 } 97 98 99 protected void updateNameRelativeFields() { 100 if (fFeatureIdText == null || fFeatureNameText == null) 101 return; 102 fSelfModification = true; 103 String id = IdUtil.getValidId(getProjectName()); 104 fFeatureIdText.setText(id); 105 fFeatureNameText.setText(IdUtil.getValidName(id, PDEUIMessages.FeatureSpecPage_feature)); 106 fFeatureProviderText.setText(IdUtil.getValidProvider(id)); 107 fSelfModification = false; 108 } 109 } 110 | Popular Tags |