summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2011-09-22 09:51:42 (EDT)
committer Steffen Pingel2011-09-22 09:51:42 (EDT)
commit10d9b832545efa426005f8fdbf387446909e27fe (patch)
tree2ab46f713e1bd54b9e4e188ec2092c3de0666ecf
parentce263b1b45333fc35f8c49dd91374e8ad096d423 (diff)
downloadorg.eclipse.mylyn.tasks-10d9b832545efa426005f8fdbf387446909e27fe.zip
org.eclipse.mylyn.tasks-10d9b832545efa426005f8fdbf387446909e27fe.tar.gz
org.eclipse.mylyn.tasks-10d9b832545efa426005f8fdbf387446909e27fe.tar.bz2
fix Bugzilla query dialog
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaSearch.java55
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java285
-rw-r--r--org.eclipse.mylyn.tasks.ui/.settings/.api_filters9
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/QueryWizardDialog.java16
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositoryQueryPage2.java133
-rw-r--r--org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/TracQueryPage.java55
6 files changed, 209 insertions, 344 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaSearch.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaSearch.java
new file mode 100644
index 0000000..e55a924
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaSearch.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.core;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+
+/**
+ * @author Steffen Pingel
+ */
+public class BugzillaSearch {
+
+ private final Map<String, String> parameters;
+
+ public BugzillaSearch(TaskRepository repository, String queryUrl) throws UnsupportedEncodingException {
+ parameters = new LinkedHashMap<String, String>();
+
+ queryUrl = queryUrl.substring(queryUrl.indexOf("?") + 1); //$NON-NLS-1$
+ String[] options = queryUrl.split("&"); //$NON-NLS-1$
+ for (String option : options) {
+ String key;
+ int endindex = option.indexOf("="); //$NON-NLS-1$
+ if (endindex == -1) {
+ key = null;
+ } else {
+ key = option.substring(0, option.indexOf("=")); //$NON-NLS-1$
+ }
+ if (key == null) {
+ continue;
+ }
+ String value = URLDecoder.decode(option.substring(option.indexOf("=") + 1), //$NON-NLS-1$
+ repository.getCharacterEncoding());
+ parameters.put(key, value);
+ }
+ }
+
+ public Map<String, String> getParameters() {
+ return Collections.unmodifiableMap(parameters);
+ }
+
+}
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 9e6119f..eb7498c 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
@@ -12,11 +12,7 @@
package org.eclipse.mylyn.internal.bugzilla.ui.search;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Arrays;
@@ -37,6 +33,7 @@ import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.window.Window;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCustomField;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
+import org.eclipse.mylyn.internal.bugzilla.core.BugzillaSearch;
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
import org.eclipse.mylyn.internal.bugzilla.ui.BugzillaUiPlugin;
@@ -336,76 +333,12 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage2 implements
protected String[] chartFieldValues;
- // /** File containing saved queries */
- // protected static SavedQueryFile input;
-
- // /** "Remember query" button */
- // protected Button saveButton;
-
- // /** "Saved queries..." button */
- // protected Button loadButton;
-
- // /** Run a remembered query */
- // protected boolean rememberedQuery = false;
-
/** Index of the saved query to run */
protected int selIndex;
- // --------------- Configuration handling --------------
-
// Dialog store taskId constants
protected final static String PAGE_NAME = "BugzillaSearchPage"; //$NON-NLS-1$
- private static final String STORE_PRODUCT_ID = PAGE_NAME + ".PRODUCT"; //$NON-NLS-1$
-
- private static final String STORE_COMPONENT_ID = PAGE_NAME + ".COMPONENT"; //$NON-NLS-1$
-
- private static final String STORE_VERSION_ID = PAGE_NAME + ".VERSION"; //$NON-NLS-1$
-
- private static final String STORE_MSTONE_ID = PAGE_NAME + ".MILESTONE"; //$NON-NLS-1$
-
- private static final String STORE_STATUS_ID = PAGE_NAME + ".STATUS"; //$NON-NLS-1$
-
- private static final String STORE_RESOLUTION_ID = PAGE_NAME + ".RESOLUTION"; //$NON-NLS-1$
-
- private static final String STORE_SEVERITY_ID = PAGE_NAME + ".SEVERITY"; //$NON-NLS-1$
-
- private static final String STORE_PRIORITY_ID = PAGE_NAME + ".PRIORITY"; //$NON-NLS-1$
-
- private static final String STORE_HARDWARE_ID = PAGE_NAME + ".HARDWARE"; //$NON-NLS-1$
-
- private static final String STORE_OS_ID = PAGE_NAME + ".OS"; //$NON-NLS-1$
-
- private static final String STORE_SUMMARYMATCH_ID = PAGE_NAME + ".SUMMARYMATCH"; //$NON-NLS-1$
-
- private static final String STORE_COMMENTMATCH_ID = PAGE_NAME + ".COMMENTMATCH"; //$NON-NLS-1$
-
- private static final String STORE_EMAILMATCH_ID = PAGE_NAME + ".EMAILMATCH"; //$NON-NLS-1$
-
- private static final String STORE_EMAIL2MATCH_ID = PAGE_NAME + ".EMAIL2MATCH"; //$NON-NLS-1$
-
- private static final String STORE_EMAILBUTTON_ID = PAGE_NAME + ".EMAILATTR"; //$NON-NLS-1$
-
- private static final String STORE_EMAIL2BUTTON_ID = PAGE_NAME + ".EMAIL2ATTR"; //$NON-NLS-1$
-
- private static final String STORE_SUMMARYTEXT_ID = PAGE_NAME + ".SUMMARYTEXT"; //$NON-NLS-1$
-
- private static final String STORE_COMMENTTEXT_ID = PAGE_NAME + ".COMMENTTEXT"; //$NON-NLS-1$
-
- private static final String STORE_EMAILADDRESS_ID = PAGE_NAME + ".EMAILADDRESS"; //$NON-NLS-1$
-
- private static final String STORE_EMAIL2ADDRESS_ID = PAGE_NAME + ".EMAIL2ADDRESS"; //$NON-NLS-1$
-
- private static final String STORE_KEYWORDS_ID = PAGE_NAME + ".KEYWORDS"; //$NON-NLS-1$
-
- private static final String STORE_KEYWORDSMATCH_ID = PAGE_NAME + ".KEYWORDSMATCH"; //$NON-NLS-1$
-
- private static final String STORE_WHITEBOARD_ID = PAGE_NAME + ".WHITEBOARD"; //$NON-NLS-1$
-
- private static final String STORE_WHITEBOARDMATCH_ID = PAGE_NAME + ".WHITEBOARDMATCH"; //$NON-NLS-1$
-
- private static final String STORE_CHARTS_ID = PAGE_NAME + ".CHARTS"; //$NON-NLS-1$
-
private final FormToolkit toolkit;
private ExpandableComposite moreOptionsSection;
@@ -414,7 +347,7 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage2 implements
private SectionComposite scrolledComposite;
- private ArrayList<Chart> charts = new ArrayList<Chart>(1);
+ private final ArrayList<Chart> charts = new ArrayList<Chart>(1);
private class ChartControls {
private final Combo field;
@@ -494,7 +427,7 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage2 implements
}
@Override
- public void doClearFields() {
+ public void doClearControls() {
product.deselectAll();
component.deselectAll();
version.deselectAll();
@@ -531,17 +464,16 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage2 implements
recreateChartControls();
}
- private void createOptionsGroup(Composite control) {
- scrolledComposite = new SectionComposite(control, SWT.NONE);
- GridData g = new GridData(GridData.FILL, GridData.FILL, true, true);
- scrolledComposite.setLayoutData(g);
+ @Override
+ protected void createPageContent(SectionComposite parent) {
+ this.scrolledComposite = parent;
+
Composite scrolledBodyComposite = scrolledComposite.getContent();
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.horizontalSpacing = 0;
layout.verticalSpacing = 0;
-
scrolledBodyComposite.setLayout(layout);
basicCompositeCreate(scrolledBodyComposite);
@@ -687,10 +619,6 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage2 implements
} else {
updateAttributesFromConfiguration(null);
}
- if (restoring) {
- restoring = false;
- restoreWidgetValues();
- }
setPageComplete(isPageComplete());
}
});
@@ -1465,13 +1393,6 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage2 implements
return fDialogSettings;
}
- /**
- * Initializes itself from the stored page settings.
- */
- private void readConfiguration() {
- getDialogSettings();
- }
-
@SuppressWarnings("unchecked")
private void updateAttributesFromConfiguration(String[] selectedProducts) {
RepositoryConfiguration repositoryConfiguration = getRepositoryConfiguration();
@@ -1548,26 +1469,25 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage2 implements
}
}
- /**
- * TODO: get rid of this?
- */
- public void updateDefaults(String startingUrl) throws UnsupportedEncodingException {
+ public void updateDefaults(String queryUrl) throws UnsupportedEncodingException {
+ BugzillaSearch search = new BugzillaSearch(getTaskRepository(), queryUrl);
+
+ // set product first to initialize dependent fields
+ String productValue = search.getParameters().get("product"); //$NON-NLS-1$
+ if (productValue != null) {
+ String[] sel = product.getSelection();
+ java.util.List<String> selList = Arrays.asList(sel);
+ selList = new ArrayList<String>(selList);
+ selList.add(productValue);
+ sel = new String[selList.size()];
+ product.setSelection(selList.toArray(sel));
+ updateAttributesFromConfiguration(selList.toArray(sel));
+ }
+
boolean adjustChart = false;
- startingUrl = startingUrl.substring(startingUrl.indexOf("?") + 1); //$NON-NLS-1$
- String[] options = startingUrl.split("&"); //$NON-NLS-1$
- for (String option : options) {
- String key;
- int endindex = option.indexOf("="); //$NON-NLS-1$
- if (endindex == -1) {
- key = null;
- } else {
- key = option.substring(0, option.indexOf("=")); //$NON-NLS-1$
- }
- if (key == null) {
- continue;
- }
- String value = URLDecoder.decode(option.substring(option.indexOf("=") + 1), //$NON-NLS-1$
- getTaskRepository().getCharacterEncoding());
+ for (Map.Entry<String, String> entry : search.getParameters().entrySet()) {
+ String key = entry.getKey();
+ String value = entry.getValue();
if (key.equals("short_desc")) { //$NON-NLS-1$
summaryPattern.setText(value);
@@ -1583,13 +1503,7 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage2 implements
summaryOperation.select(index);
}
} else if (key.equals("product")) { //$NON-NLS-1$
- String[] sel = product.getSelection();
- java.util.List<String> selList = Arrays.asList(sel);
- selList = new ArrayList<String>(selList);
- selList.add(value);
- sel = new String[selList.size()];
- product.setSelection(selList.toArray(sel));
- updateAttributesFromConfiguration(selList.toArray(sel));
+ // ignore, see above
} else if (key.equals("component")) { //$NON-NLS-1$
String[] sel = component.getSelection();
java.util.List<String> selList = Arrays.asList(sel);
@@ -1892,102 +1806,6 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage2 implements
}
}
- private String[] nonNullArray(IDialogSettings settings, String id) {
- String[] value = settings.getArray(id);
- if (value == null) {
- return new String[] {};
- }
- return value;
- }
-
- @SuppressWarnings("unchecked")
- private void restoreWidgetValues() {
- try {
- IDialogSettings settings = getDialogSettings();
- String repoId = "." + getTaskRepository().getRepositoryUrl(); //$NON-NLS-1$
- if (!restoreQueryOptions || settings.getArray(STORE_PRODUCT_ID + repoId) == null || product == null) {
- return;
- }
-
- // set widgets to stored values
- product.setSelection(nonNullArray(settings, STORE_PRODUCT_ID + repoId));
- component.setSelection(nonNullArray(settings, STORE_COMPONENT_ID + repoId));
- version.setSelection(nonNullArray(settings, STORE_VERSION_ID + repoId));
- target.setSelection(nonNullArray(settings, STORE_MSTONE_ID + repoId));
- status.setSelection(nonNullArray(settings, STORE_STATUS_ID + repoId));
- resolution.setSelection(nonNullArray(settings, STORE_RESOLUTION_ID + repoId));
- severity.setSelection(nonNullArray(settings, STORE_SEVERITY_ID + repoId));
- priority.setSelection(nonNullArray(settings, STORE_PRIORITY_ID + repoId));
- hardware.setSelection(nonNullArray(settings, STORE_HARDWARE_ID + repoId));
- os.setSelection(nonNullArray(settings, STORE_OS_ID + repoId));
- summaryOperation.select(settings.getInt(STORE_SUMMARYMATCH_ID + repoId));
- commentOperation.select(settings.getInt(STORE_COMMENTMATCH_ID + repoId));
- emailOperation.select(settings.getInt(STORE_EMAILMATCH_ID + repoId));
- for (int i = 0; i < emailButtons.length; i++) {
- emailButtons[i].setSelection(settings.getBoolean(STORE_EMAILBUTTON_ID + i + repoId));
- }
- summaryPattern.setText(settings.get(STORE_SUMMARYTEXT_ID + repoId));
- commentPattern.setText(settings.get(STORE_COMMENTTEXT_ID + repoId));
- emailPattern.setText(settings.get(STORE_EMAILADDRESS_ID + repoId));
- try {
- emailOperation2.select(settings.getInt(STORE_EMAIL2MATCH_ID + repoId));
- } catch (Exception e) {
- //ignore
- }
- for (int i = 0; i < emailButtons2.length; i++) {
- emailButtons2[i].setSelection(settings.getBoolean(STORE_EMAIL2BUTTON_ID + i + repoId));
- }
- emailPattern2.setText(settings.get(STORE_EMAIL2ADDRESS_ID + repoId));
- if (settings.get(STORE_KEYWORDS_ID + repoId) != null) {
- keywords.setText(settings.get(STORE_KEYWORDS_ID + repoId));
- keywordsOperation.select(settings.getInt(STORE_KEYWORDSMATCH_ID + repoId));
- }
- if (settings.get(STORE_WHITEBOARD_ID + repoId) != null) {
- whiteboardPattern.setText(settings.get(STORE_WHITEBOARD_ID + repoId));
- whiteboardOperation.select(settings.getInt(STORE_WHITEBOARDMATCH_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$
- (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();
- }
-
- String chartString = settings.get(STORE_CHARTS_ID + repoId);
- if (chartString != null) {
- ObjectInputStream inputStream = null;
- ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(chartString.getBytes());
- try {
- try {
- inputStream = new ObjectInputStream(byteArrayInputStream);
- charts = (ArrayList<Chart>) inputStream.readObject();
- } catch (IOException e) {
- throw e;
- } finally {
- if (inputStream != null) {
- inputStream.close();
- }
- }
- } catch (Exception e) {
- }
- }
- if (charts.size() > 0 && charts.get(0).getChartExpression(0, 0).getFieldName() > 0) {
- chartSection.setExpanded(true);
- scrolledComposite.reflow(true);
- refreshChartControls();
- }
-
- } catch (IllegalArgumentException e) {
- //ignore
- }
- }
-
/* Testing hook to see if any products are present */
public int getProductCount() throws Exception {
return product.getItemCount();
@@ -2253,16 +2071,6 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage2 implements
}
@Override
- protected void createPageContent(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout(2, false);
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- composite.setLayout(layout);
- createOptionsGroup(composite);
- }
-
- @Override
protected boolean hasRepositoryConfiguration() {
return getRepositoryConfiguration() != null;
}
@@ -2272,7 +2080,7 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage2 implements
}
@Override
- protected void doRefresh() {
+ protected void doRefreshControls() {
String[] selectedProducts = product.getSelection();
if (selectedProducts != null && selectedProducts.length == 0) {
selectedProducts = null;
@@ -2285,48 +2093,32 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage2 implements
if (query != null) {
try {
updateDefaults(query.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
+ boolean reflow = false;
+ if (commentPattern.getText().length() > 0 || emailPattern2.getText().length() > 0
+ || keywords.getText().length() > 0 || whiteboardPattern.getText().length() > 0
+ || 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();
+ reflow = true;
}
if (charts.size() > 0 && charts.get(0).getChartExpression(0, 0).getFieldName() > 0) {
chartSection.setExpanded(true);
+ reflow = true;
+ }
+
+ if (reflow) {
scrolledComposite.reflow(true);
- refreshChartControls();
}
+ 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());
+ setPageComplete(isPageComplete());
return true;
}
@@ -2335,7 +2127,6 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage2 implements
public void applyTo(IRepositoryQuery query) {
query.setUrl(getQueryURL(getTaskRepository(), getQueryParameters()));
query.setSummary(getQueryTitle());
- saveState();
}
}
diff --git a/org.eclipse.mylyn.tasks.ui/.settings/.api_filters b/org.eclipse.mylyn.tasks.ui/.settings/.api_filters
index 52f6c82..33f67ce 100644
--- a/org.eclipse.mylyn.tasks.ui/.settings/.api_filters
+++ b/org.eclipse.mylyn.tasks.ui/.settings/.api_filters
@@ -24,4 +24,13 @@
</message_arguments>
</filter>
</resource>
+ <resource path="src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositoryQueryPage2.java" type="org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositoryQueryPage2">
+ <filter id="643846161">
+ <message_arguments>
+ <message_argument value="SectionComposite"/>
+ <message_argument value="AbstractRepositoryQueryPage2"/>
+ <message_argument value="createPageContent(SectionComposite)"/>
+ </message_arguments>
+ </filter>
+ </resource>
</component>
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 f3c4d16..d2cbd7a 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
@@ -67,8 +67,12 @@ public class QueryWizardDialog extends EnhancedWizardDialog {
@Override
protected void updateExtraButtons() {
if (abstractRepositoryQueryPage != null) {
- abstractRepositoryQueryPage.setExtraButtonState(clearButton);
- abstractRepositoryQueryPage.setExtraButtonState(refreshButton);
+ if (refreshButton != null) {
+ abstractRepositoryQueryPage.setExtraButtonState(refreshButton);
+ }
+ if (clearButton != null) {
+ abstractRepositoryQueryPage.setExtraButtonState(clearButton);
+ }
}
}
@@ -88,14 +92,14 @@ public class QueryWizardDialog extends EnhancedWizardDialog {
HashMap<String, Boolean> savedEnabledState = null;
if (getShell() != null) {
savedEnabledState = new HashMap<String, Boolean>();
- if (clearButton != null && clearButton.getShell() == getShell()) {
- savedEnabledState.put(CLEAR_BUTTON_KEY, clearButton.getEnabled());
- clearButton.setEnabled(false);
- }
if (refreshButton != null && refreshButton.getShell() == getShell()) {
savedEnabledState.put(REFRESH_BUTTON_KEY, refreshButton.getEnabled());
refreshButton.setEnabled(false);
}
+ if (clearButton != null && clearButton.getShell() == getShell()) {
+ savedEnabledState.put(CLEAR_BUTTON_KEY, clearButton.getEnabled());
+ clearButton.setEnabled(false);
+ }
}
return savedEnabledState;
}
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
index 2b4204c..bc8a98c 100644
--- 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
@@ -24,6 +24,7 @@ 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.commons.ui.SectionComposite;
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;
@@ -38,7 +39,6 @@ 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;
@@ -62,10 +62,17 @@ public abstract class AbstractRepositoryQueryPage2 extends AbstractRepositoryQue
private boolean firstTime = true;
- private Composite innerComposite;
+ @SuppressWarnings("restriction")
+ private SectionComposite innerComposite;
+ /**
+ * Determines whether a 'Clear Fields' button is shown on the page.
+ */
private boolean needsClear;
+ /**
+ * Determines whether a 'Refresh' button is shown on the page.
+ */
private boolean needsRefresh = true;
private ProgressContainer progressContainer;
@@ -74,8 +81,6 @@ public abstract class AbstractRepositoryQueryPage2 extends AbstractRepositoryQue
private Text titleText;
- private Composite buttonComposite;
-
public AbstractRepositoryQueryPage2(String pageName, TaskRepository repository, IRepositoryQuery query) {
super(pageName, repository, query);
this.connector = TasksUi.getRepositoryConnector(getTaskRepository().getConnectorKind());
@@ -94,9 +99,8 @@ public abstract class AbstractRepositoryQueryPage2 extends AbstractRepositoryQue
createTitleGroup(composite);
- innerComposite = new Composite(composite, SWT.NONE);
+ innerComposite = new SectionComposite(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);
@@ -105,11 +109,6 @@ public abstract class AbstractRepositoryQueryPage2 extends AbstractRepositoryQue
setDescription(Messages.AbstractRepositoryQueryPage2_Create_a_Query_Page_Description);
}
- if (getQuery() != null) {
- titleText.setText(getQuery().getSummary());
- restoreState(getQuery());
- }
-
Dialog.applyDialogFont(composite);
setControl(composite);
}
@@ -122,7 +121,7 @@ public abstract class AbstractRepositoryQueryPage2 extends AbstractRepositoryQue
public boolean handleExtraButtonPressed(int buttonId) {
if (buttonId == QueryWizardDialog.REFRESH_BUTTON_ID) {
if (getTaskRepository() != null) {
- updateAttributesFromRepository(true);
+ refreshConfiguration(true);
} else {
MessageDialog.openInformation(
Display.getCurrent().getActiveShell(),
@@ -131,7 +130,7 @@ public abstract class AbstractRepositoryQueryPage2 extends AbstractRepositoryQue
}
return true;
} else if (buttonId == QueryWizardDialog.CLEAR_BUTTON_ID) {
- doClearFields();
+ doClearControls();
return true;
}
return false;
@@ -199,8 +198,8 @@ public abstract class AbstractRepositoryQueryPage2 extends AbstractRepositoryQue
this.needsClear = needsClearButton;
}
- public void setNeedsRefresh(boolean needsRepositoryConfiguration) {
- this.needsRefresh = needsRepositoryConfiguration;
+ public void setNeedsRefresh(boolean needsRefresh) {
+ this.needsRefresh = needsRefresh;
}
public void setQueryTitle(String text) {
@@ -228,7 +227,6 @@ public abstract class AbstractRepositoryQueryPage2 extends AbstractRepositoryQue
initializePage();
}
}
-
});
} else {
// no remote connection is needed to get attributes therefore do
@@ -239,14 +237,19 @@ public abstract class AbstractRepositoryQueryPage2 extends AbstractRepositoryQue
}
private void createButtonGroup(Composite parent) {
- buttonComposite = new Composite(parent, SWT.NONE);
+ Composite 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;
+ if (buttonComposite.getChildren().length > 0) {
+ layout.numColumns = buttonComposite.getChildren().length;
+ } else {
+ // remove composite to avoid spacing
+ buttonComposite.dispose();
+ }
}
private void createTitleGroup(Composite control) {
@@ -268,61 +271,72 @@ public abstract class AbstractRepositoryQueryPage2 extends AbstractRepositoryQue
private void initializePage() {
if (needsRefresh) {
- updateAttributesFromRepository(false);
+ boolean refreshed = refreshConfiguration(false);
+ if (!refreshed) {
+ // always do a refresh when page is initially shown
+ doRefreshControls();
+ }
}
- boolean restored = (getQuery() != null);
- if (inSearchContainer()) {
+ boolean restored = false;
+ if (getQuery() != null) {
+ titleText.setText(getQuery().getSummary());
+ restored |= restoreState(getQuery());
+ } else if (inSearchContainer()) {
restored |= restoreSavedState();
}
if (!restored) {
// initialize with default values
+ doClearControls();
}
}
- private void updateAttributesFromRepository(final boolean force) {
+ protected boolean refreshConfiguration(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);
- }
+ doRefreshConfiguration();
+ doRefreshControls();
+ return true;
} catch (InvocationTargetException e) {
if (e.getCause() instanceof CoreException) {
setErrorMessage(((CoreException) e.getCause()).getStatus().getMessage());
} else {
setErrorMessage(e.getCause().getMessage());
}
- return;
} catch (InterruptedException e) {
- return;
+ // canceled
}
}
+ return false;
+ }
- doRefresh();
+ private void doRefreshConfiguration() throws InvocationTargetException, InterruptedException {
+ 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);
+ }
}
protected void createButtons(final Composite composite) {
@@ -337,7 +351,7 @@ public abstract class AbstractRepositoryQueryPage2 extends AbstractRepositoryQue
@Override
public void widgetSelected(SelectionEvent e) {
if (getTaskRepository() != null) {
- updateAttributesFromRepository(true);
+ refreshConfiguration(true);
} else {
MessageDialog.openInformation(
Display.getCurrent().getActiveShell(),
@@ -353,7 +367,7 @@ public abstract class AbstractRepositoryQueryPage2 extends AbstractRepositoryQue
clearButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- doClearFields();
+ doClearControls();
}
});
}
@@ -365,7 +379,7 @@ public abstract class AbstractRepositoryQueryPage2 extends AbstractRepositoryQue
protected void restoreUiState(java.util.Map<Object, Object> state) {
cancelButton.setVisible(false);
CommonUiUtil.setEnabled(innerComposite, true);
- for (Control control : buttonComposite.getChildren()) {
+ for (Control control : composite.getChildren()) {
if (control instanceof ProgressMonitorPart) {
break;
}
@@ -376,7 +390,7 @@ public abstract class AbstractRepositoryQueryPage2 extends AbstractRepositoryQue
@Override
protected void saveUiState(java.util.Map<Object, Object> savedState) {
CommonUiUtil.setEnabled(innerComposite, false);
- for (Control control : buttonComposite.getChildren()) {
+ for (Control control : composite.getChildren()) {
if (control instanceof ProgressMonitorPart) {
break;
}
@@ -393,12 +407,13 @@ public abstract class AbstractRepositoryQueryPage2 extends AbstractRepositoryQue
progressContainer.setCancelButton(cancelButton);
}
- protected abstract void createPageContent(Composite parent);
+ @SuppressWarnings("restriction")
+ protected abstract void createPageContent(SectionComposite parent);
- protected void doClearFields() {
+ protected void doClearControls() {
}
- protected abstract void doRefresh();
+ protected abstract void doRefreshControls();
protected AbstractRepositoryConnector getConnector() {
return connector;
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 549d82c..76db864 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
@@ -17,7 +17,9 @@ import java.util.Map;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.mylyn.commons.core.StatusHandler;
+import org.eclipse.mylyn.internal.commons.ui.SectionComposite;
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;
@@ -36,7 +38,6 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Text;
@@ -366,7 +367,7 @@ public class TracQueryPage extends AbstractRepositoryQueryPage2 {
}
@Override
- public void doRefresh() {
+ public void doRefreshControls() {
TracRepositoryConnector connector = (TracRepositoryConnector) TasksUi.getRepositoryManager()
.getRepositoryConnector(TracCorePlugin.CONNECTOR_KIND);
ITracClient client = connector.getClientManager().getTracClient(getTaskRepository());
@@ -435,30 +436,24 @@ public class TracQueryPage extends AbstractRepositoryQueryPage2 {
}
}
- 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);
+ protected void createPageContent(@SuppressWarnings("restriction")
+ SectionComposite composite) {
+ @SuppressWarnings("restriction")
+ Composite control = composite.getContent();
+
GridLayout layout = new GridLayout(4, false);
layout.marginWidth = 0;
layout.marginHeight = 0;
control.setLayout(layout);
+ createDefaultGroup(control);
+ createProductGroup(control);
+ createTicketGroup(control);
+ createUserGroup(control);
+ }
+
+ private void createDefaultGroup(Composite control) {
summaryField = new TextSearchField("summary"); //$NON-NLS-1$
summaryField.createControls(control, Messages.TracQueryPage_Summary);
@@ -467,23 +462,19 @@ public class TracQueryPage extends AbstractRepositoryQueryPage2 {
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) {
+ protected Control createProductGroup(Composite control) {
Composite group = new Composite(control, SWT.NONE);
+ GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).span(4, 1).applyTo(group);
GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
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);
@@ -509,14 +500,14 @@ public class TracQueryPage extends AbstractRepositoryQueryPage2 {
/**
* Creates the area for selection of ticket attributes status/resolution/priority.
*/
- protected Control createTicketAttributes(Composite control) {
+ protected Control createTicketGroup(Composite control) {
Composite group = new Composite(control, SWT.NONE);
+ GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).span(4, 1).applyTo(group);
GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
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);