public final class WikiPDFExportWizardPage extends WizardExportResourcesPage implements IPropertyChangeListener, SelectionListener {
// private StringFieldEditor folderText;
- private static final String[] PDF_EXTENSION = { "pdf" };
+ private static final String[] PDF_EXTENSION = { "*.pdf" };
//dialog store id constants
- private static final String STORE_DESTINATION_NAMES_ID = "WikiPDFExportWizardPage.STORE_DESTINATION_NAMES_ID"; //$NON-NLS-1$
+ private static final String PAGE_NAME = "WikiPDFExportWizardPage"; //$NON-NLS-1$
+
+ private static final String STORE_DESTINATION_NAMES = PAGE_NAME+".STORE_DESTINATION_NAMES"; //$NON-NLS-1$
- private static final String STORE_OVERWRITE_EXISTING_FILES_ID = "WikiPDFExportWizardPage.STORE_OVERWRITE_EXISTING_FILES_ID"; //$NON-NLS-1$
+ private static final String STORE_OVERWRITE_EXISTING_FILES_ID = PAGE_NAME+".STORE_OVERWRITE_EXISTING_FILES_ID"; //$NON-NLS-1$
// private StringFieldEditor exportFileText;
- private Combo destinationNameField;
+ private Combo fDestinationNamesCombo;
private Button destinationBrowseButton;
protected Button overwriteExistingFilesCheckbox;
- private ISelection selection;
+ private ISelection fInitialSelection;
private IDialogSettings fSettings = null;
public WikiPDFExportWizardPage(IStructuredSelection selection) {
- super(WikiEditorPlugin.getResourceString("Export.wizardTitle"), selection);
+ super(PAGE_NAME, selection);
setTitle(WikiEditorPlugin.getResourceString("Export.wizardTitle"));
setDescription(WikiEditorPlugin.getResourceString("Export.wizardDescription"));
- this.selection = selection;
+ this.fInitialSelection = selection;
}
/**
destinationLabel.setFont(font);
// destination name entry field
- destinationNameField = new Combo(destinationSelectionGroup, SWT.SINGLE | SWT.BORDER);
- destinationNameField.addListener(SWT.Modify, this);
- destinationNameField.addListener(SWT.Selection, this);
+ fDestinationNamesCombo = new Combo(destinationSelectionGroup, SWT.SINGLE | SWT.BORDER);
+ fDestinationNamesCombo.addListener(SWT.Modify, this);
+ fDestinationNamesCombo.addListener(SWT.Selection, this);
GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
data.widthHint = SIZING_TEXT_FIELD_WIDTH;
- destinationNameField.setLayoutData(data);
- destinationNameField.setFont(font);
+ fDestinationNamesCombo.setLayoutData(data);
+ fDestinationNamesCombo.setFont(font);
// destination browse button
destinationBrowseButton = new Button(destinationSelectionGroup, SWT.PUSH);
*/
protected void handleDestinationBrowseButtonPressed() {
FileDialog dialog = new FileDialog(getContainer().getShell(), SWT.SAVE);
- dialog.setFilterExtensions(PDF_EXTENSION);
+ dialog.setFilterExtensions(PDF_EXTENSION);
dialog.setText("Select pdf file");
dialog.setFilterPath(getDestinationValue());
String selectedFileName = dialog.open();
}
}
+// /**
+// * Answer the contents of self's destination specification widget
+// *
+// * @return java.lang.String
+// */
+// protected String getDestinationValue() {
+//
+// return fDestinationNamesCombo.getText().trim();
+// }
/**
- * Answer the contents of self's destination specification widget
- *
- * @return java.lang.String
- */
- protected String getDestinationValue() {
- return destinationNameField.getText().trim();
- }
+ * Answer the contents of the destination specification widget. If this
+ * value does not have the required suffix then add it first.
+ *
+ * @return java.lang.String
+ */
+ protected String getDestinationValue() {
+ String destinationText= fDestinationNamesCombo.getText().trim();
+ if (destinationText.indexOf('.') < 0)
+ destinationText += getOutputSuffix();
+ return destinationText;
+ }
+
+ /**
+ * Answer the suffix that files exported from this wizard must have.
+ * If this suffix is a file extension (which is typically the case)
+ * then it must include the leading period character.
+ *
+ * @return java.lang.String
+ */
+ protected String getOutputSuffix() {
+ return ".pdf"; //$NON-NLS-1$
+ }
/**
* Set the contents of the receivers destination specification widget to the passed value
*
*/
protected void setDestinationValue(String value) {
- destinationNameField.setText(value);
+ fDestinationNamesCombo.setText(value);
}
/**
* Hook method for saving widget values for restoration by the next instance of this class.
*/
protected void internalSaveWidgetValues() {
- // update directory names history
- IDialogSettings settings = getDialogSettings();
- if (settings != null) {
- String[] fileNames = settings.getArray(STORE_DESTINATION_NAMES_ID);
- if (fileNames == null)
- fileNames = new String[0];
-
- fileNames = addToHistory(fileNames, getDestinationValue());
- settings.put(STORE_DESTINATION_NAMES_ID, fileNames);
-
- // options
- settings.put(STORE_OVERWRITE_EXISTING_FILES_ID, overwriteExistingFilesCheckbox.getSelection());
-
- // settings.put(
- // STORE_CREATE_STRUCTURE_ID,
- // createDirectoryStructureButton.getSelection());
-
- }
+
}
/**
+ * Persists resource specification control setting that are to be restored
+ * in the next instance of this page. Subclasses wishing to persist
+ * settings for their controls should extend the hook method
+ * <code>internalSaveWidgetValues</code>.
+ */
+ public final void saveWidgetValues() {
+ // update directory names history
+ IDialogSettings settings= getDialogSettings();
+ if (settings != null) {
+ String[] directoryNames= settings.getArray(STORE_DESTINATION_NAMES);
+ if (directoryNames == null)
+ directoryNames= new String[0];
+ directoryNames= addToHistory(directoryNames, getDestinationValue());
+ settings.put(STORE_DESTINATION_NAMES, directoryNames);
+
+ // options
+ settings.put(STORE_OVERWRITE_EXISTING_FILES_ID, overwriteExistingFilesCheckbox.getSelection());
+ }
+ // Allow subclasses to save values
+ internalSaveWidgetValues();
+ }
+
+ /**
* Hook method for restoring widget values to the values that they held last time this wizard was used to completion.
*/
protected void restoreWidgetValues() {
IDialogSettings settings = getDialogSettings();
if (settings != null) {
- String[] fileNames = settings.getArray(STORE_DESTINATION_NAMES_ID);
+ String[] fileNames = settings.getArray(STORE_DESTINATION_NAMES);
if (fileNames == null)
return; // ie.- no settings stored
* java.lang.String
*/
protected void addDestinationItem(String value) {
- destinationNameField.add(value);
+ fDestinationNamesCombo.add(value);
}
/**
*/
public void createControl(Composite parent) {
super.createControl(parent);
+// update();
giveFocusToDestination();
// WorkbenchHelp.setHelp(
// getControl(),
* Set the current input focus to self's destination entry field
*/
protected void giveFocusToDestination() {
- destinationNameField.setFocus();
+ fDestinationNamesCombo.setFocus();
}
// private Composite createControlsContainer(Composite parent) {
// }
// private void initialize() throws CoreException {
-// if (selection == null || selection.isEmpty() || !(selection instanceof IStructuredSelection)) {
+// if (fInitialSelection == null || fInitialSelection.isEmpty() || !(fInitialSelection instanceof IStructuredSelection)) {
// return;
// }
//
-// IStructuredSelection ssel = (IStructuredSelection) selection;
+// IStructuredSelection ssel = (IStructuredSelection) fInitialSelection;
// if (ssel.size() == 1) {
// initialiseFromSelectedObject(ssel.getFirstElement());
// }
return false;
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.wizard.WizardPage#getDialogSettings()
- */
-// protected IDialogSettings getDialogSettings() {
-// IDialogSettings dialogBounds= fSettings.getSection(DIALOG_BOUNDS_KEY);
-// if (dialogBounds == null) {
-// dialogBounds= new DialogSettings(DIALOG_BOUNDS_KEY);
-// fSettings.addSection(dialogBounds);
+
+ /**
+ * Returns a boolean indicating whether the passed File handle is
+ * is valid and available for use.
+ *
+ * @return boolean
+ */
+// protected boolean ensureTargetFileIsValid(File targetFile) {
+// if (targetFile.exists() && targetFile.isDirectory() && fDestinationNamesCombo.getText().length() > 0) {
+// setErrorMessage(JarPackagerMessages.getString("JarPackageWizardPage.error.exportDestinationMustNotBeDirectory")); //$NON-NLS-1$
+// fDestinationNamesCombo.setFocus();
+// return false;
+// }
+// if (targetFile.exists()) {
+// if (!targetFile.canWrite()) {
+// setErrorMessage(JarPackagerMessages.getString("JarPackageWizardPage.error.jarFileExistsAndNotWritable")); //$NON-NLS-1$
+// fDestinationNamesCombo.setFocus();
+// return false;
+// }
+// }
+// return true;
// }
-// dialogBounds.put(X, bounds.x);
-// dialogBounds.put(Y, bounds.y);
-// dialogBounds.put(WIDTH, bounds.width);
-// dialogBounds.put(HEIGHT, bounds.height);
-// // TODO Auto-generated method stub
-// return super.getDialogSettings();
-// }
+
}
\ No newline at end of file