Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.ui/src')
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaImages.java6
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaUiPlugin.java2
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/OfflineView.java170
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/AbstractBugEditor.java13
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/ExistingBugEditor.java13
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTask.java137
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskEditorInput.java3
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskExternalizer.java18
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskListManager.java35
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/wizard/NewBugWizard.java2
10 files changed, 284 insertions, 115 deletions
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaImages.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaImages.java
index 0ff7cdee2..a1234e439 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaImages.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaImages.java
@@ -65,6 +65,10 @@ public class BugzillaImages {
public static final ImageDescriptor BUG = create(T_ELCL, "bug.gif");
public static final ImageDescriptor IMG_COMMENT = create(T_ELCL, "bug-comment.gif");
public static final ImageDescriptor TASK_BUGZILLA = create(T_TOOL, "task-bug.gif");
+ public static final ImageDescriptor TASK_BUGZILLA_INCOMMING = create(T_TOOL, "task-bug-in.gif");;
+ public static final ImageDescriptor TASK_BUGZILLA_CONFLICT = create(T_TOOL, "task-bug-con.gif");;
+ public static final ImageDescriptor TASK_BUGZILLA_OUTGOING = create(T_TOOL, "task-bug-out.gif");;
+
public static final ImageDescriptor TASK_BUGZILLA_NEW = create(T_TOOL, "task-bug-new.gif");
public static final ImageDescriptor CATEGORY_QUERY = create(T_TOOL, "category-query.gif");
public static final ImageDescriptor CATEGORY_QUERY_NEW = create(T_TOOL, "category-query-new.gif");
@@ -74,7 +78,7 @@ public class BugzillaImages {
public static final ImageDescriptor REMOVE = create("", "remove.gif");
public static final ImageDescriptor SELECT_ALL = create("", "selectAll.gif");
public static final ImageDescriptor OPEN = create("", "openresult.gif");
-
+
private static ImageDescriptor create(String prefix, String name) {
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaUiPlugin.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaUiPlugin.java
index 9f1d35ea2..0d9a2254f 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaUiPlugin.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaUiPlugin.java
@@ -24,6 +24,7 @@ public class BugzillaUiPlugin extends AbstractUIPlugin {
private BugzillaTaskListManager bugzillaTaskListManager;
private BugzillaRefreshManager bugzillaRefreshManager;
+
private static BugzillaUiPlugin plugin;
@@ -42,6 +43,7 @@ public class BugzillaUiPlugin extends AbstractUIPlugin {
BugzillaPlugin.setResultEditorMatchAdapter(new BugzillaResultMatchAdapter());
bugzillaTaskListManager = new BugzillaTaskListManager();
bugzillaRefreshManager = new BugzillaRefreshManager();
+ BugzillaPlugin.getDefault().addOfflineStatusListener(bugzillaTaskListManager);
}
/**
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/OfflineView.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/OfflineView.java
index d6d790516..0af2d5795 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/OfflineView.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/OfflineView.java
@@ -14,7 +14,6 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
@@ -37,6 +36,7 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
import org.eclipse.mylar.bugzilla.core.IBugzillaBug;
import org.eclipse.mylar.bugzilla.core.IBugzillaConstants;
+import org.eclipse.mylar.bugzilla.core.IOfflineBugListener.BugzillaOfflineStaus;
import org.eclipse.mylar.bugzilla.core.offline.OfflineReportsFile;
import org.eclipse.mylar.bugzilla.ui.actions.AbstractOfflineReportsAction;
import org.eclipse.mylar.bugzilla.ui.actions.DeleteOfflineReportAction;
@@ -51,6 +51,7 @@ import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
@@ -213,13 +214,13 @@ public class OfflineView extends ViewPart {
toolbar.add(selectAll);
// create actions to handle the sorting of the OfflineReports
- sortByIDAction = new SortByAction(OfflineReportsFile.ID_SORT);
- sortByIDAction.setText("by &Bug ID");
- sortByIDAction.setToolTipText("Sorts by Bug number");
-
- sortByTypeAction = new SortByAction(OfflineReportsFile.TYPE_SORT);
- sortByTypeAction.setText("by &Bug Type");
- sortByTypeAction.setToolTipText("Sorts by locally created/from server status");
+// sortByIDAction = new SortByAction(OfflineReportsFile.ID_SORT);
+// sortByIDAction.setText("by &Bug ID");
+// sortByIDAction.setToolTipText("Sorts by Bug number");
+//
+// sortByTypeAction = new SortByAction(OfflineReportsFile.TYPE_SORT);
+// sortByTypeAction.setText("by &Bug Type");
+// sortByTypeAction.setToolTipText("Sorts by locally created/from server status");
// get the menu manager and create a submenu to contain sorting
IMenuManager menu = actionBars.getMenuManager();
@@ -227,51 +228,51 @@ public class OfflineView extends ViewPart {
// add the sorting actions to the menu bar
menu.add(submenu);
- submenu.add(sortByIDAction);
- submenu.add(sortByTypeAction);
+// submenu.add(sortByIDAction);
+// submenu.add(sortByTypeAction);
- updateSortingState();
+// updateSortingState();
}
- /**
- * Function to make sure that the appropriate sort is checked
- */
- void updateSortingState() {
- int curCriterion = OfflineReportsFile.lastSel;
-
- sortByIDAction.setChecked(curCriterion == OfflineReportsFile.ID_SORT);
- sortByTypeAction.setChecked(curCriterion == OfflineReportsFile.TYPE_SORT);
- viewer.setInput(viewer.getInput());
- }
-
- // Sorting actions for the OfflineReports view
- SortByAction sortByIDAction, sortByTypeAction/*, sortBySeverityAction, sortByPriorityAction, sortByStatusAction*/;
-
- /**
- * Inner class to handle sorting
- * @author Shawn Minto
- */
- class SortByAction extends Action {
- /** The criteria to sort the OfflineReports menu based on */
- private int criterion;
-
- /**
- * Constructor
- * @param criteria The criteria to sort the OfflineReports menu based on
- */
- public SortByAction(int criteria) {
- this.criterion = criteria;
- }
-
- /**
- * Perform the sort
- */
- @Override
- public void run() {
- BugzillaPlugin.getDefault().getOfflineReports().sort(criterion);
- updateSortingState();
- }
- }
+// /**
+// * Function to make sure that the appropriate sort is checked
+// */
+// void updateSortingState() {
+// int curCriterion = OfflineReportsFile.lastSel;
+//
+// sortByIDAction.setChecked(curCriterion == OfflineReportsFile.ID_SORT);
+// sortByTypeAction.setChecked(curCriterion == OfflineReportsFile.TYPE_SORT);
+// viewer.setInput(viewer.getInput());
+// }
+//
+// // Sorting actions for the OfflineReports view
+// SortByAction sortByIDAction, sortByTypeAction/*, sortBySeverityAction, sortByPriorityAction, sortByStatusAction*/;
+
+// /**
+// * Inner class to handle sorting
+// * @author Shawn Minto
+// */
+// class SortByAction extends Action {
+// /** The criteria to sort the OfflineReports menu based on */
+// private int criterion;
+//
+// /**
+// * Constructor
+// * @param criteria The criteria to sort the OfflineReports menu based on
+// */
+// public SortByAction(int criteria) {
+// this.criterion = criteria;
+// }
+//
+// /**
+// * Perform the sort
+// */
+// @Override
+// public void run() {
+// BugzillaPlugin.getDefault().getOfflineReports().sort(criterion);
+// updateSortingState();
+// }
+// }
/**
* Create context menu.
@@ -445,9 +446,11 @@ public class OfflineView extends ViewPart {
*/
@SuppressWarnings("unchecked")
public void deleteSelectedOfflineReports() {
- List<IBugzillaBug> selection = ((IStructuredSelection)viewer.getSelection()).toList();
+ List<IBugzillaBug> selection = ((IStructuredSelection)viewer.getSelection()).toList();
closeOfflineReports(selection);
- BugzillaPlugin.getDefault().getOfflineReports().remove(selection);
+ for (IBugzillaBug bug : selection) {
+ removeReport(bug);
+ }
viewer.setInput(viewer.getInput());
}
@@ -456,7 +459,10 @@ public class OfflineView extends ViewPart {
*/
public void deleteAllOfflineReports() {
closeOfflineReports(BugzillaPlugin.getDefault().getOfflineReports().elements());
- BugzillaPlugin.getDefault().getOfflineReports().removeAll();
+ List<IBugzillaBug> reports = new ArrayList<IBugzillaBug>(OfflineReportsFile.getOfflineBugs());
+ for (IBugzillaBug bug : reports) {
+ removeReport(bug);
+ }
viewer.setInput(viewer.getInput());
}
@@ -466,28 +472,35 @@ public class OfflineView extends ViewPart {
*
* @param bug
* The bug to add/update.
+ * @param saveChosen
+ * This is used to determine a refresh from a user save
*/
- public static void saveOffline(IBugzillaBug bug) {
- OfflineReportsFile file = BugzillaPlugin.getDefault().getOfflineReports();
- // If there is already an offline report for this bug, update the file.
- if (bug.isSavedOffline()) {
- file.update();
- }
- // If this bug has not been saved offline before, add it to the file.
- else {
- // If there is already an offline report with the same id, don't save this report.
- int index = -1;
- if ((index = file.find(bug.getId())) >= 0) {
- removeReport(getOfflineBugs().get(index));
-// MessageDialog.openInformation(null, "Bug's Id is already used.", "There is already a bug saved offline with an identical id.");
-// return;
+ public static void saveOffline(final IBugzillaBug bug, final boolean saveChosen) {
+ Display.getDefault().asyncExec(new Runnable(){
+ public void run() {
+
+ OfflineReportsFile file = BugzillaPlugin.getDefault().getOfflineReports();
+ // If there is already an offline report for this bug, update the file.
+ if (bug.isSavedOffline()) {
+ file.update();
+ }
+ // If this bug has not been saved offline before, add it to the file.
+ else {
+ // If there is already an offline report with the same id, don't save this report.
+ // int index = -1;
+ // if ((index = file.find(bug.getId())) >= 0) {
+ // removeReport(getOfflineBugs().get(index));
+ // MessageDialog.openInformation(null, "Bug's Id is already used.", "There is already a bug saved offline with an identical id.");
+ // return;
+ // }
+ file.add(bug, saveChosen);
+ bug.setOfflineState(true);
+ // file.sort(OfflineReportsFile.lastSel);
+ }
+ OfflineView.checkWindow();
+ OfflineView.refreshView();
}
- file.add(bug);
- bug.setOfflineState(true);
- file.sort(OfflineReportsFile.lastSel);
- }
- OfflineView.checkWindow();
- OfflineView.refreshView();
+ });
}
public static List<IBugzillaBug> getOfflineBugs(){
@@ -502,6 +515,8 @@ public class OfflineView extends ViewPart {
* The report to remove.
*/
public static void removeReport(IBugzillaBug bug) {
+ BugzillaPlugin.getDefault().fireOfflineStatusChanged(bug, BugzillaOfflineStaus.DELETED);
+
ArrayList<IBugzillaBug> bugList = new ArrayList<IBugzillaBug>();
bugList.add(bug);
BugzillaPlugin.getDefault().getOfflineReports().remove(bugList);
@@ -515,6 +530,15 @@ public class OfflineView extends ViewPart {
}
}
+ public static IBugzillaBug find(int bugId) {
+ int location = BugzillaPlugin.getDefault().getOfflineReports().find(bugId);
+ if(location != -1){
+ return BugzillaPlugin.getDefault().getOfflineReports().elements().get(location);
+ }
+ return null;
+ }
+
+
/**
* @see SelectionListener#widgetSelected(SelectionEvent)
*/
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/AbstractBugEditor.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/AbstractBugEditor.java
index c783107ae..ccdc070da 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/AbstractBugEditor.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/AbstractBugEditor.java
@@ -48,6 +48,7 @@ import org.eclipse.mylar.bugzilla.core.IBugzillaAttributeListener;
import org.eclipse.mylar.bugzilla.core.IBugzillaBug;
import org.eclipse.mylar.bugzilla.core.IBugzillaConstants;
import org.eclipse.mylar.bugzilla.core.IBugzillaReportSelection;
+import org.eclipse.mylar.bugzilla.core.IOfflineBugListener.BugzillaOfflineStaus;
import org.eclipse.mylar.bugzilla.ui.BugzillaUITools;
import org.eclipse.mylar.bugzilla.ui.OfflineView;
import org.eclipse.mylar.bugzilla.ui.outline.BugzillaOutlineNode;
@@ -447,6 +448,7 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener {
infoArea.setLayout(infoLayout);
infoArea.setBackground(background);
if (getBug() == null) {
+ close();
MessageDialog.openError(infoArea.getShell(), "No such bug",
"No bug exists with this id");
return null;
@@ -1281,8 +1283,17 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener {
*/
public void saveBug() {
updateBug();
+
+ IBugzillaBug bug = getBug();
+
+ if(bug.hasChanges()){
+ BugzillaPlugin.getDefault().fireOfflineStatusChanged(bug, BugzillaOfflineStaus.SAVED_WITH_OUTGOING_CHANGES);
+ } else {
+ BugzillaPlugin.getDefault().fireOfflineStatusChanged(bug, BugzillaOfflineStaus.SAVED);
+ }
+
changeDirtyStatus(false);
- OfflineView.saveOffline(getBug());
+ OfflineView.saveOffline(getBug(), true);
OfflineView.checkWindow();
OfflineView.refreshView();
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/ExistingBugEditor.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/ExistingBugEditor.java
index 4f7d3f4b8..3c24c01e3 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/ExistingBugEditor.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/ExistingBugEditor.java
@@ -693,17 +693,28 @@ public class ExistingBugEditor extends AbstractBugEditor
// go through all of the attributes and update the main values to the new ones
for (Iterator<Attribute> it = bug.getAttributes().iterator(); it.hasNext(); ) {
Attribute a = it.next();
+ if(a.getNewValue().compareTo(a.getValue()) != 0){
+ bug.setHasChanged(true);
+ }
a.setValue(a.getNewValue());
+
}
-
+ if(bug.getNewComment().compareTo(bug.getNewNewComment()) != 0){
+ bug.setHasChanged(true);
+ }
+
// Update some other fields as well.
bug.setNewComment(bug.getNewNewComment());
+
}
@Override
protected void restoreBug() {
+ if(bug == null)
+ return;
+
// go through all of the attributes and restore the new values to the main ones
for (Iterator<Attribute> it = bug.getAttributes().iterator(); it.hasNext(); ) {
Attribute a = it.next();
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTask.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTask.java
index 5f24e0e9b..aaae8c5df 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTask.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTask.java
@@ -14,9 +14,7 @@
package org.eclipse.mylar.bugzilla.ui.tasklist;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.Date;
-import java.util.List;
import javax.security.auth.login.LoginException;
@@ -32,7 +30,6 @@ import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
import org.eclipse.mylar.bugzilla.core.BugzillaRepository;
import org.eclipse.mylar.bugzilla.core.IBugzillaBug;
import org.eclipse.mylar.bugzilla.core.internal.HtmlStreamTokenizer;
-import org.eclipse.mylar.bugzilla.core.offline.OfflineReportsFile;
import org.eclipse.mylar.bugzilla.ui.BugzillaImages;
import org.eclipse.mylar.bugzilla.ui.BugzillaUITools;
import org.eclipse.mylar.bugzilla.ui.BugzillaUiPlugin;
@@ -41,6 +38,7 @@ import org.eclipse.mylar.core.MylarPlugin;
import org.eclipse.mylar.tasklist.MylarTasklistPlugin;
import org.eclipse.mylar.tasklist.Task;
import org.eclipse.mylar.tasklist.TaskListImages;
+import org.eclipse.mylar.tasklist.ui.views.TaskListView;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
@@ -55,6 +53,10 @@ import org.eclipse.ui.internal.Workbench;
*/
public class BugzillaTask extends Task {
+ public enum BugReportSyncState {
+ OUTGOING, OK, INCOMMING, CONFLICT
+
+ }
/**
* Comment for <code>serialVersionUID</code>
*/
@@ -318,9 +320,11 @@ public class BugzillaTask extends Task {
if(!isBugDownloaded() && offline){
MessageDialog.openInformation(null, "Unable to open bug", "Unable to open the selected bugzilla task since you are currently offline");
return;
- }else if(!isBugDownloaded()) {
+ }else if(!isBugDownloaded() && syncState != BugReportSyncState.OUTGOING) {
input.getBugTask().downloadReport();
input.setOfflineBug(input.getBugTask().getBugReport());
+ } else if(syncState == BugReportSyncState.OUTGOING){
+ input.setOfflineBug(bugReport);
}
// get the active workbench page
@@ -333,6 +337,25 @@ public class BugzillaTask extends Task {
// try to open an editor on the input bug
//page.openEditor(input, IBugzillaConstants.EXISTING_BUG_EDITOR_ID);
page.openEditor(input, "org.eclipse.mylar.bugzilla.ui.tasklist.bugzillaTaskEditor");
+ if(syncState == BugReportSyncState.INCOMMING){
+ syncState = BugReportSyncState.OK;
+ Display.getDefault().asyncExec(new Runnable(){
+ public void run() {
+ if(TaskListView.getDefault() != null && TaskListView.getDefault().getViewer() != null && !TaskListView.getDefault().getViewer().getControl().isDisposed()){
+ TaskListView.getDefault().getViewer().refresh();
+ }
+ }
+ });
+ } else if(syncState == BugReportSyncState.CONFLICT){
+ syncState = BugReportSyncState.OUTGOING;
+ Display.getDefault().asyncExec(new Runnable(){
+ public void run() {
+ if(TaskListView.getDefault() != null && TaskListView.getDefault().getViewer() != null && !TaskListView.getDefault().getViewer().getControl().isDisposed()){
+ TaskListView.getDefault().getViewer().refresh();
+ }
+ }
+ });
+ }
}
catch (Exception ex) {
MylarPlugin.log(ex, "couldn't open bugzilla task");
@@ -365,15 +388,20 @@ public class BugzillaTask extends Task {
@Override
protected IStatus run(IProgressMonitor monitor) {
- state = BugTaskState.DOWNLOADING;
- notifyTaskDataChange();
- // Update time this bugtask was last downloaded.
- lastRefresh = new Date();
- bugReport = downloadReport();
- state = BugTaskState.FREE;
- updateTaskDetails();
- notifyTaskDataChange();
- saveBugReport(true);
+ try{
+ state = BugTaskState.DOWNLOADING;
+ notifyTaskDataChange();
+ // Update time this bugtask was last downloaded.
+ lastRefresh = new Date();
+ bugReport = downloadReport();
+ state = BugTaskState.FREE;
+ updateTaskDetails();
+ notifyTaskDataChange();
+ saveBugReport(true);
+ } catch (Exception e){
+ e.printStackTrace();
+ // ignore
+ }
BugzillaUiPlugin.getDefault().getBugzillaRefreshManager().removeRefreshingTask(BugzillaTask.this);
return new Status(IStatus.OK, MylarPlugin.IDENTIFIER, IStatus.OK, "", null);
}
@@ -382,7 +410,7 @@ public class BugzillaTask extends Task {
public void updateTaskDetails() {
try {
if(bugReport == null)
- downloadReport();
+ bugReport = downloadReport();
if(bugReport == null)
return;
setPriority(bugReport.getAttribute("Priority").getValue());
@@ -410,7 +438,8 @@ public class BugzillaTask extends Task {
@Override
protected IStatus run(IProgressMonitor monitor) {
try{
- final BugzillaTaskEditorInput input = new BugzillaTaskEditorInput(bugTask, offline);
+ boolean isLikeOffline = offline || syncState == BugReportSyncState.OUTGOING;
+ final BugzillaTaskEditorInput input = new BugzillaTaskEditorInput(bugTask, isLikeOffline);
// state = BugTaskState.OPENING;
// notifyTaskDataChange();
openTaskEditor(input, offline);
@@ -453,12 +482,15 @@ public class BugzillaTask extends Task {
public boolean readBugReport() {
// XXX server name needs to be with the bug report
- int location = BugzillaPlugin.getDefault().getOfflineReports().find(getBugId(getHandle()));
- if(location == -1){
+ IBugzillaBug tempBug = OfflineView.find(getBugId(getHandle()));
+ if(tempBug == null){
bugReport = null;
return true;
}
- bugReport = (BugReport)BugzillaPlugin.getDefault().getOfflineReports().elements().get(location);
+ bugReport = (BugReport)tempBug;
+
+ if(bugReport.hasChanges())
+ syncState = BugReportSyncState.OUTGOING;
return true;
}
@@ -467,16 +499,20 @@ public class BugzillaTask extends Task {
return;
// XXX use the server name for multiple repositories
- OfflineReportsFile offlineReports = BugzillaPlugin.getDefault().getOfflineReports();
- int location = offlineReports.find(getBugId(getHandle()));
- if(location != -1){
- IBugzillaBug tmpBugReport = offlineReports.elements().get(location);
- List<IBugzillaBug> l = new ArrayList<IBugzillaBug>(1);
- l.add(tmpBugReport);
- offlineReports.remove(l);
- }
- offlineReports.add(bugReport);
+// OfflineReportsFile offlineReports = BugzillaPlugin.getDefault().getOfflineReports();
+// IBugzillaBug tempBug = OfflineView.find(getBugId(getHandle()));
+// OfflineView.re
+// if(location != -1){
+// IBugzillaBug tmpBugReport = offlineReports.elements().get(location);
+// List<IBugzillaBug> l = new ArrayList<IBugzillaBug>(1);
+// l.add(tmpBugReport);
+// offlineReports.remove(l);
+// }
+// OfflineView.removeReport(tempBug);
+ OfflineView.saveOffline(bugReport, false);
+
+
final IWorkbench workbench = PlatformUI.getWorkbench();
if (refresh && !workbench.getDisplay().isDisposed()) {
workbench.getDisplay().asyncExec(new Runnable() {
@@ -490,14 +526,16 @@ public class BugzillaTask extends Task {
public void removeReport() {
// XXX do we really want to do this???
// XXX remove from registry too??
- OfflineReportsFile offlineReports = BugzillaPlugin.getDefault().getOfflineReports();
- int location = offlineReports.find(getBugId(getHandle()));
- if(location != -1){
- IBugzillaBug tmpBugReport = offlineReports.elements().get(location);
- List<IBugzillaBug> l = new ArrayList<IBugzillaBug>(1);
- l.add(tmpBugReport);
- offlineReports.remove(l);
- }
+ IBugzillaBug tempBug = OfflineView.find(getBugId(getHandle()));
+ OfflineView.removeReport(tempBug);
+// OfflineReportsFile offlineReports = BugzillaPlugin.getDefault().getOfflineReports();
+// int location = offlineReports.find(getBugId(getHandle()));
+// if(location != -1){
+// IBugzillaBug tmpBugReport = offlineReports.elements().get(location);
+// List<IBugzillaBug> l = new ArrayList<IBugzillaBug>(1);
+// l.add(tmpBugReport);
+// offlineReports.remove(l);
+// }
}
public static String getServerName(String handle) {
@@ -519,7 +557,18 @@ public class BugzillaTask extends Task {
@Override
public Image getIcon() {
- return TaskListImages.getImage(BugzillaImages.TASK_BUGZILLA);
+ if(syncState == BugReportSyncState.OK){
+ return TaskListImages.getImage(BugzillaImages.TASK_BUGZILLA);
+ }else if(syncState == BugReportSyncState.OUTGOING){
+ return TaskListImages.getImage(BugzillaImages.TASK_BUGZILLA_OUTGOING);
+ } else if(syncState == BugReportSyncState.INCOMMING){
+ return TaskListImages.getImage(BugzillaImages.TASK_BUGZILLA_INCOMMING);
+ } else if(syncState == BugReportSyncState.CONFLICT){
+ return TaskListImages.getImage(BugzillaImages.TASK_BUGZILLA_CONFLICT);
+ } else {
+ return TaskListImages.getImage(BugzillaImages.TASK_BUGZILLA);
+ }
+
}
public String getBugUrl() {
@@ -565,6 +614,7 @@ public class BugzillaTask extends Task {
public Job getRefreshJob() {
if (isDirty() || (state != BugTaskState.FREE)) {
+ System.out.println("didn't get job for " + getHandle());
return null;
}
GetBugReportJob job = new GetBugReportJob("Refreshing with Bugzilla server...");
@@ -581,4 +631,19 @@ public class BugzillaTask extends Task {
long timeDifference = (timeNow.getTime() - lastRefresh.getTime())/60000;
return timeDifference;
}
+
+ private BugReportSyncState syncState = BugReportSyncState.OK;
+
+ public void setSyncState(BugReportSyncState syncState) {
+ if((this.syncState != BugReportSyncState.INCOMMING && syncState != BugReportSyncState.OK))
+ this.syncState = syncState;
+ }
+
+ public static String getHandle(IBugzillaBug bug) {
+ return "Bugzilla-"+bug.getId();
+ }
+
+ public BugReportSyncState getSyncState() {
+ return syncState;
+ }
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskEditorInput.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskEditorInput.java
index c56114904..ce561da5d 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskEditorInput.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskEditorInput.java
@@ -20,6 +20,7 @@ import javax.security.auth.login.LoginException;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.mylar.bugzilla.core.BugReport;
import org.eclipse.mylar.bugzilla.ui.editor.ExistingBugEditorInput;
+import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaTask.BugReportSyncState;
import org.eclipse.ui.IPersistableElement;
@@ -100,7 +101,7 @@ public class BugzillaTaskEditorInput extends ExistingBugEditorInput {
* Returns the offline bug for this input's Bugzilla task
*/
public BugReport getOfflineBug() {
- if(offline)
+ if(offline || bugTask.getSyncState() == BugReportSyncState.OUTGOING)
return offlineBug;
else
return super.getBug();
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskExternalizer.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskExternalizer.java
index 4c89f0cf2..81e5fffe7 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskExternalizer.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskExternalizer.java
@@ -14,6 +14,7 @@ package org.eclipse.mylar.bugzilla.ui.tasklist;
import java.util.Date;
import org.eclipse.mylar.bugzilla.ui.BugzillaUiPlugin;
+import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaTask.BugReportSyncState;
import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaTask.BugTaskState;
import org.eclipse.mylar.core.MylarPlugin;
import org.eclipse.mylar.tasklist.ICategory;
@@ -42,6 +43,7 @@ public class BugzillaTaskExternalizer extends DefaultTaskListExternalizer {
private static final String BUGZILLA = "Bugzilla";
private static final String LAST_DATE = "LastDate";
private static final String DIRTY = "Dirty";
+ private static final String SYNC_STATE = "offlineSyncState";
private static final String DESCRIPTION = "Description";
private static final String URL = "URL";
@@ -164,6 +166,8 @@ public class BugzillaTaskExternalizer extends DefaultTaskListExternalizer {
node.setAttribute(LAST_DATE, new Long(new Date().getTime()).toString());
}
+ node.setAttribute(SYNC_STATE, bt.getSyncState().toString());
+
if (bt.isDirty()) {
node.setAttribute(DIRTY, TRUE);
} else {
@@ -199,6 +203,7 @@ public class BugzillaTaskExternalizer extends DefaultTaskListExternalizer {
task.setState(BugTaskState.FREE);
task.setLastRefresh(new Date(new Long(element.getAttribute("LastDate"))
.longValue()));
+
if (element.getAttribute("Dirty").compareTo("true") == 0) {
task.setDirty(true);
} else {
@@ -212,6 +217,19 @@ public class BugzillaTaskExternalizer extends DefaultTaskListExternalizer {
MylarPlugin.log(e, "Failed to read bug report");
}
+ if (element.hasAttribute(SYNC_STATE)) {
+ String syncState = element.getAttribute(SYNC_STATE);
+ if(syncState.compareTo(BugReportSyncState.OK.toString()) == 0){
+ task.setSyncState(BugReportSyncState.OK);
+ } else if(syncState.compareTo(BugReportSyncState.INCOMMING.toString()) == 0){
+ task.setSyncState(BugReportSyncState.INCOMMING);
+ } else if(syncState.compareTo(BugReportSyncState.OUTGOING.toString()) == 0){
+ task.setSyncState(BugReportSyncState.OUTGOING);
+ } else if(syncState.compareTo(BugReportSyncState.CONFLICT.toString()) == 0){
+ task.setSyncState(BugReportSyncState.CONFLICT);
+ }
+ }
+
ITaskHandler taskHandler = MylarTasklistPlugin.getDefault().getTaskHandlerForElement(task);
if(taskHandler != null){
ITask addedTask = taskHandler.taskAdded(task);
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskListManager.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskListManager.java
index c5dbb45af..333a8a33c 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskListManager.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskListManager.java
@@ -14,12 +14,18 @@ package org.eclipse.mylar.bugzilla.ui.tasklist;
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.mylar.bugzilla.core.IBugzillaBug;
+import org.eclipse.mylar.bugzilla.core.IOfflineBugListener;
+import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaTask.BugReportSyncState;
+import org.eclipse.mylar.tasklist.ITask;
+import org.eclipse.mylar.tasklist.MylarTasklistPlugin;
import org.eclipse.mylar.tasklist.internal.TaskCategory;
+import org.eclipse.mylar.tasklist.ui.views.TaskListView;
/**
* @author Mik Kersten and Ken Sueda
*/
-public class BugzillaTaskListManager {
+public class BugzillaTaskListManager implements IOfflineBugListener {
private Map<String, BugzillaTask> bugzillaTaskRegistry = new HashMap<String, BugzillaTask>();
@@ -47,5 +53,32 @@ public class BugzillaTaskListManager {
public void setTaskRegistyCategory(TaskCategory cat) {
this.cat = cat;
}
+
+ public void offlineStatusChange(IBugzillaBug bug, BugzillaOfflineStaus status) {
+ BugReportSyncState state = null;
+ if(status == BugzillaOfflineStaus.SAVED_WITH_OUTGOING_CHANGES){
+ state = BugReportSyncState.OUTGOING;
+ } else if(status == BugzillaOfflineStaus.SAVED){
+ state = BugReportSyncState.OK;
+ }else if(status == BugzillaOfflineStaus.SAVED_WITH_INCOMMING_CHANGES){
+ state = BugReportSyncState.INCOMMING;
+ }else if(status == BugzillaOfflineStaus.CONFLICT){
+ state = BugReportSyncState.CONFLICT;
+ }
+ if(state == null){
+ // this means that we got a status that we didn't understand
+ return;
+ }
+
+ String handle = BugzillaTask.getHandle(bug);
+ ITask task = MylarTasklistPlugin.getTaskListManager().getTaskForHandle(handle, true);
+ if(task != null && task instanceof BugzillaTask){
+ BugzillaTask bugTask = (BugzillaTask) task;
+ bugTask.setSyncState(state);
+ if(TaskListView.getDefault() != null && TaskListView.getDefault().getViewer() != null && !TaskListView.getDefault().getViewer().getControl().isDisposed()){
+ TaskListView.getDefault().getViewer().refresh();
+ }
+ }
+ }
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/wizard/NewBugWizard.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/wizard/NewBugWizard.java
index 2c16bf603..ee95abb13 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/wizard/NewBugWizard.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/wizard/NewBugWizard.java
@@ -129,7 +129,7 @@ public class NewBugWizard extends AbstractBugWizard {
protected void saveBugOffline() {
// Since the bug report is new, it just needs to be added to the
// existing list of reports in the offline file.
- OfflineView.saveOffline(model);
+ OfflineView.saveOffline(model, true);
}
@Override

Back to the top