blob: 61697c3406a78a91471fbd8280fd54fe2c5e8427 [file] [log] [blame]
//------------------------------------------------------------------------------
// 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 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.PublishingPreferencePage;
import org.eclipse.epf.publishing.ui.preferences.PublishingUIPreferences;
import org.eclipse.epf.ui.wizards.BaseWizardPage;
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();
private Text titleText;
private Text bannerImageText;
private Text aboutHTMLText;
private Text feedbackURLText;
private Button selectImageButton;
private Button selectHTMLButton;
private Button publishGlossaryCheckbox;
private Button publishIndexCheckbox;
private Button checkExternalLinksCheckbox;
private Button convertBrokenLinksCheckbox;
private Button autoGenerateADDCheckbox;
private Button publishBaseADCheckbox;
private Button publishLightWeightTreeCheckbox;
private Button extraDescriptorInfoCtr;
private String configName = "";
/**
* 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));
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 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.titleLabel_text);
titleText = createEditableText(lookAndFeelGroup, "", 360, 1); //$NON-NLS-1$
createLabel(lookAndFeelGroup, ""); //$NON-NLS-1$
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);
createLabel(lookAndFeelGroup, PublishingUIResources.aboutHTMLLabel_text);
aboutHTMLText = createEditableText(lookAndFeelGroup, "", 360, 1); //$NON-NLS-1$
selectHTMLButton = new Button(lookAndFeelGroup, SWT.NONE);
selectHTMLButton.setText(AuthoringUIText.SELECT_BUTTON_TEXT);
createLabel(lookAndFeelGroup,
PublishingUIResources.feedbackURLLabel_text);
feedbackURLText = createEditableText(lookAndFeelGroup, "", 360, 1); //$NON-NLS-1$
createLabel(lookAndFeelGroup, ""); //$NON-NLS-1$
publishGlossaryCheckbox = createCheckbox(lookAndFeelGroup,
PublishingUIResources.publishGlossaryLabel_text, 3);
publishIndexCheckbox = createCheckbox(lookAndFeelGroup,
PublishingUIResources.publishIndexLabel_text, 3);
return lookAndFeelGroup;
}
/**
* 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(1, false));
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);
extraDescriptorInfoCtr
.setSelection(PublishingUIPreferences
.getBooleanValue(PublishingPreferencePage.EXTRA_DESCRIPTOR_INFO));
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() {
}
/**
* @see org.eclipse.epf.ui.wizards.BaseWizardPage#onEnterPage(Object)
*/
public void onEnterPage(Object obj) {
super.onEnterPage(obj);
if (obj instanceof String) {
configName = (String) obj;
} else {
configName = ""; //$NON-NLS-1$
}
titleText.setText(PublishingUIPreferences.getTitle(configName));
bannerImageText.setText(PublishingUIPreferences
.getBannerImage(configName));
aboutHTMLText.setText(PublishingUIPreferences.getAboutHTML(configName));
String feedbackURL = PublishingUIPreferences.getFeedbackURL(configName);
if (feedbackURL == null || feedbackURL.length() <= 0)
feedbackURL = PublishingUIPreferences.getDefaultFeedbackURL();
feedbackURLText.setText(feedbackURL);
publishGlossaryCheckbox.setSelection(PublishingUIPreferences
.getIncludeGlossary(configName));
publishIndexCheckbox.setSelection(PublishingUIPreferences
.getIncludeIndex(configName));
checkExternalLinksCheckbox.setSelection(PublishingUIPreferences
.getCheckExternalLinks(configName));
convertBrokenLinksCheckbox.setSelection(PublishingUIPreferences
.getConvertBrokenLinks(configName));
autoGenerateADDCheckbox.setSelection(PublishingUIPreferences
.getPublishADForActivityExtension(configName));
publishBaseADCheckbox.setSelection(PublishingUIPreferences
.getPublishUnopenActivitydd(configName));
publishLightWeightTreeCheckbox.setSelection(PublishingUIPreferences
.getLightWeightTree(configName));
extraDescriptorInfoCtr.setSelection(PublishingUIPreferences
.getExtraDescriptorInfo(configName));
}
/**
* @see org.eclipse.jface.wizard.WizardPage#isPageComplete()
*/
public boolean isPageComplete() {
return super.isPageComplete();
}
/**
* @see org.eclipse.jface.wizard.WizardPage#getNextPage()
*/
public IWizardPage getNextPage() {
return null;
}
/**
* 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.publishConfiguration = true;
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 selection on this wizard page to preference store.
*/
public void savePreferences() {
PublishingUIPreferences.setTitle(configName, getWebSiteTitle());
PublishingUIPreferences
.setBannerImage(configName, getBannerImagePath());
PublishingUIPreferences.setAboutHTML(configName, getAboutHTMLPath());
PublishingUIPreferences.setFeedbackURL(configName, getFeedbackURL());
PublishingUIPreferences.setIncludeGlossary(configName,
getPublishGlossarySelection());
PublishingUIPreferences.setIncludeIndex(configName,
getPublishIndexSelection());
PublishingUIPreferences.setCheckExternalLinks(configName,
getCheckExternalLinksSelection());
PublishingUIPreferences.setConvertBrokenLinks(configName,
getConvertBrokenLinksSelection());
PublishingUIPreferences.setPublishUnopenActivitydd(configName,
getAutoGenerateADDSelection());
PublishingUIPreferences.setPublishADForActivityExtension(configName,
getPublishBaseADSelection());
PublishingUIPreferences.setLightWeightTree(configName,
getPublishLightWeightTreeSelection());
PublishingUIPreferences.setExtraDescriptorInfo(configName,
getShowExtraDescriptorInfoSelection());
}
}