| //------------------------------------------------------------------------------ |
| // Copyright (c) 2005, 2007 IBM Corporation 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: |
| // IBM Corporation - initial implementation |
| //------------------------------------------------------------------------------ |
| package org.eclipse.epf.publishing.ui.wizards; |
| |
| import java.util.ArrayList; |
| import java.util.List; |
| |
| import org.eclipse.epf.authoring.ui.AuthoringUIHelpContexts; |
| import org.eclipse.epf.authoring.ui.AuthoringUIText; |
| import org.eclipse.epf.publishing.services.PublishOptions; |
| import org.eclipse.epf.publishing.ui.PublishingUIPlugin; |
| import org.eclipse.epf.publishing.ui.PublishingUIResources; |
| import org.eclipse.epf.publishing.ui.preferences.PublishingUIPreferences; |
| import org.eclipse.epf.ui.wizards.BaseWizardPage; |
| import org.eclipse.epf.uma.MethodConfiguration; |
| import org.eclipse.jface.wizard.IWizardPage; |
| import org.eclipse.swt.SWT; |
| 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.Display; |
| import org.eclipse.swt.widgets.FileDialog; |
| import org.eclipse.swt.widgets.Group; |
| import org.eclipse.swt.widgets.Text; |
| import org.eclipse.ui.PlatformUI; |
| |
| /** |
| * A wizard page that prompts the user to select the publishing options for the |
| * generated web site. |
| * |
| * @author Kelvin Low |
| * @author Bingxue Xu |
| * @author Jinhua Xi |
| * @since 1.0 |
| */ |
| public class SelectPublishingOptionsPage extends BaseWizardPage { |
| |
| /** |
| * The wizard page name. |
| */ |
| public static final String PAGE_NAME = SelectPublishingOptionsPage.class |
| .getName(); |
| |
| protected Text titleText; |
| |
| protected Text bannerImageText; |
| |
| protected Text aboutHTMLText; |
| |
| protected Text feedbackURLText; |
| |
| protected Button selectImageButton; |
| |
| protected Button selectHTMLButton; |
| |
| protected Button publishGlossaryCheckbox; |
| |
| protected Button publishIndexCheckbox; |
| |
| protected Button checkExternalLinksCheckbox; |
| |
| protected Button convertBrokenLinksCheckbox; |
| |
| protected Button autoGenerateADDCheckbox; |
| |
| protected Button publishBaseADCheckbox; |
| |
| protected Button publishLightWeightTreeCheckbox; |
| |
| protected Button extraDescriptorInfoCtr; |
| |
| protected MethodConfiguration config; |
| |
| protected List<MethodConfiguration> selectedConfigs = new ArrayList<MethodConfiguration>(); |
| |
| /** |
| * Creates a new instance. |
| * |
| * @param name |
| * the name of the wizard page |
| */ |
| public SelectPublishingOptionsPage(String name) { |
| super(name); |
| setTitle(PublishingUIResources.selectPublishingOptionsWizardPage_title); |
| setDescription(PublishingUIResources.selectPublishingOptionsWizardPage_text); |
| setImageDescriptor(PublishingUIPlugin.getDefault().getImageDescriptor( |
| "full/wizban/PublishConfiguration.gif")); //$NON-NLS-1$ |
| } |
| |
| /** |
| * Creates a new instance. |
| */ |
| public SelectPublishingOptionsPage() { |
| this(PAGE_NAME); |
| } |
| |
| /** |
| * @see org.eclipse.jface.dialogs.IDialogPage#createControl(Composite) |
| */ |
| public void createControl(Composite parent) { |
| Composite composite = new Composite(parent, SWT.NULL); |
| composite.setLayout(new GridLayout(1, false)); |
| |
| createTitleAndLinksGroup(composite); |
| createGlossaryAndIndexGroup(composite); |
| createLookAndFeelGroup(composite); |
| createValidation(composite); |
| createDiagramGenerationGroup(composite); |
| createLayoutGroup(composite); |
| |
| initControls(); |
| |
| addListeners(composite); |
| |
| setControl(composite); |
| |
| PlatformUI |
| .getWorkbench() |
| .getHelpSystem() |
| .setHelp( |
| composite, |
| AuthoringUIHelpContexts.CONFIGURATION_PUBLISH_WIZARD_ALL_PAGES_CONTEXT); |
| } |
| |
| /** |
| * Creates the Title and links group. |
| * |
| * @param composite |
| * the parent composite |
| * @return the group composite |
| */ |
| protected Group createTitleAndLinksGroup(Composite composite) { |
| Group titleAndLinksGroup = new Group(composite, SWT.NULL); |
| titleAndLinksGroup.setLayout(new GridLayout(3, false)); |
| titleAndLinksGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
| titleAndLinksGroup.setText(PublishingUIResources.titleAndLinksGroup_text); |
| |
| createLabel(titleAndLinksGroup, PublishingUIResources.titleLabel_text); |
| titleText = createEditableText(titleAndLinksGroup, "", 360, 1); //$NON-NLS-1$ |
| createLabel(titleAndLinksGroup, ""); //$NON-NLS-1$ |
| |
| createLabel(titleAndLinksGroup, PublishingUIResources.aboutHTMLLabel_text); |
| aboutHTMLText = createEditableText(titleAndLinksGroup, "", 360, 1); //$NON-NLS-1$ |
| selectHTMLButton = new Button(titleAndLinksGroup, SWT.NONE); |
| selectHTMLButton.setText(AuthoringUIText.SELECT_BUTTON_TEXT); |
| |
| createLabel(titleAndLinksGroup, |
| PublishingUIResources.feedbackURLLabel_text); |
| feedbackURLText = createEditableText(titleAndLinksGroup, "", 360, 1); //$NON-NLS-1$ |
| createLabel(titleAndLinksGroup, ""); //$NON-NLS-1$ |
| |
| return titleAndLinksGroup; |
| } |
| |
| /** |
| * Creates the Look and feel group. |
| * |
| * @param composite |
| * the parent composite |
| * @return the group composite |
| */ |
| protected Group createLookAndFeelGroup(Composite composite) { |
| Group lookAndFeelGroup = new Group(composite, SWT.NULL); |
| lookAndFeelGroup.setLayout(new GridLayout(3, false)); |
| lookAndFeelGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
| lookAndFeelGroup.setText(PublishingUIResources.lookAndFeelGroup_text); |
| |
| createLabel(lookAndFeelGroup, |
| PublishingUIResources.bannerImageLabel_text); |
| bannerImageText = createEditableText(lookAndFeelGroup, "", 360, 1); //$NON-NLS-1$ |
| selectImageButton = new Button(lookAndFeelGroup, SWT.NONE); |
| selectImageButton.setText(AuthoringUIText.SELECT_BUTTON_TEXT); |
| |
| return lookAndFeelGroup; |
| } |
| |
| /** |
| * Creates the Glosary and index group. |
| * |
| * @param composite |
| * the parent composite |
| * @return the group composite |
| */ |
| protected Group createGlossaryAndIndexGroup(Composite composite) { |
| Group glossaryAndIndexGroup = new Group(composite, SWT.NULL); |
| glossaryAndIndexGroup.setLayout(new GridLayout(2, true)); |
| glossaryAndIndexGroup.setLayoutData(new GridData( |
| GridData.FILL_HORIZONTAL)); |
| glossaryAndIndexGroup |
| .setText(PublishingUIResources.glossaryAndIndexGroup_text); |
| |
| publishGlossaryCheckbox = createCheckbox(glossaryAndIndexGroup, |
| PublishingUIResources.publishGlossaryLabel_text); |
| publishIndexCheckbox = createCheckbox(glossaryAndIndexGroup, |
| PublishingUIResources.publishIndexLabel_text); |
| |
| return glossaryAndIndexGroup; |
| } |
| |
| /** |
| * Creates the Validation group. |
| * |
| * @param composite |
| * the parent composite |
| * @return the group composite |
| */ |
| protected Group createValidation(Composite composite) { |
| Group validationGroup = new Group(composite, SWT.NULL); |
| validationGroup.setLayout(new GridLayout(2, true)); |
| validationGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
| validationGroup.setText(PublishingUIResources.validationGroup_text); |
| |
| checkExternalLinksCheckbox = createCheckbox(validationGroup, |
| PublishingUIResources.checkExternalLinksLabel_text); |
| |
| convertBrokenLinksCheckbox = createCheckbox(validationGroup, |
| PublishingUIResources.convertBrokenLinksLabel_text); |
| |
| return validationGroup; |
| } |
| |
| /** |
| * Creates the Diagram Generation group. |
| * |
| * @param composite |
| * the parent composite |
| * @return the group composite |
| */ |
| protected Group createDiagramGenerationGroup(Composite composite) { |
| Group diagramGroup = new Group(composite, SWT.NULL); |
| diagramGroup.setLayout(new GridLayout(1, false)); |
| diagramGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
| diagramGroup.setText(PublishingUIResources.diagramGroup_text); |
| |
| autoGenerateADDCheckbox = createCheckbox(diagramGroup, |
| PublishingUIResources.publishActivityDetailDiagramsLabel_text); |
| |
| publishBaseADCheckbox = createCheckbox(diagramGroup, |
| PublishingUIResources.publishExtendedActivityDiagramsLabel_text); |
| |
| return diagramGroup; |
| } |
| |
| /** |
| * Creates the Layout group. |
| * |
| * @param composite |
| * the parent composite |
| * @return the group composite |
| */ |
| protected Group createLayoutGroup(Composite composite) { |
| Group layoutGroup = new Group(composite, SWT.NULL); |
| layoutGroup.setLayout(new GridLayout()); |
| layoutGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
| layoutGroup.setText(PublishingUIResources.layoutGroup_text); |
| |
| publishLightWeightTreeCheckbox = createCheckbox(layoutGroup, |
| PublishingUIResources.publishLightWeightTreeLabel_text); |
| |
| extraDescriptorInfoCtr = createCheckbox(layoutGroup, |
| PublishingUIResources.publishExtraDescriptorInfoLabel_text); |
| |
| return layoutGroup; |
| } |
| |
| /** |
| * Provide a means to add additional options to the published web site |
| * group. |
| * |
| * @param composite |
| * the parent composite |
| */ |
| protected void includeAdditionalPublishingOptions(Composite composite) { |
| } |
| |
| /** |
| * Creates the publishing options groups to this wizard page. |
| * |
| * @param composite |
| * the parent composite |
| */ |
| protected void createPublishingOptionsGroups(Composite composite) { |
| } |
| |
| /** |
| * Initializes the wizard page controls with data. |
| */ |
| protected void initControls() { |
| String configId = config != null ? config.getGuid() : ""; //$NON-NLS-1$ |
| |
| titleText.setText(PublishingUIPreferences.getTitle(configId)); |
| bannerImageText.setText(PublishingUIPreferences |
| .getBannerImage(configId)); |
| aboutHTMLText.setText(PublishingUIPreferences.getAboutHTML(configId)); |
| feedbackURLText.setText(PublishingUIPreferences |
| .getFeedbackURL(configId)); |
| publishGlossaryCheckbox.setSelection(PublishingUIPreferences |
| .getIncludeGlossary(configId)); |
| publishIndexCheckbox.setSelection(PublishingUIPreferences |
| .getIncludeIndex(configId)); |
| checkExternalLinksCheckbox.setSelection(PublishingUIPreferences |
| .getCheckExternalLinks(configId)); |
| convertBrokenLinksCheckbox.setSelection(PublishingUIPreferences |
| .getConvertBrokenLinks(configId)); |
| autoGenerateADDCheckbox.setSelection(PublishingUIPreferences |
| .getPublishADForActivityExtension(configId)); |
| publishBaseADCheckbox.setSelection(PublishingUIPreferences |
| .getPublishUnopenActivitydd(configId)); |
| publishLightWeightTreeCheckbox.setSelection(PublishingUIPreferences |
| .getLightWeightTree(configId)); |
| extraDescriptorInfoCtr.setSelection(PublishingUIPreferences |
| .getExtraDescriptorInfo(configId)); |
| } |
| |
| /** |
| * @see org.eclipse.epf.ui.wizards.BaseWizardPage#onEnterPage(Object) |
| */ |
| public void onEnterPage(Object obj) { |
| if (obj != null && obj instanceof MethodConfiguration) { |
| config = (MethodConfiguration) obj; |
| if (!selectedConfigs.contains(config)) { |
| selectedConfigs.add(config); |
| initControls(); |
| } |
| } |
| } |
| |
| /** |
| * @see org.eclipse.jface.wizard.WizardPage#isPageComplete() |
| */ |
| public boolean isPageComplete() { |
| return super.isPageComplete(); |
| } |
| |
| /** |
| * @see org.eclipse.jface.wizard.WizardPage#getNextPage() |
| */ |
| public IWizardPage getNextPage() { |
| IWizardPage page = getWizard().getNextPage(this); |
| try { |
| ((BaseWizardPage) page).onEnterPage(config); |
| } catch (Exception e) { |
| } |
| return page; |
| } |
| |
| /** |
| * Adds the listeners for the controls on this page. |
| */ |
| private void addListeners(final Composite composite) { |
| selectImageButton.addSelectionListener(new SelectionAdapter() { |
| public void widgetSelected(SelectionEvent event) { |
| try { |
| FileDialog dialog = new FileDialog(composite.getShell(), |
| SWT.OPEN); |
| dialog.setFilterExtensions(new String[] { |
| "*.gif", "*.jpg", "*.bmp" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
| String imageFile = dialog.open(); |
| if (imageFile != null) { |
| bannerImageText.setText(imageFile); |
| } |
| } catch (Exception e) { |
| e.printStackTrace(); |
| } |
| } |
| }); |
| |
| selectHTMLButton.addSelectionListener(new SelectionAdapter() { |
| public void widgetSelected(SelectionEvent event) { |
| try { |
| FileDialog dialog = new FileDialog(composite.getShell(), |
| SWT.OPEN); |
| dialog |
| .setFilterExtensions(new String[] { |
| "*.htm", "*.html" }); //$NON-NLS-1$ //$NON-NLS-2$ |
| String htmlFile = dialog.open(); |
| if (htmlFile != null) { |
| aboutHTMLText.setText(htmlFile); |
| } |
| } catch (Exception e) { |
| e.printStackTrace(); |
| } |
| } |
| }); |
| } |
| |
| /** |
| * @see org.eclipse.jface.dialogs.DialogPage#setVisible() |
| */ |
| public void setVisible(boolean visible) { |
| super.setVisible(visible); |
| if (visible) { |
| Display display = titleText.getDisplay(); |
| if (!(display == null || display.isDisposed())) { |
| display.asyncExec(new Runnable() { |
| public void run() { |
| titleText.setFocus(); |
| } |
| }); |
| } |
| } |
| } |
| |
| /** |
| * Gets the user selected publishing options. |
| * |
| * @return a <code>PublishOptions</code> object |
| */ |
| public PublishOptions getPublishingOptions() { |
| PublishOptions options = new PublishOptions(); |
| |
| options.setTitle(getWebSiteTitle()); |
| options.setBannerImage(getBannerImagePath()); |
| options.setAboutHTML(getAboutHTMLPath()); |
| options.setFeedbackURL(getFeedbackURL()); |
| options.setGenerateGlossary(getPublishGlossarySelection()); |
| options.setGenerateIndex(getPublishIndexSelection()); |
| options.setCheckExtLinks(getCheckExternalLinksSelection()); |
| options.setAutoGenerateActivityDiagrams(getAutoGenerateADDSelection()); |
| options.setUnopenExtendedActivityDiagram(getPublishBaseADSelection()); |
| options.setConvertBrokenLinks(getConvertBrokenLinksSelection()); |
| options |
| .setGenerateLightWeightTree(getPublishLightWeightTreeSelection()); |
| options |
| .setShowExtraDescriptorInfo(getShowExtraDescriptorInfoSelection()); |
| |
| return options; |
| } |
| |
| /** |
| * Gets the user specified web site title. |
| */ |
| protected String getWebSiteTitle() { |
| return titleText.getText().trim(); |
| } |
| |
| /** |
| * Gets the user specified banner image path. |
| */ |
| protected String getBannerImagePath() { |
| return bannerImageText.getText().trim(); |
| } |
| |
| /** |
| * Gets the user specified about HTML path. |
| */ |
| protected String getAboutHTMLPath() { |
| return aboutHTMLText.getText().trim(); |
| } |
| |
| /** |
| * Gets the user specified feedback URL. |
| */ |
| protected String getFeedbackURL() { |
| return feedbackURLText.getText().trim(); |
| } |
| |
| /** |
| * Gets the user specified publish glossary selection. |
| */ |
| protected boolean getPublishGlossarySelection() { |
| return publishGlossaryCheckbox.getSelection(); |
| } |
| |
| /** |
| * Gets the user specified publish index selection. |
| */ |
| protected boolean getPublishIndexSelection() { |
| return publishIndexCheckbox.getSelection(); |
| } |
| |
| /** |
| * Gets the user specified check external links selection. |
| */ |
| protected boolean getCheckExternalLinksSelection() { |
| return checkExternalLinksCheckbox.getSelection(); |
| } |
| |
| /** |
| * Gets the user specified convert broken links selection. |
| */ |
| protected boolean getConvertBrokenLinksSelection() { |
| return convertBrokenLinksCheckbox.getSelection(); |
| } |
| |
| /** |
| * Gets the user specified auto generate activity detail diagrams selection. |
| */ |
| protected boolean getAutoGenerateADDSelection() { |
| return autoGenerateADDCheckbox.getSelection(); |
| } |
| |
| /** |
| * Gets the user specified publish activity diagram for base activties with |
| * unmodified extensions. |
| */ |
| protected boolean getPublishBaseADSelection() { |
| return publishBaseADCheckbox.getSelection(); |
| } |
| |
| /** |
| * Gets the user specified generate light weight tree selection. |
| */ |
| protected boolean getPublishLightWeightTreeSelection() { |
| return publishLightWeightTreeCheckbox.getSelection(); |
| } |
| |
| /** |
| * Gets the user specified show extra descriptor info selection. |
| */ |
| protected boolean getShowExtraDescriptorInfoSelection() { |
| return extraDescriptorInfoCtr.getSelection(); |
| } |
| |
| /** |
| * Saves the user selections in this wizard page to preference store. |
| */ |
| public void savePreferences() { |
| if (config != null) { |
| String configId = config.getGuid(); |
| PublishingUIPreferences.setTitle(configId, getWebSiteTitle()); |
| PublishingUIPreferences.setBannerImage(configId, |
| getBannerImagePath()); |
| PublishingUIPreferences |
| .setAboutHTML(configId, getAboutHTMLPath()); |
| PublishingUIPreferences |
| .setFeedbackURL(configId, getFeedbackURL()); |
| PublishingUIPreferences.setIncludeGlossary(configId, |
| getPublishGlossarySelection()); |
| PublishingUIPreferences.setIncludeIndex(configId, |
| getPublishIndexSelection()); |
| PublishingUIPreferences.setCheckExternalLinks(configId, |
| getCheckExternalLinksSelection()); |
| PublishingUIPreferences.setConvertBrokenLinks(configId, |
| getConvertBrokenLinksSelection()); |
| PublishingUIPreferences.setPublishUnopenActivitydd(configId, |
| getAutoGenerateADDSelection()); |
| PublishingUIPreferences.setPublishADForActivityExtension( |
| configId, getPublishBaseADSelection()); |
| PublishingUIPreferences.setLightWeightTree(configId, |
| getPublishLightWeightTreeSelection()); |
| PublishingUIPreferences.setExtraDescriptorInfo(configId, |
| getShowExtraDescriptorInfoSelection()); |
| } |
| } |
| |
| } |