001: /*******************************************************************************
002: * Copyright (c) 2000, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.pde.internal.ui.wizards.feature;
011:
012: import org.eclipse.pde.internal.core.util.IdUtil;
013: import org.eclipse.pde.internal.ui.IHelpContextIds;
014: import org.eclipse.pde.internal.ui.PDEUIMessages;
015: import org.eclipse.swt.SWT;
016: import org.eclipse.swt.events.ModifyListener;
017: import org.eclipse.swt.layout.GridData;
018: import org.eclipse.swt.layout.GridLayout;
019: import org.eclipse.swt.widgets.Composite;
020: import org.eclipse.swt.widgets.Group;
021: import org.eclipse.swt.widgets.Label;
022: import org.eclipse.swt.widgets.Text;
023:
024: public class FeatureSpecPage extends AbstractFeatureSpecPage {
025:
026: private Text fFeatureProviderText;
027: private Text fFeatureIdText;
028:
029: public FeatureSpecPage() {
030: super ();
031: setTitle(PDEUIMessages.NewFeatureWizard_SpecPage_title);
032: setDescription(PDEUIMessages.NewFeatureWizard_SpecPage_desc);
033: }
034:
035: protected void initialize() {
036: String projectName = getProjectName();
037: if (fInitialId == null)
038: fFeatureIdText.setText(IdUtil.getValidId(projectName));
039: if (fInitialName == null)
040: fFeatureNameText.setText(projectName);
041: fFeatureVersionText.setText("1.0.0"); //$NON-NLS-1$
042: setMessage(PDEUIMessages.NewFeatureWizard_MainPage_desc);
043: }
044:
045: public FeatureData getFeatureData() {
046: FeatureData data = new FeatureData();
047: data.id = fFeatureIdText.getText();
048: data.version = fFeatureVersionText.getText();
049: data.provider = fFeatureProviderText.getText();
050: data.name = fFeatureNameText.getText();
051: data.library = getInstallHandlerLibrary();
052: return data;
053: }
054:
055: protected String validateContent() {
056: setMessage(null);
057: return null;
058: }
059:
060: protected String getHelpId() {
061: return IHelpContextIds.NEW_FEATURE_DATA;
062: }
063:
064: protected void createContents(Composite container) {
065: Group group = new Group(container, SWT.NULL);
066: group.setLayout(new GridLayout(2, false));
067: GridData gd = new GridData(GridData.FILL_HORIZONTAL);
068: gd.verticalIndent = 10;
069: group.setLayoutData(gd);
070: group
071: .setText(PDEUIMessages.BaseFeatureSpecPage_featurePropertiesGroup_title);
072:
073: Label label = new Label(group, SWT.NULL);
074: label.setText(PDEUIMessages.NewFeatureWizard_SpecPage_id);
075: fFeatureIdText = new Text(group, SWT.BORDER);
076: fFeatureIdText.setLayoutData(new GridData(
077: GridData.FILL_HORIZONTAL));
078:
079: createCommonInput(group);
080:
081: label = new Label(group, SWT.NULL);
082: label.setText(PDEUIMessages.NewFeatureWizard_SpecPage_provider);
083: fFeatureProviderText = new Text(group, SWT.BORDER);
084: fFeatureProviderText.setLayoutData(new GridData(
085: GridData.FILL_HORIZONTAL));
086:
087: createInstallHandlerText(group);
088: }
089:
090: protected void attachListeners(ModifyListener listener) {
091: fFeatureProviderText.addModifyListener(listener);
092: fFeatureIdText.addModifyListener(listener);
093: }
094:
095: protected String getFeatureId() {
096: return fFeatureIdText.getText();
097: }
098:
099: 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,
106: PDEUIMessages.FeatureSpecPage_feature));
107: fFeatureProviderText.setText(IdUtil.getValidProvider(id));
108: fSelfModification = false;
109: }
110: }
|