### Eclipse Workspace Patch 1.0 #P org.eclipse.mylyn.bugzilla.ui Index: src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaAttachmentUpdateAction.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaAttachmentUpdateAction.java,v retrieving revision 1.1 diff -u -r1.1 BugzillaAttachmentUpdateAction.java --- src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaAttachmentUpdateAction.java 24 Jan 2010 14:30:08 -0000 1.1 +++ src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaAttachmentUpdateAction.java 3 Feb 2010 19:56:29 -0000 @@ -13,19 +13,16 @@ import java.util.List; -import org.eclipse.core.runtime.jobs.IJobChangeEvent; -import org.eclipse.core.runtime.jobs.JobChangeAdapter; import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.IMessageProvider; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.window.Window; import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants; -import org.eclipse.mylyn.internal.bugzilla.ui.dialogs.BugzillaAttachmentDialog; import org.eclipse.mylyn.internal.bugzilla.ui.editor.BugzillaTaskEditorPage; import org.eclipse.mylyn.internal.bugzilla.ui.editor.FlagAttributeEditor; +import org.eclipse.mylyn.internal.bugzilla.ui.wizard.BugzillaAttachmentWizard; import org.eclipse.mylyn.internal.tasks.core.TaskTask; import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; +import org.eclipse.mylyn.internal.tasks.ui.wizards.NewAttachmentWizardDialog; import org.eclipse.mylyn.tasks.core.ITask; import org.eclipse.mylyn.tasks.core.ITaskAttachment; import org.eclipse.mylyn.tasks.core.TaskRepository; @@ -34,6 +31,8 @@ import org.eclipse.mylyn.tasks.core.data.TaskAttributeMetaData; import org.eclipse.mylyn.tasks.core.data.TaskData; import org.eclipse.mylyn.tasks.core.data.TaskDataModel; +import org.eclipse.mylyn.tasks.core.data.TaskDataModelEvent; +import org.eclipse.mylyn.tasks.core.data.TaskDataModelListener; import org.eclipse.mylyn.tasks.ui.TasksUi; import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor; import org.eclipse.mylyn.tasks.ui.editors.AttributeEditorFactory; @@ -128,40 +127,23 @@ }; TaskAttribute target = workingCopy.getLocalData().getRoot(); - BugzillaAttachmentDialog dialog = new BugzillaAttachmentDialog(shell, model, factory, target, false); - if (dialog.open() == Window.OK) { - TaskAttribute attachmentAttribute = attachment.getTaskAttribute(); - for (TaskAttribute child : target.getAttributes().values()) { - attachmentAttribute.deepAddCopy(child); + target.setValue(target0.getValue()); + + final BugzillaAttachmentWizard attachmentWizard = new BugzillaAttachmentWizard(shell, factory, target, + taskEditor, attachment); + final NewAttachmentWizardDialog dialog = new NewAttachmentWizardDialog(shell, attachmentWizard, false); + model.addModelListener(new TaskDataModelListener() { + + @Override + public void attributeChanged(TaskDataModelEvent event) { + attachmentWizard.setChanged(true); + dialog.updateButtons(); } - final ChangeAttachmentJob job = new ChangeAttachmentJob(attachment, taskEditor); - job.setUser(true); - job.addJobChangeListener(new JobChangeAdapter() { - - @Override - public void done(IJobChangeEvent event) { - IFormPage formPage = taskEditor.getActivePageInstance(); - if (formPage instanceof BugzillaTaskEditorPage) { - final BugzillaTaskEditorPage bugzillaPage = (BugzillaTaskEditorPage) formPage; - if (job.getError() != null) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - public void run() { - bugzillaPage.getTaskEditor().setMessage(job.getError().getMessage(), - IMessageProvider.ERROR); - } - }); - } else { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - public void run() { - bugzillaPage.refreshFormContent(); - } - }); - } - } - } - }); - job.schedule(); - } + }); + + dialog.setBlockOnOpen(false); + dialog.create(); + dialog.open(); } } } Index: src/org/eclipse/mylyn/internal/bugzilla/ui/action/ChangeAttachmentJob.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/ChangeAttachmentJob.java,v retrieving revision 1.1 diff -u -r1.1 ChangeAttachmentJob.java --- src/org/eclipse/mylyn/internal/bugzilla/ui/action/ChangeAttachmentJob.java 24 Jan 2010 14:30:08 -0000 1.1 +++ src/org/eclipse/mylyn/internal/bugzilla/ui/action/ChangeAttachmentJob.java 3 Feb 2010 19:56:29 -0000 @@ -60,7 +60,7 @@ } @Override - protected IStatus run(IProgressMonitor monitor) { + public IStatus run(IProgressMonitor monitor) { final ITask task; task = editor.getTaskEditorInput().getTask(); @@ -122,8 +122,6 @@ } catch (CoreException e) { StatusHandler.log(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN, "Update of an Attachment failed", e)); //$NON-NLS-1$ - } finally { - monitor.done(); } return Status.OK_STATUS; } Index: src/org/eclipse/mylyn/internal/bugzilla/ui/dialogs/BugzillaAttachmentDialog.java =================================================================== RCS file: src/org/eclipse/mylyn/internal/bugzilla/ui/dialogs/BugzillaAttachmentDialog.java diff -N src/org/eclipse/mylyn/internal/bugzilla/ui/dialogs/BugzillaAttachmentDialog.java --- src/org/eclipse/mylyn/internal/bugzilla/ui/dialogs/BugzillaAttachmentDialog.java 24 Jan 2010 14:30:07 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,289 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Frank Becker 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: - * Frank Becker - initial API and implementation - *******************************************************************************/ - -package org.eclipse.mylyn.internal.bugzilla.ui.dialogs; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.layout.GridDataFactory; -import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute; -import org.eclipse.mylyn.internal.bugzilla.ui.tasklist.Messages; -import org.eclipse.mylyn.tasks.core.data.TaskAttribute; -import org.eclipse.mylyn.tasks.core.data.TaskDataModel; -import org.eclipse.mylyn.tasks.core.data.TaskDataModelEvent; -import org.eclipse.mylyn.tasks.core.data.TaskDataModelListener; -import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor; -import org.eclipse.mylyn.tasks.ui.editors.AttributeEditorFactory; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.dialogs.SelectionDialog; -import org.eclipse.ui.forms.events.ExpansionAdapter; -import org.eclipse.ui.forms.events.ExpansionEvent; -import org.eclipse.ui.forms.widgets.ExpandableComposite; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * @author Frank Becker - */ -public class BugzillaAttachmentDialog extends SelectionDialog { - - private final FormToolkit toolkit; - - private Composite scrollComposite; - - private ExpandableComposite flagExpandComposite = null; - - private final TaskAttribute attachment; - - private final Shell parentShell; - - private final boolean readOnly; - - private final AttributeEditorFactory attributeEditorFactory; - - private static final int LABEL_WIDTH = 120; - - private static final int COLUMN_GAP = 5; - - private static final int MULTI_ROW_HEIGHT = 55; - - private static final int COLUMN_WIDTH = 200; - - private static final int MULTI_COLUMN_WIDTH = COLUMN_WIDTH + 5 + COLUMN_GAP + LABEL_WIDTH + 5 + COLUMN_WIDTH; - - private AbstractAttributeEditor commentEditor; - - private final TaskDataModel model; - - private boolean changed = false; - - public BugzillaAttachmentDialog(Shell parentShell, TaskDataModel model, AttributeEditorFactory factory, - TaskAttribute attachment, boolean readonly) { - super(parentShell); - this.attachment = attachment; - this.parentShell = parentShell; - this.readOnly = readonly; - attributeEditorFactory = factory; - this.model = model; - model.addModelListener(new TaskDataModelListener() { - - @Override - public void attributeChanged(TaskDataModelEvent event) { - if (!changed) { - changed = true; - getOkButton().setEnabled(changed); - - } - } - - }); - toolkit = new FormToolkit(Display.getCurrent()); - this.setTitle(readonly ? Messages.BugzillaAttachmentDialog_DetailTitle - : Messages.BugzillaAttachmentDialog_DetailTitle); - } - - @Override - protected Control createDialogArea(Composite parent) { - int currentColumn = 1; - int columnCount = 4; - Composite composite = (Composite) super.createDialogArea(parent); - - initializeDialogUnits(composite); - - Composite attributeArea = new Composite(composite, SWT.FLAT); - GridLayout layout = new GridLayout(4, false); - attributeArea.setLayout(layout); - createAttributeEditors(currentColumn, columnCount, attributeArea); - createCommentEditor(currentColumn, columnCount, attributeArea); - Composite advancedComposite = createFlagSection(attributeArea); - createFlagEditors(columnCount, advancedComposite); - createAttributeEditor(attachment.getMappedAttribute(TaskAttribute.ATTACHMENT_URL), currentColumn, columnCount, - advancedComposite); - Dialog.applyDialogFont(composite); - return composite; - } - - private void createAttributeEditor(TaskAttribute attribute, int currentColumn, int columnCount, - Composite attributeArea) { - String type = attribute.getMetaData().getType(); - if (type != null) { - AbstractAttributeEditor editor = attributeEditorFactory.createEditor(type, attribute); - if (attribute.getId().equals(BugzillaAttribute.TOKEN.getKey()) - || attribute.getId().equals("size") || attribute.getId().equals(TaskAttribute.ATTACHMENT_URL)) { //$NON-NLS-1$ - editor.setReadOnly(true); - } else { - editor.setReadOnly(readOnly); - } - if (editor.hasLabel()) { - editor.createLabelControl(attributeArea, toolkit); - Label label = editor.getLabelControl(); - label.setBackground(attributeArea.getBackground()); - String labelString = editor.getLabel(); - if (labelString != null && !labelString.equals("")) { //$NON-NLS-1$ - GridData gd = GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).hint(LABEL_WIDTH, - SWT.DEFAULT).create(); - if (currentColumn > 1) { - gd.horizontalIndent = COLUMN_GAP; - gd.widthHint = LABEL_WIDTH + COLUMN_GAP; - } - label.setLayoutData(gd); - currentColumn++; - } - } - editor.createControl(attributeArea, toolkit); - GridData gd = new GridData(SWT.FILL, SWT.CENTER, false, false); - if (type.equals(TaskAttribute.TYPE_BOOLEAN) || type.equals(TaskAttribute.TYPE_SHORT_TEXT) - || type.equals(TaskAttribute.TYPE_URL)) { - gd.horizontalSpan = 3; - } else { - gd.horizontalSpan = 1; - } - editor.getControl().setLayoutData(gd); - editor.getControl().setBackground(parentShell.getBackground()); - currentColumn += gd.horizontalSpan; - currentColumn %= columnCount; - } - } - - private void createAttributeEditors(int currentColumn, int columnCount, Composite attributeArea) { - createAttributeEditor(attachment.getMappedAttribute(TaskAttribute.ATTACHMENT_DESCRIPTION), currentColumn, - columnCount, attributeArea); - createAttributeEditor(attachment.getMappedAttribute(TaskAttribute.ATTACHMENT_FILENAME), currentColumn, - columnCount, attributeArea); - createAttributeEditor(attachment.getMappedAttribute(TaskAttribute.ATTACHMENT_SIZE), currentColumn, columnCount, - attributeArea); - createAttributeEditor(attachment.getMappedAttribute(TaskAttribute.ATTACHMENT_CONTENT_TYPE), currentColumn, - columnCount, attributeArea); - createAttributeEditor(attachment.getMappedAttribute(TaskAttribute.ATTACHMENT_IS_PATCH), currentColumn, - columnCount, attributeArea); - createAttributeEditor(attachment.getMappedAttribute(TaskAttribute.ATTACHMENT_IS_DEPRECATED), currentColumn, - columnCount, attributeArea); - } - - private void createFlagEditors(int columnCount, Composite advancedComposite) { - int currentFlagColumn = 1; - - for (TaskAttribute attribute : attachment.getAttributes().values()) { - if (!attribute.getId().startsWith("task.common.kind.flag")) { //$NON-NLS-1$ - continue; - } - String type = attribute.getMetaData().getType(); - if (type != null) { - AbstractAttributeEditor editor = attributeEditorFactory.createEditor(type, attribute); - editor.setReadOnly(readOnly); - - if (editor.hasLabel()) { - editor.createLabelControl(advancedComposite, toolkit); - Label label = editor.getLabelControl(); - label.setBackground(advancedComposite.getBackground()); - GridData gd = GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).hint(LABEL_WIDTH, - SWT.DEFAULT).create(); - if (currentFlagColumn > 1) { - gd.horizontalIndent = COLUMN_GAP; - gd.widthHint = LABEL_WIDTH + COLUMN_GAP; - } - label.setLayoutData(gd); - currentFlagColumn++; - } - editor.createControl(advancedComposite, toolkit); - GridData gd = new GridData(SWT.FILL, SWT.CENTER, false, false); - gd.widthHint = 150;//COLUMN_WIDTH; - gd.horizontalSpan = 3; - editor.getControl().setLayoutData(gd); - currentFlagColumn += gd.horizontalSpan; - currentFlagColumn %= columnCount; - editor.getControl().setBackground(parentShell.getBackground()); - } - } - } - - private void createCommentEditor(int currentColumn, int columnCount, Composite attributeArea) { - TaskAttribute commentAttribute = attachment.getAttribute("comment"); //$NON-NLS-1$ - if (commentAttribute == null || readOnly) { - return; - } - String type = commentAttribute.getMetaData().getType(); - if (type != null) { - commentEditor = attributeEditorFactory.createEditor(type, commentAttribute); - String labelString = commentEditor.getLabel(); - if (commentEditor.hasLabel()) { - commentEditor.createLabelControl(attributeArea, toolkit); - if (!labelString.equals("")) { //$NON-NLS-1$ - Label label = commentEditor.getLabelControl(); - label.setBackground(attributeArea.getBackground()); - GridData gd = GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.TOP).hint(LABEL_WIDTH, - SWT.DEFAULT).create(); - if (currentColumn > 1) { - gd.horizontalIndent = COLUMN_GAP; - gd.widthHint = LABEL_WIDTH + COLUMN_GAP; - } - label.setLayoutData(gd); - } - } - commentEditor.createControl(attributeArea, toolkit); - commentEditor.getControl().setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); - GridData gd = new GridData(SWT.FILL, SWT.CENTER, false, false); - gd.heightHint = MULTI_ROW_HEIGHT; - gd.widthHint = MULTI_COLUMN_WIDTH; - gd.horizontalSpan = 2;//columnCount - currentColumn + 1; - commentEditor.getControl().setLayoutData(gd); - toolkit.paintBordersFor(attributeArea); - } - } - - private Composite createFlagSection(Composite container) { - flagExpandComposite = toolkit.createExpandableComposite(container, ExpandableComposite.COMPACT - | ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR); - flagExpandComposite.setFont(container.getFont()); - flagExpandComposite.setBackground(container.getBackground()); - flagExpandComposite.setText(Messages.BugzillaTaskAttachmentPage_Advanced); - GridLayout gLayout = new GridLayout(4, false); - gLayout.horizontalSpacing = 0; - gLayout.marginWidth = 0; - flagExpandComposite.setLayout(new GridLayout(4, false)); - GridData g = new GridData(GridData.FILL_HORIZONTAL); - g.horizontalSpan = 4; - flagExpandComposite.setLayoutData(g); - flagExpandComposite.addExpansionListener(new ExpansionAdapter() { - @Override - public void expansionStateChanged(ExpansionEvent e) { - parentShell.getDisplay().getActiveShell().pack(); - } - }); - - scrollComposite = new Composite(flagExpandComposite, SWT.NONE); - GridLayout gLayout2 = new GridLayout(4, false); - gLayout2.horizontalSpacing = 0; - scrollComposite.setLayout(gLayout2); - flagExpandComposite.setClient(scrollComposite); - return scrollComposite; - } - - @Override - protected void okPressed() { - commentEditor.getControl().forceFocus(); - super.okPressed(); - } - - @Override - protected Control createButtonBar(Composite parent) { - Control control = super.createButtonBar(parent); - getOkButton().setText(Messages.BugzillaAttachmentDialog_OK_ButtonText); - getOkButton().setEnabled(changed); - return control; - } - -} \ No newline at end of file Index: src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java,v retrieving revision 1.43 diff -u -r1.43 BugzillaTaskEditorPage.java --- src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java 24 Jan 2010 14:30:07 -0000 1.43 +++ src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java 3 Feb 2010 19:56:29 -0000 @@ -139,7 +139,7 @@ } else if (IBugzillaConstants.EDITOR_TYPE_VOTES.equals(type)) { editor = new BugzillaVotesEditor(getModel(), taskAttribute); } else if (IBugzillaConstants.EDITOR_TYPE_FLAG.equals(type)) { - editor = new FlagAttributeEditor(getModel(), taskAttribute, 78); + editor = new FlagAttributeEditor(getModel(), taskAttribute, 105); } else { editor = super.createEditor(type, taskAttribute); if (TaskAttribute.TYPE_BOOLEAN.equals(type)) { Index: src/org/eclipse/mylyn/internal/bugzilla/ui/editor/FlagAttributeEditor.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/FlagAttributeEditor.java,v retrieving revision 1.8 diff -u -r1.8 FlagAttributeEditor.java --- src/org/eclipse/mylyn/internal/bugzilla/ui/editor/FlagAttributeEditor.java 24 Jan 2010 14:30:07 -0000 1.8 +++ src/org/eclipse/mylyn/internal/bugzilla/ui/editor/FlagAttributeEditor.java 3 Feb 2010 19:56:29 -0000 @@ -20,6 +20,10 @@ import org.eclipse.mylyn.tasks.ui.editors.LayoutHint.RowSpan; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.CCombo; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.KeyListener; +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; @@ -53,7 +57,7 @@ @Override public void createControl(Composite parent, FormToolkit toolkit) { final Composite composite = toolkit.createComposite(parent); - GridLayout layout = new GridLayout(3, false); + GridLayout layout = new GridLayout(2, false); layout.marginWidth = 1; composite.setLayout(layout); if (isReadOnly()) { @@ -117,9 +121,31 @@ if (requestee != null && !requestee.getMetaData().isReadOnly()) { requesteeText = toolkit.createText(composite, requestee.getValue()); requesteeText.setEnabled("?".equals(getValueLabel())); //$NON-NLS-1$ - GridData requesteeData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); + GridData requesteeData = new GridData(SWT.FILL, SWT.CENTER, false, false); requesteeData.widthHint = requesteeTextHint; requesteeText.setLayoutData(requesteeData); + requesteeText.setFont(EditorUtil.TEXT_FONT); + requesteeText.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER); + + requesteeText.addKeyListener(new KeyListener() { + + public void keyReleased(KeyEvent e) { + // ignore + setRequestee(requesteeText.getText()); + + } + + public void keyPressed(KeyEvent e) { + } + }); + requesteeText.addModifyListener(new ModifyListener() { + + public void modifyText(ModifyEvent e) { + setRequestee(requesteeText.getText()); + } + }); + toolkit.adapt(requesteeText, false, false); + } } toolkit.paintBordersFor(composite); @@ -127,12 +153,10 @@ } public String getValue() { -// return getAttributeMapper().getValue(getTaskAttribute()); return getAttributeMapper().getValue(getAttributeMapper().getAssoctiatedAttribute(getTaskAttribute())); } public String getValueLabel() { -// return getAttributeMapper().getValueLabel(getTaskAttribute()); return getAttributeMapper().getValueLabel(getAttributeMapper().getAssoctiatedAttribute(getTaskAttribute())); } @@ -153,8 +177,10 @@ TaskAttribute requestee = getTaskAttribute().getAttribute("requestee"); //$NON-NLS-1$ if (requestee != null) { if (!requestee.getValue().equals(value)) { - getAttributeMapper().setValue(requestee, value); - attributeChanged(); + if (!requestee.getValue().equals(value)) { + getAttributeMapper().setValue(requestee, value); + attributeChanged(); + } } } } Index: src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/Messages.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/Messages.java,v retrieving revision 1.5 diff -u -r1.5 Messages.java --- src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/Messages.java 24 Jan 2010 14:30:07 -0000 1.5 +++ src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/Messages.java 3 Feb 2010 19:56:29 -0000 @@ -81,8 +81,4 @@ public static String BugzillaTaskAttachmentPage_Advanced; - public static String BugzillaAttachmentDialog_DetailTitle; - - public static String BugzillaAttachmentDialog_OK_ButtonText; - } Index: src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/messages.properties =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/messages.properties,v retrieving revision 1.5 diff -u -r1.5 messages.properties --- src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/messages.properties 24 Jan 2010 14:30:07 -0000 1.5 +++ src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/messages.properties 3 Feb 2010 19:56:29 -0000 @@ -39,5 +39,3 @@ BugzillaRepositorySettingsPage_supports_bugzilla_X=Supports Bugzilla {0} BugzillaRepositorySettingsPage_Validating_server_settings=Validating server settings BugzillaTaskAttachmentPage_Advanced=Advanced -BugzillaAttachmentDialog_DetailTitle=Attachment Details -BugzillaAttachmentDialog_OK_ButtonText=Update Index: src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/BugzillaAttachmentWizard.java =================================================================== RCS file: src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/BugzillaAttachmentWizard.java diff -N src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/BugzillaAttachmentWizard.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/BugzillaAttachmentWizard.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,165 @@ +/******************************************************************************* + * Copyright (c) 2010 Frank Becker 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: + * Frank Becker - initial API and implementation + *******************************************************************************/ + +package org.eclipse.mylyn.internal.bugzilla.ui.wizard; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.dialogs.IMessageProvider; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.mylyn.commons.core.StatusHandler; +import org.eclipse.mylyn.internal.bugzilla.ui.BugzillaUiPlugin; +import org.eclipse.mylyn.internal.bugzilla.ui.action.ChangeAttachmentJob; +import org.eclipse.mylyn.internal.bugzilla.ui.editor.BugzillaTaskEditorPage; +import org.eclipse.mylyn.tasks.core.ITaskAttachment; +import org.eclipse.mylyn.tasks.core.data.TaskAttribute; +import org.eclipse.mylyn.tasks.ui.editors.AttributeEditorFactory; +import org.eclipse.mylyn.tasks.ui.editors.TaskEditor; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.forms.editor.IFormPage; + +public class BugzillaAttachmentWizard extends Wizard { + + private final AttributeEditorFactory factory; + + private final TaskAttribute attachmentAttribute; + + private BugzillaAttachmentWizardPage attachmentWizardPage; + + private final Shell parentShell; + + private boolean changed = false; + + private final TaskEditor taskEditor; + + private final ITaskAttachment attachment; + + public BugzillaAttachmentWizard(Shell parentShell, AttributeEditorFactory factory, + TaskAttribute attachmentAttribute, TaskEditor taskEditor, ITaskAttachment attachment) { + super(); + this.factory = factory; + this.attachmentAttribute = attachmentAttribute; + this.parentShell = parentShell; + this.taskEditor = taskEditor; + this.attachment = attachment; + setNeedsProgressMonitor(true); + + } + + @Override + public boolean performFinish() { + TaskAttribute attachmentTaskAttribute = attachment.getTaskAttribute(); + for (TaskAttribute child : attachmentAttribute.getAttributes().values()) { + attachmentTaskAttribute.deepAddCopy(child); + } + + final ChangeAttachmentJob job = new ChangeAttachmentJob(attachment, taskEditor); + job.setUser(true); + if (attachmentWizardPage.runInBackground()) { + runInBackground(job); + } else { + runInWizard(job); + } + return true; + } + + private void handleDone(final ChangeAttachmentJob job, IProgressMonitor monitor) { + try { + if (job.getError() != null) { + IFormPage formPage = taskEditor.getActivePageInstance(); + if (formPage instanceof BugzillaTaskEditorPage) { + final BugzillaTaskEditorPage bugzillaPage = (BugzillaTaskEditorPage) formPage; + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + public void run() { + bugzillaPage.getTaskEditor() + .setMessage(job.getError().getMessage(), IMessageProvider.ERROR); + } + }); + } + } else { + monitor.setTaskName(Messages.BugzillaAttachmentWizard_Now_synchronize_the_Task); + IFormPage formPage = taskEditor.getActivePageInstance(); + if (formPage instanceof BugzillaTaskEditorPage) { + final BugzillaTaskEditorPage bugzillaPage = (BugzillaTaskEditorPage) formPage; + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + public void run() { + bugzillaPage.refreshFormContent(); + } + }); + } + } + } finally { + monitor.done(); + } + } + + private boolean runInWizard(final ChangeAttachmentJob job) { + try { + getContainer().run(true, true, new IRunnableWithProgress() { + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { +// try { + job.run(monitor); +// } finally { +// handleDone(job, monitor); +// } + } + }); + return true; + } catch (InvocationTargetException e) { + StatusHandler.fail(new Status(IStatus.ERROR, BugzillaUiPlugin.ID_PLUGIN, "Unexpected error", e)); //$NON-NLS-1$ + return false; + } catch (InterruptedException e) { + // canceled + return false; + } + } + + private void runInBackground(final ChangeAttachmentJob job) { +// getContainer().getShell().setVisible(false); +// job.addJobChangeListener(new JobChangeAdapter() { +// @Override +// public void done(IJobChangeEvent event) { +// Display.getDefault().asyncExec(new Runnable() { +// public void run() { +//// handleDone(job, new NullProgressMonitor()); +// } +// }); +// } +// }); + job.schedule(); + } + + @Override + public void addPages() { + attachmentWizardPage = new BugzillaAttachmentWizardPage(parentShell, factory, attachmentAttribute, + attachment.getTask().getTaskId()); + addPage(attachmentWizardPage); + } + + @Override + public boolean canFinish() { + return isChanged(); + } + + public boolean isChanged() { + return changed; + } + + public void setChanged(boolean changed) { + this.changed = changed; + } + +} Index: src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/Messages.java =================================================================== RCS file: src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/Messages.java diff -N src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/Messages.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/Messages.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2010 Tasktop Technologies 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: + * Tasktop Technologies - initial API and implementation + *******************************************************************************/ + +package org.eclipse.mylyn.internal.bugzilla.ui.wizard; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.mylyn.internal.bugzilla.ui.wizard.messages"; //$NON-NLS-1$ + + public static String BugzillaAttachmentWizard_Now_synchronize_the_Task; + + public static String BugzillaAttachmentWizardPage_Advanced; + + public static String BugzillaAttachmentWizardPage_Description; + + public static String BugzillaAttachmentWizardPage_Titel; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} Index: src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/messages.properties =================================================================== RCS file: src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/messages.properties diff -N src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/messages.properties --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/messages.properties 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,4 @@ +BugzillaAttachmentWizard_Now_synchronize_the_Task=Updating Attachment: Now synchronize the Task +BugzillaAttachmentWizardPage_Advanced=Advanced +BugzillaAttachmentWizardPage_Description=Show Attachment {0} Details for Bug {1} +BugzillaAttachmentWizardPage_Titel=Attachment Detail