diff options
14 files changed, 950 insertions, 664 deletions
diff --git a/org.eclipse.mylyn.bugzilla.ui/META-INF/MANIFEST.MF b/org.eclipse.mylyn.bugzilla.ui/META-INF/MANIFEST.MF index 3640b8d62..5024e0e61 100644 --- a/org.eclipse.mylyn.bugzilla.ui/META-INF/MANIFEST.MF +++ b/org.eclipse.mylyn.bugzilla.ui/META-INF/MANIFEST.MF @@ -22,7 +22,6 @@ Require-Bundle: org.eclipse.ui, Bundle-ActivationPolicy: lazy Export-Package: org.eclipse.mylyn.internal.bugzilla.ui;x-internal:=true, org.eclipse.mylyn.internal.bugzilla.ui.action;x-internal:=true, - org.eclipse.mylyn.internal.bugzilla.ui.dialogs;x-internal:=true, org.eclipse.mylyn.internal.bugzilla.ui.editor;x-internal:=true, org.eclipse.mylyn.internal.bugzilla.ui.search;x-internal:=true, org.eclipse.mylyn.internal.bugzilla.ui.tasklist;x-internal:=true, diff --git a/org.eclipse.mylyn.bugzilla.ui/icons/wizban/banner-attachment-update.gif b/org.eclipse.mylyn.bugzilla.ui/icons/wizban/banner-attachment-update.gif Binary files differnew file mode 100644 index 000000000..700c882ee --- /dev/null +++ b/org.eclipse.mylyn.bugzilla.ui/icons/wizban/banner-attachment-update.gif diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaAttachmentUpdateAction.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaAttachmentUpdateAction.java index a4b0a6e2c..579785910 100644 --- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaAttachmentUpdateAction.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaAttachmentUpdateAction.java @@ -13,19 +13,16 @@ package org.eclipse.mylyn.internal.bugzilla.ui.action; 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.TaskAttribute; 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 @@ public class BugzillaAttachmentUpdateAction extends BaseSelectionListenerAction }; 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(); } } } diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/ChangeAttachmentJob.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/ChangeAttachmentJob.java index f754da27d..0c8c2d3a2 100644 --- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/ChangeAttachmentJob.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/ChangeAttachmentJob.java @@ -60,7 +60,7 @@ public class ChangeAttachmentJob extends Job { } @Override - protected IStatus run(IProgressMonitor monitor) { + public IStatus run(IProgressMonitor monitor) { final ITask task; task = editor.getTaskEditorInput().getTask(); diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/dialogs/BugzillaAttachmentDialog.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/dialogs/BugzillaAttachmentDialog.java deleted file mode 100644 index 007d37aa8..000000000 --- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/dialogs/BugzillaAttachmentDialog.java +++ /dev/null @@ -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 diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java index 04a98330f..d1215dd5c 100644 --- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java @@ -139,7 +139,7 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage { } 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)) { diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/FlagAttributeEditor.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/FlagAttributeEditor.java index 241f59bf2..ad5217eed 100644 --- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/FlagAttributeEditor.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/FlagAttributeEditor.java @@ -20,6 +20,10 @@ import org.eclipse.mylyn.tasks.ui.editors.LayoutHint.ColumnSpan; 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 @@ public class FlagAttributeEditor extends AbstractAttributeEditor { @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 @@ public class FlagAttributeEditor extends AbstractAttributeEditor { 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 class FlagAttributeEditor extends AbstractAttributeEditor { } 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 @@ public class FlagAttributeEditor extends AbstractAttributeEditor { 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(); + } } } } diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java index 0b40d8171..17d696423 100644 --- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java @@ -75,6 +75,10 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.fieldassist.ContentAssistCommandAdapter; +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; import org.eclipse.ui.progress.IProgressService; import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds; @@ -258,6 +262,10 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage implements L private RepositoryConfiguration repositoryConfiguration; + private final FormToolkit toolkit; + + private ExpandableComposite advancedExpandComposite; + private final SelectionAdapter updateActionSelectionAdapter = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { @@ -300,44 +308,19 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage implements L public BugzillaSearchPage(TaskRepository repository) { super(Messages.BugzillaSearchPage_Bugzilla_Query, repository); - // setTitle(TITLE); - // setDescription(DESCRIPTION); - // setImageDescriptor(TaskListImages.BANNER_REPOSITORY); - // setPageComplete(false); -// try { -// repositoryConfiguration = BugzillaCorePlugin.getRepositoryConfiguration(repository, false); -// } catch (final CoreException e) { -// PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { -// public void run() { -// MessageDialog.openError(Display.getDefault().getActiveShell(), "Bugzilla Search Page", -// "Unable to get configuration. Ensure proper repository configuration in " -// + TasksUiPlugin.LABEL_VIEW_REPOSITORIES + ".\n\n"); -// } -// }); -// } + + toolkit = new FormToolkit(Display.getCurrent()); } public BugzillaSearchPage(TaskRepository repository, IRepositoryQuery origQuery) { super(Messages.BugzillaSearchPage_Bugzilla_Query, repository, origQuery); originalQuery = origQuery; setDescription(Messages.BugzillaSearchPage_Select_the_Bugzilla_query_parameters); - // setTitle(TITLE); - // setDescription(DESCRIPTION); - // setPageComplete(false); -// try { -// repositoryConfiguration = BugzillaCorePlugin.getRepositoryConfiguration(repository, false); -// } catch (final CoreException e) { -// PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { -// public void run() { -// MessageDialog.openError(Display.getDefault().getActiveShell(), "Bugzilla Search Page", -// "Unable to get configuration. Ensure proper repository configuration in " -// + TasksUiPlugin.LABEL_VIEW_REPOSITORIES + ".\n\n"); -// } -// }); -// } + toolkit = new FormToolkit(Display.getCurrent()); } public void createControl(Composite parent) { + initializeDialogUnits(parent); readConfiguration(); Composite control = new Composite(parent, SWT.NONE); @@ -345,86 +328,125 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage implements L layout.marginHeight = 0; control.setLayout(layout); control.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL)); - -// if (scontainer == null) { - // Not presenting in search pane so want query title -// super.createControl(control); -// Label lblName = new Label(control, SWT.NONE); -// final GridData gridData = new GridData(); -// lblName.setLayoutData(gridData); -// lblName.setText("Query Title:"); -// -// title = new Text(control, SWT.BORDER); -// title.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1)); -// title.addModifyListener(new ModifyListener() { -// public void modifyText(ModifyEvent e) { -// setPageComplete(isPageComplete()); -// } -// }); -// } - - // else { - // // if (repository == null) { - // // search pane so add repository selection - // createRepositoryGroup(control); - // } createOptionsGroup(control); - createSearchGroup(control); - - // createSaveQuery(control); - // createMaxHits(control); - // input = new SavedQueryFile(BugzillaPlugin.getDefault().getStateLocation().toString(), "/queries"); - // createUpdate(control); - // if (originalQuery != null) { - // try { - // updateDefaults(originalQuery.getQueryUrl(), String.valueOf(originalQuery.getMaxHits())); - // } catch (UnsupportedEncodingException e) { - // // ignore - // } - // } + createButtons(control); Dialog.applyDialogFont(control); setControl(control); PlatformUI.getWorkbench().getHelpSystem().setHelp(control, BugzillaUiPlugin.SEARCH_PAGE_CONTEXT); restoreBounds(); } - protected void createOptionsGroup(Composite control) { - GridLayout sashFormLayout = new GridLayout(); - sashFormLayout.numColumns = 4; - sashFormLayout.marginHeight = 5; - sashFormLayout.marginWidth = 5; - sashFormLayout.horizontalSpacing = 5; + private void createButtons(Composite control) { + Composite buttonComposite = new Composite(control, SWT.NONE); + buttonComposite.setLayout(new GridLayout(2, false)); + GridData g = new GridData(GridData.FILL_HORIZONTAL); + g.widthHint = 500; + g.heightHint = 200; + Button clearButton = new Button(buttonComposite, SWT.PUSH); + clearButton.setText(Messages.BugzillaSearchPage_ClearFields); + clearButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false)); + clearButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + product.deselectAll(); + component.deselectAll(); + version.deselectAll(); + target.deselectAll(); + status.deselectAll(); + resolution.deselectAll(); + severity.deselectAll(); + priority.deselectAll(); + hardware.deselectAll(); + os.deselectAll(); + summaryOperation.deselectAll(); + commentOperation.deselectAll(); + emailOperation.deselectAll(); + + for (Button emailButton : emailButtons) { + emailButton.setSelection(false); + } + summaryPattern.setText(""); //$NON-NLS-1$ + commentPattern.setText(""); //$NON-NLS-1$ + emailPattern.setText(""); //$NON-NLS-1$ + emailOperation2.deselectAll(); + for (Button element : emailButtons2) { + element.setSelection(false); + } + emailPattern2.setText(""); //$NON-NLS-1$ + keywords.setText(""); //$NON-NLS-1$ + keywordsOperation.deselectAll(); + daysText.setText(""); //$NON-NLS-1$ + } + }); - final Composite composite = new Composite(control, SWT.NONE); - composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); - final GridLayout gridLayout = new GridLayout(); - gridLayout.marginBottom = 8; - gridLayout.marginHeight = 0; - gridLayout.marginWidth = 0; - gridLayout.numColumns = 4; - composite.setLayout(gridLayout); + Button updateButton = new Button(buttonComposite, SWT.PUSH); + updateButton.setText(Messages.BugzillaSearchPage_Update_Attributes_from_Repository); + updateButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false)); + updateButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (getTaskRepository() != null) { + updateConfiguration(true); + } else { + MessageDialog.openInformation(Display.getCurrent().getActiveShell(), + IBugzillaConstants.TITLE_MESSAGE_DIALOG, + Messages.BugzillaSearchPage_No_repository_available); + } + } + }); + + buttonComposite.setLayoutData(g); + Dialog.applyDialogFont(buttonComposite); - if (!inSearchContainer()) { - final Label queryTitleLabel = new Label(composite, SWT.NONE); - queryTitleLabel.setText(Messages.BugzillaSearchPage_Query_Title); + } - queryTitle = new Text(composite, SWT.BORDER); - queryTitle.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1)); - if (originalQuery != null) { - queryTitle.setText(originalQuery.getSummary()); + private void createOptionsGroup(Composite control) { + Composite basicComposite = new Composite(control, SWT.NONE); + basicComposite.setLayout(new GridLayout(4, false)); + GridData g = new GridData(GridData.FILL_HORIZONTAL); + g.widthHint = 500; + g.heightHint = 200; + basicComposite.setLayoutData(g); + Dialog.applyDialogFont(basicComposite); + + advancedExpandComposite = toolkit.createExpandableComposite(control, ExpandableComposite.COMPACT + | ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR); + advancedExpandComposite.setFont(control.getFont()); + advancedExpandComposite.setBackground(null); + advancedExpandComposite.setText(Messages.BugzillaSearchPage_Advanced); + advancedExpandComposite.setLayout(new GridLayout(3, false)); + g = new GridData(GridData.FILL_HORIZONTAL); + g.horizontalSpan = 3; + advancedExpandComposite.setLayoutData(g); + advancedExpandComposite.addExpansionListener(new ExpansionAdapter() { + @Override + public void expansionStateChanged(ExpansionEvent e) { + getControl().getShell().pack(); } - queryTitle.addModifyListener(new ModifyListenerImplementation()); - queryTitle.setFocus(); - } + }); + Composite advancedComposite = new Composite(advancedExpandComposite, SWT.NULL); + advancedComposite.setLayout(new GridLayout(4, false)); + g = new GridData(GridData.FILL_HORIZONTAL); + g.widthHint = 500; + g.heightHint = 200; + + advancedComposite.setLayoutData(g); + Dialog.applyDialogFont(advancedComposite); + advancedExpandComposite.setClient(advancedComposite); + + createBasicComposite(basicComposite); + createAdvancedComposite(advancedComposite); + createSearchGroup(advancedComposite); + } + + private void createBasicComposite(Composite basicComposite) { // Info text - Label labelSummary = new Label(composite, SWT.LEFT); + Label labelSummary = new Label(basicComposite, SWT.LEFT); labelSummary.setText(Messages.BugzillaSearchPage_Summary); -// labelSummary.setLayoutData(new GridData(LABEL_WIDTH, SWT.DEFAULT)); - //labelSummary.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); // Pattern combo - summaryPattern = new Combo(composite, SWT.SINGLE | SWT.BORDER); + summaryPattern = new Combo(basicComposite, SWT.SINGLE | SWT.BORDER); summaryPattern.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); summaryPattern.addModifyListener(new ModifyListenerImplementation()); summaryPattern.addSelectionListener(new SelectionAdapter() { @@ -434,39 +456,17 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage implements L } }); - summaryOperation = new Combo(composite, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER); + summaryOperation = new Combo(basicComposite, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER); summaryOperation.setItems(patternOperationText); summaryOperation.setText(patternOperationText[0]); summaryOperation.select(0); - - // Info text - Label labelComment = new Label(composite, SWT.LEFT); - labelComment.setText(Messages.BugzillaSearchPage_Comment); - //labelComment.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); - - // Comment pattern combo - commentPattern = new Combo(composite, SWT.SINGLE | SWT.BORDER); - commentPattern.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1)); - commentPattern.addModifyListener(new ModifyListenerImplementation()); - commentPattern.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - handleWidgetSelected(commentPattern, commentOperation, previousCommentPatterns); - } - }); - - commentOperation = new Combo(composite, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER); - commentOperation.setItems(patternOperationText); - commentOperation.setText(patternOperationText[0]); - commentOperation.select(0); - - Label labelEmail = new Label(composite, SWT.LEFT); + Label labelEmail = new Label(basicComposite, SWT.LEFT); labelEmail.setText(Messages.BugzillaSearchPage_Email); //labelEmail.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); // pattern combo - emailPattern = new Combo(composite, SWT.SINGLE | SWT.BORDER); - emailPattern.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + emailPattern = new Combo(basicComposite, SWT.SINGLE | SWT.BORDER); + emailPattern.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1)); emailPattern.addModifyListener(new ModifyListenerImplementation()); emailPattern.addSelectionListener(new SelectionAdapter() { @Override @@ -484,8 +484,15 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage implements L adapter.setLabelProvider(proposalLabelProvider); adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); - Composite emailComposite = new Composite(composite, SWT.NONE); - emailComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + // operation combo + emailOperation = new Combo(basicComposite, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER); + emailOperation.setItems(emailOperationText); + emailOperation.setText(emailOperationText[0]); + emailOperation.select(0); + + new Label(basicComposite, SWT.NONE); + Composite emailComposite = new Composite(basicComposite, SWT.NONE); + emailComposite.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 2, 1)); GridLayout emailLayout = new GridLayout(); emailLayout.marginWidth = 0; emailLayout.marginHeight = 0; @@ -509,22 +516,144 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage implements L button4.setText(Messages.BugzillaSearchPage_qacontact); emailButtons = new Button[] { button0, button1, button2, button3, button4 }; + new Label(basicComposite, SWT.NONE); + GridLayout sashFormLayout = new GridLayout(); + sashFormLayout.numColumns = 4; + sashFormLayout.marginHeight = 5; + sashFormLayout.marginWidth = 5; + sashFormLayout.horizontalSpacing = 5; - // operation combo - emailOperation = new Combo(composite, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER); - emailOperation.setItems(emailOperationText); - emailOperation.setText(emailOperationText[0]); - emailOperation.select(0); + SashForm sashForm = new SashForm(basicComposite, SWT.VERTICAL); + sashForm.setLayout(sashFormLayout); + final GridData gd_sashForm = new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1); + gd_sashForm.widthHint = 400; + gd_sashForm.heightHint = 100; + sashForm.setLayoutData(gd_sashForm); + + GridLayout topLayout = new GridLayout(); + topLayout.numColumns = 4; + SashForm topForm = new SashForm(sashForm, SWT.NONE); + GridData topLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1); + topLayoutData.widthHint = 00; + topLayoutData.heightHint = 100; + topForm.setLayoutData(topLayoutData); + topForm.setLayout(topLayout); + + GridLayout productLayout = new GridLayout(); + productLayout.marginWidth = 0; + productLayout.marginHeight = 0; + productLayout.horizontalSpacing = 0; + Composite productComposite = new Composite(topForm, SWT.NONE); + productComposite.setLayout(productLayout); + + Label productLabel = new Label(productComposite, SWT.LEFT); + productLabel.setText(Messages.BugzillaSearchPage_Product); + productLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + GridData productLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true); + productLayoutData.heightHint = HEIGHT_ATTRIBUTE_COMBO; + product = new List(productComposite, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER); + product.setLayoutData(productLayoutData); + product.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (product.getSelectionIndex() != -1) { + String[] selectedProducts = product.getSelection(); + updateAttributesFromConfiguration(selectedProducts); + } else { + updateAttributesFromConfiguration(null); + } + if (restoring) { + restoring = false; + restoreWidgetValues(); + } + setPageComplete(isPageComplete()); + } + }); + + GridLayout componentLayout = new GridLayout(); + componentLayout.marginWidth = 0; + componentLayout.marginHeight = 0; + componentLayout.horizontalSpacing = 0; + Composite componentComposite = new Composite(topForm, SWT.NONE); + componentComposite.setLayout(componentLayout); + + Label componentLabel = new Label(componentComposite, SWT.LEFT); + componentLabel.setText(Messages.BugzillaSearchPage_Component); + componentLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + component = new List(componentComposite, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER); + GridData componentLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true); + componentLayoutData.heightHint = HEIGHT_ATTRIBUTE_COMBO; + component.setLayoutData(componentLayoutData); + component.addSelectionListener(updateActionSelectionAdapter); + + Composite statusComposite = new Composite(topForm, SWT.NONE); + GridLayout statusLayout = new GridLayout(); + statusLayout.marginWidth = 0; + statusLayout.horizontalSpacing = 0; + statusLayout.marginHeight = 0; + statusComposite.setLayout(statusLayout); + + Label statusLabel = new Label(statusComposite, SWT.LEFT); + statusLabel.setText(Messages.BugzillaSearchPage_Status); + statusLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + status = new List(statusComposite, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER); + final GridData gd_status = new GridData(SWT.FILL, SWT.FILL, true, true); + gd_status.heightHint = HEIGHT_ATTRIBUTE_COMBO; + status.setLayoutData(gd_status); + status.addSelectionListener(updateActionSelectionAdapter); + + Composite priorityComposite = new Composite(topForm, SWT.NONE); + GridLayout priorityLayout = new GridLayout(); + priorityLayout.marginWidth = 0; + priorityLayout.marginHeight = 0; + priorityLayout.horizontalSpacing = 0; + priorityComposite.setLayout(priorityLayout); + + Label priorityLabel = new Label(priorityComposite, SWT.LEFT); + priorityLabel.setText(Messages.BugzillaSearchPage_PROORITY); + priorityLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + priority = new List(priorityComposite, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER); + final GridData gd_priority = new GridData(SWT.FILL, SWT.FILL, true, true); + gd_priority.heightHint = HEIGHT_ATTRIBUTE_COMBO; + priority.setLayoutData(gd_priority); + priority.addSelectionListener(updateActionSelectionAdapter); + + } + + private void createAdvancedComposite(Composite advancedComposite) { + + // Info text + Label labelComment = new Label(advancedComposite, SWT.LEFT); + labelComment.setText(Messages.BugzillaSearchPage_Comment); + //labelComment.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); + + // Comment pattern combo + commentPattern = new Combo(advancedComposite, SWT.SINGLE | SWT.BORDER); + commentPattern.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1)); + commentPattern.addModifyListener(new ModifyListenerImplementation()); + commentPattern.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + handleWidgetSelected(commentPattern, commentOperation, previousCommentPatterns); + } + }); - // Email2 + commentOperation = new Combo(advancedComposite, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER); + commentOperation.setItems(patternOperationText); + commentOperation.setText(patternOperationText[0]); + commentOperation.select(0); - Label labelEmail2 = new Label(composite, SWT.LEFT); + Label labelEmail2 = new Label(advancedComposite, SWT.LEFT); labelEmail2.setText(Messages.BugzillaSearchPage_Email_2); //labelEmail.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); // pattern combo - emailPattern2 = new Combo(composite, SWT.SINGLE | SWT.BORDER); - emailPattern2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + emailPattern2 = new Combo(advancedComposite, SWT.SINGLE | SWT.BORDER); + emailPattern2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1)); emailPattern2.addModifyListener(new ModifyListenerImplementation()); emailPattern2.addSelectionListener(new SelectionAdapter() { @Override @@ -532,14 +661,25 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage implements L handleWidgetSelected(emailPattern2, emailOperation2, previousEmailPatterns2); } }); + IContentProposalProvider proposalProvider = TasksUi.getUiFactory().createPersonContentProposalProvider( + getTaskRepository()); + ILabelProvider proposalLabelProvider = TasksUi.getUiFactory().createPersonContentProposalLabelProvider( + getTaskRepository()); ContentAssistCommandAdapter adapter2 = new ContentAssistCommandAdapter(emailPattern2, new ComboContentAdapter(), proposalProvider, ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, new char[0], true); - adapter.setLabelProvider(proposalLabelProvider); + adapter2.setLabelProvider(proposalLabelProvider); adapter2.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); - Composite emailComposite2 = new Composite(composite, SWT.NONE); - emailComposite2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + // operation combo + emailOperation2 = new Combo(advancedComposite, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER); + emailOperation2.setItems(emailOperationText); + emailOperation2.setText(emailOperationText[0]); + emailOperation2.select(0); + + new Label(advancedComposite, SWT.NONE); + Composite emailComposite2 = new Composite(advancedComposite, SWT.NONE); + emailComposite2.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 2, 1)); GridLayout emailLayout2 = new GridLayout(); emailLayout2.marginWidth = 0; emailLayout2.marginHeight = 0; @@ -563,21 +703,11 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage implements L e2button4.setText(Messages.BugzillaSearchPage_qacontact); emailButtons2 = new Button[] { e2button0, e2button1, e2button2, e2button3, e2button4 }; + new Label(advancedComposite, SWT.NONE); + Label keywordsLabel = new Label(advancedComposite, SWT.NONE); + keywordsLabel.setText(Messages.BugzillaSearchPage_Keywords); - // operation combo - emailOperation2 = new Combo(composite, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER); - emailOperation2.setItems(emailOperationText); - emailOperation2.setText(emailOperationText[0]); - emailOperation2.select(0); - - ///// - - Label labelKeywords = new Label(composite, SWT.NONE); - labelKeywords.setText(Messages.BugzillaSearchPage_Keywords); -// labelKeywords.setLayoutData(new GridData(LABEL_WIDTH, SWT.DEFAULT)); - //labelKeywords.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); - - Composite keywordsComposite = new Composite(composite, SWT.NONE); + Composite keywordsComposite = new Composite(advancedComposite, SWT.NONE); keywordsComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 3, 1)); GridLayout keywordsLayout = new GridLayout(); keywordsLayout.marginWidth = 0; @@ -616,70 +746,51 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage implements L }); keywordsSelectButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); keywordsSelectButton.setText(Messages.BugzillaSearchPage_Select_); - SashForm sashForm = new SashForm(control, SWT.VERTICAL); - sashForm.setLayout(sashFormLayout); - final GridData gd_sashForm = new GridData(SWT.FILL, SWT.FILL, true, true); - gd_sashForm.widthHint = 500; - sashForm.setLayoutData(gd_sashForm); - GridLayout topLayout = new GridLayout(); - topLayout.numColumns = 4; - SashForm topForm = new SashForm(sashForm, SWT.NONE); - GridData topLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1); - topLayoutData.widthHint = 500; - topForm.setLayoutData(topLayoutData); - topForm.setLayout(topLayout); + SashForm bottomForm = new SashForm(advancedComposite, SWT.NONE); + GridLayout bottomLayout = new GridLayout(); + bottomLayout.numColumns = 6; + bottomForm.setLayout(bottomLayout); + GridData bottomLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1); + bottomLayoutData.heightHint = 119; + bottomLayoutData.widthHint = 400; + bottomForm.setLayoutData(bottomLayoutData); - GridLayout productLayout = new GridLayout(); - productLayout.marginWidth = 0; - productLayout.marginHeight = 0; - productLayout.horizontalSpacing = 0; - Composite productComposite = new Composite(topForm, SWT.NONE); - productComposite.setLayout(productLayout); + Composite severityComposite = new Composite(bottomForm, SWT.NONE); + GridLayout severityLayout = new GridLayout(); + severityLayout.marginWidth = 0; + severityLayout.marginHeight = 0; + severityLayout.horizontalSpacing = 0; + severityComposite.setLayout(severityLayout); - Label productLabel = new Label(productComposite, SWT.LEFT); - productLabel.setText(Messages.BugzillaSearchPage_Product); - productLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + Label severityLabel = new Label(severityComposite, SWT.LEFT); + severityLabel.setText(Messages.BugzillaSearchPage_Severity); + severityLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - GridData productLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true); - productLayoutData.heightHint = HEIGHT_ATTRIBUTE_COMBO; - product = new List(productComposite, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER); - product.setLayoutData(productLayoutData); - product.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - if (product.getSelectionIndex() != -1) { - String[] selectedProducts = product.getSelection(); - updateAttributesFromConfiguration(selectedProducts); - } else { - updateAttributesFromConfiguration(null); - } - if (restoring) { - restoring = false; - restoreWidgetValues(); - } - setPageComplete(isPageComplete()); - } - }); + severity = new List(severityComposite, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER); + final GridData gd_severity = new GridData(SWT.FILL, SWT.FILL, true, true); + gd_severity.heightHint = HEIGHT_ATTRIBUTE_COMBO; + severity.setLayoutData(gd_severity); + severity.addSelectionListener(updateActionSelectionAdapter); - GridLayout componentLayout = new GridLayout(); - componentLayout.marginWidth = 0; - componentLayout.marginHeight = 0; - componentLayout.horizontalSpacing = 0; - Composite componentComposite = new Composite(topForm, SWT.NONE); - componentComposite.setLayout(componentLayout); + Composite resolutionComposite = new Composite(bottomForm, SWT.NONE); + GridLayout resolutionLayout = new GridLayout(); + resolutionLayout.marginWidth = 0; + resolutionLayout.marginHeight = 0; + resolutionLayout.horizontalSpacing = 0; + resolutionComposite.setLayout(resolutionLayout); - Label componentLabel = new Label(componentComposite, SWT.LEFT); - componentLabel.setText(Messages.BugzillaSearchPage_Component); - componentLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + Label resolutionLabel = new Label(resolutionComposite, SWT.LEFT); + resolutionLabel.setText(Messages.BugzillaSearchPage_Resolution); + resolutionLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - component = new List(componentComposite, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER); - GridData componentLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true); - componentLayoutData.heightHint = HEIGHT_ATTRIBUTE_COMBO; - component.setLayoutData(componentLayoutData); - component.addSelectionListener(updateActionSelectionAdapter); + resolution = new List(resolutionComposite, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER); + final GridData gd_resolution = new GridData(SWT.FILL, SWT.FILL, true, true); + gd_resolution.heightHint = HEIGHT_ATTRIBUTE_COMBO; + resolution.setLayoutData(gd_resolution); + resolution.addSelectionListener(updateActionSelectionAdapter); - Composite versionComposite = new Composite(topForm, SWT.NONE); + Composite versionComposite = new Composite(bottomForm, SWT.NONE); GridLayout versionLayout = new GridLayout(); versionLayout.marginWidth = 0; versionLayout.marginHeight = 0; @@ -696,7 +807,7 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage implements L version.setLayoutData(versionLayoutData); version.addSelectionListener(updateActionSelectionAdapter); - Composite milestoneComposite = new Composite(topForm, SWT.NONE); + Composite milestoneComposite = new Composite(bottomForm, SWT.NONE); GridLayout milestoneLayout = new GridLayout(); milestoneLayout.marginWidth = 0; milestoneLayout.marginHeight = 0; @@ -713,90 +824,8 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage implements L target.setLayoutData(targetLayoutData); target.addSelectionListener(updateActionSelectionAdapter); - SashForm bottomForm = new SashForm(sashForm, SWT.NONE); - GridLayout bottomLayout = new GridLayout(); - bottomLayout.numColumns = 6; - bottomForm.setLayout(bottomLayout); - GridData bottomLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1); - bottomLayoutData.heightHint = 119; - bottomLayoutData.widthHint = 400; - bottomForm.setLayoutData(bottomLayoutData); - - Composite statusComposite = new Composite(bottomForm, SWT.NONE); - GridLayout statusLayout = new GridLayout(); - statusLayout.marginTop = 7; - statusLayout.marginWidth = 0; - statusLayout.horizontalSpacing = 0; - statusLayout.marginHeight = 0; - statusComposite.setLayout(statusLayout); - - Label statusLabel = new Label(statusComposite, SWT.LEFT); - statusLabel.setText(Messages.BugzillaSearchPage_Status); - statusLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - status = new List(statusComposite, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER); - final GridData gd_status = new GridData(SWT.FILL, SWT.FILL, true, true); - gd_status.heightHint = 60; - status.setLayoutData(gd_status); - status.addSelectionListener(updateActionSelectionAdapter); - - Composite resolutionComposite = new Composite(bottomForm, SWT.NONE); - GridLayout resolutionLayout = new GridLayout(); - resolutionLayout.marginTop = 7; - resolutionLayout.marginWidth = 0; - resolutionLayout.marginHeight = 0; - resolutionLayout.horizontalSpacing = 0; - resolutionComposite.setLayout(resolutionLayout); - - Label resolutionLabel = new Label(resolutionComposite, SWT.LEFT); - resolutionLabel.setText(Messages.BugzillaSearchPage_Resolution); - resolutionLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - resolution = new List(resolutionComposite, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER); - final GridData gd_resolution = new GridData(SWT.FILL, SWT.FILL, true, true); - gd_resolution.heightHint = 60; - resolution.setLayoutData(gd_resolution); - resolution.addSelectionListener(updateActionSelectionAdapter); - - Composite priorityComposite = new Composite(bottomForm, SWT.NONE); - GridLayout priorityLayout = new GridLayout(); - priorityLayout.marginTop = 7; - priorityLayout.marginWidth = 0; - priorityLayout.marginHeight = 0; - priorityLayout.horizontalSpacing = 0; - priorityComposite.setLayout(priorityLayout); - - Label priorityLabel = new Label(priorityComposite, SWT.LEFT); - priorityLabel.setText(Messages.BugzillaSearchPage_PROORITY); - priorityLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - priority = new List(priorityComposite, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER); - final GridData gd_priority = new GridData(SWT.FILL, SWT.FILL, true, true); - gd_priority.heightHint = 60; - priority.setLayoutData(gd_priority); - priority.addSelectionListener(updateActionSelectionAdapter); - - Composite severityComposite = new Composite(bottomForm, SWT.NONE); - GridLayout severityLayout = new GridLayout(); - severityLayout.marginTop = 7; - severityLayout.marginWidth = 0; - severityLayout.marginHeight = 0; - severityLayout.horizontalSpacing = 0; - severityComposite.setLayout(severityLayout); - - Label severityLabel = new Label(severityComposite, SWT.LEFT); - severityLabel.setText(Messages.BugzillaSearchPage_Severity); - severityLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - severity = new List(severityComposite, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER); - final GridData gd_severity = new GridData(SWT.FILL, SWT.FILL, true, true); - gd_severity.heightHint = 60; - severity.setLayoutData(gd_severity); - severity.addSelectionListener(updateActionSelectionAdapter); - Composite hardwareComposite = new Composite(bottomForm, SWT.NONE); GridLayout hardwareLayout = new GridLayout(); - hardwareLayout.marginTop = 7; hardwareLayout.marginWidth = 0; hardwareLayout.marginHeight = 0; hardwareLayout.horizontalSpacing = 0; @@ -808,13 +837,12 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage implements L hardware = new List(hardwareComposite, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER); final GridData gd_hardware = new GridData(SWT.FILL, SWT.FILL, true, true); - gd_hardware.heightHint = 60; + gd_hardware.heightHint = HEIGHT_ATTRIBUTE_COMBO; hardware.setLayoutData(gd_hardware); hardware.addSelectionListener(updateActionSelectionAdapter); Composite osComposite = new Composite(bottomForm, SWT.NONE); GridLayout osLayout = new GridLayout(); - osLayout.marginTop = 7; osLayout.marginWidth = 0; osLayout.marginHeight = 0; osLayout.horizontalSpacing = 0; @@ -826,20 +854,22 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage implements L os = new List(osComposite, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER); final GridData gd_os = new GridData(SWT.FILL, SWT.FILL, true, true); - gd_os.heightHint = 60; + gd_os.heightHint = HEIGHT_ATTRIBUTE_COMBO; os.setLayoutData(gd_os); os.addSelectionListener(updateActionSelectionAdapter); - bottomForm.setWeights(new int[] { 88, 90, 50, 77, 88, 85 }); + } private void createSearchGroup(Composite control) { Composite composite = new Composite(control, SWT.NONE); - composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false); + gd.horizontalSpan = 4; + composite.setLayoutData(gd); GridLayout gridLayout = new GridLayout(); gridLayout.marginTop = 7; gridLayout.marginHeight = 0; gridLayout.marginWidth = 0; - gridLayout.numColumns = 2; + gridLayout.numColumns = 3; composite.setLayout(gridLayout); Label changedInTheLabel = new Label(composite, SWT.LEFT); @@ -848,7 +878,7 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage implements L Composite updateComposite = new Composite(composite, SWT.NONE); updateComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); - GridLayout updateLayout = new GridLayout(3, false); + GridLayout updateLayout = new GridLayout(2, false); updateLayout.marginWidth = 0; updateLayout.horizontalSpacing = 0; updateLayout.marginHeight = 0; @@ -862,33 +892,6 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage implements L Label label = new Label(updateComposite, SWT.LEFT); label.setText(Messages.BugzillaSearchPage_days); - Button updateButton = new Button(updateComposite, SWT.PUSH); - updateButton.setText(Messages.BugzillaSearchPage_Update_Attributes_from_Repository); - updateButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false)); - updateButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - if (getTaskRepository() != null) { -// try { - - updateConfiguration(true); - -// } catch (final CoreException e1) { -// PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { -// public void run() { -// MessageDialog.openError(Display.getDefault().getActiveShell(), "Bugzilla Search Page", -// "Unable to get configuration. Ensure proper repository configuration in " -// + TasksUiPlugin.LABEL_VIEW_REPOSITORIES + ".\n\n"); -// } -// }); -// } - } else { - MessageDialog.openInformation(Display.getCurrent().getActiveShell(), - IBugzillaConstants.TITLE_MESSAGE_DIALOG, - Messages.BugzillaSearchPage_No_repository_available); - } - } - }); } /** @@ -1767,6 +1770,16 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage implements L keywords.setText(settings.get(STORE_KEYWORDS_ID + repoId)); keywordsOperation.select(settings.getInt(STORE_KEYWORDSMATCH_ID + repoId)); } + + if ((commentPattern.getText() != null && !commentPattern.getText().equals("")) || // //$NON-NLS-1$ + (emailPattern2.getText() != null && !emailPattern2.getText().equals("")) || // //$NON-NLS-1$ + (keywords.getText() != null && !keywords.getText().equals("")) || // //$NON-NLS-1$ + severity.getSelection().length > 0 || resolution.getSelection().length > 0 + || version.getSelection().length > 0 || target.getSelection().length > 0 + || hardware.getSelection().length > 0 || os.getSelection().length > 0) { + advancedExpandComposite.setExpanded(true); + } + } catch (IllegalArgumentException e) { //ignore } @@ -1922,8 +1935,6 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage implements L shell.setEnabled(true); } return; -// this.setPageComplete(this.isPageComplete()); -// this.setControlsEnabled(true); } else { StatusHandler.log(new Status(IStatus.ERROR, BugzillaUiPlugin.ID_PLUGIN, cause.getMessage(), cause)); @@ -1992,4 +2003,14 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage implements L } } + @Override + public void dispose() { + if (toolkit != null) { + if (toolkit.getColors() != null) { + toolkit.dispose(); + } + } + super.dispose(); + } + } diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/Messages.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/Messages.java index e31a16418..e78fe55cb 100644 --- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/Messages.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/Messages.java @@ -81,8 +81,4 @@ public class Messages extends NLS { public static String BugzillaTaskAttachmentPage_Advanced; - public static String BugzillaAttachmentDialog_DetailTitle; - - public static String BugzillaAttachmentDialog_OK_ButtonText; - } diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/messages.properties b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/messages.properties index 801f60e9a..d0779cf57 100644 --- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/messages.properties +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/messages.properties @@ -39,5 +39,3 @@ BugzillaRepositorySettingsPage_Server_URL_is_invalid=Server URL is invalid. 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 diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/BugzillaAttachmentWizard.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/BugzillaAttachmentWizard.java new file mode 100644 index 000000000..29192b08c --- /dev/null +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/BugzillaAttachmentWizard.java @@ -0,0 +1,152 @@ +/******************************************************************************* + * 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; + } + +/* currently not needed + 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 { + job.run(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) { + 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; + } + +} diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/BugzillaAttachmentWizardPage.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/BugzillaAttachmentWizardPage.java new file mode 100644 index 000000000..e28117fe3 --- /dev/null +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/BugzillaAttachmentWizardPage.java @@ -0,0 +1,361 @@ +/******************************************************************************* + * 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 java.net.MalformedURLException; +import java.net.URL; +import java.text.MessageFormat; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.layout.GridDataFactory; +import org.eclipse.jface.layout.GridLayoutFactory; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute; +import org.eclipse.mylyn.internal.bugzilla.ui.BugzillaUiPlugin; +import org.eclipse.mylyn.tasks.core.data.TaskAttribute; +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.custom.SashForm; +import org.eclipse.swt.custom.ScrolledComposite; +import org.eclipse.swt.graphics.Point; +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.Label; +import org.eclipse.swt.widgets.Shell; +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; + +public class BugzillaAttachmentWizardPage extends WizardPage { + private static final String PAGE_NAME = "AttachmentDetailPage"; //$NON-NLS-1$ + + private static final String DIALOG_SETTING_RUN_IN_BACKGROUND = "run-in-background"; //$NON-NLS-1$ + + private static final String DIALOG_SETTINGS_SECTION_BUGZILLA_ATTACHMENTS_WIZARD = "bugzilla-attachments-wizard"; //$NON-NLS-1$ + + private final AttributeEditorFactory factory; + + private final TaskAttribute attachmentAttribute; + + private FormToolkit toolkit; + + 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 = 100; + + private static final int MULTI_COLUMN_WIDTH = COLUMN_WIDTH + 5 + COLUMN_GAP + LABEL_WIDTH + 5 + COLUMN_WIDTH; + + private AbstractAttributeEditor commentEditor; + + private ExpandableComposite flagExpandComposite; + + private Button runInBackgroundButton; + + private ScrolledComposite scrolledComposite; + + private Composite scrolledBodyComposite; + + public BugzillaAttachmentWizardPage(Shell parentShell, AttributeEditorFactory factory, + TaskAttribute attachmentAttribute, String taskID) { + super(PAGE_NAME); + setTitle(Messages.BugzillaAttachmentWizardPage_Titel); + setDescription(MessageFormat.format(Messages.BugzillaAttachmentWizardPage_Description, + attachmentAttribute.getValue(), taskID)); + setImageDescriptor(createImageDescriptor()); + this.factory = factory; + this.attachmentAttribute = attachmentAttribute; + } + + private static ImageDescriptor createImageDescriptor() { + return ImageDescriptor.createFromURL(makeIconFileURL()); + } + + private static URL makeIconFileURL() { + URL baseURL = BugzillaUiPlugin.getDefault().getBundle().getEntry("/icons/"); //$NON-NLS-1$ + if (baseURL == null) { + return null; + } + try { + return new URL(baseURL, "wizban/banner-attachment-update.gif"); //$NON-NLS-1$ + } catch (MalformedURLException e) { + e.printStackTrace(); + } + return null; + } + + public void createControl(Composite parent) { + toolkit = new FormToolkit(parent.getDisplay()); + + Composite pageArea = new Composite(parent, SWT.NONE); + pageArea.setBackground(parent.getBackground()); + pageArea.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND)); + pageArea.setLayout(new GridLayout(1, false)); + + SashForm bottomForm = new SashForm(pageArea, SWT.NONE); + bottomForm.setOrientation(SWT.VERTICAL); + GridLayout bottomLayout = new GridLayout(); + bottomLayout.numColumns = 1; + bottomForm.setLayout(bottomLayout); + GridData bottomLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); + bottomLayoutData.heightHint = 119; + bottomLayoutData.widthHint = 200; + bottomForm.setLayoutData(bottomLayoutData); + int currentColumn = 1; + int columnCount = 4; + + scrolledComposite = new ScrolledComposite(bottomForm, SWT.H_SCROLL | SWT.V_SCROLL) { + @Override + public Point computeSize(int hint, int hint2, boolean changed) { + return new Point(64, 64); + } + }; + scrolledComposite.setExpandHorizontal(true); + scrolledComposite.setExpandVertical(true); + + scrolledBodyComposite = new Composite(scrolledComposite, SWT.NONE); + scrolledBodyComposite.setBackground(pageArea.getBackground()); + scrolledBodyComposite.setForeground(scrolledBodyComposite.getDisplay() + .getSystemColor(SWT.COLOR_LIST_FOREGROUND)); + GridLayout layout = new GridLayout(4, false); + scrolledBodyComposite.setLayout(layout); + scrolledComposite.setContent(scrolledBodyComposite); + + Composite commentArea = new Composite(bottomForm, SWT.NONE); + commentArea.setBackground(pageArea.getBackground()); + commentArea.setForeground(commentArea.getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND)); + layout = new GridLayout(4, false); + commentArea.setLayout(layout); + + createAttributeEditors(currentColumn, columnCount, scrolledBodyComposite); + createCommentEditor(currentColumn, columnCount, commentArea); + createFlagSection(scrolledBodyComposite); + createAttributeEditor(attachmentAttribute.getMappedAttribute(TaskAttribute.ATTACHMENT_URL), currentColumn, + columnCount, scrolledBodyComposite); + GridDataFactory.fillDefaults().grab(true, false).hint(200, SWT.DEFAULT).span(4, SWT.DEFAULT).applyTo( + scrolledBodyComposite); + + runInBackgroundButton = new Button(pageArea, SWT.CHECK); + runInBackgroundButton.setText(Messages.BugzillaAttachmentWizardPage_RunInBackground); + IDialogSettings settings = BugzillaUiPlugin.getDefault().getDialogSettings(); + IDialogSettings attachmentsSettings = settings.getSection(DIALOG_SETTINGS_SECTION_BUGZILLA_ATTACHMENTS_WIZARD); + if (attachmentsSettings != null) { + runInBackgroundButton.setSelection(attachmentsSettings.getBoolean(DIALOG_SETTING_RUN_IN_BACKGROUND)); + } + setControl(pageArea); + Dialog.applyDialogFont(pageArea); + bottomForm.setWeights(new int[] { 65, 35 }); + scrolledComposite.setMinSize(scrolledBodyComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT, true)); + } + + private void createAttributeEditor(TaskAttribute attribute, int currentColumn, int columnCount, + Composite attributeArea) { + String type = attribute.getMetaData().getType(); + if (type != null) { + AbstractAttributeEditor editor = factory.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(false); + } + if (editor.hasLabel() && !TaskAttribute.ATTACHMENT_IS_PATCH.equals(attribute.getId())) { + editor.createLabelControl(attributeArea, toolkit); + Label label = editor.getLabelControl(); + label.setBackground(attributeArea.getBackground()); + label.setForeground(attributeArea.getForeground()); + + 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 (BugzillaAttribute.CTYPE.getKey().equals(attribute.getId())) { + gd.horizontalSpan = 2; + gd.widthHint = LABEL_WIDTH * 2; + } else if (TaskAttribute.ATTACHMENT_IS_PATCH.equals(attribute.getId())) { + gd.horizontalSpan = 1; + } else 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(attributeArea.getBackground()); + editor.getControl().setForeground(attributeArea.getForeground()); + currentColumn += gd.horizontalSpan; + currentColumn %= columnCount; + } + } + + private void createAttributeEditors(int currentColumn, int columnCount, Composite attributeArea) { + createAttributeEditor(attachmentAttribute.getMappedAttribute(TaskAttribute.ATTACHMENT_DESCRIPTION), + currentColumn, columnCount, attributeArea); + createAttributeEditor(attachmentAttribute.getMappedAttribute(TaskAttribute.ATTACHMENT_FILENAME), currentColumn, + columnCount, attributeArea); + createAttributeEditor(attachmentAttribute.getMappedAttribute(TaskAttribute.ATTACHMENT_SIZE), currentColumn, + columnCount, attributeArea); + createAttributeEditor(attachmentAttribute.getMappedAttribute(TaskAttribute.ATTACHMENT_CONTENT_TYPE), + currentColumn, columnCount, attributeArea); + createAttributeEditor(attachmentAttribute.getMappedAttribute(TaskAttribute.ATTACHMENT_IS_PATCH), currentColumn, + columnCount, attributeArea); + createAttributeEditor(attachmentAttribute.getMappedAttribute(TaskAttribute.ATTACHMENT_IS_DEPRECATED), + currentColumn, columnCount, attributeArea); + } + + private void createCommentEditor(int currentColumn, int columnCount, Composite attributeArea) { + TaskAttribute commentAttribute = attachmentAttribute.getAttribute("comment"); //$NON-NLS-1$ + if (commentAttribute == null) { + return; + } + String type = commentAttribute.getMetaData().getType(); + if (type != null) { + commentEditor = factory.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()); + label.setForeground(attributeArea.getForeground()); + 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.FILL, true, true); + gd.heightHint = MULTI_ROW_HEIGHT; + gd.widthHint = MULTI_COLUMN_WIDTH; + gd.horizontalSpan = 3; + commentEditor.getControl().setLayoutData(gd); + commentEditor.getControl().setForeground(attributeArea.getForeground()); + + toolkit.paintBordersFor(attributeArea); + } + + } + + private void createFlagSection(final Composite container) { + boolean flagFound = false; + for (TaskAttribute attribute : attachmentAttribute.getAttributes().values()) { + if (!attribute.getId().startsWith("task.common.kind.flag")) { //$NON-NLS-1$ + continue; + } + flagFound = true; + break; + } + if (!flagFound) { + return; + } + flagExpandComposite = toolkit.createExpandableComposite(container, ExpandableComposite.COMPACT + | ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR); + flagExpandComposite.setFont(container.getFont()); + flagExpandComposite.setBackground(container.getBackground()); + flagExpandComposite.setText(Messages.BugzillaAttachmentWizardPage_Advanced); + flagExpandComposite.setLayout(new GridLayout(4, false)); + GridDataFactory.fillDefaults().indent(0, 5).grab(true, false).span(4, SWT.DEFAULT).applyTo(flagExpandComposite); + + flagExpandComposite.addExpansionListener(new ExpansionAdapter() { + @Override + public void expansionStateChanged(ExpansionEvent e) { + scrolledComposite.setMinSize(scrolledBodyComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT, true)); + getControl().getShell().pack(); + } + }); + Composite flagBodyComposite = new Composite(flagExpandComposite, SWT.NONE); + GridLayoutFactory.fillDefaults().margins(0, 0).numColumns(2).applyTo(flagBodyComposite); + flagBodyComposite.setBackground(container.getBackground()); + createFlagEditors(2, flagBodyComposite); + flagExpandComposite.setClient(flagBodyComposite); + } + + private void createFlagEditors(int columnCount, Composite flagBodyComposite) { + int currentFlagColumn = 1; + + for (TaskAttribute attribute : attachmentAttribute.getAttributes().values()) { + if (!attribute.getId().startsWith("task.common.kind.flag")) { //$NON-NLS-1$ + continue; + } + String type = attribute.getMetaData().getType(); + if (type != null) { + AbstractAttributeEditor editor = factory.createEditor(type, attribute); + + if (editor.hasLabel()) { + editor.createLabelControl(flagBodyComposite, toolkit); + Label label = editor.getLabelControl(); + label.setBackground(flagBodyComposite.getBackground()); + label.setForeground(flagBodyComposite.getForeground()); + + GridData gd = GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).hint( + LABEL_WIDTH - (4 * COLUMN_GAP), SWT.DEFAULT).create(); + if (currentFlagColumn > 1) { + gd.horizontalIndent = COLUMN_GAP; + gd.widthHint = LABEL_WIDTH + COLUMN_GAP; + } else { + gd.horizontalIndent = COLUMN_GAP * 3; + } + label.setLayoutData(gd); + currentFlagColumn++; + } + editor.createControl(flagBodyComposite, toolkit); + GridData gd = new GridData(SWT.FILL, SWT.CENTER, false, false); + gd.widthHint = MULTI_COLUMN_WIDTH;//COLUMN_WIDTH; + editor.getControl().setLayoutData(gd); + currentFlagColumn += gd.horizontalSpan; + currentFlagColumn %= columnCount; + editor.getControl().setBackground(flagBodyComposite.getBackground()); + editor.getControl().setForeground(flagBodyComposite.getForeground()); + } + } + } + + @Override + public void dispose() { + IDialogSettings settings = BugzillaUiPlugin.getDefault().getDialogSettings(); + IDialogSettings attachmentsSettings = settings.getSection(DIALOG_SETTINGS_SECTION_BUGZILLA_ATTACHMENTS_WIZARD); + if (attachmentsSettings == null) { + attachmentsSettings = settings.addNewSection(DIALOG_SETTINGS_SECTION_BUGZILLA_ATTACHMENTS_WIZARD); + } + attachmentsSettings.put(DIALOG_SETTING_RUN_IN_BACKGROUND, runInBackgroundButton.getSelection()); + super.dispose(); + } + + public boolean runInBackground() { + return runInBackgroundButton.getSelection(); + } + +} diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/Messages.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/Messages.java new file mode 100644 index 000000000..c49f0f4de --- /dev/null +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/Messages.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * 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_RunInBackground; + + public static String BugzillaAttachmentWizardPage_Titel; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/messages.properties b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/messages.properties new file mode 100644 index 000000000..aa7cea206 --- /dev/null +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/messages.properties @@ -0,0 +1,5 @@ +BugzillaAttachmentWizard_Now_synchronize_the_Task=Updating Attachment: Now synchronize the Task +BugzillaAttachmentWizardPage_Advanced=Advanced +BugzillaAttachmentWizardPage_Description=Show Attachment {0} Details for Bug {1} +BugzillaAttachmentWizardPage_RunInBackground=Run in Background +BugzillaAttachmentWizardPage_Titel=Attachment Detail |