summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2011-09-16 12:30:35 (EDT)
committerSteffen Pingel2011-09-16 12:30:35 (EDT)
commit6e184421ca62955dc533b039f58e824abb4786c6 (patch)
tree5cd676c5b41105305d9130b8e37f691a9945d9a6
parent6d8a2fc7c721e548710f2b05e6b1ce818efac316 (diff)
downloadorg.eclipse.mylyn.tasks-6e184421ca62955dc533b039f58e824abb4786c6.zip
org.eclipse.mylyn.tasks-6e184421ca62955dc533b039f58e824abb4786c6.tar.gz
org.eclipse.mylyn.tasks-6e184421ca62955dc533b039f58e824abb4786c6.tar.bz2
NEW - bug 245152: opening "Task Search" blocks UI when page is first
shown https://bugs.eclipse.org/bugs/show_bug.cgi?id=245152 Change-Id: I2ca9f5e0e7aac6f3cf1ee735f41e40c634867cfd
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java328
-rw-r--r--org.eclipse.mylyn.tasks.search/src/org/eclipse/mylyn/internal/tasks/ui/TaskSearchPage.java14
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/provisional/tasks/ui/wizards/AbstractRepositoryQueryPage2.java112
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/Messages.java19
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/QueryWizardDialog.java43
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/messages.properties10
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositoryQueryPage.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositoryQueryPage2.java426
-rw-r--r--org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/TracQueryPage.java882
9 files changed, 926 insertions, 910 deletions
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 f8914ca..9e6119f 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
@@ -13,15 +13,11 @@
package org.eclipse.mylyn.internal.bugzilla.ui.search;
import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
import java.io.UnsupportedEncodingException;
-import java.lang.reflect.InvocationTargetException;
import java.net.URLDecoder;
import java.net.URLEncoder;
-import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -31,25 +27,14 @@ import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.fieldassist.ComboContentAdapter;
import org.eclipse.jface.fieldassist.ContentProposalAdapter;
import org.eclipse.jface.fieldassist.IContentProposalProvider;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.window.Window;
-import org.eclipse.mylyn.commons.core.CoreUtil;
-import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCustomField;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
@@ -61,12 +46,10 @@ import org.eclipse.mylyn.internal.provisional.commons.ui.dialogs.AbstractInPlace
import org.eclipse.mylyn.internal.provisional.commons.ui.dialogs.IInPlaceDialogListener;
import org.eclipse.mylyn.internal.provisional.commons.ui.dialogs.InPlaceCheckBoxTreeDialog;
import org.eclipse.mylyn.internal.provisional.commons.ui.dialogs.InPlaceDialogEvent;
-import org.eclipse.mylyn.internal.provisional.tasks.ui.wizards.AbstractRepositoryQueryPage2;
-import org.eclipse.mylyn.internal.tasks.ui.util.WebBrowserDialog;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
-import org.eclipse.mylyn.tasks.core.RepositoryStatus;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.TasksUi;
+import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositoryQueryPage2;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
@@ -87,13 +70,10 @@ import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Listener;
-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.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.progress.IProgressService;
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
/**
@@ -426,8 +406,6 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage2 implements
private static final String STORE_CHARTS_ID = PAGE_NAME + ".CHARTS"; //$NON-NLS-1$
- private RepositoryConfiguration repositoryConfiguration;
-
private final FormToolkit toolkit;
private ExpandableComposite moreOptionsSection;
@@ -516,7 +494,7 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage2 implements
}
@Override
- public void clearFields() {
+ public void doClearFields() {
product.deselectAll();
component.deselectAll();
version.deselectAll();
@@ -940,8 +918,10 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage2 implements
}
Map<String, String> validValues = new HashMap<String, String>();
- for (String string : repositoryConfiguration.getKeywords()) {
- validValues.put(string, string);
+ if (getRepositoryConfiguration() != null) {
+ for (String string : getRepositoryConfiguration().getKeywords()) {
+ validValues.put(string, string);
+ }
}
final InPlaceCheckBoxTreeDialog selectionDialog = new InPlaceCheckBoxTreeDialog(
WorkbenchUtil.getShell(), keywordsSelectButton, values, validValues, ""); //$NON-NLS-1$
@@ -1174,94 +1154,23 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage2 implements
if (visible && summaryPattern != null) {
if (firstTime) {
firstTime = false;
- // Set item and text here to prevent page from resizing
+ // restore items from history here to prevent page from resizing
for (String searchPattern : getPreviousPatterns(previousSummaryPatterns)) {
summaryPattern.add(searchPattern);
}
- // summaryPattern.setItems(getPreviousPatterns(previousSummaryPatterns));
for (String comment : getPreviousPatterns(previousCommentPatterns)) {
commentPattern.add(comment);
}
- // commentPattern.setItems(getPreviousPatterns(previousCommentPatterns));
for (String email : getPreviousPatterns(previousEmailPatterns)) {
emailPattern.add(email);
}
-
for (String email : getPreviousPatterns(previousEmailPatterns2)) {
emailPattern2.add(email);
}
-
- // emailPattern.setItems(getPreviousPatterns(previousEmailPatterns));
for (String keyword : getPreviousPatterns(previousKeywords)) {
keywords.add(keyword);
}
- // TODO: update status, resolution, severity etc if possible...
- if (getTaskRepository() != null) {
- BugzillaRepositoryConnector connector = (BugzillaRepositoryConnector) TasksUi.getRepositoryConnector(getTaskRepository().getConnectorKind());
- repositoryConfiguration = connector.getRepositoryConfiguration(getTaskRepository().getUrl());
- updateAttributesFromConfiguration(null);
- if (product.getItemCount() == 0) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- if (getControl() != null && !getControl().isDisposed()) {
- updateConfiguration(true);
- updateAttributesFromConfiguration(null);
- }
- }
-
- });
- }
- }
- if (originalQuery != null) {
- try {
- updateDefaults(originalQuery.getUrl());
- refreshChartControls();
- } catch (UnsupportedEncodingException e) {
- // ignore
- }
- }
- 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$
- (whiteboardPattern.getText() != null && !whiteboardPattern.getText().equals("")) || // //$NON-NLS-1$
- priority.getSelection().length > 0 || resolution.getSelection().length > 0
- || version.getSelection().length > 0 || target.getSelection().length > 0
- || hardware.getSelection().length > 0 || os.getSelection().length > 0) {
- moreOptionsSection.setExpanded(true);
- scrolledComposite.reflow(true);
- refreshChartControls();
- }
- if (charts.size() > 0 && charts.get(0).getChartExpression(0, 0).getFieldName() > 0) {
- chartSection.setExpanded(true);
- scrolledComposite.reflow(true);
- refreshChartControls();
- }
- }
-
- /*
- * hack: we have to select the correct product, then update the
- * attributes so the component/version/milestone lists have the
- * proper values, then we can restore all the widget selections.
- */
- if (getTaskRepository() != null) {
- IDialogSettings settings = getDialogSettings();
- String repoId = "." + getTaskRepository().getRepositoryUrl(); //$NON-NLS-1$
- if (getWizard() == null && restoreQueryOptions && settings.getArray(STORE_PRODUCT_ID + repoId) != null
- && product != null) {
- product.setSelection(nonNullArray(settings, STORE_PRODUCT_ID + repoId));
- if (product.getSelection().length > 0) {
- updateAttributesFromConfiguration(product.getSelection());
- }
- restoreWidgetValues();
- }
- }
- setPageComplete(isPageComplete());
- }
- if (visible) {
- if (getWizard() == null && summaryPattern != null) {
- // TODO: wierd check
- summaryPattern.setFocus();
}
}
super.setVisible(visible);
@@ -1565,6 +1474,7 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage2 implements
@SuppressWarnings("unchecked")
private void updateAttributesFromConfiguration(String[] selectedProducts) {
+ RepositoryConfiguration repositoryConfiguration = getRepositoryConfiguration();
if (repositoryConfiguration != null) {
String[] saved_product = product.getSelection();
String[] saved_component = component.getSelection();
@@ -2078,60 +1988,6 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage2 implements
}
}
- @Override
- public void saveState() {
- String repoId = "." + getTaskRepository().getRepositoryUrl(); //$NON-NLS-1$
- IDialogSettings settings = getDialogSettings();
- settings.put(STORE_PRODUCT_ID + repoId, product.getSelection());
- settings.put(STORE_COMPONENT_ID + repoId, component.getSelection());
- settings.put(STORE_VERSION_ID + repoId, version.getSelection());
- settings.put(STORE_MSTONE_ID + repoId, target.getSelection());
- settings.put(STORE_STATUS_ID + repoId, status.getSelection());
- settings.put(STORE_RESOLUTION_ID + repoId, resolution.getSelection());
- settings.put(STORE_SEVERITY_ID + repoId, severity.getSelection());
- settings.put(STORE_PRIORITY_ID + repoId, priority.getSelection());
- settings.put(STORE_HARDWARE_ID + repoId, hardware.getSelection());
- settings.put(STORE_OS_ID + repoId, os.getSelection());
- settings.put(STORE_SUMMARYMATCH_ID + repoId, summaryOperation.getSelectionIndex());
- settings.put(STORE_COMMENTMATCH_ID + repoId, commentOperation.getSelectionIndex());
- settings.put(STORE_EMAILMATCH_ID + repoId, emailOperation.getSelectionIndex());
- for (int i = 0; i < emailButtons.length; i++) {
- settings.put(STORE_EMAILBUTTON_ID + i + repoId, emailButtons[i].getSelection());
- }
- settings.put(STORE_SUMMARYTEXT_ID + repoId, summaryPattern.getText());
- settings.put(STORE_COMMENTTEXT_ID + repoId, commentPattern.getText());
- settings.put(STORE_EMAILADDRESS_ID + repoId, emailPattern.getText());
- settings.put(STORE_EMAIL2ADDRESS_ID + repoId, emailPattern2.getText());
- settings.put(STORE_EMAIL2MATCH_ID + repoId, emailOperation2.getSelectionIndex());
- for (int i = 0; i < emailButtons2.length; i++) {
- settings.put(STORE_EMAIL2BUTTON_ID + i + repoId, emailButtons2[i].getSelection());
- }
-
- settings.put(STORE_KEYWORDS_ID + repoId, keywords.getText());
- settings.put(STORE_KEYWORDSMATCH_ID + repoId, keywordsOperation.getSelectionIndex());
- settings.put(STORE_WHITEBOARD_ID + repoId, whiteboardPattern.getText());
- settings.put(STORE_WHITEBOARDMATCH_ID + repoId, whiteboardOperation.getSelectionIndex());
-
- ObjectOutputStream outputStream = null;
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- try {
- try {
- outputStream = new ObjectOutputStream(byteArrayOutputStream);
- outputStream.writeObject(charts);
- outputStream.flush();
- settings.put(STORE_CHARTS_ID + repoId, byteArrayOutputStream.toString());
- } catch (IOException e) {
- throw e;
- } finally {
- if (outputStream != null) {
- outputStream.close();
- }
- }
- } catch (Exception e) {
- }
-
- }
-
/* Testing hook to see if any products are present */
public int getProductCount() throws Exception {
return product.getItemCount();
@@ -2149,98 +2005,6 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage2 implements
return stringList.toArray(new String[stringList.size()]);
}
- private void updateConfiguration(final boolean force) {
- String[] selectedProducts = product.getSelection();
- if (selectedProducts != null && selectedProducts.length == 0) {
- selectedProducts = null;
- }
- if (getTaskRepository() != null) {
- IRunnableWithProgress updateRunnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- try {
- monitor.beginTask(Messages.BugzillaSearchPage_Updating_search_options_,
- IProgressMonitor.UNKNOWN);
- BugzillaRepositoryConnector connector = (BugzillaRepositoryConnector) TasksUi.getRepositoryConnector(getTaskRepository().getConnectorKind());
- repositoryConfiguration = connector.getRepositoryConfiguration(getTaskRepository(), force,
- monitor);
- } catch (final Exception e) {
- throw new InvocationTargetException(e);
- } finally {
- monitor.done();
- }
- }
- };
-
- try {
- if (getContainer() != null) {
- getContainer().run(true, true, updateRunnable);
- } else if (getSearchContainer() != null) {
- getSearchContainer().getRunnableContext().run(true, true, updateRunnable);
- } else {
- IProgressService service = PlatformUI.getWorkbench().getProgressService();
- service.busyCursorWhile(updateRunnable);
- }
-
- } catch (InvocationTargetException ex) {
- Shell shell = null;
- shell = getShell();
- if (ex.getCause() instanceof CoreException) {
- CoreException cause = ((CoreException) ex.getCause());
- if (cause.getStatus() instanceof RepositoryStatus
- && ((RepositoryStatus) cause.getStatus()).isHtmlMessage()) {
- if (shell != null) {
- shell.setEnabled(false);
- }
- // TODO: eliminate use of internal api
- WebBrowserDialog dialog = new WebBrowserDialog(shell,
- Messages.BugzillaSearchPage_Error_updating_search_options, null, cause.getStatus()
- .getMessage(), NONE, new String[] { IDialogConstants.OK_LABEL }, 0,
- ((RepositoryStatus) cause.getStatus()).getHtmlMessage());
- dialog.setBlockOnOpen(true);
- dialog.open();
- if (shell != null) {
- shell.setEnabled(true);
- }
- return;
- } else {
- StatusHandler.log(new Status(IStatus.ERROR, BugzillaUiPlugin.ID_PLUGIN, cause.getMessage(),
- cause));
- }
- }
- if (ex.getCause() instanceof OperationCanceledException) {
- return;
- }
-
- // FIXME improve error reporting
- if (!CoreUtil.TEST_MODE) {
- MessageDialog.openError(shell, Messages.BugzillaSearchPage_Error_updating_search_options,
- MessageFormat.format(Messages.BugzillaSearchPage_Error_was_X, ex.getCause().getMessage()));
- }
- return;
-
- } catch (InterruptedException ex) {
- return;
- }
-
- updateAttributesFromConfiguration(selectedProducts);
- }
- }
-
- @Override
- public Shell getShell() {
- Shell shell = null;
- if (getWizard() != null && getWizard().getContainer() != null) {
- shell = getWizard().getContainer().getShell();
- }
- if (shell == null && getControl() != null) {
- shell = getControl().getShell();
- }
- return shell;
- }
-
private void setSelection(List listControl, String[] selection) {
for (String item : selection) {
int index = listControl.indexOf(item);
@@ -2350,8 +2114,8 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage2 implements
ChartExpression chartExpression = charts.get(chartNum).getChartExpression(chartRow,
chartColumn);
chartExpression.setFieldName(comboField.getSelectionIndex());
- getShell().layout(true);
- getShell().redraw();
+ comboField.getShell().layout(true);
+ comboField.getShell().redraw();
}
});
comboField.setToolTipText(Messages.BugzillaSearchPage_Tooltip_Custom_fields_at_end);
@@ -2474,24 +2238,18 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage2 implements
}
public BugzillaSearchPage(TaskRepository repository) {
- super(Messages.BugzillaSearchPage_Bugzilla_Query, repository, null);
-
- toolkit = new FormToolkit(Display.getCurrent());
- setNeedsClearButton(true);
- setMessage(Messages.BugzillaSearchPage_Enter_search_option);
- BugzillaRepositoryConnector connector = (BugzillaRepositoryConnector) TasksUi.getRepositoryConnector(getTaskRepository().getConnectorKind());
- repositoryConfiguration = connector.getRepositoryConfiguration(getTaskRepository().getUrl());
+ this(repository, null);
}
public BugzillaSearchPage(TaskRepository repository, IRepositoryQuery origQuery) {
super(Messages.BugzillaSearchPage_Bugzilla_Query, repository, origQuery);
- originalQuery = origQuery;
- setNeedsClearButton(true);
+ this.originalQuery = origQuery;
+
+ setNeedsClear(true);
setDescription(Messages.BugzillaSearchPage_Select_the_Bugzilla_query_parameters);
setMessage(Messages.BugzillaSearchPage_Enter_search_option);
+
toolkit = new FormToolkit(Display.getCurrent());
- BugzillaRepositoryConnector connector = (BugzillaRepositoryConnector) TasksUi.getRepositoryConnector(getTaskRepository().getConnectorKind());
- repositoryConfiguration = connector.getRepositoryConfiguration(getTaskRepository().getUrl());
}
@Override
@@ -2506,27 +2264,71 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage2 implements
@Override
protected boolean hasRepositoryConfiguration() {
- return repositoryConfiguration != null;
+ return getRepositoryConfiguration() != null;
+ }
+
+ public RepositoryConfiguration getRepositoryConfiguration() {
+ return ((BugzillaRepositoryConnector) getConnector()).getRepositoryConfiguration(getTaskRepository().getUrl());
}
@Override
protected void doRefresh() {
- // ignore
-
+ String[] selectedProducts = product.getSelection();
+ if (selectedProducts != null && selectedProducts.length == 0) {
+ selectedProducts = null;
+ }
+ updateAttributesFromConfiguration(selectedProducts);
}
@Override
protected boolean restoreState(IRepositoryQuery query) {
- if (originalQuery != null) {
+ if (query != null) {
try {
- updateDefaults(originalQuery.getUrl());
+ updateDefaults(query.getUrl());
refreshChartControls();
} catch (UnsupportedEncodingException e) {
// ignore
}
}
- return false;
+ 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$
+ (whiteboardPattern.getText() != null && !whiteboardPattern.getText().equals("")) || // //$NON-NLS-1$
+ priority.getSelection().length > 0 || resolution.getSelection().length > 0
+ || version.getSelection().length > 0 || target.getSelection().length > 0
+ || hardware.getSelection().length > 0 || os.getSelection().length > 0) {
+ moreOptionsSection.setExpanded(true);
+ scrolledComposite.reflow(true);
+ refreshChartControls();
+ }
+
+ if (charts.size() > 0 && charts.get(0).getChartExpression(0, 0).getFieldName() > 0) {
+ chartSection.setExpanded(true);
+ scrolledComposite.reflow(true);
+ refreshChartControls();
+ }
+
+ /*
+ * hack: we have to select the correct product, then update the
+ * attributes so the component/version/milestone lists have the
+ * proper values, then we can restore all the widget selections.
+ */
+// if (getTaskRepository() != null) {
+// IDialogSettings settings = getDialogSettings();
+// String repoId = "." + getTaskRepository().getRepositoryUrl(); //$NON-NLS-1$
+// if (getWizard() == null && restoreQueryOptions && settings.getArray(STORE_PRODUCT_ID + repoId) != null
+// && product != null) {
+// product.setSelection(nonNullArray(settings, STORE_PRODUCT_ID + repoId));
+// if (product.getSelection().length > 0) {
+// updateAttributesFromConfiguration(product.getSelection());
+// }
+// restoreWidgetValues();
+// }
+// }
+// setPageComplete(isPageComplete());
+
+ return true;
}
@Override
diff --git a/org.eclipse.mylyn.tasks.search/src/org/eclipse/mylyn/internal/tasks/ui/TaskSearchPage.java b/org.eclipse.mylyn.tasks.search/src/org/eclipse/mylyn/internal/tasks/ui/TaskSearchPage.java
index 7badc3c..8237332 100644
--- a/org.eclipse.mylyn.tasks.search/src/org/eclipse/mylyn/internal/tasks/ui/TaskSearchPage.java
+++ b/org.eclipse.mylyn.tasks.search/src/org/eclipse/mylyn/internal/tasks/ui/TaskSearchPage.java
@@ -144,23 +144,16 @@ public class TaskSearchPage extends DialogPage implements ISearchPage {
fParentComposite.setLayoutData(gd);
createRepositoryGroup(fParentComposite);
- createSeparator(fParentComposite);
- this.setControl(fParentComposite);
+ setControl(fParentComposite);
Dialog.applyDialogFont(fParentComposite);
}
- private void createSeparator(Composite parent) {
- Label separator = new Label(parent, SWT.NONE);
- separator.setVisible(false);
- GridData data = new GridData(GridData.FILL, GridData.FILL, false, false, 2, 1);
- data.heightHint = convertHeightInCharsToPixels(1) / 3;
- separator.setLayoutData(data);
- }
-
private void createRepositoryGroup(Composite control) {
Composite group = new Composite(control, SWT.NONE);
GridLayout layout = new GridLayout(6, false);
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
group.setLayout(layout);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
group.setLayoutData(gd);
@@ -242,6 +235,7 @@ public class TaskSearchPage extends DialogPage implements ISearchPage {
// Page wrapper
final Composite pageWrapper = new Composite(fParentComposite, SWT.NONE);
pageWrapper.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ // m4.0 replace with FillLayout
GridLayout layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/provisional/tasks/ui/wizards/AbstractRepositoryQueryPage2.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/provisional/tasks/ui/wizards/AbstractRepositoryQueryPage2.java
index cb1e440..7b109e5 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/provisional/tasks/ui/wizards/AbstractRepositoryQueryPage2.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/provisional/tasks/ui/wizards/AbstractRepositoryQueryPage2.java
@@ -19,7 +19,6 @@ import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.mylyn.internal.tasks.ui.wizards.QueryWizardDialog;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.TaskRepository;
@@ -35,6 +34,7 @@ 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.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
@@ -44,7 +44,9 @@ import org.eclipse.ui.progress.IProgressService;
/**
* @author Steffen Pingel
* @since 3.1
+ * @deprecated use {@link org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositoryQueryPage2} instead
*/
+@Deprecated
public abstract class AbstractRepositoryQueryPage2 extends AbstractRepositoryQueryPage {
private Text titleText;
@@ -57,8 +59,6 @@ public abstract class AbstractRepositoryQueryPage2 extends AbstractRepositoryQue
private boolean needsRepositoryConfiguration = true;
- private boolean needsClearButton = false;
-
public AbstractRepositoryQueryPage2(String pageName, TaskRepository repository, IRepositoryQuery query) {
super(pageName, repository, query);
this.connector = TasksUi.getRepositoryConnector(getTaskRepository().getConnectorKind());
@@ -69,10 +69,6 @@ public abstract class AbstractRepositoryQueryPage2 extends AbstractRepositoryQue
this.needsRepositoryConfiguration = needsRepositoryConfiguration;
}
- public void setNeedsClearButton(boolean needsClearButton) {
- this.needsClearButton = needsClearButton;
- }
-
public void createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(composite);
@@ -89,8 +85,10 @@ public abstract class AbstractRepositoryQueryPage2 extends AbstractRepositoryQue
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).span(2, 1).applyTo(innerComposite);
innerComposite.setLayout(new FillLayout());
createPageContent(innerComposite);
- createButtonGroup(composite);
- if (!needsRepositoryConfiguration) {
+
+ if (needsRepositoryConfiguration) {
+ createUpdateButton(composite);
+ } else {
setDescription(Messages.AbstractRepositoryQueryPage2_Create_a_Query_Page_Description);
}
@@ -126,49 +124,30 @@ public abstract class AbstractRepositoryQueryPage2 extends AbstractRepositoryQue
});
}
- private void createButtonGroup(Composite control) {
+ private Control createUpdateButton(final Composite control) {
Composite composite = new Composite(control, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
composite.setLayout(layout);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).span(2, 1).applyTo(composite);
- createButtons(composite);
- }
- protected void createButtons(final Composite control) {
- if (getSearchContainer() == null) {
- return;
- }
- if (needsClearButton) {
- Button clearButton = new Button(control, SWT.PUSH);
- clearButton.setText(Messages.AbstractRepositoryQueryPage2_Clear_Fields);
- clearButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
- clearButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- clearFields();
+ updateButton = new Button(composite, SWT.PUSH);
+ updateButton.setText(Messages.AbstractRepositoryQueryPage2__Refresh_From_Repository);
+ updateButton.setLayoutData(new GridData());
+ updateButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (getTaskRepository() != null) {
+ updateAttributesFromRepository(true);
+ } else {
+ MessageDialog.openInformation(
+ Display.getCurrent().getActiveShell(),
+ Messages.AbstractRepositoryQueryPage2_Update_Attributes_Failed,
+ Messages.AbstractRepositoryQueryPage2_No_repository_available_please_add_one_using_the_Task_Repositories_view);
}
+ }
+ });
- });
- }
- if (needsRepositoryConfiguration) {
- updateButton = new Button(control, SWT.PUSH);
- updateButton.setText(Messages.AbstractRepositoryQueryPage2__Refresh_From_Repository);
- updateButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
-// updateButton.setImage(TasksUiImages.REPOSITORY_UPDATE_CONFIGURATION.createImage());
- updateButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (getTaskRepository() != null) {
- updateAttributesFromRepository(true);
- } else {
- MessageDialog.openInformation(
- Display.getCurrent().getActiveShell(),
- Messages.AbstractRepositoryQueryPage2_Update_Attributes_Failed,
- Messages.AbstractRepositoryQueryPage2_No_repository_available_please_add_one_using_the_Task_Repositories_view);
- }
- }
- });
- }
+ return composite;
}
@Override
@@ -290,47 +269,4 @@ public abstract class AbstractRepositoryQueryPage2 extends AbstractRepositoryQue
}
}
- public void setExtraButtonState(Button button) {
- Integer obj = (Integer) button.getData();
- if (obj == QueryWizardDialog.UPDATE_BUTTON_ID) {
- if (needsRepositoryConfiguration) {
- if (!button.isVisible()) {
- button.setVisible(true);
- }
- button.setEnabled(true);
- } else {
- if (button != null && button.isVisible()) {
- button.setVisible(false);
- }
- }
- } else if (obj == QueryWizardDialog.CLEAR_BUTTON_ID) {
- if (!button.isVisible()) {
- button.setVisible(true);
- }
- button.setEnabled(true);
- }
-
- }
-
- public boolean handleExtraButtonPressed(int buttonId) {
- if (buttonId == QueryWizardDialog.UPDATE_BUTTON_ID) {
- if (getTaskRepository() != null) {
- updateAttributesFromRepository(true);
- } else {
- MessageDialog.openInformation(
- Display.getCurrent().getActiveShell(),
- Messages.AbstractRepositoryQueryPage2_Update_Attributes_Failed,
- Messages.AbstractRepositoryQueryPage2_No_repository_available_please_add_one_using_the_Task_Repositories_view);
- }
- return true;
- } else if (buttonId == QueryWizardDialog.CLEAR_BUTTON_ID) {
- clearFields();
- return true;
- }
- return false;
- }
-
- public void clearFields() {
-
- }
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/Messages.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/Messages.java
index 62248c8..a18e181 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/Messages.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/Messages.java
@@ -290,4 +290,23 @@ public class Messages extends NLS {
public static String QueryWizardDialog_Clear_Fields;
public static String QueryWizardDialog_Update_Attributes_from_Repository;
+
+ public static String AbstractRepositoryQueryPage2__Refresh_From_Repository;
+
+ public static String AbstractRepositoryQueryPage2__Title_;
+
+ public static String AbstractRepositoryQueryPage2_Clear_Fields;
+
+ public static String AbstractRepositoryQueryPage2_Create_a_Query_Page_Description;
+
+ public static String AbstractRepositoryQueryPage2_Enter_a_title;
+
+ public static String AbstractRepositoryQueryPage2_Enter_query_parameters;
+
+ public static String AbstractRepositoryQueryPage2_No_repository_available_please_add_one_using_the_Task_Repositories_view;
+
+ public static String AbstractRepositoryQueryPage2_Refresh_Configuration_Button_Label;
+
+ public static String AbstractRepositoryQueryPage2_Update_Attributes_Failed;
+
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/QueryWizardDialog.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/QueryWizardDialog.java
index 0ca217f..f3c4d16 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/QueryWizardDialog.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/QueryWizardDialog.java
@@ -16,22 +16,22 @@ import java.util.HashMap;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.mylyn.internal.provisional.commons.ui.dialogs.EnhancedWizardDialog;
-import org.eclipse.mylyn.internal.provisional.tasks.ui.wizards.AbstractRepositoryQueryPage2;
+import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositoryQueryPage2;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
public class QueryWizardDialog extends EnhancedWizardDialog {
- private static final String UPDATE_BUTTON_KEY = "update"; //$NON-NLS-1$
+ private static final String REFRESH_BUTTON_KEY = "refresh"; //$NON-NLS-1$
private static final String CLEAR_BUTTON_KEY = "clear"; //$NON-NLS-1$
- public static final int UPDATE_BUTTON_ID = 2001;
+ public static final int REFRESH_BUTTON_ID = 2001;
public static final int CLEAR_BUTTON_ID = 2002;
- private Button updateButton;
+ private Button refreshButton;
private Button clearButton;
@@ -49,21 +49,26 @@ public class QueryWizardDialog extends EnhancedWizardDialog {
@Override
protected void createExtraButtons(Composite composite) {
- clearButton = createButton(composite, CLEAR_BUTTON_ID, Messages.QueryWizardDialog_Clear_Fields, false);
- clearButton.setVisible(false);
- setButtonLayoutData(clearButton);
- updateButton = createButton(composite, UPDATE_BUTTON_ID,
- Messages.QueryWizardDialog_Update_Attributes_from_Repository, false);
-// updateButton.setImage(TasksUiImages.REPOSITORY_UPDATE_CONFIGURATION_SMALL.createImage());
- updateButton.setVisible(false);
- setButtonLayoutData(updateButton);
+ if (abstractRepositoryQueryPage != null) {
+ if (abstractRepositoryQueryPage.needsRefresh()) {
+ refreshButton = createButton(composite, REFRESH_BUTTON_ID,
+ Messages.QueryWizardDialog_Update_Attributes_from_Repository, false);
+ refreshButton.setVisible(false);
+ setButtonLayoutData(refreshButton);
+ }
+ if (abstractRepositoryQueryPage.needsClear()) {
+ clearButton = createButton(composite, CLEAR_BUTTON_ID, Messages.QueryWizardDialog_Clear_Fields, false);
+ clearButton.setVisible(false);
+ setButtonLayoutData(clearButton);
+ }
+ }
}
@Override
protected void updateExtraButtons() {
if (abstractRepositoryQueryPage != null) {
abstractRepositoryQueryPage.setExtraButtonState(clearButton);
- abstractRepositoryQueryPage.setExtraButtonState(updateButton);
+ abstractRepositoryQueryPage.setExtraButtonState(refreshButton);
}
}
@@ -87,9 +92,9 @@ public class QueryWizardDialog extends EnhancedWizardDialog {
savedEnabledState.put(CLEAR_BUTTON_KEY, clearButton.getEnabled());
clearButton.setEnabled(false);
}
- if (updateButton != null && updateButton.getShell() == getShell()) {
- savedEnabledState.put(UPDATE_BUTTON_KEY, updateButton.getEnabled());
- updateButton.setEnabled(false);
+ if (refreshButton != null && refreshButton.getShell() == getShell()) {
+ savedEnabledState.put(REFRESH_BUTTON_KEY, refreshButton.getEnabled());
+ refreshButton.setEnabled(false);
}
}
return savedEnabledState;
@@ -107,9 +112,9 @@ public class QueryWizardDialog extends EnhancedWizardDialog {
if (clearButton != null && savedValidateEnabledState != null) {
clearButton.setEnabled(savedValidateEnabledState);
}
- savedValidateEnabledState = savedEnabledState.get(UPDATE_BUTTON_KEY);
- if (updateButton != null && savedValidateEnabledState != null) {
- updateButton.setEnabled(savedValidateEnabledState);
+ savedValidateEnabledState = savedEnabledState.get(REFRESH_BUTTON_KEY);
+ if (refreshButton != null && savedValidateEnabledState != null) {
+ refreshButton.setEnabled(savedValidateEnabledState);
}
}
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/messages.properties b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/messages.properties
index e1a25a3..eae7251 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/messages.properties
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/messages.properties
@@ -159,3 +159,13 @@ LocalRepositorySettingsPage_Configure_the_local_repository=Configure the local r
LocalRepositorySettingsPage_Local_Repository_Settings=Local Repository Settings
QueryWizardDialog_Clear_Fields=Clear Fields
QueryWizardDialog_Update_Attributes_from_Repository=Refresh
+
+AbstractRepositoryQueryPage2__Refresh_From_Repository=&Refresh
+AbstractRepositoryQueryPage2__Title_=&Title:
+AbstractRepositoryQueryPage2_Clear_Fields=Clear Fields
+AbstractRepositoryQueryPage2_Create_a_Query_Page_Description=Create a query.
+AbstractRepositoryQueryPage2_Enter_a_title=Enter a title
+AbstractRepositoryQueryPage2_Enter_query_parameters=Enter query parameters
+AbstractRepositoryQueryPage2_No_repository_available_please_add_one_using_the_Task_Repositories_view=No repository available, please add one using the Task Repositories view.
+AbstractRepositoryQueryPage2_Refresh_Configuration_Button_Label=Refresh Configuration
+AbstractRepositoryQueryPage2_Update_Attributes_Failed=Update Attributes Failed
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositoryQueryPage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositoryQueryPage.java
index 0140e79..09d75c7 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositoryQueryPage.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositoryQueryPage.java
@@ -32,6 +32,8 @@ import org.eclipse.swt.widgets.Control;
/**
* Extend to provide repository-specific query page to the Workbench search dialog.
+ * <p>
+ * It is recommended that clients extend {@link AbstractRepositoryQueryPage2} instead.
*
* @author Rob Elves
* @author Steffen Pingel
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositoryQueryPage2.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositoryQueryPage2.java
new file mode 100644
index 0000000..2b4204c
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositoryQueryPage2.java
@@ -0,0 +1,426 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 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
+ * Frank Becker - improvements
+ *******************************************************************************/
+package org.eclipse.mylyn.tasks.ui.wizards;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.wizard.ProgressMonitorPart;
+import org.eclipse.mylyn.internal.provisional.commons.ui.CommonUiUtil;
+import org.eclipse.mylyn.internal.provisional.commons.ui.ProgressContainer;
+import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
+import org.eclipse.mylyn.internal.tasks.ui.wizards.Messages;
+import org.eclipse.mylyn.internal.tasks.ui.wizards.QueryWizardDialog;
+import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
+import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.ui.TasksUi;
+import org.eclipse.swt.SWT;
+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.FillLayout;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+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.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.progress.IProgressService;
+
+/**
+ * @author Steffen Pingel
+ * @author Frank Becker
+ * @since 3.7
+ */
+public abstract class AbstractRepositoryQueryPage2 extends AbstractRepositoryQueryPage {
+
+ private Button cancelButton;
+
+ private final AbstractRepositoryConnector connector;
+
+ private boolean firstTime = true;
+
+ private Composite innerComposite;
+
+ private boolean needsClear;
+
+ private boolean needsRefresh = true;
+
+ private ProgressContainer progressContainer;
+
+ private Button refreshButton;
+
+ private Text titleText;
+
+ private Composite buttonComposite;
+
+ public AbstractRepositoryQueryPage2(String pageName, TaskRepository repository, IRepositoryQuery query) {
+ super(pageName, repository, query);
+ this.connector = TasksUi.getRepositoryConnector(getTaskRepository().getConnectorKind());
+ setTitle(Messages.AbstractRepositoryQueryPage2_Enter_query_parameters);
+ }
+
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(composite);
+ GridLayout layout = new GridLayout(2, false);
+ if (inSearchContainer()) {
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ }
+ composite.setLayout(layout);
+
+ createTitleGroup(composite);
+
+ innerComposite = new Composite(composite, SWT.NONE);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).span(2, 1).applyTo(innerComposite);
+ innerComposite.setLayout(new FillLayout());
+ createPageContent(innerComposite);
+
+ createButtonGroup(composite);
+
+ if (!needsRefresh) {
+ setDescription(Messages.AbstractRepositoryQueryPage2_Create_a_Query_Page_Description);
+ }
+
+ if (getQuery() != null) {
+ titleText.setText(getQuery().getSummary());
+ restoreState(getQuery());
+ }
+
+ Dialog.applyDialogFont(composite);
+ setControl(composite);
+ }
+
+ @Override
+ public String getQueryTitle() {
+ return (titleText != null) ? titleText.getText() : null;
+ }
+
+ public boolean handleExtraButtonPressed(int buttonId) {
+ if (buttonId == QueryWizardDialog.REFRESH_BUTTON_ID) {
+ if (getTaskRepository() != null) {
+ updateAttributesFromRepository(true);
+ } else {
+ MessageDialog.openInformation(
+ Display.getCurrent().getActiveShell(),
+ Messages.AbstractRepositoryQueryPage2_Update_Attributes_Failed,
+ Messages.AbstractRepositoryQueryPage2_No_repository_available_please_add_one_using_the_Task_Repositories_view);
+ }
+ return true;
+ } else if (buttonId == QueryWizardDialog.CLEAR_BUTTON_ID) {
+ doClearFields();
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean isPageComplete() {
+ if (titleText != null && titleText.getText().length() > 0) {
+ return true;
+ }
+ setMessage(Messages.AbstractRepositoryQueryPage2_Enter_a_title);
+ return false;
+ }
+
+ public boolean needsClear() {
+ return needsClear;
+ }
+
+ public boolean needsRefresh() {
+ return needsRefresh;
+ }
+
+ @Override
+ public boolean performSearch() {
+ if (inSearchContainer()) {
+ saveState();
+ }
+ return super.performSearch();
+ }
+
+ @Override
+ public void saveState() {
+ if (inSearchContainer()) {
+ RepositoryQuery query = new RepositoryQuery(getTaskRepository().getConnectorKind(), "handle"); //$NON-NLS-1$
+ applyTo(query);
+
+ IDialogSettings settings = getDialogSettings();
+ settings.put(getSavedStateSettingKey(), query.getRepositoryUrl());
+ }
+ }
+
+ public void setExtraButtonState(Button button) {
+ Integer obj = (Integer) button.getData();
+ if (obj == QueryWizardDialog.REFRESH_BUTTON_ID) {
+ if (needsRefresh) {
+ if (!button.isVisible()) {
+ button.setVisible(true);
+ }
+ button.setEnabled(true);
+ } else {
+ if (button != null && button.isVisible()) {
+ button.setVisible(false);
+ }
+ }
+ } else if (obj == QueryWizardDialog.CLEAR_BUTTON_ID) {
+ if (!button.isVisible()) {
+ button.setVisible(true);
+ }
+ button.setEnabled(true);
+ }
+
+ }
+
+ public void setNeedsClear(boolean needsClearButton) {
+ this.needsClear = needsClearButton;
+ }
+
+ public void setNeedsRefresh(boolean needsRepositoryConfiguration) {
+ this.needsRefresh = needsRepositoryConfiguration;
+ }
+
+ public void setQueryTitle(String text) {
+ if (titleText != null) {
+ titleText.setText(text);
+ }
+ }
+
+ @Override
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+
+ if (getSearchContainer() != null) {
+ getSearchContainer().setPerformActionEnabled(true);
+ }
+
+ if (visible && firstTime) {
+ firstTime = false;
+ if (!hasRepositoryConfiguration() && needsRefresh) {
+ // delay the execution so the dialog's progress bar is visible
+ // when the attributes are updated
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (getControl() != null && !getControl().isDisposed()) {
+ initializePage();
+ }
+ }
+
+ });
+ } else {
+ // no remote connection is needed to get attributes therefore do
+ // not use delayed execution to avoid flickering
+ initializePage();
+ }
+ }
+ }
+
+ private void createButtonGroup(Composite parent) {
+ buttonComposite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(1, false);
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ buttonComposite.setLayout(layout);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).span(2, 1).applyTo(buttonComposite);
+ createButtons(buttonComposite);
+ layout.numColumns = buttonComposite.getChildren().length;
+ }
+
+ private void createTitleGroup(Composite control) {
+ if (inSearchContainer()) {
+ return;
+ }
+
+ Label titleLabel = new Label(control, SWT.NONE);
+ titleLabel.setText(Messages.AbstractRepositoryQueryPage2__Title_);
+
+ titleText = new Text(control, SWT.BORDER);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).applyTo(titleText);
+ titleText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ getContainer().updateButtons();
+ }
+ });
+ }
+
+ private void initializePage() {
+ if (needsRefresh) {
+ updateAttributesFromRepository(false);
+ }
+ boolean restored = (getQuery() != null);
+ if (inSearchContainer()) {
+ restored |= restoreSavedState();
+ }
+ if (!restored) {
+ // initialize with default values
+ }
+ }
+
+ private void updateAttributesFromRepository(final boolean force) {
+ if (!hasRepositoryConfiguration() || force) {
+ setErrorMessage(null);
+ try {
+ IRunnableWithProgress runnable = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ monitor = SubMonitor.convert(monitor);
+ monitor.beginTask(Messages.AbstractRepositoryQueryPage2_Refresh_Configuration_Button_Label,
+ IProgressMonitor.UNKNOWN);
+ try {
+ connector.updateRepositoryConfiguration(getTaskRepository(), monitor);
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ } catch (OperationCanceledException e) {
+ throw new InterruptedException();
+ } finally {
+ monitor.done();
+ }
+ }
+ };
+
+ if (getContainer() != null) {
+ getContainer().run(true, true, runnable);
+ } else if (progressContainer != null) {
+ progressContainer.run(true, true, runnable);
+ } else if (getSearchContainer() != null) {
+ getSearchContainer().getRunnableContext().run(true, true, runnable);
+ } else {
+ IProgressService service = PlatformUI.getWorkbench().getProgressService();
+ service.busyCursorWhile(runnable);
+ }
+ } catch (InvocationTargetException e) {
+ if (e.getCause() instanceof CoreException) {
+ setErrorMessage(((CoreException) e.getCause()).getStatus().getMessage());
+ } else {
+ setErrorMessage(e.getCause().getMessage());
+ }
+ return;
+ } catch (InterruptedException e) {
+ return;
+ }
+ }
+
+ doRefresh();
+ }
+
+ protected void createButtons(final Composite composite) {
+ if (getContainer() instanceof QueryWizardDialog) {
+ // refresh and clear buttons are provided by the dialog
+ return;
+ }
+ if (needsRefresh) {
+ refreshButton = new Button(composite, SWT.PUSH);
+ refreshButton.setText(Messages.AbstractRepositoryQueryPage2__Refresh_From_Repository);
+ refreshButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (getTaskRepository() != null) {
+ updateAttributesFromRepository(true);
+ } else {
+ MessageDialog.openInformation(
+ Display.getCurrent().getActiveShell(),
+ Messages.AbstractRepositoryQueryPage2_Update_Attributes_Failed,
+ Messages.AbstractRepositoryQueryPage2_No_repository_available_please_add_one_using_the_Task_Repositories_view);
+ }
+ }
+ });
+ }
+ if (needsClear) {
+ Button clearButton = new Button(composite, SWT.PUSH);
+ clearButton.setText(Messages.AbstractRepositoryQueryPage2_Clear_Fields);
+ clearButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ doClearFields();
+ }
+ });
+ }
+ final ProgressMonitorPart progressMonitorPart = new ProgressMonitorPart(composite, null);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.BEGINNING).grab(true, false).applyTo(progressMonitorPart);
+ progressMonitorPart.setVisible(false);
+ progressContainer = new ProgressContainer(composite.getShell(), progressMonitorPart) {
+ @Override
+ protected void restoreUiState(java.util.Map<Object, Object> state) {
+ cancelButton.setVisible(false);
+ CommonUiUtil.setEnabled(innerComposite, true);
+ for (Control control : buttonComposite.getChildren()) {
+ if (control instanceof ProgressMonitorPart) {
+ break;
+ }
+ control.setEnabled(true);
+ }
+ }
+
+ @Override
+ protected void saveUiState(java.util.Map<Object, Object> savedState) {
+ CommonUiUtil.setEnabled(innerComposite, false);
+ for (Control control : buttonComposite.getChildren()) {
+ if (control instanceof ProgressMonitorPart) {
+ break;
+ }
+ control.setEnabled(false);
+ }
+ cancelButton.setEnabled(true);
+ cancelButton.setVisible(true);
+ }
+ };
+
+ cancelButton = new Button(composite, SWT.PUSH);
+ cancelButton.setText(IDialogConstants.CANCEL_LABEL);
+ cancelButton.setVisible(false);
+ progressContainer.setCancelButton(cancelButton);
+ }
+
+ protected abstract void createPageContent(Composite parent);
+
+ protected void doClearFields() {
+ }
+
+ protected abstract void doRefresh();
+
+ protected AbstractRepositoryConnector getConnector() {
+ return connector;
+ }
+
+ protected String getSavedStateSettingKey() {
+ return getName() + "." + getTaskRepository().getRepositoryUrl(); //$NON-NLS-1$
+ }
+
+ protected abstract boolean hasRepositoryConfiguration();
+
+ protected boolean restoreSavedState() {
+ IDialogSettings settings = getDialogSettings();
+ String queryUrl = settings.get(getSavedStateSettingKey());
+ if (queryUrl != null) {
+ RepositoryQuery query = new RepositoryQuery(getTaskRepository().getConnectorKind(), "handle"); //$NON-NLS-1$
+ query.setUrl(queryUrl);
+ return restoreState(query);
+ }
+ return false;
+ }
+
+ protected abstract boolean restoreState(IRepositoryQuery query);
+
+}
diff --git a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/TracQueryPage.java b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/TracQueryPage.java
index 4adb3db..549d82c 100644
--- a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/TracQueryPage.java
+++ b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/TracQueryPage.java
@@ -14,21 +14,13 @@ package org.eclipse.mylyn.internal.trac.ui.wizard;
import java.util.HashMap;
import java.util.Map;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.mylyn.commons.core.StatusHandler;
-import org.eclipse.mylyn.internal.provisional.commons.ui.CommonUiUtil;
-import org.eclipse.mylyn.internal.provisional.commons.ui.ICoreRunnable;
import org.eclipse.mylyn.internal.trac.core.TracCorePlugin;
import org.eclipse.mylyn.internal.trac.core.TracRepositoryConnector;
import org.eclipse.mylyn.internal.trac.core.client.ITracClient;
-import org.eclipse.mylyn.internal.trac.core.client.TracException;
import org.eclipse.mylyn.internal.trac.core.model.TracSearch;
import org.eclipse.mylyn.internal.trac.core.model.TracSearchFilter;
import org.eclipse.mylyn.internal.trac.core.model.TracSearchFilter.CompareOperator;
@@ -37,453 +29,100 @@ import org.eclipse.mylyn.internal.trac.ui.TracUiPlugin;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.TasksUi;
-import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositoryQueryPage;
+import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositoryQueryPage2;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
/**
- * Trac search page. Provides a form similar to the one the Bugzilla connector uses.
+ * Trac search page.
*
* @author Steffen Pingel
*/
-public class TracQueryPage extends AbstractRepositoryQueryPage {
+public class TracQueryPage extends AbstractRepositoryQueryPage2 {
- private Text titleText;
-
- private static final int PRODUCT_HEIGHT = 60;
-
- private static final int STATUS_HEIGHT = 40;
-
- protected final static String PAGE_NAME = "TracSearchPage"; //$NON-NLS-1$
-
- private static final String SEARCH_URL_ID = PAGE_NAME + ".SEARCHURL"; //$NON-NLS-1$
-
- protected Combo summaryText = null;
-
- protected Combo repositoryCombo = null;
-
- private TextSearchField summaryField;
-
- private TextSearchField descriptionField;
-
- private ListSearchField componentField;
-
- private ListSearchField versionField;
-
- private ListSearchField milestoneField;
-
- private ListSearchField priorityField;
-
- private ListSearchField typeField;
-
- private ListSearchField resolutionField;
-
- private ListSearchField statusField;
-
- private Button updateButton;
-
- private TextSearchField keywordsField;
-
- private final Map<String, SearchField> searchFieldByName = new HashMap<String, SearchField>();
-
- private boolean firstTime = true;
-
- // private UserSearchField ownerField;
- //
- // private UserSearchField reporterField;
- //
- // private UserSearchField ccField;
-
- public TracQueryPage(TaskRepository repository, IRepositoryQuery query) {
- super(Messages.TracQueryPage_Enter_query_parameters, repository, query);
- setTitle(Messages.TracQueryPage_Enter_query_parameters);
- setDescription(Messages.TracQueryPage_If_attributes_are_blank_or_stale_press_the_Update_button);
- }
-
- public TracQueryPage(TaskRepository repository) {
- this(repository, null);
- }
-
- public void createControl(Composite parent) {
- Composite control = new Composite(parent, SWT.NONE);
- GridData gd = new GridData(GridData.FILL_BOTH);
- control.setLayoutData(gd);
- GridLayout layout = new GridLayout(4, false);
- if (inSearchContainer()) {
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- }
- control.setLayout(layout);
-
- createTitleGroup(control);
-
- summaryField = new TextSearchField("summary"); //$NON-NLS-1$
- summaryField.createControls(control, Messages.TracQueryPage_Summary);
-
- descriptionField = new TextSearchField("description"); //$NON-NLS-1$
- descriptionField.createControls(control, Messages.TracQueryPage_Description);
-
- keywordsField = new TextSearchField("keywords"); //$NON-NLS-1$
- keywordsField.createControls(control, Messages.TracQueryPage_Keywords);
-
- createOptionsGroup(control);
-
- createUserGroup(control);
-
- if (getQuery() != null) {
- titleText.setText(getQuery().getSummary());
- TracSearch search = TracUtil.toTracSearch(getQuery());
- if (search != null) {
- restoreWidgetValues(search);
- }
- }
-
- Dialog.applyDialogFont(control);
- setControl(control);
- }
+ private class ListSearchField extends SearchField {
- @Override
- public boolean canFlipToNextPage() {
- return false;
- }
+ private List list;
- private void restoreWidgetValues(TracSearch search) {
- java.util.List<TracSearchFilter> filters = search.getFilters();
- for (TracSearchFilter filter : filters) {
- SearchField field = searchFieldByName.get(filter.getFieldName());
- if (field != null) {
- field.setFilter(filter);
- } else {
- StatusHandler.log(new Status(IStatus.WARNING, TracUiPlugin.ID_PLUGIN,
- "Ignoring invalid search filter: " + filter)); //$NON-NLS-1$
- }
+ public ListSearchField(String fieldName) {
+ super(fieldName);
}
- }
- private void createTitleGroup(Composite control) {
- if (inSearchContainer()) {
- return;
+ public void createControls(Composite parent, int height) {
+ list = new List(parent, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gd.heightHint = height;
+ list.setLayoutData(gd);
}
- Label titleLabel = new Label(control, SWT.NONE);
- titleLabel.setText(Messages.TracQueryPage_Query_Title);
-
- titleText = new Text(control, SWT.BORDER);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
- gd.horizontalSpan = 3;
- titleText.setLayoutData(gd);
- titleText.addKeyListener(new KeyListener() {
- public void keyPressed(KeyEvent e) {
- // ignore
- }
-
- public void keyReleased(KeyEvent e) {
- getContainer().updateButtons();
- }
- });
- }
-
- protected Control createOptionsGroup(Composite control) {
- Group group = new Group(control, SWT.NONE);
- // group.setText("Ticket Attributes");
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- group.setLayout(layout);
- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- gd.horizontalSpan = 4;
- group.setLayoutData(gd);
-
- createProductAttributes(group);
- createTicketAttributes(group);
- createUpdateButton(group);
-
- return group;
- }
-
- protected void createUserGroup(Composite control) {
- UserSearchField userField = new UserSearchField();
- userField.createControls(control);
- }
-
- /**
- * Creates the area for selection on product attributes component/version/milestone.
- */
- protected Control createProductAttributes(Composite control) {
- Composite group = new Composite(control, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 3;
- group.setLayout(layout);
- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- gd.horizontalSpan = 1;
- group.setLayoutData(gd);
-
- Label label = new Label(group, SWT.LEFT);
- label.setText(Messages.TracQueryPage_Component);
-
- label = new Label(group, SWT.LEFT);
- label.setText(Messages.TracQueryPage_Version);
-
- label = new Label(group, SWT.LEFT);
- label.setText(Messages.TracQueryPage_Milestone);
-
- componentField = new ListSearchField("component"); //$NON-NLS-1$
- componentField.createControls(group, PRODUCT_HEIGHT);
-
- versionField = new ListSearchField("version"); //$NON-NLS-1$
- versionField.createControls(group, PRODUCT_HEIGHT);
-
- milestoneField = new ListSearchField("milestone"); //$NON-NLS-1$
- milestoneField.createControls(group, PRODUCT_HEIGHT);
-
- return group;
- }
-
- /**
- * Creates the area for selection of ticket attributes status/resolution/priority.
- */
- protected Control createTicketAttributes(Composite control) {
- Composite group = new Composite(control, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 4;
- group.setLayout(layout);
- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- gd.horizontalSpan = 1;
- group.setLayoutData(gd);
-
- Label label = new Label(group, SWT.LEFT);
- label.setText(Messages.TracQueryPage_Status);
-
- label = new Label(group, SWT.LEFT);
- label.setText(Messages.TracQueryPage_Resolution);
-
- label = new Label(group, SWT.LEFT);
- label.setText(Messages.TracQueryPage_Type);
-
- label = new Label(group, SWT.LEFT);
- label.setText(Messages.TracQueryPage_Priority);
-
- statusField = new ListSearchField("status"); //$NON-NLS-1$
- statusField.createControls(group, STATUS_HEIGHT);
-
- resolutionField = new ListSearchField("resolution"); //$NON-NLS-1$
- resolutionField.createControls(group, STATUS_HEIGHT);
-
- typeField = new ListSearchField("type"); //$NON-NLS-1$
- typeField.createControls(group, STATUS_HEIGHT);
-
- priorityField = new ListSearchField("priority"); //$NON-NLS-1$
- priorityField.createControls(group, STATUS_HEIGHT);
-
- return group;
- }
-
- protected Control createUpdateButton(final Composite control) {
- Composite group = new Composite(control, SWT.NONE);
- GridLayout layout = new GridLayout(2, false);
- group.setLayout(layout);
- group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- updateButton = new Button(group, SWT.PUSH);
- updateButton.setText(Messages.TracQueryPage_Update_Attributes_from_Repository);
- updateButton.setLayoutData(new GridData());
- updateButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (getTaskRepository() != null) {
- updateAttributesFromRepository(true);
- } else {
- MessageDialog.openInformation(Display.getCurrent().getActiveShell(),
- Messages.TracQueryPage_Update_Attributes_Failed,
- Messages.TracQueryPage_No_repository_available);
- }
+ @Override
+ public TracSearchFilter getFilter() {
+ int[] indicies = list.getSelectionIndices();
+ if (indicies.length == 0) {
+ return null;
}
- });
-
- return group;
- }
-
- @Override
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- if (getSearchContainer() != null) {
- getSearchContainer().setPerformActionEnabled(true);
- }
-
- if (visible && firstTime) {
- firstTime = false;
- if (!hasAttributes()) {
- // delay the execution so the dialog's progress bar is visible
- // when the attributes are updated
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- if (getControl() != null && !getControl().isDisposed()) {
- initializePage();
- }
- }
-
- });
- } else {
- // no remote connection is needed to get attributes therefore do
- // not use delayed execution to avoid flickering
- initializePage();
+ TracSearchFilter newFilter = new TracSearchFilter(getFieldName());
+ newFilter.setOperator(CompareOperator.IS);
+ for (int i : indicies) {
+ newFilter.addValue(list.getItem(i));
}
+ return newFilter;
}
- }
-
- private void initializePage() {
- updateAttributesFromRepository(false);
- boolean restored = (getQuery() != null);
- if (inSearchContainer()) {
- restored |= restoreWidgetValues();
- }
- if (!restored) {
- // initialize with default values
- }
- }
- private boolean hasAttributes() {
- TracRepositoryConnector connector = (TracRepositoryConnector) TasksUi.getRepositoryManager()
- .getRepositoryConnector(TracCorePlugin.CONNECTOR_KIND);
- ITracClient client = connector.getClientManager().getTracClient(getTaskRepository());
- return client.hasAttributes();
- }
-
- private void updateAttributesFromRepository(final boolean force) {
- TracRepositoryConnector connector = (TracRepositoryConnector) TasksUi.getRepositoryManager()
- .getRepositoryConnector(TracCorePlugin.CONNECTOR_KIND);
- final ITracClient client = connector.getClientManager().getTracClient(getTaskRepository());
-
- if (!client.hasAttributes() || force) {
- try {
- ICoreRunnable runnable = new ICoreRunnable() {
-
- public void run(IProgressMonitor monitor) throws CoreException {
- try {
- client.updateAttributes(monitor, force);
- } catch (TracException e) {
- throw new CoreException(TracCorePlugin.toStatus(e, getTaskRepository()));
- }
- }
- };
-
- if (getContainer() != null) {
- CommonUiUtil.run(getContainer(), runnable);
- } else if (getSearchContainer() != null) {
- CommonUiUtil.run(getSearchContainer().getRunnableContext(), runnable);
+ @Override
+ public void setFilter(TracSearchFilter filter) {
+ list.deselectAll();
+ java.util.List<String> values = filter.getValues();
+ for (String item : values) {
+ int i = list.indexOf(item);
+ if (i != -1) {
+ list.select(i);
} else {
- CommonUiUtil.run(PlatformUI.getWorkbench().getProgressService(), runnable);
+ list.add(item, 0);
+ list.select(0);
}
- } catch (CoreException e) {
- CommonUiUtil.setMessage(this, e.getStatus());
- return;
- } catch (OperationCanceledException e) {
- return;
}
}
- statusField.setValues(client.getTicketStatus());
- resolutionField.setValues(client.getTicketResolutions());
- typeField.setValues(client.getTicketTypes());
- priorityField.setValues(client.getPriorities());
-
- componentField.setValues(client.getComponents());
- versionField.setValues(client.getVersions());
- milestoneField.setValues(client.getMilestones());
- }
-
- @Override
- public boolean isPageComplete() {
- if (titleText != null && titleText.getText().length() > 0) {
- return true;
- }
- return false;
- }
-
- public String getQueryUrl(String repsitoryUrl) {
- TracSearch search = getTracSearch();
+ public void setValues(Object[] items) {
+ // preserve selected values
+ TracSearchFilter filter = getFilter();
- StringBuilder sb = new StringBuilder();
- sb.append(repsitoryUrl);
- sb.append(ITracClient.QUERY_URL);
- sb.append(search.toUrl());
- return sb.toString();
- }
+ list.removeAll();
+ if (items != null) {
+ list.setEnabled(true);
+ for (Object item : items) {
+ list.add(item.toString());
+ }
- private TracSearch getTracSearch() {
- TracSearch search = new TracSearch();
- for (SearchField field : searchFieldByName.values()) {
- TracSearchFilter filter = field.getFilter();
- if (filter != null) {
- search.addFilter(filter);
+ // restore selected values
+ if (filter != null) {
+ setFilter(filter);
+ }
+ } else {
+ list.setEnabled(false);
}
}
- return search;
- }
-
- // public boolean performAction() {
- //
- // Proxy proxySettings = TasksUiPlugin.getDefault().getProxySettings();
- // SearchHitCollector collector = new
- // SearchHitCollector(TasksUiPlugin.getTaskList(),
- // repository, getQuery(), proxySettings);
- // NewSearchUI.runQueryInBackground(collector);
- //
- // return true;
- // }
-
- @Override
- public boolean performSearch() {
- if (inSearchContainer()) {
- saveState();
- }
-
- return super.performSearch();
- }
-
- @Override
- public IDialogSettings getDialogSettings() {
- IDialogSettings settings = TracUiPlugin.getDefault().getDialogSettings();
- IDialogSettings dialogSettings = settings.getSection(PAGE_NAME);
- if (dialogSettings == null) {
- dialogSettings = settings.addNewSection(PAGE_NAME);
- }
- return dialogSettings;
- }
-
- private boolean restoreWidgetValues() {
- IDialogSettings settings = getDialogSettings();
- String repoId = "." + getTaskRepository().getRepositoryUrl(); //$NON-NLS-1$
- String searchUrl = settings.get(SEARCH_URL_ID + repoId);
- if (searchUrl == null) {
- return false;
- }
-
- restoreWidgetValues(new TracSearch(searchUrl));
- return true;
- }
+// public void selectItems(String[] items) {
+// list.deselectAll();
+// for (String item : items) {
+// int i = list.indexOf(item);
+// if (i != -1) {
+// list.select(i);
+// }
+// }
+// }
- @Override
- public void saveState() {
- String repoId = "." + getTaskRepository().getRepositoryUrl(); //$NON-NLS-1$
- IDialogSettings settings = getDialogSettings();
- settings.put(SEARCH_URL_ID + repoId, getTracSearch().toUrl());
}
private abstract class SearchField {
@@ -511,14 +150,14 @@ public class TracQueryPage extends AbstractRepositoryQueryPage {
private class TextSearchField extends SearchField {
- private Combo conditionCombo;
+ private final CompareOperator[] compareOperators = { CompareOperator.CONTAINS, CompareOperator.CONTAINS_NOT,
+ CompareOperator.BEGINS_WITH, CompareOperator.ENDS_WITH, CompareOperator.IS, CompareOperator.IS_NOT, };
- protected Text searchText;
+ private Combo conditionCombo;
private Label label;
- private final CompareOperator[] compareOperators = { CompareOperator.CONTAINS, CompareOperator.CONTAINS_NOT,
- CompareOperator.BEGINS_WITH, CompareOperator.ENDS_WITH, CompareOperator.IS, CompareOperator.IS_NOT, };
+ protected Text searchText;
public TextSearchField(String fieldName) {
super(fieldName);
@@ -549,6 +188,19 @@ public class TracQueryPage extends AbstractRepositoryQueryPage {
return compareOperators[conditionCombo.getSelectionIndex()];
}
+ @Override
+ public TracSearchFilter getFilter() {
+ String text = getSearchText();
+ if (text.length() == 0) {
+ return null;
+ }
+
+ TracSearchFilter newFilter = new TracSearchFilter(getFieldName());
+ newFilter.setOperator(getCondition());
+ newFilter.addValue(getSearchText());
+ return newFilter;
+ }
+
public String getSearchText() {
return searchText.getText();
}
@@ -564,21 +216,8 @@ public class TracQueryPage extends AbstractRepositoryQueryPage {
return false;
}
- public void setSearchText(String text) {
- searchText.setText(text);
- }
-
- @Override
- public TracSearchFilter getFilter() {
- String text = getSearchText();
- if (text.length() == 0) {
- return null;
- }
-
- TracSearchFilter newFilter = new TracSearchFilter(getFieldName());
- newFilter.setOperator(getCondition());
- newFilter.addValue(getSearchText());
- return newFilter;
+ public void setFieldName(String fieldName) {
+ this.fieldName = fieldName;
}
@Override
@@ -588,91 +227,42 @@ public class TracQueryPage extends AbstractRepositoryQueryPage {
setSearchText(values.get(0));
}
- public void setFieldName(String fieldName) {
- this.fieldName = fieldName;
+ public void setSearchText(String text) {
+ searchText.setText(text);
}
}
- private class ListSearchField extends SearchField {
-
- private List list;
+ private class UserSearchField extends SearchField {
- public ListSearchField(String fieldName) {
- super(fieldName);
- }
+ class UserSelectionSearchField extends SearchField {
- public void setValues(Object[] items) {
- // preserve selected values
- TracSearchFilter filter = getFilter();
+ private final int index;
- list.removeAll();
- if (items != null) {
- list.setEnabled(true);
- for (Object item : items) {
- list.add(item.toString());
- }
+ public UserSelectionSearchField(String fieldName, int index) {
+ super(fieldName);
- // restore selected values
- if (filter != null) {
- setFilter(filter);
- }
- } else {
- list.setEnabled(false);
+ this.index = index;
}
- }
- public void createControls(Composite parent, int height) {
- list = new List(parent, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);
- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- gd.heightHint = height;
- list.setLayoutData(gd);
- }
-
- @Override
- public TracSearchFilter getFilter() {
- int[] indicies = list.getSelectionIndices();
- if (indicies.length == 0) {
+ @Override
+ public TracSearchFilter getFilter() {
+ if (index == getSelection()) {
+ textField.setFieldName(fieldName);
+ return textField.getFilter();
+ }
return null;
}
- TracSearchFilter newFilter = new TracSearchFilter(getFieldName());
- newFilter.setOperator(CompareOperator.IS);
- for (int i : indicies) {
- newFilter.addValue(list.getItem(i));
+ @Override
+ public void setFilter(TracSearchFilter filter) {
+ textField.setFieldName(fieldName);
+ textField.setFilter(filter);
+ setSelection(index);
}
- return newFilter;
- }
- @Override
- public void setFilter(TracSearchFilter filter) {
- list.deselectAll();
- java.util.List<String> values = filter.getValues();
- for (String item : values) {
- int i = list.indexOf(item);
- if (i != -1) {
- list.select(i);
- } else {
- list.add(item, 0);
- list.select(0);
- }
- }
}
-// public void selectItems(String[] items) {
-// list.deselectAll();
-// for (String item : items) {
-// int i = list.indexOf(item);
-// if (i != -1) {
-// list.select(i);
-// }
-// }
-// }
-
- }
-
- private class UserSearchField extends SearchField {
-
private final TextSearchField textField;
private Combo userCombo;
@@ -708,53 +298,285 @@ public class TracQueryPage extends AbstractRepositoryQueryPage {
public void setFilter(TracSearchFilter filter) {
}
+ private int getSelection() {
+ return userCombo.getSelectionIndex();
+ }
+
private void setSelection(int index) {
userCombo.select(index);
}
- private int getSelection() {
- return userCombo.getSelectionIndex();
+ }
+
+ private static final int HEIGHT_PRODUCT = 60;
+
+ private static final int HEIGHT_STATUS = 40;
+
+ private final static String PAGE_NAME = "TracSearchPage"; //$NON-NLS-1$
+
+ private static final String SEARCH_URL_ID = PAGE_NAME + ".SEARCHURL"; //$NON-NLS-1$
+
+ private ListSearchField componentField;
+
+ private TextSearchField descriptionField;
+
+ private TextSearchField keywordsField;
+
+ private ListSearchField milestoneField;
+
+ private ListSearchField priorityField;
+
+ private ListSearchField resolutionField;
+
+ private final Map<String, SearchField> searchFieldByName = new HashMap<String, SearchField>();
+
+ private ListSearchField statusField;
+
+ private TextSearchField summaryField;
+
+ private ListSearchField typeField;
+
+ // private UserSearchField ownerField;
+ //
+ // private UserSearchField reporterField;
+ //
+ // private UserSearchField ccField;
+
+ private ListSearchField versionField;
+
+ public TracQueryPage(TaskRepository repository) {
+ this(repository, null);
+ }
+
+ public TracQueryPage(TaskRepository repository, IRepositoryQuery query) {
+ super(PAGE_NAME, repository, query);
+ setTitle(Messages.TracQueryPage_Enter_query_parameters);
+ setDescription(Messages.TracQueryPage_If_attributes_are_blank_or_stale_press_the_Update_button);
+ }
+
+ @Override
+ public void applyTo(IRepositoryQuery query) {
+ query.setUrl(getQueryUrl(getTaskRepository().getRepositoryUrl()));
+ query.setSummary(getQueryTitle());
+ }
+
+ @Override
+ public boolean canFlipToNextPage() {
+ return false;
+ }
+
+ @Override
+ public void doRefresh() {
+ TracRepositoryConnector connector = (TracRepositoryConnector) TasksUi.getRepositoryManager()
+ .getRepositoryConnector(TracCorePlugin.CONNECTOR_KIND);
+ ITracClient client = connector.getClientManager().getTracClient(getTaskRepository());
+
+ statusField.setValues(client.getTicketStatus());
+ resolutionField.setValues(client.getTicketResolutions());
+ typeField.setValues(client.getTicketTypes());
+ priorityField.setValues(client.getPriorities());
+
+ componentField.setValues(client.getComponents());
+ versionField.setValues(client.getVersions());
+ milestoneField.setValues(client.getMilestones());
+ }
+
+ @Override
+ public IDialogSettings getDialogSettings() {
+ IDialogSettings settings = TracUiPlugin.getDefault().getDialogSettings();
+ IDialogSettings dialogSettings = settings.getSection(PAGE_NAME);
+ if (dialogSettings == null) {
+ dialogSettings = settings.addNewSection(PAGE_NAME);
}
+ return dialogSettings;
+ }
- class UserSelectionSearchField extends SearchField {
+ public String getQueryUrl(String repsitoryUrl) {
+ TracSearch search = getTracSearch();
- private final int index;
+ StringBuilder sb = new StringBuilder();
+ sb.append(repsitoryUrl);
+ sb.append(ITracClient.QUERY_URL);
+ sb.append(search.toUrl());
+ return sb.toString();
+ }
- public UserSelectionSearchField(String fieldName, int index) {
- super(fieldName);
+ @Override
+ public void saveState() {
+ IDialogSettings settings = getDialogSettings();
+ settings.put(getSavedStateSettingsKey(), getTracSearch().toUrl());
+ }
- this.index = index;
- }
+ private String getSavedStateSettingsKey() {
+ return SEARCH_URL_ID + "." + getTaskRepository().getRepositoryUrl(); //$NON-NLS-1$
+ }
- @Override
- public TracSearchFilter getFilter() {
- if (index == getSelection()) {
- textField.setFieldName(fieldName);
- return textField.getFilter();
- }
- return null;
+ private TracSearch getTracSearch() {
+ TracSearch search = new TracSearch();
+ for (SearchField field : searchFieldByName.values()) {
+ TracSearchFilter filter = field.getFilter();
+ if (filter != null) {
+ search.addFilter(filter);
}
+ }
+ return search;
+ }
- @Override
- public void setFilter(TracSearchFilter filter) {
- textField.setFieldName(fieldName);
- textField.setFilter(filter);
- setSelection(index);
+ private void restoreWidgetValues(TracSearch search) {
+ java.util.List<TracSearchFilter> filters = search.getFilters();
+ for (TracSearchFilter filter : filters) {
+ SearchField field = searchFieldByName.get(filter.getFieldName());
+ if (field != null) {
+ field.setFilter(filter);
+ } else {
+ StatusHandler.log(new Status(IStatus.WARNING, TracUiPlugin.ID_PLUGIN,
+ "Ignoring invalid search filter: " + filter)); //$NON-NLS-1$
}
-
}
+ }
+
+ protected Control createOptionsGroup(Composite control) {
+ Group group = new Group(control, SWT.NONE);
+ // group.setText("Ticket Attributes");
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ group.setLayout(layout);
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gd.horizontalSpan = 4;
+ group.setLayoutData(gd);
+
+ createProductAttributes(group);
+ createTicketAttributes(group);
+
+ return group;
+ }
+
+ @Override
+ protected void createPageContent(Composite parent) {
+ Composite control = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(4, false);
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ control.setLayout(layout);
+
+ summaryField = new TextSearchField("summary"); //$NON-NLS-1$
+ summaryField.createControls(control, Messages.TracQueryPage_Summary);
+
+ descriptionField = new TextSearchField("description"); //$NON-NLS-1$
+ descriptionField.createControls(control, Messages.TracQueryPage_Description);
+
+ keywordsField = new TextSearchField("keywords"); //$NON-NLS-1$
+ keywordsField.createControls(control, Messages.TracQueryPage_Keywords);
+
+ createOptionsGroup(control);
+
+ createUserGroup(control);
+ }
+
+ /**
+ * Creates the area for selection on product attributes component/version/milestone.
+ */
+ protected Control createProductAttributes(Composite control) {
+ Composite group = new Composite(control, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 3;
+ group.setLayout(layout);
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gd.horizontalSpan = 1;
+ group.setLayoutData(gd);
+
+ Label label = new Label(group, SWT.LEFT);
+ label.setText(Messages.TracQueryPage_Component);
+
+ label = new Label(group, SWT.LEFT);
+ label.setText(Messages.TracQueryPage_Version);
+
+ label = new Label(group, SWT.LEFT);
+ label.setText(Messages.TracQueryPage_Milestone);
+
+ componentField = new ListSearchField("component"); //$NON-NLS-1$
+ componentField.createControls(group, HEIGHT_PRODUCT);
+ versionField = new ListSearchField("version"); //$NON-NLS-1$
+ versionField.createControls(group, HEIGHT_PRODUCT);
+
+ milestoneField = new ListSearchField("milestone"); //$NON-NLS-1$
+ milestoneField.createControls(group, HEIGHT_PRODUCT);
+
+ return group;
+ }
+
+ /**
+ * Creates the area for selection of ticket attributes status/resolution/priority.
+ */
+ protected Control createTicketAttributes(Composite control) {
+ Composite group = new Composite(control, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 4;
+ group.setLayout(layout);
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gd.horizontalSpan = 1;
+ group.setLayoutData(gd);
+
+ Label label = new Label(group, SWT.LEFT);
+ label.setText(Messages.TracQueryPage_Status);
+
+ label = new Label(group, SWT.LEFT);
+ label.setText(Messages.TracQueryPage_Resolution);
+
+ label = new Label(group, SWT.LEFT);
+ label.setText(Messages.TracQueryPage_Type);
+
+ label = new Label(group, SWT.LEFT);
+ label.setText(Messages.TracQueryPage_Priority);
+
+ statusField = new ListSearchField("status"); //$NON-NLS-1$
+ statusField.createControls(group, HEIGHT_STATUS);
+
+ resolutionField = new ListSearchField("resolution"); //$NON-NLS-1$
+ resolutionField.createControls(group, HEIGHT_STATUS);
+
+ typeField = new ListSearchField("type"); //$NON-NLS-1$
+ typeField.createControls(group, HEIGHT_STATUS);
+
+ priorityField = new ListSearchField("priority"); //$NON-NLS-1$
+ priorityField.createControls(group, HEIGHT_STATUS);
+
+ return group;
+ }
+
+ protected void createUserGroup(Composite control) {
+ UserSearchField userField = new UserSearchField();
+ userField.createControls(control);
}
@Override
- public String getQueryTitle() {
- return (titleText != null) ? titleText.getText() : null;
+ protected boolean hasRepositoryConfiguration() {
+ TracRepositoryConnector connector = (TracRepositoryConnector) TasksUi.getRepositoryManager()
+ .getRepositoryConnector(TracCorePlugin.CONNECTOR_KIND);
+ ITracClient client = connector.getClientManager().getTracClient(getTaskRepository());
+ return client.hasAttributes();
}
@Override
- public void applyTo(IRepositoryQuery query) {
- query.setUrl(getQueryUrl(getTaskRepository().getRepositoryUrl()));
- query.setSummary(getQueryTitle());
+ protected boolean restoreState(IRepositoryQuery query) {
+ TracSearch search = TracUtil.toTracSearch(query);
+ if (search != null) {
+ restoreWidgetValues(search);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ protected boolean restoreSavedState() {
+ IDialogSettings settings = getDialogSettings();
+ String searchUrl = settings.get(getSavedStateSettingsKey());
+ if (searchUrl != null) {
+ restoreWidgetValues(new TracSearch(searchUrl));
+ return true;
+ }
+ return false;
}
}