### Eclipse Workspace Patch 1.0 #P org.eclipse.mylyn.tasks.ui Index: .refactorings/2007/11/47/refactorings.index =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/.refactorings/2007/11/47/refactorings.index,v retrieving revision 1.5 diff -u -r1.5 refactorings.index --- .refactorings/2007/11/47/refactorings.index 22 Nov 2007 01:30:38 -0000 1.5 +++ .refactorings/2007/11/47/refactorings.index 24 Nov 2007 04:35:10 -0000 @@ -12,3 +12,5 @@ 1195690416890 Extract constant 'LINK_PROVIDER_TIMEOUT' 1195690426717 Rename field 'LINK_PROVIDER_TIMEOUT' 1195693776294 Rename method 'refreshAndFocus' +1195866162937 Rename local variable 'workbenchSettings' +1195866309625 Rename local variable 'dialogSettings' Index: .refactorings/2007/11/47/refactorings.history =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/.refactorings/2007/11/47/refactorings.history,v retrieving revision 1.5 diff -u -r1.5 refactorings.history --- .refactorings/2007/11/47/refactorings.history 22 Nov 2007 01:30:38 -0000 1.5 +++ .refactorings/2007/11/47/refactorings.history 24 Nov 2007 04:35:10 -0000 @@ -1,3 +1,3 @@ - + \ No newline at end of file Index: src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewAttachmentPage.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewAttachmentPage.java,v retrieving revision 1.14 diff -u -r1.14 NewAttachmentPage.java --- src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewAttachmentPage.java 9 Oct 2007 04:27:12 -0000 1.14 +++ src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewAttachmentPage.java 24 Nov 2007 04:35:10 -0000 @@ -204,7 +204,7 @@ } }); - filePath.setText(attachment.getFilePath()); + filePath.setText(attachment.getFilePath() == null ? "" : attachment.getFilePath()); //$NON-NLS-1$ /* Listener for isPatch */ isPatchButton.addSelectionListener(new SelectionListener() { Index: src/org/eclipse/mylyn/internal/tasks/ui/wizards/InputAttachmentSourcePage.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/InputAttachmentSourcePage.java,v retrieving revision 1.10 diff -u -r1.10 InputAttachmentSourcePage.java --- src/org/eclipse/mylyn/internal/tasks/ui/wizards/InputAttachmentSourcePage.java 9 Oct 2007 04:27:12 -0000 1.10 +++ src/org/eclipse/mylyn/internal/tasks/ui/wizards/InputAttachmentSourcePage.java 24 Nov 2007 04:35:10 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. + * Copyright (c) 2000, 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 @@ -9,6 +9,7 @@ * IBM Corporation - initial API and implementation * Sebastian Davids - layout tweaks * Jeff Pound - modified for attachment input + * Chris Aniszczyk - bug 209572 *******************************************************************************/ package org.eclipse.mylyn.internal.tasks.ui.wizards; @@ -29,6 +30,7 @@ import org.eclipse.core.runtime.Path; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.viewers.DoubleClickEvent; import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.ISelection; @@ -39,6 +41,7 @@ import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.mylyn.tasks.ui.TasksUiPlugin; import org.eclipse.swt.SWT; import org.eclipse.swt.dnd.Clipboard; import org.eclipse.swt.dnd.TextTransfer; @@ -46,8 +49,6 @@ import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.ShellAdapter; -import org.eclipse.swt.events.ShellEvent; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -57,11 +58,10 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.model.WorkbenchContentProvider; import org.eclipse.ui.model.WorkbenchLabelProvider; -import org.eclipse.ui.views.navigator.*; +import org.eclipse.ui.views.navigator.ResourceSorter; /** * A wizard to input the source of the attachment. This is a modified version of @@ -93,8 +93,6 @@ private boolean showError = false; - private ActivationListener activationListener = new ActivationListener(); - // SWT widgets private Button useClipboardButton; @@ -117,25 +115,10 @@ private String clipboardContents; private boolean initUseClipboard = false; - - class ActivationListener extends ShellAdapter { - @Override - public void shellActivated(ShellEvent e) { - // allow error messages if the selected input actually has something - // selected in it - showError = true; - switch (getInputMethod()) { - case FILE: - showError = (fileNameField.getText() != ""); //$NON-NLS-1$ - break; - - case WORKSPACE: - showError = (!treeViewer.getSelection().isEmpty()); - break; - } - updateWidgetEnablements(); - } - } + + private String DIALOG_SETTINGS = "InputAttachmentSourcePage"; //$NON-NLS-1$ + + private String S_LAST_SELECTION = "lastSelection"; //$NON-NLS-1$ public InputAttachmentSourcePage(NewAttachmentWizard wizard) { super("InputAttachmentPage"); @@ -145,6 +128,13 @@ // setMessage("Please select the source for the attachment"); } + private void initialize(IDialogSettings settings) { + String selection = settings.get(S_LAST_SELECTION); + if(selection != null) { + setInputMethod(Integer.valueOf(selection).intValue()); + } + } + /* * Get a path from the supplied text widget. @return * org.eclipse.core.runtime.IPath @@ -178,10 +168,7 @@ // No error for dialog opening showError = false; clearErrorMessage(); - updateWidgetEnablements(); - - Shell shell = getShell(); - shell.addShellListener(activationListener); + initialize(getDialogSettings()); Dialog.applyDialogFont(composite); @@ -191,8 +178,15 @@ public IWizardPage getNextPage() { if (getInputMethod() == SCREENSHOT) { return wizard.getPage("ScreenShotAttachment"); - } else + } else { + saveDialogSettings(); return wizard.getNextPage(this); + } + } + + private void saveDialogSettings() { + IDialogSettings settings = getDialogSettings(); + settings.put(S_LAST_SELECTION, getInputMethod()); } /* @@ -275,9 +269,6 @@ clearErrorMessage(); showError = true; - int state = getInputMethod(); - setEnableAttachmentFile(state == FILE); - setEnableWorkspaceAttachment(state == WORKSPACE); storeClipboardContents(); updateWidgetEnablements(); } @@ -306,9 +297,6 @@ // If there is anything typed in at all clearErrorMessage(); showError = (fileNameField.getText() != ""); //$NON-NLS-1$ - int state = getInputMethod(); - setEnableAttachmentFile(state == FILE); - setEnableWorkspaceAttachment(state == WORKSPACE); updateWidgetEnablements(); } }); @@ -352,9 +340,6 @@ clearErrorMessage(); // If there is anything typed in at all showError = (!treeViewer.getSelection().isEmpty()); - int state = getInputMethod(); - setEnableAttachmentFile(state == FILE); - setEnableWorkspaceAttachment(state == WORKSPACE); updateWidgetEnablements(); } }); @@ -473,6 +458,9 @@ if (showError) { setErrorMessage(error); } + + setEnableAttachmentFile(inputMethod == FILE); + setEnableWorkspaceAttachment(inputMethod == WORKSPACE); } /** @@ -543,6 +531,27 @@ } return WORKSPACE; } + + protected void setInputMethod(int input) { + switch (input) { + case WORKSPACE: + useWorkspaceButton.setSelection(true); + useClipboardButton.setSelection(false); + useFileButton.setSelection(false); + break; + case CLIPBOARD: + useClipboardButton.setSelection(true); + useFileButton.setSelection(false); + useWorkspaceButton.setSelection(false); + break; + default: + useFileButton.setSelection(true); + useWorkspaceButton.setSelection(false); + useClipboardButton.setSelection(false); + break; + } + updateWidgetEnablements(); + } private String getAttachmentFilePath() { if (fileNameField != null) { @@ -645,5 +654,15 @@ } initUseClipboard = b; } + + protected IDialogSettings getDialogSettings() { + TasksUiPlugin plugin = TasksUiPlugin.getDefault(); + IDialogSettings settings = plugin.getDialogSettings(); + IDialogSettings section = settings.getSection(DIALOG_SETTINGS); + if (section == null) { + section = settings.addNewSection(DIALOG_SETTINGS); + } + return section; + } }