diff options
author | Cédric Bosdonnat <cedricbosdo@openoffice.org> | 2009-11-10 14:57:33 +0100 |
---|---|---|
committer | Cédric Bosdonnat <cedricbosdo@openoffice.org> | 2009-11-10 14:57:33 +0100 |
commit | 823d45c63e62e91a4ccccab79583a84b8491be38 (patch) | |
tree | 97a5e877c981e337534da8ddf89b405090c02038 | |
parent | f962959a0cfd42068fc737f90de88c67702b39e1 (diff) |
[Core]Added description field in description.xml
This is a first step before removing the equivalent part of the
package.properties file. The next steps will be to completely replace
the package.properties file by the manifest.xml file.
6 files changed, 89 insertions, 20 deletions
diff --git a/core/source/org/openoffice/ide/eclipse/core/editors/description/DescriptionFormPage.java b/core/source/org/openoffice/ide/eclipse/core/editors/description/DescriptionFormPage.java index bcf9613..66aa645 100644 --- a/core/source/org/openoffice/ide/eclipse/core/editors/description/DescriptionFormPage.java +++ b/core/source/org/openoffice/ide/eclipse/core/editors/description/DescriptionFormPage.java @@ -176,6 +176,9 @@ public class DescriptionFormPage extends FormPage { rightColumn.setLayoutData( new GridData( GridData.FILL_BOTH ) ); rightColumn.setLayout( new GridLayout( ) ); + IFileEditorInput input = (IFileEditorInput)getEditorInput(); + IProject project = input.getFile().getProject(); + /* * Left column: Right column: * + Section "General" + Section "Update mirrors" @@ -183,7 +186,7 @@ public class DescriptionFormPage extends FormPage { * + Section "Publisher" * + Section "Release notes" */ - GeneralSection generalSection = new GeneralSection( leftColumn, this ); + GeneralSection generalSection = new GeneralSection( leftColumn, this, project ); localized.add( generalSection ); mSections.add( generalSection ); @@ -201,8 +204,6 @@ public class DescriptionFormPage extends FormPage { MirrorsSection mirrorSection = new MirrorsSection( rightColumn, this ); mSections.add( mirrorSection ); - IFileEditorInput input = (IFileEditorInput)getEditorInput(); - IProject project = input.getFile().getProject(); LicenseSection licenseSection = new LicenseSection( rightColumn, this, project ); mSections.add( licenseSection ); localized.add( licenseSection ); diff --git a/core/source/org/openoffice/ide/eclipse/core/editors/description/GeneralSection.java b/core/source/org/openoffice/ide/eclipse/core/editors/description/GeneralSection.java index 683cb95..e716828 100644 --- a/core/source/org/openoffice/ide/eclipse/core/editors/description/GeneralSection.java +++ b/core/source/org/openoffice/ide/eclipse/core/editors/description/GeneralSection.java @@ -32,11 +32,17 @@ package org.openoffice.ide.eclipse.core.editors.description; import java.util.Locale; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; 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.Label; import org.eclipse.swt.widgets.Text; @@ -44,6 +50,7 @@ import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Section; import org.openoffice.ide.eclipse.core.editors.Messages; import org.openoffice.ide.eclipse.core.editors.utils.LocalizedSection; +import org.openoffice.ide.eclipse.core.gui.ProjectSelectionDialog; import org.openoffice.ide.eclipse.core.model.description.DescriptionModel; /** @@ -52,21 +59,27 @@ import org.openoffice.ide.eclipse.core.model.description.DescriptionModel; */ public class GeneralSection extends LocalizedSection< DescriptionModel > { + private static final int LAYOUT_COLS = 3; + + private IProject mProject; + private Text mNameTxt; private Text mIdTxt; private Text mVersionTxt; + private Text mDescriptionTxt; + private Button mDescriptionBtn; /** * @param pParent the parent composite where to add the section * @param pPage the parent page + * @param pProject the project containing the description.xml file */ - public GeneralSection( Composite pParent, DescriptionFormPage pPage ) { + public GeneralSection( Composite pParent, DescriptionFormPage pPage, IProject pProject ) { super( pParent, pPage, Section.TITLE_BAR ); - - getSection( ).setText( Messages.getString("GeneralSection.Title") ); //$NON-NLS-1$ + mProject = pProject; setModel( pPage.getModel() ); } @@ -78,6 +91,7 @@ public class GeneralSection extends LocalizedSection< DescriptionModel > { mNameTxt.setText( getModel().getDisplayNames().get( mCurrentLocale ) ); mIdTxt.setText( getModel().getId() ); mVersionTxt.setText( getModel().getVersion() ); + mDescriptionTxt.setText( getModel().getDescriptions().get( mCurrentLocale ) ); getModel().setSuspendEvent( false ); } @@ -87,19 +101,21 @@ public class GeneralSection extends LocalizedSection< DescriptionModel > { @Override protected void createControls( FormToolkit pToolkit, Composite pParent ) { - pParent.setLayout( new GridLayout( 2, false ) ); + pParent.setLayout( new GridLayout( LAYOUT_COLS, false ) ); Label descrLbl = pToolkit.createLabel( pParent, Messages.getString("GeneralSection.Description"), //$NON-NLS-1$ SWT.WRAP ); GridData gd = new GridData( GridData.FILL_HORIZONTAL ); - gd.horizontalSpan = 2; + gd.horizontalSpan = LAYOUT_COLS; descrLbl.setLayoutData( gd ); // Name controls pToolkit.createLabel( pParent, Messages.getString("GeneralSection.Name") ); //$NON-NLS-1$ mNameTxt = pToolkit.createText( pParent, new String( ) ); - mNameTxt.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); + gd = new GridData( GridData.FILL_HORIZONTAL ); + gd.horizontalSpan = LAYOUT_COLS - 1; + mNameTxt.setLayoutData( gd ); mNameTxt.setEnabled( false ); mNameTxt.addModifyListener( new ModifyListener () { public void modifyText(ModifyEvent pE) { @@ -110,7 +126,9 @@ public class GeneralSection extends LocalizedSection< DescriptionModel > { // Identifier controls pToolkit.createLabel( pParent, Messages.getString("GeneralSection.Identifier") ); //$NON-NLS-1$ mIdTxt = pToolkit.createText( pParent, new String( ) ); - mIdTxt.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); + gd = new GridData( GridData.FILL_HORIZONTAL ); + gd.horizontalSpan = LAYOUT_COLS - 1; + mIdTxt.setLayoutData( gd ); mIdTxt.addModifyListener( new ModifyListener () { public void modifyText(ModifyEvent pE) { getModel().setId( mIdTxt.getText() ); @@ -120,12 +138,45 @@ public class GeneralSection extends LocalizedSection< DescriptionModel > { // Version controls pToolkit.createLabel( pParent, Messages.getString("GeneralSection.Version") ); //$NON-NLS-1$ mVersionTxt = pToolkit.createText( pParent, new String( ) ); - mVersionTxt.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); + gd = new GridData( GridData.FILL_HORIZONTAL ); + gd.horizontalSpan = LAYOUT_COLS - 1; + mVersionTxt.setLayoutData( gd ); mVersionTxt.addModifyListener( new ModifyListener () { public void modifyText(ModifyEvent pE) { getModel().setVersion( mVersionTxt.getText() ); } }); + + // Description controls + pToolkit.createLabel( pParent, Messages.getString("GeneralSection.Description") ); //$NON-NLS-1$ + mDescriptionTxt = pToolkit.createText( pParent, new String( ) ); + mDescriptionTxt.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); + mDescriptionTxt.setEnabled( false ); + mDescriptionTxt.addModifyListener( new ModifyListener () { + public void modifyText(ModifyEvent pE) { + getModel().addDisplayName( mCurrentLocale, mDescriptionTxt.getText() ); + } + }); + + mDescriptionBtn = pToolkit.createButton( pParent, "...", SWT.PUSH ); //$NON-NLS-1$ + mDescriptionBtn.setLayoutData( new GridData( GridData.HORIZONTAL_ALIGN_END ) ); + mDescriptionBtn.addSelectionListener( new SelectionAdapter( ) { + @Override + public void widgetSelected(SelectionEvent pE) { + // Open the folder selection dialog + ProjectSelectionDialog dlg = new ProjectSelectionDialog( mProject, + Messages.getString("GeneralSection.FileChooserTooltip") ); //$NON-NLS-1$ + + if ( dlg.open() == ProjectSelectionDialog.OK ) { + IResource res = dlg.getSelected(); + if ( res != null && res.getType() == IResource.FILE ) { + IFile file = (IFile)res; + String path = file.getProjectRelativePath().toString(); + mDescriptionBtn.setText( path ); + } + } + } + }); } /** @@ -135,7 +186,12 @@ public class GeneralSection extends LocalizedSection< DescriptionModel > { if ( !getModel().getDisplayNames().containsKey( pLocale ) ) { getModel().addDisplayName( pLocale, new String( ) ); } + if ( !getModel().getDescriptions().containsKey( pLocale ) ) { + getModel().addDescription( pLocale, new String( ) ); + } mNameTxt.setEnabled( true ); + mDescriptionTxt.setEnabled( true ); + mDescriptionBtn.setEnabled( true ); } /** @@ -143,9 +199,15 @@ public class GeneralSection extends LocalizedSection< DescriptionModel > { */ public void deleteLocale(Locale pLocale) { getModel().removeDisplayName( pLocale ); - if ( getModel().getDisplayNames().size() == 0 ) { + getModel().removeDescription( pLocale ); + if ( getModel().getDisplayNames().isEmpty() ) { mNameTxt.setEnabled( false ); } + + if ( getModel().getDescriptions().isEmpty() ) { + mDescriptionTxt.setEnabled( false ); + mDescriptionBtn.setEnabled( false ); + } } /** @@ -156,9 +218,11 @@ public class GeneralSection extends LocalizedSection< DescriptionModel > { if ( mCurrentLocale != null ) { getModel().addDisplayName( mCurrentLocale, mNameTxt.getText( ) ); + getModel().addDescription( mCurrentLocale, mDescriptionTxt.getText( ) ); } super.selectLocale(pLocale); String name = getModel().getDisplayNames().get( pLocale ); mNameTxt.setText( name ); + mDescriptionTxt.setText( getModel().getDescriptions().get( pLocale ) ); } } diff --git a/core/source/org/openoffice/ide/eclipse/core/editors/description/LicenseSection.java b/core/source/org/openoffice/ide/eclipse/core/editors/description/LicenseSection.java index b2c04d4..dbea745 100644 --- a/core/source/org/openoffice/ide/eclipse/core/editors/description/LicenseSection.java +++ b/core/source/org/openoffice/ide/eclipse/core/editors/description/LicenseSection.java @@ -205,7 +205,7 @@ public class LicenseSection extends LocalizedSection< DescriptionModel > { */ public void deleteLocale(Locale pLocale) { getModel().removeLicense( pLocale ); - if ( getModel().getLicenses().size() == 0 ) { + if ( getModel().getLicenses().isEmpty() ) { // disable the text and file mFileBrowseBtn.setEnabled( false ); mFileTxt.setEnabled( false ); diff --git a/core/source/org/openoffice/ide/eclipse/core/editors/description/PublisherSection.java b/core/source/org/openoffice/ide/eclipse/core/editors/description/PublisherSection.java index 3cadc28..443d067 100644 --- a/core/source/org/openoffice/ide/eclipse/core/editors/description/PublisherSection.java +++ b/core/source/org/openoffice/ide/eclipse/core/editors/description/PublisherSection.java @@ -55,6 +55,7 @@ import org.openoffice.ide.eclipse.core.model.description.PublisherInfos; */ public class PublisherSection extends LocalizedSection< DescriptionModel > { + private static final int LAYOUT_COLS = 2; private Text mUrlTxt; private Text mNameTxt; @@ -88,13 +89,13 @@ public class PublisherSection extends LocalizedSection< DescriptionModel > { @Override protected void createControls(FormToolkit pToolkit, Composite pParent) { - pParent.setLayout( new GridLayout( 2, false ) ); + pParent.setLayout( new GridLayout( LAYOUT_COLS, false ) ); Label descrLbl = pToolkit.createLabel( pParent, Messages.getString("PublisherSection.Description"), //$NON-NLS-1$ SWT.WRAP ); GridData gd = new GridData( GridData.FILL_HORIZONTAL ); - gd.horizontalSpan = 2; + gd.horizontalSpan = LAYOUT_COLS; descrLbl.setLayoutData( gd ); // Name controls @@ -140,7 +141,7 @@ public class PublisherSection extends LocalizedSection< DescriptionModel > { */ public void deleteLocale(Locale pLocale) { getModel().removePublisherInfo( pLocale ); - if ( getModel().getPublisherInfos().size( ) == 0 ) { + if ( getModel().getPublisherInfos().isEmpty() ) { mNameTxt.setEnabled( false ); mUrlTxt.setEnabled( false ); } diff --git a/core/source/org/openoffice/ide/eclipse/core/editors/description/ReleaseNotesSection.java b/core/source/org/openoffice/ide/eclipse/core/editors/description/ReleaseNotesSection.java index 38f51db..e0f112d 100644 --- a/core/source/org/openoffice/ide/eclipse/core/editors/description/ReleaseNotesSection.java +++ b/core/source/org/openoffice/ide/eclipse/core/editors/description/ReleaseNotesSection.java @@ -56,6 +56,7 @@ import org.openoffice.ide.eclipse.core.model.description.DescriptionModel; public class ReleaseNotesSection extends LocalizedSection< DescriptionModel > implements ILocaleListener { + private static final int LAYOUT_COLS = 2; private Text mUrlTxt; /** @@ -85,13 +86,13 @@ public class ReleaseNotesSection extends LocalizedSection< DescriptionModel > im */ @Override protected void createControls(FormToolkit pToolkit, Composite pParent) { - pParent.setLayout( new GridLayout( 2, false ) ); + pParent.setLayout( new GridLayout( LAYOUT_COLS, false ) ); Label descrLbl = pToolkit.createLabel( pParent, Messages.getString("ReleaseNotesSection.Description"), //$NON-NLS-1$ SWT.WRAP ); GridData gd = new GridData( GridData.FILL_HORIZONTAL ); - gd.horizontalSpan = 2; + gd.horizontalSpan = LAYOUT_COLS; descrLbl.setLayoutData( gd ); // Url controls @@ -122,7 +123,7 @@ public class ReleaseNotesSection extends LocalizedSection< DescriptionModel > im */ public void deleteLocale(Locale pLocale) { getModel().removeReleaseNote( pLocale ); - if ( getModel().getReleaseNotes().size( ) == 0 ) { + if ( getModel().getReleaseNotes().isEmpty() ) { mUrlTxt.setEnabled( false ); } } diff --git a/core/source/org/openoffice/ide/eclipse/core/editors/messages.properties b/core/source/org/openoffice/ide/eclipse/core/editors/messages.properties index 1cbcf30..4707345 100644 --- a/core/source/org/openoffice/ide/eclipse/core/editors/messages.properties +++ b/core/source/org/openoffice/ide/eclipse/core/editors/messages.properties @@ -26,8 +26,10 @@ GeneralSection.Identifier=Identifier GeneralSection.Name=Name GeneralSection.Title=General informations GeneralSection.Version=Version +GeneralSection.Description=Description file +GeneralSection.FileChooserTooltip=Choose the description file for the locale LicenseSection.Description=License files are localized TXT files.\nIf no file is selected for any locale, then no license will apply. -LicenseSection.FileChooserTooltip=Choose the folder where to place the license files +LicenseSection.FileChooserTooltip=Choose the license file for the locale LicenseSection.LicenseFile=License file LicenseSection.SuppressUpdate=Do not ask to accept the license during an update. LicenseSection.Title=License |