diff options
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui/src/org')
58 files changed, 0 insertions, 10779 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/AbstractCategory.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/AbstractCategory.java deleted file mode 100644 index 599106aba..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/AbstractCategory.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ - -package org.eclipse.mylar.tasks; - -import org.eclipse.swt.graphics.Image; - -/** - * @author Ken Sueda - */ -public class AbstractCategory implements ITaskListElement { - - private String priority = ""; - private String description = ""; - private String handle = ""; - - public AbstractCategory(String description) { - this.description = description; - } - - public Image getIcon() { - return null; - } - - public String getPriority() { - return priority; - } - - public String getDescription(boolean label) { - return description; - } - - public String getHandle() { - return handle; - } - - public void setDescription(String description) { - this.description = description; - } - - public void setHandle(String handle) { - this.handle = handle; - } - - public void setPriority(String priority) { - this.priority = priority; - } - - public Image getStatusIcon() { - return null; - } -} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaHit.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaHit.java deleted file mode 100644 index f768eca1d..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaHit.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ - -package org.eclipse.mylar.tasks; - -import org.eclipse.mylar.bugzilla.BugzillaImages; -import org.eclipse.mylar.ui.MylarImages; -import org.eclipse.swt.graphics.Image; - -/** - * @author Ken Sueda - */ -public class BugzillaHit implements ITaskListElement { - - private String description; - private String priority; - private int id; - private BugzillaTask task; - - public BugzillaHit(String description, String priority, int id, BugzillaTask task) { - this.description = description; - this.priority = priority; - this.id = id; - this.task = task; - } - - public boolean isTask(){ - return task != null; - } - - public BugzillaTask getAssociatedTask(){ - return task; - } - - public void setAssociatedTask(BugzillaTask task){ - this.task = task; - } - - public Image getIcon() { - if(isTask()){ - return task.getIcon(); - } else { - return BugzillaImages.getImage(BugzillaImages.BUG); - } - } - - public Image getStatusIcon() { - if (isTask()) { - return task.getStatusIcon(); - } else { - return MylarImages.getImage(MylarImages.TASK_INACTIVE); - } - } - - public String getPriority() { - return priority; - } - - public String getDescription(boolean label) { - return description; - } - - public String getHandle() { - return getServerName()+"-"+getID(); - } - public void setDescription(String description) { - this.description = description; - } - public String getServerName() { - // TODO need the right server name - get from the handle - return "Bugzilla"; - } - public int getID() { - - return id; - } - - public String getIDString() { - Integer bugId = new Integer(this.id); - return bugId.toString(); - } - -} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaQueryCategory.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaQueryCategory.java deleted file mode 100644 index 2858c3236..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaQueryCategory.java +++ /dev/null @@ -1,155 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ - -package org.eclipse.mylar.tasks; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.security.auth.login.LoginException; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.mylar.bugzilla.BugzillaPlugin; -import org.eclipse.mylar.bugzilla.IBugzillaConstants; -import org.eclipse.mylar.bugzilla.search.BugzillaSearchHit; -import org.eclipse.mylar.tasks.bugzilla.search.BugzillaCategorySearchOperation; -import org.eclipse.mylar.tasks.bugzilla.search.BugzillaResultCollector; -import org.eclipse.mylar.tasks.bugzilla.search.BugzillaCategorySearchOperation.ICategorySearchListener; -import org.eclipse.mylar.ui.MylarImages; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.PlatformUI; - -/** - * @author Shawn Minto - */ -public class BugzillaQueryCategory extends AbstractCategory { - - private static final long serialVersionUID = 5517146402031743253L; - private String url; - private List<BugzillaHit> hits = new ArrayList<BugzillaHit>(); - private boolean hasBeenRefreshed = false; - - public class BugzillaQueryCategorySearchListener implements - ICategorySearchListener { - - Map<Integer, BugzillaSearchHit> hits = new HashMap<Integer, BugzillaSearchHit>(); - - public void searchCompleted(BugzillaResultCollector collector) { - for(BugzillaSearchHit hit: collector.getResults()){ - - // HACK need the server name and handle properly - addHit(new BugzillaHit(hit.getId() + ": " + hit.getDescription(), hit.getPriority(), hit.getId(), null)); - } - } - - } - - private ICategorySearchListener listener = new BugzillaQueryCategorySearchListener(); - - public BugzillaQueryCategory(String label, String url) { - super(label); - this.url = url; - } - - public String getDescription(boolean label) { - if (hits.size() > 0 || !label) { - return super.getDescription(label); - } else if (!hasBeenRefreshed) { - return super.getDescription(label) + " <needs refresh>"; - } else { - return super.getDescription(label) + " <no hits>"; - } - } - - - public Image getIcon() { - return MylarImages.getImage(MylarImages.CATEGORY_QUERY); - } - - public String getUrl() { - return url; - } - - public List<BugzillaHit> getHits() { - return hits; - } - - public void addHit(BugzillaHit hit) { - BugzillaTask task = MylarTasksPlugin.getTaskListManager().getTaskList().getFromBugzillaTaskRegistry(hit.getHandle()); - hit.setAssociatedTask(task); - hits.add(hit); - } - - public void removeHit(BugzillaHit hit) { - hits.remove(hit); - } - - public void refreshBugs() { - hits.clear(); - final BugzillaCategorySearchOperation catSearch = new BugzillaCategorySearchOperation( - getUrl()); - catSearch.addResultsListener(listener); - final IStatus[] status = new IStatus[1]; - - try { - // execute the search operation - catSearch.execute(new NullProgressMonitor()); - hasBeenRefreshed = true; - - // get the status of the search operation - status[0] = catSearch.getStatus(); - - // determine if there was an error, if it was cancelled, or if it is - // ok - if (status[0].getCode() == IStatus.CANCEL) { - // it was cancelled, so just return - status[0] = Status.OK_STATUS; - // return status[0]; - return; - } else if (!status[0].isOK()) { - // there was an error, so display an error message - PlatformUI.getWorkbench().getDisplay().asyncExec( - new Runnable() { - public void run() { - ErrorDialog.openError(null, - "Bugzilla Search Error", null, - status[0]); - } - }); - status[0] = Status.OK_STATUS; - return; - // return status[0]; - } - } catch (LoginException e) { - // we had a problem while searching that seems like a login info - // problem - // thrown in BugzillaSearchOperation - MessageDialog - .openError( - null, - "Login Error", - "Bugzilla could not log you in to get the information you requested since login name or password is incorrect.\nPlease check your settings in the bugzilla preferences. "); - BugzillaPlugin.log(new Status(IStatus.ERROR, - IBugzillaConstants.PLUGIN_ID, IStatus.OK, "", e)); - } - return; - } - - public void setUrl(String url) { - this.url = url; - } - -} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaTask.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaTask.java deleted file mode 100644 index 9385f7666..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaTask.java +++ /dev/null @@ -1,471 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on 14-Jan-2005 - */ -package org.eclipse.mylar.tasks; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import javax.security.auth.login.LoginException; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.IJobChangeEvent; -import org.eclipse.core.runtime.jobs.IJobChangeListener; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.mylar.bugzilla.BugzillaPlugin; -import org.eclipse.mylar.bugzilla.core.BugReport; -import org.eclipse.mylar.bugzilla.core.BugzillaRepository; -import org.eclipse.mylar.bugzilla.core.IBugzillaBug; -import org.eclipse.mylar.bugzilla.offlineReports.OfflineReportsFile; -import org.eclipse.mylar.bugzilla.ui.OfflineView; -import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.ui.BugzillaTaskEditorInput; -import org.eclipse.mylar.ui.MylarImages; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.internal.Workbench; - - -/** - * @author Mik Kersten - */ -public class BugzillaTask extends Task { - - /** - * Comment for <code>serialVersionUID</code> - */ - private static final long serialVersionUID = 3257007648544469815L; - - public static final String FILE_EXTENSION = ".bug_reports"; - - public enum BugTaskState {FREE, WAITING, DOWNLOADING, COMPARING, OPENING} - private transient BugTaskState state; - - /** - * The bug report for this BugzillaTask. This is <code>null</code> if the - * bug report with the specified ID was unable to download. - */ - protected transient BugReport bugReport = null; - - /** - * Value is <code>true</code> if the bug report has saved changes that - * need synchronizing with the Bugzilla server. - */ - private boolean isDirty; - - /** The last time this task's bug report was downloaded from the server. */ - protected Date lastRefresh; - - public static final ISchedulingRule rule = new ISchedulingRule() { - public boolean isConflicting(ISchedulingRule schedulingRule) { - return schedulingRule == this; - } - public boolean contains(ISchedulingRule schedulingRule) { - return schedulingRule == this; - } - }; - - public BugzillaTask(String id, String label) { - super(id, label); - isDirty = false; - GetBugReportJob job = new GetBugReportJob("Downloading from Bugzilla server..."); - job.schedule(); - } - - public BugzillaTask(String id, String label, boolean noDownload) { - super(id, label); - isDirty = false; - if (!noDownload) { - GetBugReportJob job = new GetBugReportJob("Downloading from Bugzilla server..."); - job.schedule(); - } - } - - public BugzillaTask(BugzillaHit hit) { - this(hit.getHandle(), hit.getDescription(false)); - } - - @Override - public String getLabel() { - return MylarTasksPlugin.getDefault().getBugzillaProvider().getBugzillaDescription(this); - } - - /** - * @return Returns the bugReport. - */ - public BugReport getBugReport() { - return bugReport; - } - - /** - * @param bugReport The bugReport to set. - */ - public void setBugReport(BugReport bugReport) { - this.bugReport = bugReport; - } - - /** - * @return Returns the serialVersionUID. - */ - public static long getSerialVersionUID() { - return serialVersionUID; - } - /** - * @return Returns the lastRefresh. - */ - public Date getLastRefresh() { - return lastRefresh; - } - /** - * @param lastRefresh The lastRefresh to set. - */ - public void setLastRefresh(Date lastRefresh) { - this.lastRefresh = lastRefresh; - } - /** - * @param state The state to set. - */ - public void setState(BugTaskState state) { - this.state = state; - } - /** - * @return Returns <code>true</code> if the bug report has saved changes - * that need synchronizing with the Bugzilla server. - */ - public boolean isDirty() { - return isDirty; - } - - /** - * @param isDirty The isDirty to set. - */ - public void setDirty(boolean isDirty) { - this.isDirty = isDirty; - notifyTaskDataChange(); - } - - /** - * @return Returns the state of the Bugzilla task. - */ - public BugTaskState getState() { - return state; - } - - /** - * Try to download the bug from the server. - * @param bugId The ID of the bug report to download. - * - * @return The bug report, or <code>null</code> if it was unsuccessfully - * downloaded. - */ - public BugReport downloadReport() { -// BugzillaTaskEditorInput input = new BugzillaTaskEditorInput(this); - try { - // XXX make sure to send in the server name if there are multiple repositories - return BugzillaRepository.getInstance().getBug(getBugId(getHandle())); - } catch (LoginException e) { - MylarPlugin.log(e, "download failed"); - } catch (IOException e) { - MylarPlugin.log(e, "download failed"); - } - return null; - } - - @Override - public void openTaskInEditor(){ - openTask(-1); - } - - /** - * Opens this task's bug report in an editor revealing the selected comment. - * @param commentNumber The comment number to reveal - */ - public void openTask(int commentNumber) { - if (state != BugTaskState.FREE) { - return; - } - - state = BugTaskState.OPENING; - notifyTaskDataChange(); - OpenBugTaskJob job = new OpenBugTaskJob("Opening Bugzilla task in editor...", this); - job.schedule(); - job.addJobChangeListener(new IJobChangeListener(){ - - public void aboutToRun(IJobChangeEvent event) { - // don't care about this event - } - - public void awake(IJobChangeEvent event) { - // don't care about this event - } - - public void done(IJobChangeEvent event) { - state = BugTaskState.FREE; - notifyTaskDataChange(); - } - - public void running(IJobChangeEvent event) { - // don't care about this event - } - - public void scheduled(IJobChangeEvent event) { - // don't care about this event - } - - public void sleeping(IJobChangeEvent event) { - // don't care about this event - } - }); - } - - /** - * @return <code>true</code> if the bug report for this BugzillaTask was - * successfully downloaded. - */ - public boolean isBugDownloaded() { - return bugReport != null; - } - - @Override - public String toString() { - return "bugzilla report id: " + getHandle(); - } - - protected void openTaskEditor(final IEditorInput input) { - if (isBugDownloaded()) { - - Workbench.getInstance().getDisplay().asyncExec(new Runnable() { - public void run() { - // get the active workbench page - IWorkbenchPage page = MylarTasksPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage(); - - // if we couldn't get the page, get out of here - if (page == null) - return; - - try { - // try to open an editor on the input bug - //page.openEditor(input, IBugzillaConstants.EXISTING_BUG_EDITOR_ID); - page.openEditor(input, "org.eclipse.mylar.tasks.ui.bugzillaTaskEditor"); - } - catch (PartInitException ex) { - MylarPlugin.log(ex, "couldn't open"); - return; - } - } - }); - } - else { - Workbench.getInstance().getDisplay().asyncExec(new Runnable() { - public void run() { - MessageDialog.openInformation(Workbench.getInstance().getActiveWorkbenchWindow().getShell(), - "Could not open bug.", "Bug #" + getHandle() - + " could not be read from the server. Try refreshing the bug task."); - } - }); - } - } - - /** - * @return Returns the last time this task's bug report was downloaded from - * the server. - */ - public Date getLastRefreshTime() { - return lastRefresh; - } - - /** - * @return The number of seconds ago that this task's bug report was - * downloaded from the server. - */ - public long getTimeSinceLastRefresh() { - Date timeNow = new Date(); - return (timeNow.getTime() - lastRefresh.getTime())/1000; - } - - private class GetBugReportJob extends Job { - public GetBugReportJob(String name) { - super(name); - setRule(rule); - state = BugTaskState.WAITING; - notifyTaskDataChange(); - } - - @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); - return new Status(IStatus.OK, MylarPlugin.IDENTIFIER, IStatus.OK, "", null); - } - } - - public void updateTaskDetails() { - setPriority(bugReport.getAttribute("Priority").getValue()); - String status = bugReport.getAttribute("Status").getValue(); - if (status.equals("RESOLVED")) { - setCompleted(true); - } - } - - private class OpenBugTaskJob extends Job { - - protected BugzillaTask bugTask; - - public OpenBugTaskJob(String name, BugzillaTask bugTask) { - super(name); - this.bugTask = bugTask; - } - - @Override - protected IStatus run(IProgressMonitor monitor) { - try{ - final IEditorInput input = new BugzillaTaskEditorInput(bugTask); - state = BugTaskState.OPENING; - notifyTaskDataChange(); - openTaskEditor(input); - - state = BugTaskState.FREE; - notifyTaskDataChange(); - return new Status(IStatus.OK, MylarPlugin.IDENTIFIER, IStatus.OK, "", null); - }catch(Exception e){ - MylarPlugin.log(e, "couldn't open"); - } - return Status.CANCEL_STATUS; - } - } - - /** - * Refreshes the bug report with the Bugzilla server. - */ - public void refresh() { - // The bug report must be untouched, and this task must not be busy. - if (isDirty() || (state != BugTaskState.FREE)) { - return; - } - GetBugReportJob job = new GetBugReportJob("Refreshing with Bugzilla server..."); - job.schedule(); - } - - @Override - public String getToolTipText() { - if(lastRefresh == null) - return ""; - // Get the current time. - Date timeNow = new Date(); - - // Get the number of minutes between the current time - // and the last time the bug report was downloaded - long timeDifference = (timeNow.getTime() - lastRefresh.getTime())/60000; - - // Calculate the number of minutes and hours. - // The amount left in "timeDifference" is the - // days' difference. - long minutes = timeDifference % 60; - timeDifference /= 60; - long hours = timeDifference % 24; - timeDifference /= 24; - - // Gradually generate the tooltip string... - String toolTip; - if (bugReport == null) { - toolTip = "Last attempted download "; - } - else { - toolTip = "Last downloaded "; - } - - if (timeDifference > 0) { - toolTip += timeDifference + ((timeDifference == 1) ? " day " : " days "); - } - if (hours > 0 || timeDifference > 0) { - toolTip += hours + ((hours == 1) ? " hour " : " hours "); - } - toolTip += minutes + ((minutes == 1) ? " minute " : " minutes ") + "ago"; - - return toolTip; - } - - public boolean readBugReport() { - // XXX server name needs to be with the bug report - int location = BugzillaPlugin.getDefault().getOfflineReports().find(getBugId(getHandle())); - if(location == -1){ - bugReport = null; - return true; - } - bugReport = (BugReport)BugzillaPlugin.getDefault().getOfflineReports().elements().get(location); - return true; - } - - public void saveBugReport(boolean refresh) { - if(bugReport == null) - 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); - - if(refresh){ - final IWorkbench workbench = PlatformUI.getWorkbench(); - workbench.getDisplay().asyncExec(new Runnable() { - public void run() { - OfflineView.refresh(); - } - }); - } - } - - public static String getServerName(String handle) { - int index = handle.lastIndexOf('-'); - if(index != -1){ - return handle.substring(0, index); - } - return null; - } - - public static int getBugId(String handle) { - int index = handle.lastIndexOf('-'); - if(index != -1){ - String id = handle.substring(index+1); - return Integer.parseInt(id); - } - return -1; - } - - public Image getIcon() { - return MylarImages.getImage(MylarImages.TASK_BUGZILLA); - } -} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITask.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITask.java deleted file mode 100644 index 7380741d2..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITask.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on Jan 13, 2005 - */ -package org.eclipse.mylar.tasks; - -import java.io.Serializable; -import java.util.List; - -/** - * @author Mik Kersten - * - * TODO: make IDs be handles - */ -public interface ITask extends Serializable { - - @Override - public abstract String toString(); - - public abstract String getPath(); - - public abstract void setPath(String path); - - public abstract String getHandle(); - - public abstract void setHandle(String id); - - public abstract String getLabel(); - - public abstract void setLabel(String label); - - public abstract ITask getParent(); - - public abstract void setParent(ITask parent); - - public abstract boolean isActive(); - - public abstract void setActive(boolean active); - - public abstract boolean isCompleted(); - - public abstract void setCompleted(boolean completed); - - public abstract RelatedLinks getRelatedLinks(); - - public abstract void setRelatedLinks(RelatedLinks relatedLinks); - - public abstract void addLink(String url); - - public abstract void removeLink(String url); - - public abstract String getNotes(); - - public abstract void setNotes(String notes); - - public abstract String getElapsedTime(); - - public abstract void setElapsedTime(String elapsed); - - public abstract String getEstimatedTime(); - - public abstract void setEstimatedTime(String estimated); - - public abstract List<ITask> getChildren(); - - public abstract void addSubTask(ITask t); - - public abstract void removeSubTask(ITask t); - - /** - * Opens this task in an editor - */ - public abstract void openTaskInEditor(); - - public abstract String getToolTipText(); - - public abstract String getPriority(); - - public abstract void setPriority(String priority); - @Deprecated - public abstract boolean isCategory(); - @Deprecated - public abstract void setIsCategory(boolean b); - - public abstract void setCategory(TaskCategory cat); - - public abstract TaskCategory getCategory(); -}
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITaskActivityListener.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITaskActivityListener.java deleted file mode 100644 index 98abbe02a..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITaskActivityListener.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on Jan 13, 2005 - */ -package org.eclipse.mylar.tasks; - -import java.util.List; - -/** - * @author Mik Kersten - */ -public interface ITaskActivityListener { - - public abstract void taskActivated(ITask task); - - public abstract void tasksActivated(List<ITask> tasks); - - public abstract void taskDeactivated(ITask task); - - public abstract void taskPropertyChanged(ITask updatedTask, String property); -} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITaskInfo.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITaskInfo.java deleted file mode 100644 index e8fbc8de8..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITaskInfo.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on Jan 12, 2005 - */ -package org.eclipse.mylar.tasks; - -/** - * @author Mik Kersten - */ -public interface ITaskInfo { - - public String getHandle(); - -} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITaskListElement.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITaskListElement.java deleted file mode 100644 index b8b0a5927..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITaskListElement.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -package org.eclipse.mylar.tasks; - -import org.eclipse.swt.graphics.Image; - -/** - * @author Ken Sueda - */ -public interface ITaskListElement { - - public abstract Image getIcon(); - - public abstract Image getStatusIcon(); - - public abstract String getPriority(); - - public abstract String getDescription(boolean label); - - public abstract String getHandle(); -} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/MylarTasksPlugin.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/MylarTasksPlugin.java deleted file mode 100644 index 061cc0fd2..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/MylarTasksPlugin.java +++ /dev/null @@ -1,356 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -package org.eclipse.mylar.tasks; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -import org.eclipse.core.runtime.Preferences.IPropertyChangeListener; -import org.eclipse.core.runtime.Preferences.PropertyChangeEvent; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.bugzilla.BugzillaContentProvider; -import org.eclipse.mylar.tasks.bugzilla.BugzillaEditingMonitor; -import org.eclipse.mylar.tasks.bugzilla.BugzillaMylarBridge; -import org.eclipse.mylar.tasks.bugzilla.BugzillaReferencesProvider; -import org.eclipse.mylar.tasks.bugzilla.BugzillaStructureBridge; -import org.eclipse.mylar.tasks.bugzilla.ui.BugzillaUiBridge; -import org.eclipse.mylar.ui.MylarUiPlugin; -import org.eclipse.swt.events.ShellEvent; -import org.eclipse.swt.events.ShellListener; -import org.eclipse.ui.IStartup; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.internal.Workbench; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -/** - * @author Mik Kersten - */ -public class MylarTasksPlugin extends AbstractUIPlugin implements IStartup { - - private static MylarTasksPlugin plugin; - private static TaskListManager taskListManager; - private BugzillaContentProvider bugzillaProvider; - - public static final String FILE_EXTENSION = ".xml"; - public static final String TASK_ID = "org.eclipse.mylar.tasks.userid"; - public static final String DEFAULT_TASK_LIST_FILE = "tasklist" + FILE_EXTENSION; - public static final String TASK_EDITOR_ID = "org.eclipse.mylar.tasks.ui.taskEditor"; - public static final String SHOW_P1_MODE = "org.eclipse.mylar.tasks.show.p1"; - public static final String SHOW_P2_MODE = "org.eclipse.mylar.tasks.show.p2"; - public static final String SHOW_P3_MODE = "org.eclipse.mylar.tasks.show.p3"; - public static final String SHOW_P4_MODE = "org.eclipse.mylar.tasks.show.p4"; - public static final String SHOW_P5_MODE = "org.eclipse.mylar.tasks.show.p5"; - public static final String FILTER_COMPLETE_MODE = "org.eclipse.mylar.tasks.filter.complete"; - public static final String FILTER_INCOMPLETE_MODE = "org.eclipse.mylar.tasks.filter.incomplete"; - - private ResourceBundle resourceBundle; - - public enum Priority_Level { - P1, - P2, - P3, - P4, - P5; - - @Override - public String toString() { - switch(this) { - case P1: return "P1"; - case P2: return "P2"; - case P3: return "P3"; - case P4: return "P4"; - case P5: return "P5"; - default: return "null"; - } - } - public static Priority_Level fromString(String string) { - if (string == null) return null; - if (string.equals("P1")) return P1; - if (string.equals("P2")) return P2; - if (string.equals("P3")) return P3; - if (string.equals("P4")) return P4; - if (string.equals("P5")) return P5; - return null; - } - } - - /** The bridge between Bugzilla and mylar */ - private static BugzillaMylarBridge bridge = null; - - private BugzillaStructureBridge structureBridge; - - private static BugzillaReferencesProvider referencesProvider = new BugzillaReferencesProvider(); - - private static ITaskActivityListener TASK_LIST_LISTENER = new ITaskActivityListener() { - - public void taskActivated(ITask task) { - MylarPlugin.getTaskscapeManager().taskActivated(task.getHandle(), task.getPath()); - } - - public void tasksActivated(List<ITask> tasks) { - for (ITask task : tasks) { - MylarPlugin.getTaskscapeManager().taskActivated(task.getHandle(), task.getPath()); - } - } - - public void taskDeactivated(ITask task) { - MylarPlugin.getTaskscapeManager().taskDeactivated(task.getHandle(), task.getPath()); - } - - public void taskPropertyChanged(ITask updatedTask, String property) { - // don't care about property change - } - - }; - - private static ShellListener SHELL_LISTENER = new ShellListener() { - private void saveState() { - taskListManager.saveTaskList(); - for(ITask task : taskListManager.getTaskList().getActiveTasks()) { - MylarPlugin.getTaskscapeManager().saveTaskscape(task.getHandle(), task.getPath()); - } - } - public void shellClosed(ShellEvent arg0) { - saveState(); - } - public void shellDeactivated(ShellEvent arg0) { - saveState(); - } - public void shellActivated(ShellEvent arg0) { } - public void shellDeiconified(ShellEvent arg0) { } - public void shellIconified(ShellEvent arg0) { } - }; - - private static IPropertyChangeListener PREFERENCE_LISTENER = new IPropertyChangeListener() { - - public void propertyChange(PropertyChangeEvent event) { - // TODO Auto-generated method stub - if (event.getProperty().equals(MylarPlugin.MYLAR_DIR)) { - if (event.getOldValue() instanceof String) { - String prevDir = (String) event.getOldValue(); - MylarPlugin.getTaskscapeManager().updateMylarDirContents(prevDir); - getTaskListManager().updateTaskscapeReference(prevDir); - - String path = MylarPlugin.getDefault().getUserDataDirectory() + File.separator + DEFAULT_TASK_LIST_FILE; - getTaskListManager().setFile(new File(path)); - } - } else { - } - } - }; - - public MylarTasksPlugin() { - super(); - plugin = this; - } - - public void earlyStartup() { - final IWorkbench workbench = PlatformUI.getWorkbench(); - workbench.getDisplay().asyncExec(new Runnable() { - public void run() { - - structureBridge = new BugzillaStructureBridge(); - - MylarPlugin.getDefault().addBridge(structureBridge); - MylarPlugin.getTaskscapeManager().addListener(referencesProvider); - MylarUiPlugin.getDefault().addAdapter(BugzillaStructureBridge.EXTENSION, new BugzillaUiBridge()); - MylarPlugin.getDefault().getSelectionMonitors().add(new BugzillaEditingMonitor()); - - IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); - - Workbench.getInstance().getActiveWorkbenchWindow().getShell().addShellListener(SHELL_LISTENER); - MylarPlugin.getDefault().getPluginPreferences().addPropertyChangeListener(PREFERENCE_LISTENER); - - getPrefs().setDefault(SHOW_P1_MODE, true); - getPrefs().setDefault(SHOW_P2_MODE, true); - getPrefs().setDefault(SHOW_P3_MODE, true); - getPrefs().setDefault(SHOW_P4_MODE, true); - getPrefs().setDefault(SHOW_P5_MODE, true); - if (window != null) { - // create a new bridge and initialize it - bridge = new BugzillaMylarBridge(); - } - } - }); - } - - @Override - public void start(BundleContext context) throws Exception { - bugzillaProvider = new BugzillaContentProvider(); - String path = MylarPlugin.getDefault().getUserDataDirectory() + File.separator + DEFAULT_TASK_LIST_FILE; - File taskListFile = new File(path); - taskListManager = new TaskListManager(taskListFile); - taskListManager.addListener(TASK_LIST_LISTENER); - taskListManager.readTaskList(); - if (taskListManager.getTaskList() == null) taskListManager.createNewTaskList(); - - super.start(context); - } - - @Override - public void stop(BundleContext context) throws Exception { - super.stop(context); - plugin = null; - resourceBundle = null; - } - - /** - * Get the bridge for this plugin - * - * @return The bugzilla mylar bridge - */ - public static BugzillaMylarBridge getBridge() { - // make sure that the bridge initialized, if not, make a new one - if (bridge == null) { - bridge = new BugzillaMylarBridge(); -// MylarPlugin.getTaskscapeManager().addRelationshipProvider(new BugzillaRelationshipProvider()); -// MylarUiPlugin.getDefault().getAdapters().put(ITaskscapeNode.Kind.Bugzilla, new BugzillaUiAdapter()); - } - return bridge; - } - - - public static TaskListManager getTaskListManager() { - return taskListManager; - } - - /** - * Returns the shared instance. - */ - public static MylarTasksPlugin getDefault() { - return plugin; - } - - /** - * Returns the string from the plugin's resource bundle, - * or 'key' if not found. - */ - public static String getResourceString(String key) { - ResourceBundle bundle = MylarTasksPlugin.getDefault().getResourceBundle(); - try { - return (bundle != null) ? bundle.getString(key) : key; - } catch (MissingResourceException e) { - return key; - } - } - - /** - * Returns the plugin's resource bundle, - */ - public ResourceBundle getResourceBundle() { - try { - if (resourceBundle == null) - resourceBundle = ResourceBundle.getBundle("taskListPlugin.TaskListPluginPluginResources"); - } catch (MissingResourceException x) { - resourceBundle = null; - } - return resourceBundle; - } - - public BugzillaContentProvider getBugzillaProvider() { - return bugzillaProvider; - } - - public void setBugzillaProvider(BugzillaContentProvider bugzillaProvider) { - this.bugzillaProvider = bugzillaProvider; - } - - public BugzillaStructureBridge getStructureBridge() { - return structureBridge; - } - - public static BugzillaReferencesProvider getReferenceProvider() { - return referencesProvider; - - } - - public static IPreferenceStore getPrefs() { - return MylarPlugin.getDefault().getPreferenceStore(); - } - - public static void setPriorityLevel(Priority_Level pl, boolean showPriority) { - String key = ""; - switch(pl) { - case P1: key = SHOW_P1_MODE; break; - case P2: key = SHOW_P2_MODE; break; - case P3: key = SHOW_P3_MODE; break; - case P4: key = SHOW_P4_MODE; break; - case P5: key = SHOW_P5_MODE; break; - default: key = SHOW_P1_MODE; break; - } - getPrefs().setValue(key, showPriority); - } - public static boolean getPriorityLevel(Priority_Level pl) { - String key = ""; - switch(pl) { - case P1: key = SHOW_P1_MODE; break; - case P2: key = SHOW_P2_MODE; break; - case P3: key = SHOW_P3_MODE; break; - case P4: key = SHOW_P4_MODE; break; - case P5: key = SHOW_P5_MODE; break; - default: key = SHOW_P1_MODE; break; - } - if(getPrefs().contains(key)) { - return getPrefs().getBoolean(key); - } else { - return true; - } - } - public static List<Priority_Level> getPriorityLevels() { - List<Priority_Level> levels = new ArrayList<Priority_Level>(); - if (getPriorityLevel(Priority_Level.P1)) { - levels.add(Priority_Level.P1); - } - if (getPriorityLevel(Priority_Level.P2)) { - levels.add(Priority_Level.P2); - } - if (getPriorityLevel(Priority_Level.P3)) { - levels.add(Priority_Level.P3); - } - if (getPriorityLevel(Priority_Level.P4)) { - levels.add(Priority_Level.P4); - } - if (getPriorityLevel(Priority_Level.P5)) { - levels.add(Priority_Level.P5); - } - return levels; - } - public void setFilterCompleteMode(boolean isFilterOn) { - getPrefs().setValue(FILTER_COMPLETE_MODE, isFilterOn); - } - - public boolean isFilterCompleteMode() { - if (getPrefs().contains(FILTER_COMPLETE_MODE)) { - return getPrefs().getBoolean(FILTER_COMPLETE_MODE); - } else { - return false; - } - } - - public void setFilterInCompleteMode(boolean isFilterOn) { - getPrefs().setValue(FILTER_INCOMPLETE_MODE, isFilterOn); - } - - public boolean isFilterInCompleteMode() { - if (getPrefs().contains(FILTER_INCOMPLETE_MODE)) { - return getPrefs().getBoolean(FILTER_INCOMPLETE_MODE); - } else { - return false; - } - } -} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/RelatedLinks.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/RelatedLinks.java deleted file mode 100644 index 1e11116dc..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/RelatedLinks.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -package org.eclipse.mylar.tasks; - -import java.util.ArrayList; -import java.util.List; - -/** - * Related links stored for each task used as input to the Table - * used in the TaskSummaryEditor - * - * @author Ken Sueda - */ -public class RelatedLinks { - private List<String> links; - - public RelatedLinks() { - links = new ArrayList<String>(); - } - public void add(String link) { - links.add(link); - } - public List<String> getLinks() { - return links; - } - public void remove(String link) { - links.remove(link); - } -} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Task.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Task.java deleted file mode 100644 index e9509c4e8..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Task.java +++ /dev/null @@ -1,298 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on Dec 22, 2004 - */ -package org.eclipse.mylar.tasks; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.ui.TaskEditorInput; -import org.eclipse.mylar.tasks.ui.views.TaskListView; -import org.eclipse.mylar.ui.MylarImages; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.internal.Workbench; - - -/** - * @author Mik Kersten - */ -public class Task implements ITask, ITaskListElement { - - private static final long serialVersionUID = 3545518391537382197L; - private boolean active = false; - protected String handle = "-1"; - private boolean category = false; - - - /** - * Either to local resource or URL. - * TODO: consider changing to java.net.URL - */ - private String path; - private String label; - private String priority = "P3"; - private String notes = ""; - private String estimatedTime = ""; - private String elapsedTime = ""; - private boolean completed; - private RelatedLinks links = new RelatedLinks(); - private TaskCategory parentCategory = null; - - /** - * null if root - */ - private transient ITask parent; - - private List<ITask> children = new ArrayList<ITask>(); - - @Override - public String toString() { - return label; - } - - public String getPath() { - // returns relative path Mylar Directory - return path; - } - - public void setPath(String path) { - if (path.startsWith(".mylar")) { - this.path = path.substring(path.lastIndexOf('/')+1, path.length()); - } else if (!path.equals("")) { - this.path = path; - } - } - - public Task(String handle, String label) { - this.handle = handle; - this.label = label; - this.path = handle; - } - - public String getHandle() { - return handle; - } - public void setHandle(String id) { - this.handle = id; - } - public String getLabel() { - return label; - } - public void setLabel(String label) { - this.label = label; - } - - public ITask getParent() { - return parent; - } - - public void setParent(ITask parent) { - this.parent = parent; - } - public Object getAdapter(Class adapter) { - return null; - } - - /** - * Package visible in order to prevent sets that don't update the index. - */ - public void setActive(boolean active) { - this.active = active; - } - - public boolean isActive() { - return active; - } - - public void openTaskInEditor() { - Workbench.getInstance().getDisplay().asyncExec(new Runnable() { - public void run() { - openTaskEditor(); - } - }); - } - - /** - * Opens the task in an editor. - * @return Resulting <code>IStatus</code> of the operation - */ - protected void openTaskEditor() { - - // get the active page so that we can reuse it - IWorkbenchPage page = MylarTasksPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage(); - - // if we couldn't get a page, get out - if (page == null) { - return; - } - - IEditorInput input = new TaskEditorInput(this); - try - { - // try to open an editor on the input task - page.openEditor(input, MylarTasksPlugin.TASK_EDITOR_ID); - - } - catch (PartInitException ex) - { - MylarPlugin.log(ex, "open failed"); - } - } - - /** - * Refreshes the tasklist viewer. - */ - public void notifyTaskDataChange() { - final Task task = this; - Workbench.getInstance().getDisplay().asyncExec(new Runnable() { - public void run() { - if (TaskListView.getDefault() != null) TaskListView.getDefault().notifyTaskDataChanged(task); - } - }); - } - - public String getToolTipText() { - // No tool-tip used for a general task as of yet. - return null; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof Task && obj != null) { - return this.getHandle() == ((Task)obj).getHandle(); - } else { - return false; - } - } - - @Override - public int hashCode() { - return this.getHandle().hashCode(); - } - public boolean isCompleted() { - return completed; - } - public void setCompleted(boolean completed) { - this.completed = completed; - } - - public boolean isCategory() { - return category; - } - - public void setIsCategory(boolean category) { - this.category = category; - } - - public String getPriority() { - return priority; - } - - public void setPriority(String priority) { - this.priority = priority; - } - - public RelatedLinks getRelatedLinks() { - // TODO: removed check for null once xml updated. - if (links == null) { - links = new RelatedLinks(); - } - return links; - } - - public void setRelatedLinks(RelatedLinks relatedLinks) { - this.links = relatedLinks; - } - - public void addLink(String url) { - links.add(url); - } - - public void removeLink(String url) { - links.remove(url); - } - - public String getNotes() { - // TODO: removed check for null once xml updated. - if (notes == null) { - notes = ""; - } - return notes; - } - - public void setNotes(String notes) { - this.notes = notes; - } - - public String getElapsedTime() { - if (elapsedTime == null) { - elapsedTime = ""; - } - return elapsedTime; - } - - public void setElapsedTime(String elapsed) { - this.elapsedTime = elapsed; - } - - public String getEstimatedTime() { - if (estimatedTime == null) { - estimatedTime = ""; - } - return estimatedTime; - } - - public void setEstimatedTime(String estimated) { - this.estimatedTime = estimated; - } - - public List<ITask> getChildren() { - return children; - } - - public void addSubTask(ITask t) { - children.add(t); - } - - public void removeSubTask(ITask t) { - children.remove(t); - } - - public void setCategory(TaskCategory cat) { - this.parentCategory = cat; - } - - public TaskCategory getCategory() { - return parentCategory; - } - - public Image getIcon() { - return MylarImages.getImage(MylarImages.TASK); - } - - public String getDescription(boolean label) { - return getLabel(); - } - - public Image getStatusIcon() { - if (isActive()) { - return MylarImages.getImage(MylarImages.TASK_ACTIVE); - } else { - return MylarImages.getImage(MylarImages.TASK_INACTIVE); - } - } -} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskCategory.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskCategory.java deleted file mode 100644 index 5562381d1..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskCategory.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on Dec 26, 2004 - */ -package org.eclipse.mylar.tasks; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.mylar.ui.MylarImages; -import org.eclipse.swt.graphics.Image; - - -/** - * @author Mik Kersten - */ -public class TaskCategory extends AbstractCategory implements Serializable { - - private static final long serialVersionUID = 3834024740813027380L; - - private List<ITask> tasks = new ArrayList<ITask>(); - - public TaskCategory(String description) { - super(description); - } - - public Image getIcon() { - return MylarImages.getImage(MylarImages.CATEGORY); - } - - public void addTask(ITask task) { - if(task instanceof BugzillaTask){ - BugzillaTask bugTask = MylarTasksPlugin.getTaskListManager().getTaskList().getFromBugzillaTaskRegistry(task.getHandle()); - if(bugTask == null){ - MylarTasksPlugin.getTaskListManager().getTaskList().addToBugzillaTaskRegistry((BugzillaTask)task); - } else { - task = bugTask; - } - } - tasks.add(task); - - } - - public void removeTask(ITask task) { - tasks.remove(task); - } - - public List<ITask> getChildren() { - return tasks; - } - - @Override - public boolean equals(Object object) { - if (object == null) return false; - if (object instanceof TaskCategory) { - TaskCategory compare = (TaskCategory)object; - return this.getDescription(false).equals(compare.getDescription(false)); - } else { - return false; - } - } -} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskList.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskList.java deleted file mode 100644 index e7c525052..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskList.java +++ /dev/null @@ -1,194 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on Dec 22, 2004 - */ -package org.eclipse.mylar.tasks; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - - -/** - * @author Mik Kersten - */ -public class TaskList implements Serializable { - - private static final long serialVersionUID = 3618984485791021105L; - - private List<ITask> rootTasks = new ArrayList<ITask>(); - private List<AbstractCategory> categories = new ArrayList<AbstractCategory>(); - private transient List<ITask> activeTasks = new ArrayList<ITask>(); - - // XXX we never delete anything from this registry - private Map<String, BugzillaTask> bugzillaTaskRegistry = new HashMap<String, BugzillaTask>(); - - public void addToBugzillaTaskRegistry(BugzillaTask task){ - if(bugzillaTaskRegistry.get(task.getHandle()) == null){ - bugzillaTaskRegistry.put(task.getHandle(), task); - } - } - - public BugzillaTask getFromBugzillaTaskRegistry(String handle){ - return bugzillaTaskRegistry.get(handle); - } - - public Map<String, BugzillaTask> getBugzillaTaskRegistry(){ - return bugzillaTaskRegistry; - } - - public void addRootTask(ITask task) { - if(task instanceof BugzillaTask){ - BugzillaTask bugTask = bugzillaTaskRegistry.get(task.getHandle()); - if(bugTask == null){ - bugzillaTaskRegistry.put(task.getHandle(), (BugzillaTask)task); - rootTasks.add(task); - } else { - rootTasks.add(bugTask); - } - } else { - rootTasks.add(task); - } - } - - public void addCategory(AbstractCategory cat) { - categories.add(cat); - } - - public void setActive(ITask task, boolean active) { - task.setActive(active); - if (active) { - activeTasks.add(task); - } else { - activeTasks.remove(task); - } - } - - public void deleteTask(ITask task) { - boolean deleted = deleteTaskHelper(rootTasks, task); - if (!deleted) { - for (TaskCategory cat : getTaskCategories()) { - deleted = deleteTaskHelper(cat.getChildren(), task); - if (deleted) { - return; - } - } - } - } - - private boolean deleteTaskHelper(List<ITask> tasks, ITask t) { - for (ITask task : tasks) { - if (task.getHandle().equals(t.getHandle())) { - tasks.remove(task); - return true; - } else { - if (deleteTaskHelper(task.getChildren(), t)) - return true; - } - } - return false; - } - - public void deleteCategory(AbstractCategory category) { - categories.remove(category); - } - /** - * TODO: make data structure handle this traversal - */ - public ITask getTaskForId(String id) { - ITask t = null; - for (TaskCategory cat : getTaskCategories()) { - if ((t = findTaskHelper(cat.getChildren(), id)) != null) { - return t; - } - } - return findTaskHelper(rootTasks, id); - } - - private ITask findTaskHelper(List<ITask> tasks, String id) { - for (ITask task : tasks) { - if (task.getHandle() == id) { - return task; - } - ITask t = findTaskHelper(task.getChildren(), id); - if (t != null) { - return t; - } - } - return null; - } - - public List<ITask> getActiveTasks() { - return activeTasks; - } - - public List<ITask> getRootTasks() { - return rootTasks; - } - - public List<AbstractCategory> getCategories() { - return categories; - } - - public int findLargestTaskHandle() { - int max = 0; - max = Math.max(largestTaskHandleHelper(rootTasks), max); - for (TaskCategory cat : getTaskCategories()) { - max = Math.max(largestTaskHandleHelper(cat.getChildren()), max); - } - return max; - } - - private int largestTaskHandleHelper(List<ITask> tasks) { - int ihandle = 0; - int max = 0; - for (ITask t : tasks) { - if (t instanceof BugzillaTask) { - ihandle = 0; - } else { - ihandle = Integer.parseInt(t.getHandle().substring(t.getHandle().indexOf('-')+1, t.getHandle().length())); - } - max = Math.max(ihandle, max); - ihandle = largestTaskHandleHelper(t.getChildren()); - max = Math.max(ihandle, max); - } - return max; - } - - public List<Object> getRoots() { - List<Object> roots = new ArrayList<Object>(); - for (ITask t : rootTasks) { - roots.add(t); - } - for (AbstractCategory cat : categories) { - roots.add(cat); - } - return roots; - } - - public void createCategory(String description) { - TaskCategory c = new TaskCategory(description); - categories.add(c); - } - - public List<TaskCategory> getTaskCategories() { - List<TaskCategory> cats = new ArrayList<TaskCategory>(); - for (AbstractCategory cat : categories) { - if (cat instanceof TaskCategory) { - cats.add((TaskCategory)cat); - } - } - return cats; - } -} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskListManager.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskListManager.java deleted file mode 100644 index b1dd5f9b0..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskListManager.java +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on Dec 26, 2004 - */ -package org.eclipse.mylar.tasks; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.util.RelativePathUtil; -import org.eclipse.mylar.tasks.util.XmlUtil; - - -/** - * @author Mik Kersten - */ -public class TaskListManager { - - private File file; - private TaskList taskList = new TaskList(); - private List<ITaskActivityListener> listeners = new ArrayList<ITaskActivityListener>(); - private int nextTaskId; - - public TaskListManager(File file) { - this.file = file; - if (MylarPlugin.getDefault().getPreferenceStore().contains(MylarTasksPlugin.TASK_ID)) { // TODO: fix to MylarTasksPlugin - nextTaskId = MylarPlugin.getDefault().getPreferenceStore().getInt(MylarTasksPlugin.TASK_ID); - } else { - nextTaskId = 1; - } - } - - public TaskList createNewTaskList() { - return taskList; - } - - public String genUniqueTaskId() { - return "task-" + nextTaskId++; - } - - public boolean readTaskList() { - try { - if (file.exists()) { - XmlUtil.readTaskList(taskList, file); - int maxHandle = taskList.findLargestTaskHandle(); - if (maxHandle >= nextTaskId) { - nextTaskId = maxHandle + 1; - } - for (ITaskActivityListener listener : listeners) listener.tasksActivated(taskList.getActiveTasks()); - } - return true; - } catch (Exception e) { - MylarPlugin.log(e, "task read failed"); - return false; - } - } - - public void saveTaskList() { - try { - XmlUtil.writeTaskList(taskList, file); - MylarPlugin.getDefault().getPreferenceStore().setValue(MylarTasksPlugin.TASK_ID, nextTaskId); - } catch (Exception e) { - e.printStackTrace(); // TODO: fix -// MylarPlugin.fail(e, "Could not save task list", true); - } - } - - public TaskList getTaskList() { - return taskList; - } - - public void setTaskList(TaskList taskList) { - this.taskList = taskList; - } - - public void deleteTask(ITask task) { - taskList.setActive(task, false); - taskList.deleteTask(task); - } - - public void deleteCategory(AbstractCategory cat) { - taskList.deleteCategory(cat); - } - - public void addListener(ITaskActivityListener listener) { - listeners.add(listener); - } - - public void removeListener(ITaskActivityListener listener) { - listeners.remove(listener); - } - - public void activateTask(ITask task) { - taskList.setActive(task, true); - for (ITaskActivityListener listener : listeners) listener.taskActivated(task); - } - - public void deactivateTask(ITask task) { - taskList.setActive(task, false); - for (ITaskActivityListener listener : listeners) listener.taskDeactivated(task); - } - - public void taskPropertyChanged(ITask task, String property) { - for (ITaskActivityListener listener : listeners) listener.taskPropertyChanged(task, property); - } - - public void updateTaskscapeReference(String prevDir) { - List<ITask> rootTasks = this.getTaskList().getRootTasks(); - for (TaskCategory cat : taskList.getTaskCategories()) { - updateTaskscapeReferenceHelper(cat.getChildren(), prevDir); - } - updateTaskscapeReferenceHelper(rootTasks, prevDir); - - } - public void updateTaskscapeReferenceHelper(List<ITask> list, String prevDir) { - for (ITask task : list) { - if (!task.getPath().startsWith("task-")) { - if (task.getPath().startsWith("..")) { - String path = task.getPath(); - File d = new File(prevDir); - while (path.startsWith("..")) { - d = d.getParentFile(); - path = path.substring(3, path.length()); - } - - String absPath = d.getPath() + "/" + path + MylarTasksPlugin.FILE_EXTENSION; - absPath = absPath.replaceAll("\\\\", "/"); - String rel = RelativePathUtil.findRelativePath(MylarPlugin.getDefault().getUserDataDirectory() + "/", absPath); - task.setPath(rel); - taskPropertyChanged(task, "Path"); - } else { - String absPath = prevDir + "/" + task.getPath() + MylarTasksPlugin.FILE_EXTENSION; - absPath = absPath.replaceAll("\\\\", "/"); - String rel = RelativePathUtil.findRelativePath(MylarPlugin.getDefault().getUserDataDirectory(), absPath); - task.setPath(rel); - taskPropertyChanged(task, "Path"); - } - } -// updateTaskscapeReferenceHelper(task.getChildren(), prevDir); - } - } - public void setFile(File f) { - if (this.file.exists()) { - this.file.delete(); - } - this.file = f; - } - - public void activateHit(BugzillaHit hit) { - - } -} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaCacheFile.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaCacheFile.java deleted file mode 100644 index 7da0be56e..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaCacheFile.java +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -package org.eclipse.mylar.tasks.bugzilla; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.mylar.bugzilla.BugzillaPlugin; -import org.eclipse.mylar.bugzilla.core.IBugzillaBug; - -/** - * COPIED FROM @see org.eclipse.mylar.bugzilla.offlineReports.OfflineReportsFile - * - * @author Shawn Minto - */ -public class BugzillaCacheFile { - - private File file; - - private ArrayList<IBugzillaBug> list = new ArrayList<IBugzillaBug>(); - - protected int latestNewBugId = 0; - - public BugzillaCacheFile(File file) throws ClassNotFoundException, IOException { - this.file = file; - if (file.exists()) { - readFile(); - } - } - - public void add(IBugzillaBug entry) { - // add the entry to the list and write the file to disk - list.add(entry); - writeFile(); - } - - public void update() { - writeFile(); - } - - public int getNextOfflineBugId() { - latestNewBugId++; - return latestNewBugId; - } - - public int find(int id) { - for (int i = 0; i < list.size(); i++) { - IBugzillaBug currBug = list.get(i); - if (currBug != null && (currBug.getId() == id) && !currBug.isLocallyCreated()) - return i; - } - return -1; - } - - public ArrayList<IBugzillaBug> elements() { - return list; - } - - private void writeFile() { - try { - ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(file)); - - // Write the size of the list so that we can read it back in easier - out.writeInt(list.size()); - - out.writeInt(latestNewBugId); - - // write each element in the array list - for (int i = 0; i < list.size(); i++) { - Object item = list.get(i); - out.writeObject(item); - } - out.close(); - } - catch (IOException e) { - // put up a message and log the error if there is a problem writing to the file - MessageDialog.openError(null, - "I/O Error", - "Bugzilla could not write to offline reports file."); - BugzillaPlugin.log(e); - } - } - - private void readFile() throws ClassNotFoundException, IOException { - ObjectInputStream in = new ObjectInputStream(new FileInputStream(file)); - - // get the number of offline reports in the file - int size = in.readInt(); - - // get the bug id of the most recently created offline report - latestNewBugId = in.readInt(); - - // read in each of the offline reports in the file - for (int nX = 0; nX < size; nX++) { - IBugzillaBug item = (IBugzillaBug) in.readObject(); - // add the offline report to the offlineReports list - list.add(item); - } - in.close(); - } - - public void remove(List<IBugzillaBug> sel) { - list.removeAll(sel); - - // rewrite the file so that the data is persistant - writeFile(); - } - - public void removeAll() { - list.clear(); - - // rewrite the file so that the data is persistant - writeFile(); - } -} - diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaContentProvider.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaContentProvider.java deleted file mode 100644 index 4a0b4a40e..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaContentProvider.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on Jan 13, 2005 - */ -package org.eclipse.mylar.tasks.bugzilla; - -import org.eclipse.mylar.bugzilla.core.BugReport; -import org.eclipse.mylar.tasks.BugzillaTask; - - -/** - * @author Mik Kersten - * @author Eric Booth - */ -public class BugzillaContentProvider { - - public BugzillaContentProvider() { - // don't have any initialization to do - } - - /** - * @return String containing bug priority and label, e.g. "[12345] P2: fix failing test" - */ - public String getBugzillaDescription(BugzillaTask bugTask) { - if (bugTask == null) return "<no info>"; - - String prefix = //((bugTask.isDirty()) ? ">" : "") + - BugzillaTask.getBugId(bugTask.getHandle()) + ": "; - - if (bugTask.getState() == BugzillaTask.BugTaskState.DOWNLOADING) { - return prefix + ": <Downloading bug report from server...>"; - } else if (bugTask.getState() == BugzillaTask.BugTaskState.OPENING) { - return prefix + ": <Opening bug report in editor...>"; - } else if (bugTask.getState() == BugzillaTask.BugTaskState.COMPARING) { - return prefix + ": <Comparing bug report with server...>"; - } else if (bugTask.getState() == BugzillaTask.BugTaskState.WAITING) { - return prefix + ": <Waiting to check server...>"; - } - - // generate the label - if (bugTask.isBugDownloaded()) { - BugReport report = bugTask.getBugReport(); - return prefix + report.getSummary(); - } - else { - return prefix + ": <could not find bug>"; - } - } - -} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaEditingMonitor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaEditingMonitor.java deleted file mode 100644 index 8eadb4e55..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaEditingMonitor.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on Apr 27, 2005 - */ -package org.eclipse.mylar.tasks.bugzilla; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.mylar.bugzilla.ui.editor.AbstractBugEditor; -import org.eclipse.mylar.bugzilla.ui.outline.BugzillaReportSelection; -import org.eclipse.mylar.core.AbstractSelectionMonitor; -import org.eclipse.mylar.tasks.ui.BugzillaTaskEditor; -import org.eclipse.ui.IWorkbenchPart; - - -/** - * @author Mik Kersten - */ -public class BugzillaEditingMonitor extends AbstractSelectionMonitor { - - public BugzillaEditingMonitor() { - super(); - } - - @Override - protected void handleWorkbenchPartSelection(IWorkbenchPart part, ISelection selection) { - if(!(part instanceof AbstractBugEditor) && !(part instanceof BugzillaTaskEditor)) - return; - - if(selection instanceof StructuredSelection){ - StructuredSelection ss = (StructuredSelection)selection; - Object object = ss.getFirstElement(); - if(object instanceof BugzillaReportSelection) super.handleElementSelection(part, object); - } - } - -} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaMylarBridge.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaMylarBridge.java deleted file mode 100644 index 6dc4033b9..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaMylarBridge.java +++ /dev/null @@ -1,142 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on Oct 1, 2004 - */ -package org.eclipse.mylar.tasks.bugzilla; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IMember; - - -/** - * Class to handle the bridge between mylar and bugzilla - * - * @author Shawn Minto - */ -public class BugzillaMylarBridge { - - /** The hash of all of the landmarks and their related search hits */ - private HashMap<String, Map<Integer, List<BugzillaReportNode>>> landmarksHash; - /** - * The currently running search jobs so that we can cancel it if necessary <br> KEY: IMember VALUE: Job - */ - public static HashMap<String, Job> runningJobs = new HashMap<String, Job>(); - - /** - * Constructor - */ - public BugzillaMylarBridge() { - landmarksHash = new HashMap<String, Map<Integer, List<BugzillaReportNode>>>(); - } - - - /** - * Remove a landmark from the hash - * - * @param removed - * This landmark to remove (IJavaElement) - */ - public void removeFromLandmarksHash(IJavaElement removed) { - landmarksHash.remove(removed.getHandleIdentifier()); - } - - /** - * Remove all of the landmarks from the hash that are in the list - * - * @param removed - * This list of landmarks to remove (IJavaElements) - */ - public void removeFromLandmarksHash(List<IJavaElement> removed) { - - for(IJavaElement je : removed) { - landmarksHash.remove(je.getHandleIdentifier()); - } - } - - /** - * Add data to the landmarks hash - * - * @param doiList - * The list of BugzillaSearchHitDoiInfo - * @param m - * The member that this list is for - */ - public void addToLandmarksHash(List<BugzillaReportNode> doiList, IMember m, int scope) { - Map<Integer, List<BugzillaReportNode>> searches = landmarksHash.get(m.getHandleIdentifier()); - - if(searches == null){ - searches = new HashMap<Integer, List<BugzillaReportNode>>(); - } - searches.put(scope, doiList); - landmarksHash.put(m.getHandleIdentifier(), searches); - } - - /** - * Get the doiList for the given IMember from the landmarks hash - * - * @param m - * The member to get the doiList for - * @return The doiList or null if it doesn't exist - */ - public List<BugzillaReportNode> getFromLandmarksHash(IMember m, int scope) { - Map<Integer, List<BugzillaReportNode>> scopes = landmarksHash.get(m.getHandleIdentifier()); - if(scopes == null) - return null; - else - return scopes.get(scope); - } - - /** - * Determine whether the current element has a search job running for it - * - * @param e - * The element that we want to know whether there is a search job - * or not - * @return <code>true</code> if it does else <code>false</code> - */ - public static boolean doesJobExist(String handle) { - return runningJobs.containsKey(handle); - } - - /** - * Remove search job for the given element - * - * @param m - * The element that we want to make sure that the search is - * canceled for - */ - public static void removeSearchJob(String handle) { - - // make sure that there wasn't a previous search job that we know - // of. If there was, cancel it - if (doesJobExist(handle)) { - // get the search job and wait until it is cancelled - Job prevJob = runningJobs.get(handle); - prevJob.cancel(); - runningJobs.remove(handle); - } - } - - /** - * Add a search job to our list - * @param handle The handle of the element that we are searching for - * @param searchJob The job that represents the search - */ - public static void addJob(String handle, Job searchJob) { - runningJobs.put(handle, searchJob); - } -}
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaReferencesProvider.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaReferencesProvider.java deleted file mode 100644 index 6b810f142..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaReferencesProvider.java +++ /dev/null @@ -1,142 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on Feb 2, 2005 - */ -package org.eclipse.mylar.tasks.bugzilla; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IMember; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.mylar.core.model.ITaskscapeNode; -import org.eclipse.mylar.core.search.IActiveSearchListener; -import org.eclipse.mylar.core.search.IMylarSearchOperation; -import org.eclipse.mylar.core.search.RelationshipProvider; -import org.eclipse.mylar.tasks.MylarTasksPlugin; -import org.eclipse.mylar.tasks.bugzilla.search.BugzillaMylarSearch; - - -/** - * @author Shawn Minto - */ -public class BugzillaReferencesProvider extends RelationshipProvider { - - public static final String ID = "org.eclipse.mylar.bugzilla.search.references"; - public static final String NAME = "Bugilla report references"; - - public BugzillaReferencesProvider() { - super(BugzillaStructureBridge.EXTENSION, ID); - } - - protected boolean acceptElement(IJavaElement javaElement) { - return javaElement != null - && (javaElement instanceof IMember || javaElement instanceof IType); - } - - /** - * HACK: checking kind as string - don't want the dependancy to mylar.java - */ - @Override - protected void findRelated(final ITaskscapeNode node, int degreeOfSeparation) { - if (!node.getStructureKind().equals("java")) return; - IJavaElement javaElement = JavaCore.create(node.getElementHandle()); - if (!acceptElement(javaElement)) { - return; - } - runJob(node, degreeOfSeparation); - - //XXX what if degreeOfSeparation is 5? - } - - @Override - public IMylarSearchOperation getSearchOperation(ITaskscapeNode node, int limitTo, int degreeOfSepatation) { - IJavaElement javaElement = JavaCore.create(node.getElementHandle()); - return new BugzillaMylarSearch(degreeOfSepatation, javaElement); - } - - private void runJob(final ITaskscapeNode node, final int degreeOfSeparation) { - BugzillaMylarSearch search = (BugzillaMylarSearch)getSearchOperation(node, 0, degreeOfSeparation); - - search.addListener(new IActiveSearchListener(){ - - private boolean gathered = false; - - public void searchCompleted(List<?> nodes) { - Iterator<?> itr = nodes.iterator(); - - BugzillaStructureBridge bridge = MylarTasksPlugin.getDefault().getStructureBridge(); - - while(itr.hasNext()) { - Object o = itr.next(); - if(o instanceof BugzillaReportNode){ - BugzillaReportNode bugzillaNode = (BugzillaReportNode)o; - String handle = bugzillaNode.getElementHandle(); - if(bridge.getCached(handle) == null) - cache(handle, bugzillaNode); - incrementInterest(degreeOfSeparation, BugzillaStructureBridge.EXTENSION, handle); - } - } - gathered = true; - } - - public boolean resultsGathered() { - return gathered; - } - - }); - search.run(new NullProgressMonitor()); - } - - @Override - protected String getSourceId() { - return ID; - } - - @Override - public String getName() { - return NAME; - } - - /* - * - * STUFF FOR TEMPORARILY CACHING A PROXY REPORT - * - * TODO remove the proxys and update the BugzillaStructureBridge cache so that on restart, - * we dont have to get all of the bugs - * - */ - private static final Map<String, BugzillaReportNode> reports = new HashMap<String, BugzillaReportNode>(); - - public BugzillaReportNode getCached(String handle){ - return reports.get(handle); - } - - protected void cache(String handle, BugzillaReportNode bugzillaNode) { - reports.put(handle, bugzillaNode); - } - - public void clearCachedReports(){ - reports.clear(); - } - - public Collection<? extends String> getCachedHandles() { - return reports.keySet(); - } - -} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaReportNode.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaReportNode.java deleted file mode 100644 index 6ac4c26a5..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaReportNode.java +++ /dev/null @@ -1,184 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on Oct 21, 2004 - */ -package org.eclipse.mylar.tasks.bugzilla; - -import java.io.IOException; -import java.net.MalformedURLException; -import java.util.ArrayList; -import java.util.List; - -import javax.security.auth.login.LoginException; - -import org.eclipse.mylar.bugzilla.core.BugReport; -import org.eclipse.mylar.bugzilla.core.BugzillaRepository; -import org.eclipse.mylar.bugzilla.search.BugzillaSearchHit; - - -/** - * Class to store the DoiInfo of a BugzillaSearchHit - * - * @author Shawn Minto - */ -public class BugzillaReportNode { - - private static final long serialVersionUID = 3257004367222419506L; - - /** The BugzillaSearchHit associated with this DoiInfo */ - private BugzillaSearchHit hit; - - /** Whether this search hit was from an exact search like a stack trace */ - private boolean isExact = false; - - /** List of all of the StackTrace's in the given bug */ - private List<StackTrace> stackTraces; - - /** The bug report associated with this DoiInfo */ - private BugReport bug; - - /** - * Constructor - * - * @param initialValue - * The initial Doi value - * @param hit - * The BugzillaSearchHit associated with this DoiInfo - * @param isExact - * Whether the search was exact or not - */ - public BugzillaReportNode(float initialValue, BugzillaSearchHit hit, - boolean isExact) { - this.hit = hit; - this.isExact = isExact; - bug = null; - stackTraces = new ArrayList<StackTrace>(); - } - - /** - * Get the bugzilla search hit relating to this DoiInfo - * - * @return The BugzillaSearchHit related to this DoiInfo - */ - public BugzillaSearchHit getHit() { - return hit; - } - - @Override - public String toString() { - return hit.toString(); - } - - /** - * Determine if the search hit this represents is exact or not - * - * @return <code>true</code> if the search was exact otherwise - * <code>false</code> - */ - public boolean isExact() { - return isExact; - } - - /** - * Set whether this bug has any exact elements in it - the search used was fully qualified - * - * @param isExact - - * Whether there are any exact element matches in it - */ - public void setExact(boolean isExact) { - this.isExact = isExact; - } - - /** - * Get the bug report associated with this DoiInfo<br> - * The bug is downloaded if it was not previously - * - * @return Returns the BugReport - * - * @throws IOException - * @throws LoginException - * @throws MalformedURLException - */ - public BugReport getBug() throws MalformedURLException, LoginException, IOException { - if(bug == null){ - - // get the bug report - bug = BugzillaRepository.getInstance().getBug( - hit.getId()); - } - return bug; - } - - /** - * Set the bug report associated with this DoiInfo - * - * @param bug - - * BugReport that this is associated with - */ - public void setBug(BugReport bug) { - this.bug = bug; - } - - /** - * Get all of the stack traces contained in the bug - * - * @return Returns a list of StackTrace's - */ - public List<StackTrace> getStackTraces() { - return stackTraces; - } - - /** - * Determine whether the doi info has any stack traces associated with it - * @return <code>true</code> if there are some stack traces else <code>false</code> - */ - public boolean hasStackTraces(){ - return !stackTraces.isEmpty(); - } - - /** - * Add a stack trace to this DoiInfo - * - * @param stackTrace - - * The StackTrace to add - */ - public void addStackTrace(StackTrace stackTrace) { - this.stackTraces.add(stackTrace); - } - - /** - * Add an array of stack traces to this DoiInfo - * - * @param stackTracesToAdd - - * The StackTraces to add - */ - public void addStackTraces(StackTrace[] stackTracesToAdd) { - for (int i = 0; i < stackTracesToAdd.length; i++) - this.stackTraces.add(stackTracesToAdd[i]); - } - - /** - * Get the name of the bug report - * @return The name of the bug report, max 20 characters - */ - public String getName() { - final int MAX_LENGTH = 100; - String description = hit.getDescription(); - int length = description.length(); - if (length > MAX_LENGTH) description = description.substring(0, MAX_LENGTH) + ".."; - return "bug " + hit.getId() + ": " + description; - } - - public String getElementHandle() { - return hit.getServer() + ";" + hit.getId(); - } -}
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaStructureBridge.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaStructureBridge.java deleted file mode 100644 index b3b62224d..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaStructureBridge.java +++ /dev/null @@ -1,278 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on May 2, 2005 - */ -package org.eclipse.mylar.tasks.bugzilla; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Platform; -import org.eclipse.mylar.bugzilla.core.BugReport; -import org.eclipse.mylar.bugzilla.core.BugzillaRepository; -import org.eclipse.mylar.bugzilla.core.IBugzillaBug; -import org.eclipse.mylar.bugzilla.search.BugzillaSearchHit; -import org.eclipse.mylar.bugzilla.ui.editor.AbstractBugEditor; -import org.eclipse.mylar.bugzilla.ui.outline.BugzillaOutlineNode; -import org.eclipse.mylar.bugzilla.ui.outline.BugzillaReportSelection; -import org.eclipse.mylar.bugzilla.ui.outline.BugzillaTools; -import org.eclipse.mylar.core.IMylarStructureBridge; -import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.MylarTasksPlugin; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.WorkspaceModifyOperation; -import org.eclipse.ui.progress.IProgressService; -import org.eclipse.ui.views.markers.internal.ProblemMarker; - - -public class BugzillaStructureBridge implements IMylarStructureBridge { - - public final static String EXTENSION = "bugzilla"; - - public String getResourceExtension() { - return EXTENSION; - } - - public BugzillaStructureBridge() { - super(); - readCacheFile(); - } - - /** - * Handle format: <server-name:port>;<bug-id>;<comment#> - * - * Use: BugzillaTools ??? - */ - public String getHandleIdentifier(Object object) { - if(object instanceof BugzillaOutlineNode){ - BugzillaOutlineNode n = (BugzillaOutlineNode)object; - return BugzillaTools.getHandle(n); - } - else if(object instanceof BugzillaReportSelection){ - BugzillaReportSelection n = (BugzillaReportSelection)object; - return BugzillaTools.getHandle(n); - } - return null; - } - - private BugReport result; - - public Object getObjectForHandle(final String handle) { - result = null; - - String [] parts = handle.split(";"); - if (parts.length >= 2){ - String server = parts[0]; - final int id = Integer.parseInt(parts[1]); - - String bugHandle = server + ";" + id; - - int commentNumber = -1; - if(parts.length == 3){ - commentNumber = Integer.parseInt(parts[2]); - } - - // get the bugzillaOutlineNode for the element - IEditorPart editorPart = null; - try{ - editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); - }catch(NullPointerException e){ - // do nothing, this just means that there is no active page - } - if(editorPart != null && editorPart instanceof AbstractBugEditor){ - AbstractBugEditor abe = ((AbstractBugEditor)editorPart); - BugzillaOutlineNode node = abe.getModel(); - return findNode(node, commentNumber); - } - - // try to get from the cache, if it doesn't exist, startup an operation to get it - result = getFromCache(bugHandle); - if(result == null){ - WorkspaceModifyOperation op = new WorkspaceModifyOperation() { - protected void execute(IProgressMonitor monitor) throws CoreException { - monitor.beginTask("Downloading Bug# " + id, IProgressMonitor.UNKNOWN); - try { - result = BugzillaRepository.getInstance().getCurrentBug(id); - }catch(Exception e){ - result = null; - } - }}; - - // Use the progess service to execute the runnable - IProgressService service = PlatformUI.getWorkbench().getProgressService(); - try { - service.run(false, false, op); - } catch (InvocationTargetException e) { - // Operation was canceled - } catch (InterruptedException e) { - // Handle the wrapped exception - } - - if(result != null) - cache(bugHandle, result); - } - - BugzillaOutlineNode node = BugzillaOutlineNode.parseBugReport(result); - return findNode(node, commentNumber); - } - else{ - return null; - } - } - - private BugzillaOutlineNode findNode(BugzillaOutlineNode startNode, int commentNumber){ - - if(commentNumber == -1){ - return startNode; - }else if(startNode.getComment() != null && startNode.getComment().getNumber() == commentNumber -1){ - return startNode; - } else if(startNode.isCommentHeader() && commentNumber == 1){ - return startNode; - }else if(startNode.isDescription() && commentNumber == 0){ - return startNode; - } - - BugzillaOutlineNode[] children = startNode.getChildren(); - for(int i = 0; i < children.length; i++){ - BugzillaOutlineNode n = findNode(children[i], commentNumber); - if(n != null) - return n; - } - return null; - } - - public String getParentHandle(String handle) { - - //check so that we don't need to try to get the parent if we are already at the bug report - if(!handle.matches(".*;.*;.*")) - return null; - - BugzillaOutlineNode bon = (BugzillaOutlineNode)getObjectForHandle(handle); - if(bon != null && bon.getParent() != null) - return BugzillaTools.getHandle(bon.getParent()); - else - return null; -// String [] parts = handle.split(";"); -// if (parts.length == 1){ -// return null; -// }else if (parts.length > 2) { -// String newHandle = ""; -// for(int i = 0; i < parts.length - 1; i++) -// newHandle += parts[i] + ";"; -// return newHandle.substring(0, newHandle.length() - 1); -//// return handle.substring(0, handle.lastIndexOf(";")); -// } -// return null; - } - - public String getName(Object object) { - if(object instanceof BugzillaOutlineNode){ - BugzillaOutlineNode b = (BugzillaOutlineNode)object; - return BugzillaTools.getName(b); - } else if (object instanceof BugzillaReportNode){ - BugzillaSearchHit hit = ((BugzillaReportNode)object).getHit(); - return hit.getServer() + ": Bug#: " + hit.getId() + ": " + hit.getDescription(); - } - return ""; - } - - public boolean canBeLandmark(Object element) { - return false; - } - - public boolean acceptsObject(Object object) { - return object instanceof BugzillaOutlineNode || object instanceof BugzillaReportSelection; - } - - public boolean canFilter(Object element) { - return true; - } - - public boolean isDocument(String handle) { - return (handle.indexOf(';') == handle.lastIndexOf(';') && handle.indexOf(";") != -1); - } - - public String getHandleForMarker(ProblemMarker marker) { - return null; - } - - public IProject getProjectForObject(Object object) { - // bugzilla objects do not yet sit in a project - return null; - } - - public String getResourceExtension(String elementHandle) { - return getResourceExtension(); - } - - /* - * - * STUFF FOR CACHING BUG REPORTS - * - */ - - // bug report cache - private Map<String, BugReport> cache = new HashMap<String, BugReport>(); - - public void cache(String handle, BugReport report) { - cache.put(handle, report); - cacheFile.add(report); - } - - public void clearCache(){ - cache.clear(); - cacheFile.removeAll(); - } - - private BugReport getFromCache(String bugHandle) { - return cache.get(bugHandle); - } - - public Set<String> getCachedHandles(){ - return cache.keySet(); - } - - private BugzillaCacheFile cacheFile; - - private IPath getCacheFile() { - IPath stateLocation = Platform.getPluginStateLocation(MylarTasksPlugin.getDefault()); - IPath configFile = stateLocation.append("offlineReports"); - return configFile; - } - - private void readCacheFile() { - IPath cachPath = getCacheFile(); - - try { - cacheFile = new BugzillaCacheFile(cachPath.toFile()); - ArrayList<IBugzillaBug> cached = cacheFile.elements(); - for(IBugzillaBug bug: cached){ - if(bug instanceof BugReport) - cache.put(BugzillaTools.getHandle(bug), (BugReport)bug); - } - } catch (Exception e) { - MylarPlugin.log(e, "occurred while restoring saved offline Bugzilla reports."); - } - } - - public BugReport getCached(String handle) { - return cache.get(handle); - } -} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/StackTrace.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/StackTrace.java deleted file mode 100644 index 096c0c732..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/StackTrace.java +++ /dev/null @@ -1,375 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on Dec 8, 2004 - */ -package org.eclipse.mylar.tasks.bugzilla; - -import java.util.ArrayList; -import java.util.List; - -/** - * Class to hold all of the information about a stack trace - * - * @author Shawn Minto - */ -public class StackTrace { - - /** The length of the stack trace in the original string */ - private int length; - - /** The offset of the stack trace in the orignal string */ - private int offset; - - /** The string of the stack trace */ - private String stackTrace; - - /** This is the comment that the stack trace appeared in. String if desciption else Comment */ - private Object comment; - - /** - * Constructor - * - * @param stackTrace - * The stack trace string - * @param offset - * The offset of the stack trace in the original string - * @param length - * The length of the stack trace in the original string - * @param comment - * The comment that the stack trace came from - */ - public StackTrace(String stackTrace, int offset, int length, Object comment) { - this.stackTrace = stackTrace; - this.offset = offset; - this.length = length; - this.comment = comment; - } - - /** - * Get the offset for the stack trace - * - * @return Returns the offset. - */ - public int getOffset() { - return offset; - } - - /** - * Get the stack trace for the bug - * - * @return Returns the stackTrace. - */ - public String getStackTrace() { - return stackTrace; - } - - /** - * Get the length of the bug - * - * @return Returns the length. - */ - public int getLength() { - return length; - } - - /** - * Get the Comment that this stack trace came from - * - * @return Returns the Comment if it was a comment else a String if it was the description - */ - public Object getComment() { - return comment; - } - - /** - * Find a standard java stack trace in the given string - * - * - * @param s - * The string to search for stack traces - * @param comment - * The comment that the text came from.<br> - * Comment if a comment else a String - * @return String[] of stack traces - each element is 1 trace - */ - public static StackTrace[] getStackTrace(String s, Object comment) { - - // setup the regex used to determine if it looks like we are at a - // stack trace and whether it is something that should be skipped - String regexExceptionType = "^(.*\\.)+.+(Exception|Error|Throwable).*"; - String regexSkip = ".*\\.\\..*"; - - // get all of the individual lines for the string - String[] lines = s.split("\r\n"); - - // the character start of the current stack trace - int charStackStart = 0; - - // the current character in the string - used for the start and the - // offset - int[] charPos = { 0 }; // array so pass by reference - - boolean inStackTrace = false; - List<String> stackTrace = null; - List<StackTrace> stackTraces = new ArrayList<StackTrace>(); - - // go through each of the lines of the string - for (int i = 0; i < lines.length; i++) { - - if (lines[i].matches(regexSkip)){ - - // update the current character position - charPos[0] += lines[i].length() + 2; - - }else if (lines[i].trim().matches(regexExceptionType) && !inStackTrace) { - - // we have matched the stack trace and we are not already in one - - // add the old stack trace to the list of stack traces - if (stackTrace != null && stackTrace.size() > 1) { - stackTraces.add(getStackTrace(stackTrace, charStackStart, - charPos[0] - charStackStart, comment)); - } - - // prepare for a new stack trace - stackTrace = new ArrayList<String>(); - inStackTrace = true; - - // the current line is the start of our stack trace - stackTrace.add(lines[i]); - charStackStart = charPos[0]; - charPos[0] += lines[i].length() + 2; - } else if (inStackTrace) { - // we are in a stack trace - - int[] pos = { i }; // array so pass by reference - - // get the next at clause of the stack trace - String stack = getNextAt(lines, pos, charPos); - - // check if there was an at - if (stack == null) { - - // there wasn't so we are done this stack trace - inStackTrace = false; - if (stackTrace != null && stackTrace.size() > 1) { - stackTraces.add(getStackTrace(stackTrace, - charStackStart, charPos[0] - charStackStart, comment)); - } - stackTrace = null; - } else { - - // we had one, so add it to this stack trace - stackTrace.add(stack); - } - - // update the position - i = pos[0]; - } else { - // update the current character position - charPos[0] += lines[i].length() + 2; - } - } - - // make sure to add the stack trace if it was the last in the string - if (stackTrace != null && stackTrace.size() > 1) { - stackTraces.add(getStackTrace(stackTrace, charStackStart, - charPos[0] - charStackStart, comment)); - } - - if (stackTraces.size() == 0) - return null; - - // get the string values of the stack traces and return it - return getTracesFromList(stackTraces); - } - - /** - * Get the next at clause from a potential stack trace -- looks ahead 4 - * lines - * - * @param lines - * The array of all of the lines in the bug - * @param i - * The current position to start at - * @param charPos - * The current character position in the original string - * @return The next at clause, or <code>null</code><br> - * If an at line is matched, but the end isn't within the 4 lines, - * only the first line is returned. Also, charPos is updated as well - * as i - */ - private static String getNextAt(String[] lines, int[] i, int[] charPos) { - String regexAtString = "^at.*"; - String regexEndString = ".*:\\d+\\)$"; - int index = i[0]; - String l1, l2, l3, l4; - l1 = l2 = l3 = l4 = null; - String res = null; - - // get the first line to look at - if (lines.length > index) { - l1 = lines[index]; - } else { - // if the first line doesn't exist, we are done and should - // return - return null; - } - - // get the next 3 lines - if (lines.length > index + 1) { - l2 = lines[index + 1]; - } - if (lines.length > index + 2) { - l3 = lines[index + 2]; - } - if (lines.length > index + 3) { - l4 = lines[index + 3]; - } - - // make sure that the first line is the start of an at - // if not, return null - if (l1.trim().matches(regexAtString)) { - charPos[0] += l1.length() + 2; - res = l1; - } else - return null; - - // now determine where the end is if it wasn't on 1 line - if (!res.trim().matches(regexEndString)) { - - if (l2 != null && l2.trim().matches(regexEndString)) { - - // it was on the second line - // update the current position and the result string - i[0] = index + 1; - charPos[0] += l2.length() + 2; - res += l2.trim(); - } else if (l3 != null && l3.trim().matches(regexEndString)) { - - // it was on the third line - // update the current position and the result string - i[0] = index + 2; - charPos[0] += l2.length() + l3.length() + 4; - res += l2.trim(); - res += l3.trim(); - } else if (l4 != null && l4.trim().matches(regexEndString)) { - - // it was on the fourth line - // update the current position and the result string - i[0] = index + 3; - charPos[0] += l2.length() + l3.length() + l4.length() + 6; - res += l2.trim(); - res += l3.trim(); - res += l4.trim(); - } - } - - // return the result - return res; - } - - /** - * Get the StackTrace - * - * @param l - * the list of lines that contain the trace - * @param start - * the start of the stack trace - * @param offset - * the offset of the stack trace - * @param comment - * The comment that the stack trace came from - * @return The StackTrace for the given data - */ - private static StackTrace getStackTrace(List<String> l, int offset, int length, Object comment) { - String s = ""; - for(String s2 : l) { - s += s2 + "\r\n"; - } - - return new StackTrace(s, offset, length, comment); - } - - /** - * Convert a List StackTraces to a StackTrace[] <br> - * - * @param l - * The List of StackTraces - * @return StackTrace[] of the List - */ - private static StackTrace[] getTracesFromList(List<StackTrace> l) { - - // make sure that there is something to convert, else return null - if (l == null || l.size() == 0) - return null; - - // convert the list of strings to an array of strings - int i = 0; - StackTrace[] s = new StackTrace[l.size()]; - - for(StackTrace st : l) { - s[i] = st; - i++; - } - - // return the string array - return s; - } - - /** - * Escape all of the special regex characters from the string - * - * @param s - * The string to escape the characters for - * @return A string with all of the special characters escaped <br> - * <code> - * . => \.<br> - * $ => \$<br> - * ? => \?<br> - * { => \{<br> - * } => \}<br> - * ( => \(<br> - * ) => \)<br> - * [ => \[<br> - * ] => \]<br> - * + => \+<br> - * * => \*<br> - * | => \|<br> - * ^ => \^<br> - * \ => \\<br> - * / => \/<br> - * </code> - */ - public static String escapeForRegex(String s) { - String sFixed = s; - - // replace all special regex characters - sFixed = sFixed.replaceAll("\\\\", "\\\\\\\\"); - sFixed = sFixed.replaceAll("\\$", "\\\\\\$"); - sFixed = sFixed.replaceAll("\\.", "\\\\."); - sFixed = sFixed.replaceAll("\\?", "\\\\?"); - sFixed = sFixed.replaceAll("\\{", "\\\\{"); - sFixed = sFixed.replaceAll("\\}", "\\\\}"); - sFixed = sFixed.replaceAll("\\(", "\\\\("); - sFixed = sFixed.replaceAll("\\)", "\\\\)"); - sFixed = sFixed.replaceAll("\\[", "\\\\["); - sFixed = sFixed.replaceAll("\\]", "\\\\]"); - sFixed = sFixed.replaceAll("\\+", "\\\\+"); - sFixed = sFixed.replaceAll("\\*", "\\\\*"); - sFixed = sFixed.replaceAll("\\|", "\\\\|"); - sFixed = sFixed.replaceAll("\\^", "\\\\^"); - sFixed = sFixed.replaceAll("\\/", "\\\\/"); - - return sFixed; - } -}
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/Util.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/Util.java deleted file mode 100644 index fb26f0500..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/Util.java +++ /dev/null @@ -1,226 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on Nov 19, 2004 - */ -package org.eclipse.mylar.tasks.bugzilla; - -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IMember; -import org.eclipse.jdt.core.IType; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.mylar.bugzilla.BugzillaPlugin; -import org.eclipse.mylar.bugzilla.BugzillaPreferences; -import org.eclipse.mylar.bugzilla.IBugzillaConstants; -import org.eclipse.mylar.core.model.InterestComparator; -import org.eclipse.mylar.tasks.bugzilla.search.BugzillaMylarSearchOperation; - - -/** - * Utilities methods for the BugzillaMylarBridge - * - * @author Shawn Minto - */ -public class Util { - - /** - * List of all of the search operations that can be done <br> all words, any words, regex - */ - private static final String[] patternOperationValues = { "allwordssubstr", "anywordssubstr", "regexp" }; - /** - * Sugzilla preferences so that we can get the search params - */ - private static IPreferenceStore prefs = BugzillaPlugin.getDefault().getPreferenceStore(); - /** - * List of all of the resolutions that we can have <br> FIXED, INVALID, WONTFIX, LATER, REMIND, DUPLICATE, WORKSFORME, MOVED, --- - */ - private static String[] resolutionValues = BugzillaPreferences.queryOptionsToArray(prefs.getString(IBugzillaConstants.RESOLUTION_VALUES)); - /** - * List of all of the statuses that we can have <br> UNCONFIRMED, NEW, ASSIGNED, REOPENED, RESOLVED, VERIFIED, CLOSED - */ - private static String[] statusValues = BugzillaPreferences.queryOptionsToArray(prefs.getString(IBugzillaConstants.STATUS_VALUES)); - - /** - * Get only the landmarks that are IMember and sort them according to their - * DOI value (highest to lowest) - * - * @param landmarks - * The landmarks to check - * @return List of IMember landmarks sorted by DOI value - */ - public static List<IMember> getMemberLandmarks(List<IJavaElement> landmarks) { - List<IMember> memberLandmarks = new ArrayList<IMember>(); - - for(IJavaElement je : landmarks) { - - // keep only the IMember landmarks - if (je instanceof IMember) { - memberLandmarks.add((IMember)je); - } - } - - // sort the landmarks - Collections.sort(memberLandmarks, new InterestComparator<IMember>()); - - return memberLandmarks; - } - - /** - * Get the bugzilla url used for searching for exact matches - * - * @param je - * The IMember to create the query string for - * @return A url string for the search - */ - public static String getExactSearchURL(IMember je) { - StringBuffer sb = getQueryURLStart(); - - String long_desc = ""; - - // get the fully qualified name of the element - long_desc += BugzillaMylarSearchOperation.getFullyQualifiedName(je); - - try{ - // encode the string to be used as a url - sb.append(URLEncoder.encode(long_desc, Charset.defaultCharset().toString())); - } catch (UnsupportedEncodingException e) - { - // should never get here since we are using the default encoding - } - sb.append(getQueryURLEnd()); - - return sb.toString(); - } - - /** - * Get the bugzilla url used for searching for inexact matches - * - * @param je - * The IMember to create the query string for - * @return A url string for the search - */ - public static String getInexactSearchURL(IMember je) { - StringBuffer sb = getQueryURLStart(); - - - String long_desc = ""; - - // add the member, qualified with just its parents name - if (!(je instanceof IType)) - long_desc += je.getParent().getElementName()+"."; - long_desc += je.getElementName(); - - try{ - // encode the string to be used as a url - sb.append(URLEncoder.encode(long_desc, Charset.defaultCharset().toString())); - } catch (UnsupportedEncodingException e) - { - // should never get here since we are using the default encoding - } - sb.append(getQueryURLEnd()); - - return sb.toString(); - } - - /** - * Create the end of the bugzilla query URL with all of the status' and resolutions that we want - * @return StringBuffer with the end of the query URL in it - */ - public static StringBuffer getQueryURLEnd(){ - - StringBuffer sb = new StringBuffer(); - - // add the status and resolutions that we care about - sb.append("&bug_status=" + statusValues[0]); // UNCONFIRMED - sb.append("&bug_status=" + statusValues[1]); // NEW - sb.append("&bug_status=" + statusValues[2]); // ASSIGNED - sb.append("&bug_status=" + statusValues[3]); // REOPENED - sb.append("&bug_status=" + statusValues[4]); // RESOLVED - sb.append("&bug_status=" + statusValues[5]); // VERIFIED - sb.append("&bug_status=" + statusValues[6]); // CLOSED - - sb.append("&resolution=" + resolutionValues[0]); // FIXED - sb.append("&resolution=" + resolutionValues[3]); // LATER - sb.append("&resolution=" + "---"); // --- - return sb; - } - - /** - * Create the bugzilla query URL start. - * - * @return The start of the query url as a StringBuffer <br> - * Example: https://bugs.eclipse.org/bugs/buglist.cgi?long_desc_type=allwordssubstr&long_desc= - */ - public static StringBuffer getQueryURLStart() { - StringBuffer sb = new StringBuffer(BugzillaPlugin.getDefault() - .getServerName()); - - if (sb.charAt(sb.length() - 1) != '/') { - sb.append('/'); - } - sb.append("buglist.cgi?"); - - // use the username and password if we have it - if (BugzillaPreferences.getUserName() != null - && !BugzillaPreferences.getUserName().equals("") - && BugzillaPreferences.getPassword() != null - && !BugzillaPreferences.getPassword().equals("")) { - try{ - sb.append("GoAheadAndLogIn=1&Bugzilla_login=" - + URLEncoder.encode(BugzillaPreferences.getUserName(), Charset.defaultCharset().toString()) - + "&Bugzilla_password=" - + URLEncoder.encode(BugzillaPreferences.getPassword(), Charset.defaultCharset().toString()) - + "&"); - } catch (UnsupportedEncodingException e) - { - // should never get here since we are using the default encoding - } - } - - // add the description search type - sb.append("long_desc_type="); - sb.append(patternOperationValues[0]); // search for all words - sb.append("&long_desc="); - - return sb; - } - - /** - * Search the given string for another string - * @param elementName The name of the element that we are looking for - * @param comment The text to search for this element name - * @return <code>true</code> if the element is found in the text else <code>false</code> - */ - public static boolean hasElementName(String elementName, String comment) { - - // setup a regex for the element name - String regexElement = ".*"+elementName+".*"; - - // get all of the individual lines for the string - String[] lines = comment.split("\n"); - - // go through each of the lines of the string - for (int i = 0; i < lines.length; i++) { - - if (lines[i].matches(regexElement)){ - return true; - } - } - return false; - } -}
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaCategorySearchOperation.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaCategorySearchOperation.java deleted file mode 100644 index 5fd74e240..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaCategorySearchOperation.java +++ /dev/null @@ -1,138 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on Oct 14, 2004 - */ -package org.eclipse.mylar.tasks.bugzilla.search; - -import java.util.ArrayList; -import java.util.List; - -import javax.security.auth.login.LoginException; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.mylar.bugzilla.search.BugzillaSearchEngine; -import org.eclipse.mylar.bugzilla.search.BugzillaSearchQuery; -import org.eclipse.mylar.bugzilla.search.IBugzillaSearchOperation; -import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.ui.actions.WorkspaceModifyOperation; - - -/** - * Bugzilla search operation for Mylar - * - * @author Shawn Minto - */ -public class BugzillaCategorySearchOperation extends WorkspaceModifyOperation - implements IBugzillaSearchOperation { - /** The IMember we are doing the search for */ - - public interface ICategorySearchListener { - public void searchCompleted(BugzillaResultCollector collector); - } - - /** The bugzilla collector for the search */ - private BugzillaResultCollector collector = null; - - /** The status of the search operation */ - private IStatus status; - - /** The LoginException that was thrown when trying to do the search */ - private LoginException loginException = null; - - private String url; - - /** - * Constructor - * - * @param m - * The member that we are doing the search for - */ - public BugzillaCategorySearchOperation(String url) { - this.url = url; - } - - @Override - public void execute(IProgressMonitor monitor) { - collector = new BugzillaResultCollector(); - collector.setOperation(this); - collector.setProgressMonitor(monitor); - search(url, monitor); - for(ICategorySearchListener listener: listeners) - listener.searchCompleted(collector); - } - - /** - * Perform the actual search on the Bugzilla server - * @param url The url to use for the search - * @param searchCollector The collector to put the search results into - * @param monitor The progress monitor to use for the search - * @return The BugzillaResultCollector with the search results - */ - private BugzillaResultCollector search(String url, IProgressMonitor monitor){ - - // set the initial number of matches to 0 - int matches = 0; - // setup the progress monitor and start the search - collector.setProgressMonitor(monitor); - BugzillaSearchEngine engine = new BugzillaSearchEngine(url); - try { - - // perform the search - status = engine.search(collector, matches); - - // check the status so that we don't keep searching if there - // is a problem - if (status.getCode() == IStatus.CANCEL) { - MylarPlugin.log("search cancelled", this); - return null; - } else if (!status.isOK()) { - MylarPlugin.log("search error", this); - MylarPlugin.log(status); - return null; - } - return collector; - } catch (LoginException e) { - //save this exception to throw later - this.loginException = e; - } - return null; - } - - /** - * @see org.eclipse.mylar.bugzilla.search.IBugzillaSearchOperation#getStatus() - */ - public IStatus getStatus() throws LoginException { - // if a LoginException was thrown while trying to search, throw this - if (loginException == null) - return status; - else - throw loginException; - } - - public ImageDescriptor getImageDescriptor() { - return null; - } - - public BugzillaSearchQuery getQuery() { - return null; - } - - public void setQuery(BugzillaSearchQuery newQuery) {} - - private List<ICategorySearchListener> listeners = new ArrayList<ICategorySearchListener>(); - - public void addResultsListener(ICategorySearchListener listener){ - listeners.add(listener); - } -} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaMylarSearch.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaMylarSearch.java deleted file mode 100644 index dea6339ee..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaMylarSearch.java +++ /dev/null @@ -1,148 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on Oct 13, 2004 - */ -package org.eclipse.mylar.tasks.bugzilla.search; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IMember; -import org.eclipse.mylar.core.search.IActiveSearchListener; -import org.eclipse.mylar.core.search.IMylarSearchOperation; -import org.eclipse.mylar.tasks.bugzilla.BugzillaMylarBridge; -import org.eclipse.mylar.tasks.bugzilla.BugzillaReportNode; -import org.eclipse.mylar.tasks.bugzilla.Util; - - -/** - * Used to facilitate bugzilla searches based on IJavaElements - * - * @author Shawn Minto - */ -public class BugzillaMylarSearch implements IMylarSearchOperation { - - // scope identifiers - public static final int LOCAL_QUAL = 1; // local implies a bugzilla task, not just an offline report - public static final int LOCAL_UNQUAL = 2; - public static final int FULLY_QUAL = 3; - public static final int UNQUAL = 4; - - private int scope; - - private IJavaElement element; - - private String handle = ""; - - /** - * Constructor - * @param scope The scope of this search - */ - public BugzillaMylarSearch(int scope, IJavaElement element) { - this.scope = scope; - this.element = element; - } - - public IStatus run(IProgressMonitor monitor) { - handle = element.getHandleIdentifier() + " " + scope; - List<IJavaElement> landmarks = new ArrayList<IJavaElement>(); - landmarks.add(element); - - if (!BugzillaMylarBridge.doesJobExist(handle)) { - - // perform the bugzilla search - // get only the useful landmarks (IMember) - List<IMember> members = Util.getMemberLandmarks(landmarks); - - // go through all of the landmarks that we are given and perform a - // search on them - for(IMember m : members){ - - // FIXME: decide whether to do leave the caching of searches in for now or not - // check if we have the info cached -// List<BugzillaReportNode> landmarkDoi = MylarTasksPlugin.getBridge() -// .getFromLandmarksHash(m, scope); - -// if (landmarkDoi != null) { -// //TODO decide when to queue up and do a refresh search -// notifySearchCompleted(landmarkDoi); -// continue; -// } - - // create a search operation so that we can search - BugzillaMylarSearchOperation op = new BugzillaMylarSearchOperation( - this, m, scope); - - // create a new search job so that it can be scheduled and - // run as a background thread - Job searchJob = new BugzillaMylarSearchJob( - "Querying Bugzilla Server - Mylar - " - + op.getSearchMemberName(), op); - - // schedule the new search job - searchJob.schedule(); - - // save this searchJobs handle so that we can cancel it if need be - BugzillaMylarBridge.addJob(handle, searchJob); - } - } - return Status.OK_STATUS; - } - - /** List of listeners wanting to know about the searches */ - private List<IActiveSearchListener> listeners = new ArrayList<IActiveSearchListener>(); - - /** - * Add a listener for when the bugzilla search is completed - * - * @param l - * The listener to add - */ - public void addListener(IActiveSearchListener l) { - // add the listener to the list - listeners.add(l); - } - - /** - * Remove a listener for when the bugzilla search is completed - * - * @param l - * The listener to remove - */ - public void removeListener(IActiveSearchListener l) { - // remove the listener from the list - listeners.remove(l); - } - - /** - * Notify all of the listeners that the bugzilla search is completed - * - * @param doiList - * A list of BugzillaSearchHitDoiInfo - * @param member - * The IMember that the search was performed on - */ - public void notifySearchCompleted(List<BugzillaReportNode> doiList) { - // go through all of the listeners and call searchCompleted(colelctor, - // member) - BugzillaMylarBridge.removeSearchJob(handle); - for (IActiveSearchListener listener : listeners) { - listener.searchCompleted(doiList); - } - } - -}
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaMylarSearchJob.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaMylarSearchJob.java deleted file mode 100644 index 209d17434..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaMylarSearchJob.java +++ /dev/null @@ -1,109 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on Oct 6, 2004 - */ -package org.eclipse.mylar.tasks.bugzilla.search; - -import javax.security.auth.login.LoginException; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.mylar.bugzilla.BugzillaPlugin; -import org.eclipse.mylar.bugzilla.IBugzillaConstants; -import org.eclipse.mylar.tasks.bugzilla.BugzillaMylarBridge; -import org.eclipse.ui.PlatformUI; - - -/** - * The bugzilla search job used to search a bugzilla site - * - * @author Shawn Minto - */ -public class BugzillaMylarSearchJob extends Job { - - /** The search operation used to perform the query */ - private BugzillaMylarSearchOperation operation; - - /** - * Constructor - * - * @param name - * Job name - * @param operation - * The operation to perform the search query - */ - public BugzillaMylarSearchJob(String name, - BugzillaMylarSearchOperation operation) { - super(name); - this.operation = operation; - } - - @Override - protected IStatus run(IProgressMonitor monitor) { - // create a new status - final IStatus[] status = new IStatus[1]; - - try { - // execute the search operation - operation.execute(monitor); - - // get the status of the search operation - status[0] = operation.getStatus(); - - // determine if there was an error, if it was cancelled, or if it is - // ok - if ( status[0].getCode() == IStatus.CANCEL) { - // it was cancelled, so just return - status[0] = Status.OK_STATUS; - - // make sure that we know this job is not running anymore - BugzillaMylarBridge.removeSearchJob(operation.getSearchMember().getHandleIdentifier()+" "+operation.getScope());//runningJobs.remove(operation.getSearchMember()); - return status[0]; - } else if (!status[0].isOK()) { - // there was an error, so display an error message - PlatformUI.getWorkbench().getDisplay().asyncExec( - new Runnable() { - public void run() { - ErrorDialog.openError(null, - "Bugzilla Search Error", null, - status[0]); - } - }); - status[0] = Status.OK_STATUS; - - // make sure we know that this job is not running anymore - BugzillaMylarBridge.removeSearchJob(operation.getSearchMember().getHandleIdentifier()+" "+operation.getScope());//runningJobs.remove(operation.getSearchMember()); - return status[0]; - } - } catch (LoginException e) { - // we had a problem while searching that seems like a login info - // problem - // thrown in BugzillaSearchOperation - MessageDialog - .openError( - null, - "Login Error", - "Bugzilla could not log you in to get the information you requested since login name or password is incorrect.\nPlease check your settings in the bugzilla preferences. "); - BugzillaPlugin.log(new Status(IStatus.ERROR, - IBugzillaConstants.PLUGIN_ID, IStatus.OK, "", e)); - } finally { - // make sure that we know that this job is not running anymore - BugzillaMylarBridge.removeSearchJob(operation.getSearchMember().getHandleIdentifier()+" "+operation.getScope());//.runningJobs.remove(operation.getSearchMember()); - } - - return status[0]; - } -}
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaMylarSearchOperation.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaMylarSearchOperation.java deleted file mode 100644 index f1396a849..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaMylarSearchOperation.java +++ /dev/null @@ -1,526 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on Oct 14, 2004 - */ -package org.eclipse.mylar.tasks.bugzilla.search; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import javax.security.auth.login.LoginException; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IMember; -import org.eclipse.jdt.core.IType; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.mylar.bugzilla.core.BugReport; -import org.eclipse.mylar.bugzilla.core.Comment; -import org.eclipse.mylar.bugzilla.search.BugzillaSearchEngine; -import org.eclipse.mylar.bugzilla.search.BugzillaSearchHit; -import org.eclipse.mylar.bugzilla.search.BugzillaSearchQuery; -import org.eclipse.mylar.bugzilla.search.IBugzillaSearchOperation; -import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.BugzillaTask; -import org.eclipse.mylar.tasks.ITask; -import org.eclipse.mylar.tasks.TaskCategory; -import org.eclipse.mylar.tasks.MylarTasksPlugin; -import org.eclipse.mylar.tasks.bugzilla.BugzillaReportNode; -import org.eclipse.mylar.tasks.bugzilla.StackTrace; -import org.eclipse.mylar.tasks.bugzilla.Util; -import org.eclipse.ui.actions.WorkspaceModifyOperation; - - -/** - * Bugzilla search operation for Mylar - * - * @author Shawn Minto - */ -public class BugzillaMylarSearchOperation extends WorkspaceModifyOperation - implements IBugzillaSearchOperation { - /** The IMember we are doing the search for */ - private IMember javaElement; - - /** The bugzilla collector for the search */ - private BugzillaResultCollector collector = null; - - /** The status of the search operation */ - private IStatus status; - - /** The LoginException that was thrown when trying to do the search */ - private LoginException loginException = null; - - /** The fully qualified name of the member we are searching for */ - private String name; - - /** The bugzilla search query */ - private BugzillaSearchQuery query; - - private BugzillaMylarSearch search; - - private int scope; - - /** - * Constructor - * - * @param m - * The member that we are doing the search for - */ - public BugzillaMylarSearchOperation(BugzillaMylarSearch search, IMember m, int scope) { - this.javaElement = m; - this.search = search; - this.scope = scope; - name = getFullyQualifiedName(m); - } - - /** - * Get the fully qualified name of a IMember - * TODO: move to a more central location so that others can use this, but don't want to add unecessary coupling - * - * @return String representing the fully qualified name - */ - public static String getFullyQualifiedName(IJavaElement je) { - if(!(je instanceof IMember)) return null; - - IMember m = (IMember)je; - if (m.getDeclaringType() == null) - return ((IType) m).getFullyQualifiedName(); - else - return m.getDeclaringType().getFullyQualifiedName() + "." - + m.getElementName(); - } - - @Override - public void execute(IProgressMonitor monitor) { - - BugzillaResultCollector searchCollector = null; - - if(scope == BugzillaMylarSearch.FULLY_QUAL){ - searchCollector = searchQualified(monitor); - }else if(scope == BugzillaMylarSearch.UNQUAL){ - searchCollector = searchUnqualified(monitor); - }else if(scope == BugzillaMylarSearch.LOCAL_QUAL){ - searchCollector = searchLocalQual(monitor); - }else if(scope == BugzillaMylarSearch.LOCAL_UNQUAL){ - searchCollector = searchLocalUnQual(monitor); - }else{ - return; - } - - if(searchCollector == null){ - search.notifySearchCompleted( - new ArrayList<BugzillaReportNode>()); - return; - } - - List<BugzillaSearchHit> l = searchCollector.getResults(); - - // get the list of doi elements - List<BugzillaReportNode> doiList = getDoiList(l); - - // we completed the search, so notify all of the listeners - // that the search has been completed - MylarTasksPlugin.getBridge() - .addToLandmarksHash(doiList, javaElement, scope); - search.notifySearchCompleted( - doiList); - // MIK: commmented out logging -// MonitorPlugin.log(this, "There were " + doiList.size() + " items found"); - } - - /** - * Search the local bugs for the member using the qualified name - * @param monitor The progress monitor to search with - * @return The BugzillaResultCollector with the results of the search - */ - private BugzillaResultCollector searchLocalQual(IProgressMonitor monitor) { - - //get the fully qualified name for searching - String elementName = getFullyQualifiedName(javaElement); - - // setup the search result collector - collector = new BugzillaResultCollector(); - collector.setOperation(this); - collector.setProgressMonitor(monitor); - - // get all of the root tasks and start the search - List<ITask> tasks = MylarTasksPlugin.getTaskListManager().getTaskList().getRootTasks(); - searchLocal(tasks, collector, elementName, monitor); - for (TaskCategory cat : MylarTasksPlugin.getTaskListManager().getTaskList().getTaskCategories()) { - searchLocal(cat.getChildren(), collector, elementName, monitor); - } - - // return the collector - return collector; - } - - /** - * Search the local bugs for the member using the unqualified name - * @param monitor The progress monitor to search with - * @return The BugzillaResultCollector with the results of the search - */ - private BugzillaResultCollector searchLocalUnQual(IProgressMonitor monitor) { - - // get the element name for searching - String elementName = javaElement.getElementName(); - - // setup the search result collector - collector = new BugzillaResultCollector(); - collector.setOperation(this); - collector.setProgressMonitor(monitor); - - // get all of the root tasks and start the search - List<ITask> tasks = MylarTasksPlugin.getTaskListManager().getTaskList().getRootTasks(); - searchLocal(tasks, collector, elementName, monitor); - for (TaskCategory cat : MylarTasksPlugin.getTaskListManager().getTaskList().getTaskCategories()) { - searchLocal(cat.getChildren(), collector, elementName, monitor); - } - // return the collector - return collector; - } - - /** - * Search the local bugs for the member - * @param tasks The tasks to search - * @param searchCollector The collector to add the results to - * @param elementName The name of the element that we are looking for - * @param monitor The progress monitor - */ - private void searchLocal(List<ITask> tasks, BugzillaResultCollector searchCollector, String elementName, IProgressMonitor monitor) { - if(tasks == null) return; - - // go through all of the tasks - for(ITask task : tasks){ - monitor.worked(1); - - // check what kind of task it is - if(task instanceof BugzillaTask){ - - // we have a bugzilla task, so get the bug report - BugzillaTask bugTask = (BugzillaTask)task; - BugReport bug = bugTask.getBugReport(); - - // parse the bug report for the element that we are searching for - boolean isHit = search(elementName, bug); - - // determine if we have a hit or not - if(isHit){ - - // make a search hit from the bug and then add it to the collector - BugzillaSearchHit hit = new BugzillaSearchHit(bug.getId(), bug.getDescription(), "","","","","","","", bug.getServer()); - try{ - searchCollector.accept(hit); - }catch(CoreException e){ - MylarPlugin.log(e, "bug search failed"); - } - } - } - } - status = Status.OK_STATUS; - } - - /** - * Search the bug for the given element name - * @param elementName The name of the element to search for - * @param bug The bug to search in - */ - private boolean search(String elementName, BugReport bug) { - - if (bug == null) return false; // MIK: added null check here - String description = bug.getDescription(); - String summary = bug.getSummary(); - List<Comment> comments = bug.getComments(); - - // search the description and the summary - if(Util.hasElementName(elementName, summary)) - return true; - - if(Util.hasElementName(elementName, description)) - return true; - - Iterator<Comment> comItr = comments.iterator(); - while (comItr.hasNext()) { - Comment comment = comItr.next(); - String commentText = comment.getText(); - // search the text for a reference to the element - if(Util.hasElementName(elementName, commentText)) - return true; - } - return false; - } - - /** - * Perform the actual search on the Bugzilla server - * @param url The url to use for the search - * @param searchCollector The collector to put the search results into - * @param monitor The progress monitor to use for the search - * @return The BugzillaResultCollector with the search results - */ - private BugzillaResultCollector search(String url, BugzillaResultCollector searchCollector, IProgressMonitor monitor){ - - // set the initial number of matches to 0 - int matches = 0; - // setup the progress monitor and start the search - searchCollector.setProgressMonitor(monitor); - BugzillaSearchEngine engine = new BugzillaSearchEngine(url); - try { - - // perform the search - status = engine.search(searchCollector, matches); - - // check the status so that we don't keep searching if there - // is a problem - if (status.getCode() == IStatus.CANCEL) { - MylarPlugin.log("search cancelled", this); - return null; - } else if (!status.isOK()) { - MylarPlugin.log("search error", this); - MylarPlugin.log(status); - return null; - } - return searchCollector; - } catch (LoginException e) { - //save this exception to throw later - this.loginException = e; - } - return null; - } - - /** - * Perform a search for qualified instances of the member - * @param monitor The progress monitor to use - * @return The BugzillaResultCollector with the search results - */ - private BugzillaResultCollector searchQualified(IProgressMonitor monitor) - { - // create a new collector for the results - collector = new BugzillaResultCollector(); - collector.setOperation(this); - collector.setProgressMonitor(monitor); - - // get the search url - String url = Util.getExactSearchURL(javaElement); - - // log the url that we are searching with - // MIK: commmented out logging -// MonitorPlugin.log(this, url); - - return search(url, collector, monitor); - } - - /** - * Perform a search for unqualified instances of the member - * @param monitor The progress monitor to use - * @return The BugzillaResultCollector with the search results - */ - private BugzillaResultCollector searchUnqualified(IProgressMonitor monitor) - { - // create a new collector for the results - collector = new BugzillaResultCollector(); - collector.setOperation(this); - collector.setProgressMonitor(monitor); - - // get the search url - String url = Util.getInexactSearchURL(javaElement); - - // log the url that we are searching with - // MIK: commmented out logging -// MonitorPlugin.log(this, url); - - return search(url, collector, monitor); - } - -// /** -// * Remove all of the duplicates -// * @param compare The List of BugzillaSearchHits to compare with -// * @param base The List of BugzillaSearchHits to remove the duplicates from -// */ -// private void removeDuplicates(List<BugzillaSearchHit> compare, List<BugzillaSearchHit> base){ -// -// for(BugzillaSearchHit h1 : compare){ -// Iterator itr2 = base.iterator(); -// while(itr2.hasNext()){ -// BugzillaSearchHit h2 = (BugzillaSearchHit)itr2.next(); -// if(h2.getId() == h1.getId()){ -// // we found a duplicate so remove it -// itr2.remove(); -// break; -// } -// } -// } -// } -// - /** - * Perform a second pass parse to determine if there are any stack traces in - * the bug - currently only used for the exact search results - * - * @param doiList - - * the list of BugzillaSearchHitDOI elements to parse - */ - public static void secondPassBugzillaParser(List<BugzillaReportNode> doiList) { - - // go through each of the items in the doiList - for(BugzillaReportNode info : doiList) { - - // get the bug report so that we have all of the data - // - descriptions, comments, etc - BugReport b = null; - try{ - b = info.getBug(); - }catch(Exception e){ - // don't care since null will be caught - } - - // if the report could not be downloaded, try the next one - if (b == null) - continue; - - // see if the description has a stack trace in it - StackTrace[] stackTrace = StackTrace.getStackTrace(b.getDescription(), b.getDescription()); - if (stackTrace != null) { - - // add the stack trace to the doi info - info.setExact(true); - info.addStackTraces(stackTrace); - } - - // go through all of the comments for the bug - Iterator<Comment> comItr = b.getComments().iterator(); - while (comItr.hasNext()) { - Comment comment = comItr.next(); - String commentText = comment.getText(); - - // see if the comment has a stack trace in it - stackTrace = StackTrace.getStackTrace(commentText, comment); - if (stackTrace != null) { - - // add the stack trace to the doi info - info.setExact(true); - info.addStackTraces(stackTrace); - } - } - } - } - - /** - * Add the results returned to the Hash of landmarks - * - * @param results - * The list of results - * @param isExact - * whether the search was exact or not - */ - private List<BugzillaReportNode> getDoiList(List<BugzillaSearchHit> results) { - List<BugzillaReportNode> doiList = new ArrayList<BugzillaReportNode>(); - - boolean isExact = (scope==BugzillaMylarSearch.FULLY_QUAL || scope==BugzillaMylarSearch.LOCAL_QUAL)?true:false; - - BugzillaReportNode info = null; - // go through all of the results and create a DoiInfo list - for(BugzillaSearchHit hit : results){ - - try { - float value = 0; - info = new BugzillaReportNode( - value, hit, isExact); - - // only download the bug for the exact matches - //downloading bugs kills the time - can we do this elsewhere? - different thread? persistant? -// if(isExact){ -// // get the bug report for the doi info item -// BugReport b = BugzillaRepository.getInstance().getBug( -// hit.getId()); -// // add the bug to the doi info for future use -// info.setBug(b); -// } - - } catch (Exception e) { - MylarPlugin.log(e, "search failed"); - } - finally{ - doiList.add(info); - } - } - return doiList; - } - - /** - * @see org.eclipse.mylar.bugzilla.search.IBugzillaSearchOperation#getStatus() - */ - public IStatus getStatus() throws LoginException { - // if a LoginException was thrown while trying to search, throw this - if (loginException == null) - return status; - else - throw loginException; - } - - /** - * @see org.eclipse.mylar.bugzilla.search.IBugzillaSearchOperation#getImageDescriptor() - */ - public ImageDescriptor getImageDescriptor() { - return null; - } - - /** - * Get the member that we are performing the search for - * - * @return The member this search is being performed for - */ - public IMember getSearchMember() { - return javaElement; - } - - /** - * Get the name of the member that we are searching for - * - * @return The fully qualified name of the member - */ - public String getSearchMemberName() { - return name; - } - - /** - * @see org.eclipse.mylar.bugzilla.search.IBugzillaSearchOperation#getQuery() - */ - public BugzillaSearchQuery getQuery() { - return query; - } - - /** - * @see org.eclipse.mylar.bugzilla.search.IBugzillaSearchOperation#setQuery(org.eclipse.mylar.bugzilla.search.BugzillaSearchQuery) - */ - public void setQuery(BugzillaSearchQuery newQuery) { - this.query = newQuery; - } - - /** - * Get the name of the element that we are searching for - * - * @return The name of the element - */ - public String getName(){ - return name; - } - - /** - * Get the scope of the search operation - * @return The scope - defined in BugzillaMylarSearch - */ - public int getScope() { - return scope; - } -}
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaResultCollector.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaResultCollector.java deleted file mode 100644 index 3bbc47c2b..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaResultCollector.java +++ /dev/null @@ -1,182 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on Oct 4, 2004 - */ -package org.eclipse.mylar.tasks.bugzilla.search; - -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.mylar.bugzilla.search.BugzillaSearchHit; -import org.eclipse.mylar.bugzilla.search.IBugzillaSearchOperation; -import org.eclipse.mylar.bugzilla.search.IBugzillaSearchResultCollector; - - -/** - * Collector for the bugzilla search results - * - * @author Shawn Minto - */ -public class BugzillaResultCollector implements IBugzillaSearchResultCollector { - /** A list of all of the search results found */ - private List<BugzillaSearchHit> results = new ArrayList<BugzillaSearchHit>(); - - /** The progress monitor for the search operation */ - private IProgressMonitor monitor; - - /** The number of matches found */ - private int matchCount; - - /** The bugzilla search operation */ - private IBugzillaSearchOperation operation; - - /** The string to display to the user while querying */ - private static final String STARTING = "querying the server"; - - /** The string to display to the user when the query is done */ - private static final String DONE = "done"; - - /** The string to display when there is one match from the search */ - private static final String MATCH = "Bugzilla Mylar search - 1 match"; - - /** The string to display when there is more than one match from the search */ - private static final String MATCHES = "Bugzilla Mylar search - {0} matches"; - - /** - * @see org.eclipse.mylar.bugzilla.search.IBugzillaSearchResultCollector#aboutToStart() - */ - public void aboutToStart(int startMatchCount) throws CoreException { - // initiailize the number of matches - matchCount = startMatchCount; - - // set the progress monitor to say that we are querying the server - monitor.setTaskName(STARTING); - } - - /** - * @see org.eclipse.mylar.bugzilla.search.IBugzillaSearchResultCollector#accept(org.eclipse.mylar.bugzilla.search.BugzillaSearchHit) - */ - public void accept(BugzillaSearchHit hit) throws CoreException { - // add the result to the list of results - results.add(hit); - - // increment the match count - matchCount++; - - if (getProgressMonitor() != null) { - if (!getProgressMonitor().isCanceled()) { - // if the operation is cancelled finish with whatever data was - // already found - getProgressMonitor().subTask( - getFormattedMatchesString(matchCount)); - getProgressMonitor().worked(1); - } - } - } - - /** - * @see org.eclipse.mylar.bugzilla.search.IBugzillaSearchResultCollector#done() - */ - public void done() { - if (getProgressMonitor() != null) { - if (!monitor.isCanceled()) { - // if the operation is cancelled, finish with the data that we - // already have - String matchesString = getFormattedMatchesString(matchCount); - monitor.setTaskName(MessageFormat.format(DONE, - new Object[] { matchesString })); - } - } - - monitor = null; - } - - /** - * @see org.eclipse.mylar.bugzilla.search.IBugzillaSearchResultCollector#getProgressMonitor() - */ - public IProgressMonitor getProgressMonitor() { - return monitor; - } - - /** - * @see org.eclipse.mylar.bugzilla.search.IBugzillaSearchResultCollector#setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) - */ - public void setProgressMonitor(IProgressMonitor monitor) { - this.monitor = monitor; - } - - /** - * @see org.eclipse.mylar.bugzilla.search.IBugzillaSearchResultCollector#setOperation(org.eclipse.mylar.bugzilla.search.BugzillaSearchOperation) - */ - public void setOperation(IBugzillaSearchOperation operation) { - this.operation = operation; - } - - /** - * @see org.eclipse.mylar.bugzilla.search.IBugzillaSearchResultCollector#getOperation() - */ - public IBugzillaSearchOperation getOperation() { - return operation; - } - - /** - * Get the string specifying the number of matches found - * - * @param count - * The number of matches found - * @return The <code>String</code> specifying the number of matches found - */ - private String getFormattedMatchesString(int count) { - // if only 1 match, return the singular match string - String name = ""; - if(operation instanceof BugzillaMylarSearchOperation) - name = " - " + ((BugzillaMylarSearchOperation)operation).getName(); - if (count == 1) - return MATCH + name; - - // format the matches string and return it - Object[] messageFormatArgs = { new Integer(count) }; - return MessageFormat.format(MATCHES + name, - messageFormatArgs); - } - - /** - * Get the list of results - * - * @return A List of BugzillaSearchHit - */ - public List<BugzillaSearchHit> getResults() { - return results; - } - - /** - * Get the number of matches from the operation - * - * @return Returns the matchCount. - */ - public int getMatchCount() { - return matchCount; - } - - /** - * Set the starting number of matches for the search operation - * - * @param matchCount - * The matchCount to set. - */ - public void setMatchCount(int matchCount) { - this.matchCount = matchCount; - } -}
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/ui/BugzillaNodeLabelProvider.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/ui/BugzillaNodeLabelProvider.java deleted file mode 100644 index 01a2f5791..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/ui/BugzillaNodeLabelProvider.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on Apr 18, 2005 - */ -package org.eclipse.mylar.tasks.bugzilla.ui; - -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.mylar.bugzilla.core.BugReport; -import org.eclipse.mylar.core.model.ITaskscapeNode; -import org.eclipse.mylar.tasks.MylarTasksPlugin; -import org.eclipse.mylar.tasks.bugzilla.BugzillaReportNode; -import org.eclipse.mylar.ui.MylarImages; -import org.eclipse.swt.graphics.Image; - -/** - * @author Mik Kersten - */ -public class BugzillaNodeLabelProvider implements ILabelProvider { - - public Image getImage(Object element) { - return MylarImages.getImage(MylarImages.BUG); - } - - /** - * TODO: slow? - */ - public String getText(Object element) { - ITaskscapeNode node = (ITaskscapeNode)element; - - // try to get from the cache before downloading - Object report; - BugzillaReportNode reportNode = MylarTasksPlugin.getReferenceProvider().getCached(node.getElementHandle()); - BugReport cachedReport = MylarTasksPlugin.getDefault().getStructureBridge().getCached(node.getElementHandle()); - if(reportNode != null && cachedReport == null){ - report = reportNode; - } else{ - report = MylarTasksPlugin.getDefault().getStructureBridge().getObjectForHandle(node.getElementHandle()); - } - return MylarTasksPlugin.getDefault().getStructureBridge().getName(report); - } - - public void addListener(ILabelProviderListener listener) { - // don't need to worry about listeners - } - - public void dispose() { - // don't care about dispose - } - - public boolean isLabelProperty(Object element, String property) { - return false; - } - - public void removeListener(ILabelProviderListener listener) { - // don't need to worry about listeners - } -} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/ui/BugzillaUiBridge.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/ui/BugzillaUiBridge.java deleted file mode 100644 index 406566baa..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/ui/BugzillaUiBridge.java +++ /dev/null @@ -1,141 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on Apr 6, 2005 - */ -package org.eclipse.mylar.tasks.bugzilla.ui; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.mylar.bugzilla.ui.BugzillaOpenStructure; -import org.eclipse.mylar.bugzilla.ui.ViewBugzillaAction; -import org.eclipse.mylar.bugzilla.ui.editor.AbstractBugEditor; -import org.eclipse.mylar.bugzilla.ui.outline.BugzillaOutlinePage; -import org.eclipse.mylar.core.model.ITaskscapeNode; -import org.eclipse.mylar.tasks.BugzillaTask; -import org.eclipse.mylar.tasks.ITask; -import org.eclipse.mylar.tasks.MylarTasksPlugin; -import org.eclipse.mylar.tasks.bugzilla.BugzillaReferencesProvider; -import org.eclipse.mylar.tasks.ui.BugzillaTaskEditor; -import org.eclipse.mylar.ui.IMylarUiBridge; -import org.eclipse.mylar.ui.MylarImages; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorReference; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.internal.Workbench; - -public class BugzillaUiBridge implements IMylarUiBridge { - - protected BugzillaNodeLabelProvider labelProvider = new BugzillaNodeLabelProvider(); - - public void open(ITaskscapeNode node) { - String handle = node.getElementHandle(); - String bugHandle = handle; - String server =handle.substring(0, handle.indexOf(";")); - - handle = handle.substring(handle.indexOf(";") + 1); - int next = handle.indexOf(";"); - - int bugId; - int commentNumer = -1; - if(next == -1){ - bugId = Integer.parseInt(handle); - } - else{ - bugId = Integer.parseInt(handle.substring(0, handle.indexOf(";"))); - commentNumer = Integer.parseInt(handle.substring(handle.indexOf(";") + 1)); - bugHandle = bugHandle.substring(0, next); - } - - List<BugzillaOpenStructure> l = new ArrayList<BugzillaOpenStructure>(1); - l.add(new BugzillaOpenStructure(server, bugId, commentNumer)); - - ITask task= MylarTasksPlugin.getTaskListManager().getTaskList().getTaskForId(bugHandle); - if (task != null && task instanceof BugzillaTask) { - BugzillaTask bugzillaTask = (BugzillaTask)task; - bugzillaTask.openTask(commentNumer); - } else { - // open the bug in the editor - ViewBugzillaAction viewBugs = new ViewBugzillaAction("Display bugs in editor", l); - viewBugs.schedule(); - } - } - - public ILabelProvider getLabelProvider() { - return labelProvider; - } - - public void close(ITaskscapeNode node) { - IWorkbenchPage page = Workbench.getInstance().getActiveWorkbenchWindow().getActivePage(); - if (page != null) { - IEditorReference[] references = page.getEditorReferences(); - for (int i = 0; i < references.length; i++) { - IEditorPart part = references[i].getEditor(false); - if (part != null) { - if (part instanceof AbstractBugEditor) { - ((AbstractBugEditor)part).close(); - } else if(part instanceof BugzillaTaskEditor){ - ((BugzillaTaskEditor)part).close(); - } - } - } - } - } - - public boolean acceptsEditor(IEditorPart editorPart) { - return editorPart instanceof AbstractBugEditor; - } - - public List<TreeViewer> getTreeViewers(IEditorPart editor) { - ArrayList<TreeViewer> outlines = new ArrayList<TreeViewer>(1); - TreeViewer outline = getOutlineTreeViewer(editor); - if (outline != null) { - outlines.add(outline); - return outlines; - } else { - return Collections.emptyList(); - } - } - - protected TreeViewer getOutlineTreeViewer(IEditorPart editor) { - if(editor instanceof AbstractBugEditor){ - AbstractBugEditor abe = (AbstractBugEditor)editor; - BugzillaOutlinePage outline = abe.getOutline(); - if(outline != null) return outline.getOutlineTreeViewer(); - } - return null; - } - - public void refreshOutline(Object element, boolean updateLabels) { - IEditorPart editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); - TreeViewer treeViewer = getOutlineTreeViewer(editorPart); - if (treeViewer != null) { - treeViewer.refresh(true); - - treeViewer.expandAll(); - } - } - - public ImageDescriptor getIconForRelationship(String relationshipHandle) { - return MylarImages.EDGE_REF_BUGZILLA; - - } - - public String getNameForRelationship(String relationshipHandle) { - return BugzillaReferencesProvider.NAME; - } -} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/BugzillaTaskEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/BugzillaTaskEditor.java deleted file mode 100644 index bc450ce42..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/BugzillaTaskEditor.java +++ /dev/null @@ -1,291 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on 31-Jan-2005 - */ -package org.eclipse.mylar.tasks.ui; - -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.mylar.bugzilla.IBugzillaAttributeListener; -import org.eclipse.mylar.bugzilla.core.BugReport; -import org.eclipse.mylar.bugzilla.ui.editor.AbstractBugEditor; -import org.eclipse.mylar.bugzilla.ui.editor.ExistingBugEditor; -import org.eclipse.mylar.bugzilla.ui.editor.ExistingBugEditorInput; -import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.BugzillaTask; -import org.eclipse.mylar.tasks.MylarTasksPlugin; -import org.eclipse.mylar.tasks.ui.views.TaskListView; -import org.eclipse.mylar.ui.MylarImages; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.IPartListener; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.internal.Workbench; -import org.eclipse.ui.part.MultiPageEditorPart; -import org.eclipse.ui.views.contentoutline.IContentOutlinePage; - -/** - * @author Eric Booth - */ -public class BugzillaTaskEditor extends MultiPageEditorPart { - - /** The task that created this editor */ - protected BugzillaTask bugTask; - - /** This bug report can be modified by the user and saved offline. */ - protected BugReport offlineBug; - - private ExistingBugEditor bugzillaEditor; - - private BugzillaTaskEditorInput bugzillaEditorInput; - - private TaskSummaryEditor taskSummaryEditor = new TaskSummaryEditor(); - - protected IContentOutlinePage outlinePage = null; - - private IBugzillaAttributeListener ATTRIBUTE_LISTENER = new IBugzillaAttributeListener() { - public void attributeChanged(String attribute, String value) { - if (attribute.equals("Priority")) { - bugTask.setPriority(value); - if (TaskListView.getDefault() != null) TaskListView.getDefault().notifyTaskDataChanged(bugTask); - } - } - }; - - - public BugzillaTaskEditor() { - super(); - - // get the workbench page and add a listener so we can detect when it closes - IWorkbench wb = MylarTasksPlugin.getDefault().getWorkbench(); - IWorkbenchWindow aw = wb.getActiveWorkbenchWindow(); - IWorkbenchPage ap = aw.getActivePage(); - BugzillaTaskEditorListener listener = new BugzillaTaskEditorListener(); - ap.addPartListener(listener); - - bugzillaEditor = new ExistingBugEditor(); - bugzillaEditor.addAttributeListener(ATTRIBUTE_LISTENER); - taskSummaryEditor = new TaskSummaryEditor(); - } - - public AbstractBugEditor getBugzillaEditor(){ - return bugzillaEditor; - } - - public TaskSummaryEditor getTaskEditor(){ - return taskSummaryEditor; - } - - - public void gotoMarker(IMarker marker) { - // don't do anything - } - - /** - * Creates page 1 of the multi-page editor, - * which allows you to change the font used in page 2. - */ - private void createBugzillaSubmitPage() { - bugzillaEditor.createPartControl(getContainer()); - Composite composite = bugzillaEditor.getEditorComposite(); - int index = addPage(composite); - setPageText(index, "Bugzilla"); - } - - - private void createSummaryPage() { - try{ - int index = addPage(taskSummaryEditor, new TaskEditorInput(bugTask)); - setPageText(index, "Summary"); - }catch(Exception e){ - MylarPlugin.log(e, "summary failed"); - } - } - - /** - * Creates the pages of the multi-page editor. - */ - @Override - protected void createPages() { - createBugzillaSubmitPage(); - createSummaryPage(); - } - - /** - * Saves the multi-page editor's document. - */ - @Override - public void doSave(IProgressMonitor monitor) { - getEditor(0).doSave(monitor); - } - - /** - * Saves the multi-page editor's document as another file. - * Also updates the text for page 0's tab, and updates this multi-page editor's input - * to correspond to the nested editor's. - */ - @Override - public void doSaveAs() { - IEditorPart editor = getEditor(0); - editor.doSaveAs(); - setPageText(0, editor.getTitle()); - setInput(editor.getEditorInput()); - } - - @Override - public void init(IEditorSite site, IEditorInput editorInput) throws PartInitException { - if (!(editorInput instanceof BugzillaTaskEditorInput)) - throw new PartInitException("Invalid Input: Must be BugzillaTaskEditorInput"); - bugzillaEditorInput = (BugzillaTaskEditorInput) editorInput; - bugTask = bugzillaEditorInput.getBugTask(); - - offlineBug = bugzillaEditorInput.getOfflineBug(); - super.init(site, editorInput); - super.setSite(site); - super.setInput(editorInput); - - try { - bugzillaEditor.init(this.getEditorSite(), this.getEditorInput()); - } - catch (Exception e) { - throw new PartInitException(e.getMessage()); - } - - // Set the title on the editor's tab - this.setPartName("Bug #" + bugzillaEditorInput.getBugId()); - this.setTitleImage(MylarImages.getImage(MylarImages.TASK_BUGZILLA)); - } - - @Override - public boolean isSaveAsAllowed() { - return false; - } - - /** - * Calculates the contents of page 2 when the it is activated. - */ - @Override - protected void pageChange(int newPageIndex) { - super.pageChange(newPageIndex); - } - - /** - * Sets the font related data to be applied to the text in page 2. - */ - @Override - public void setFocus() { - // The default focus for this editor is the submit page - bugzillaEditor.setFocus(); - } - - /** - * @return Returns the bugTask. - */ - public BugzillaTask getBugTask() { - return bugTask; - } - - /** - * @return Returns the offlineBug. - */ - public BugReport getOfflineBug() { - return offlineBug; - } - - /** - * Updates the title of the editor to reflect dirty status. - * If the bug report has been modified but not saved, then - * an indicator will appear in the title. - * @param isDirty - * is true when the bug report has been modified but not saved - */ - public void showDirtyStatus(boolean isDirty) { - String prefix = (isDirty) ? "*" : "" ; - setPartName(prefix + "Bug #" + bugzillaEditorInput.getBugId()); - } - - /** - * Class to listen for editor events - */ - private class BugzillaTaskEditorListener implements IPartListener - { - - public void partActivated(IWorkbenchPart part) { - // don't care about this event - } - - public void partBroughtToTop(IWorkbenchPart part) { - // don't care about this event - } - - public void partClosed(IWorkbenchPart part) { - - // if we are closing a bug editor - if (part instanceof BugzillaTaskEditor) { - BugzillaTaskEditor taskEditor = (BugzillaTaskEditor)part; - - // check if it needs to be saved - if (taskEditor.bugzillaEditor.isDirty) { - // ask the user whether they want to save it or not and perform the appropriate action - taskEditor.bugzillaEditor.changeDirtyStatus(false); - boolean response = MessageDialog.openQuestion(null, "Save Changes", - "You have made some changes to the bug, do you want to save them?"); - if (response) { - taskEditor.bugzillaEditor.saveBug(); - } else { - ExistingBugEditorInput input = (ExistingBugEditorInput)taskEditor.bugzillaEditor.getEditorInput(); - bugTask.setPriority(input.getBug().getAttribute("Priority").getValue()); - } - } - } - } - - public void partDeactivated(IWorkbenchPart part) { - // don't care about this event - } - - public void partOpened(IWorkbenchPart part) { - // don't care about this event - } - } - - public void makeNewPage(BugReport serverBug, String newCommentText) { - if (serverBug == null) { - MessageDialog.openInformation(Workbench.getInstance().getActiveWorkbenchWindow().getShell(), - "Could not open bug.", "Bug #" + offlineBug.getId() - + " could not be read from the server. Try refreshing the bug task."); - return; - } - } - - @Override - public Object getAdapter(Class adapter) { - return bugzillaEditor.getAdapter(adapter); - } - - public void close() { - Display display= getSite().getShell().getDisplay(); - display.asyncExec(new Runnable() { - public void run() { - getSite().getPage().closeEditor(BugzillaTaskEditor.this, false); - } - }); - } -} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/BugzillaTaskEditorInput.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/BugzillaTaskEditorInput.java deleted file mode 100644 index af9e7f5e9..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/BugzillaTaskEditorInput.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on 1-Feb-2005 - */ -package org.eclipse.mylar.tasks.ui; - -import java.io.IOException; - -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.tasks.BugzillaTask; -import org.eclipse.ui.IPersistableElement; - - -/** - * @author Eric Booth - */ -public class BugzillaTaskEditorInput extends ExistingBugEditorInput { - - - private String bugTitle; - - private BugReport offlineBug; - - private BugzillaTask bugTask; - - public BugzillaTaskEditorInput(BugzillaTask bugTask) throws LoginException, IOException { - super(BugzillaTask.getBugId(bugTask.getHandle())); - this.bugTask = bugTask; - offlineBug = bugTask.getBugReport(); - bugId = BugzillaTask.getBugId(bugTask.getHandle()); - bugTitle = ""; - } - - protected void setBugTitle(String str) { - // 03-20-03 Allows editor to store title (once it is known) - bugTitle = str; - } - - @Override - public boolean exists() { - return true; - } - - @Override - public ImageDescriptor getImageDescriptor() { - return null; - } - - @Override - public String getName() { - return "Bug #" + bugId; - } - - @Override - public IPersistableElement getPersistable() { - return null; - } - - @Override - public String getToolTipText() { - return bugTitle; - } - - @Override - public Object getAdapter(Class adapter) { - return null; - } - - @Override - public int getBugId() { - return bugId; - } - - /** - * Returns the online server bug for this input - * - * @see BugzillaRepository - * @see BugReport - */ -// public BugReport getServerBug() { -// return serverBug; -// } - - /** - * Returns the offline bug for this input's Bugzilla task - */ - public BugReport getOfflineBug() { - return offlineBug; - } - - /** - * Gets the bug page input stream - */ -// public InputStream getInputStream() throws IOException { -// try { -// return url.openStream(); -// } -// catch (Exception e) { -// throw new IOException(e.getMessage()); -// } -// -// } - - /** - * Returns true if the argument is a bug report editor input on the same bug id. - */ - @Override - public boolean equals(Object o) { - if (o instanceof BugzillaTaskEditorInput) { - BugzillaTaskEditorInput input = (BugzillaTaskEditorInput) o; - return getBugId() == input.getBugId(); - } - return false; - } - - /** - * @return Returns the <code>BugzillaTask</code> - */ - public BugzillaTask getBugTask() { - return bugTask; - } -} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskEditor.java deleted file mode 100644 index dc196f992..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskEditor.java +++ /dev/null @@ -1,161 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on 19-Jan-2005 - */ -package org.eclipse.mylar.tasks.ui; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.mylar.tasks.ITask; -import org.eclipse.mylar.tasks.MylarTasksPlugin; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.IPartListener; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.part.MultiPageEditorPart; - - -/** - * @author Eric Booth - */ -public class TaskEditor extends MultiPageEditorPart { - - protected ITask task; - private TaskSummaryEditor taskSummaryEditor; - private TaskEditorInput taskEditorInput; - - public TaskEditor() { - super(); - - // get the workbench page and add a listener so we can detect when it closes - IWorkbench wb = MylarTasksPlugin.getDefault().getWorkbench(); - IWorkbenchWindow aw = wb.getActiveWorkbenchWindow(); - IWorkbenchPage ap = aw.getActivePage(); - TaskEditorListener listener = new TaskEditorListener(); - ap.addPartListener(listener); - - taskSummaryEditor = new TaskSummaryEditor(); - } - - /** - * Creates page 1 of the multi-page editor, - * which displays the task for viewing. - */ - private void createTaskSummaryPage() { - taskSummaryEditor.createPartControl(getContainer()); - int index = addPage(taskSummaryEditor.getControl()); - setPageText(index, "Summary"); - } - - /** - * Creates the pages of the multi-page editor. - */ - @Override - protected void createPages() { - createTaskSummaryPage(); - } - - @Override - public void doSave(IProgressMonitor monitor) { - getEditor(0).doSave(monitor); - } - - /** - * Saves the multi-page editor's document as another file. - * Also updates the text for page 0's tab, and updates this multi-page editor's input - * to correspond to the nested editor's. - * - * @see org.eclipse.ui.ISaveablePart#doSaveAs() - */ - @Override - public void doSaveAs() { - IEditorPart editor = getEditor(0); - editor.doSaveAs(); - setPageText(0, editor.getTitle()); - setInput(editor.getEditorInput()); - } - - @Override - public void init(IEditorSite site, IEditorInput input) throws PartInitException { - - if (!(input instanceof TaskEditorInput)) - throw new PartInitException("Invalid Input: Must be TaskEditorInput"); - taskEditorInput = (TaskEditorInput)input; - super.init(site, input); - - /* - * The task data is saved only once, at the initialization of the editor. This is - * then passed to each of the child editors. This way, only one instance of - * the task data is stored for each editor opened. - */ - task = taskEditorInput.getTask(); - try { - taskSummaryEditor.init(this.getEditorSite(), this.getEditorInput()); - taskSummaryEditor.setTask(task); - // Set the title on the editor's tab - this.setPartName(taskEditorInput.getLabel()); - } catch (Exception e) { - throw new PartInitException(e.getMessage()); - } - } - - @Override - public boolean isSaveAsAllowed() { - return false; - } - - /** - * Class to listen for editor events - */ - private class TaskEditorListener implements IPartListener - { - - /** - * @see org.eclipse.ui.IPartListener#partActivated(org.eclipse.ui.IWorkbenchPart) - */ - public void partActivated(IWorkbenchPart part) { - // don't care about this event - } - - /** - * @see org.eclipse.ui.IPartListener#partBroughtToTop(org.eclipse.ui.IWorkbenchPart) - */ - public void partBroughtToTop(IWorkbenchPart part) { - // don't care about this event - } - - /** - * @see org.eclipse.ui.IPartListener#partClosed(org.eclipse.ui.IWorkbenchPart) - */ - public void partClosed(IWorkbenchPart part) { - // don't care about this event - } - - /** - * @see org.eclipse.ui.IPartListener#partDeactivated(org.eclipse.ui.IWorkbenchPart) - */ - public void partDeactivated(IWorkbenchPart part) { - // don't care about this event - } - - /** - * @see org.eclipse.ui.IPartListener#partOpened(org.eclipse.ui.IWorkbenchPart) - */ - public void partOpened(IWorkbenchPart part) { - // don't care about this event - } - } -} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskEditorCopyAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskEditorCopyAction.java deleted file mode 100644 index 90af072f7..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskEditorCopyAction.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on 20-Jan-2005 - */ -package org.eclipse.mylar.tasks.ui; - -import org.eclipse.jface.action.Action; - -/** - * TODO: delete? - */ -public class TaskEditorCopyAction extends Action { - - public TaskEditorCopyAction() { - setText("TaskSummaryEditor.copy.text"); - } - - @Override - public void run() { -// if (editorPart instanceof TaskSummaryEditor) -// ((TaskSummaryEditor)editorPart).getCurrentText().copy(); - } - -} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskEditorInput.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskEditorInput.java deleted file mode 100644 index 8c6e04b33..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskEditorInput.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on 19-Jan-2005 - */ -package org.eclipse.mylar.tasks.ui; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.mylar.tasks.ITask; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IPersistableElement; - - -/** - * @author Eric Booth - */ -public class TaskEditorInput implements IEditorInput { - - private ITask task; - - private String id; - - private String label; - - public TaskEditorInput(ITask task) { - this.task = task; - id = task.getHandle(); - label = task.getLabel(); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IEditorInput#exists() - */ - public boolean exists() { - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IEditorInput#getImageDescriptor() - */ - public ImageDescriptor getImageDescriptor() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IEditorInput#getName() - */ - public String getName() { - return "Task #" + id; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IEditorInput#getPersistable() - */ - public IPersistableElement getPersistable() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IEditorInput#getToolTipText() - */ - public String getToolTipText() { - return label; - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class adapter) { - return null; - } - - /** - * @return Returns the task. - */ - public ITask getTask() { - return task; - } - - /** - * @return Returns the id. - */ - public String getId() { - return id; - } - - /** - * @return Returns the label. - */ - public String getLabel() { - return label; - } - - /** - * Returns true if the argument is a bug report editor input on the same bug id. - */ - @Override - public boolean equals(Object o) { - if (o instanceof TaskEditorInput) { - TaskEditorInput input = (TaskEditorInput) o; - return getId() == input.getId(); - } - return false; - } -} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskSummaryEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskSummaryEditor.java deleted file mode 100644 index 1b1e5f5ad..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskSummaryEditor.java +++ /dev/null @@ -1,1261 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on 19-Jan-2005 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package org.eclipse.mylar.tasks.ui; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.List; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.dialogs.InputDialog; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.ICellModifier; -import org.eclipse.jface.viewers.IColorProvider; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.TextCellEditor; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.ITask; -import org.eclipse.mylar.tasks.ITaskActivityListener; -import org.eclipse.mylar.tasks.MylarTasksPlugin; -import org.eclipse.mylar.tasks.RelatedLinks; -import org.eclipse.mylar.tasks.ui.views.TaskListView; -import org.eclipse.mylar.tasks.util.RelativePathUtil; -import org.eclipse.mylar.ui.MylarImages; -import org.eclipse.mylar.ui.MylarUiPlugin; -import org.eclipse.swt.SWT; -import org.eclipse.swt.SWTException; -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.events.FocusListener; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.MouseTrackListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Cursor; -import org.eclipse.swt.graphics.Image; -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.FileDialog; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.actions.RetargetAction; -import org.eclipse.ui.browser.IWebBrowser; -import org.eclipse.ui.forms.FormColors; -import org.eclipse.ui.forms.events.ExpansionEvent; -import org.eclipse.ui.forms.events.IExpansionListener; -import org.eclipse.ui.forms.widgets.ExpandableComposite; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.ScrolledForm; -import org.eclipse.ui.forms.widgets.Section; -import org.eclipse.ui.forms.widgets.TableWrapData; -import org.eclipse.ui.forms.widgets.TableWrapLayout; -import org.eclipse.ui.internal.WorkbenchImages; -import org.eclipse.ui.internal.WorkbenchMessages; -import org.eclipse.ui.internal.browser.WorkbenchBrowserSupport; -import org.eclipse.ui.part.EditorPart; - -/** - * For details on forms, go to: - * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/pde-ui-home/working/EclipseForms/EclipseForms.html - * @author Ken Sueda - */ -public class TaskSummaryEditor extends EditorPart { - private ITask task; - private TaskEditorInput editorInput; - private Composite editorComposite; - private TaskEditorCopyAction copyAction; - private RetargetAction pasteAction; - private RetargetAction cutAction; - private static final String cutActionDefId = "org.eclipse.ui.edit.cut"; - private static final String pasteActionDefId = "org.eclipse.ui.edit.paste"; - private Table table; - private TableViewer tableViewer; - private RelatedLinks links; - private RelatedLinksContentProvider contentProvider; - - private Button browse; - private Text pathText; - private ScrolledForm sform; - private Action add; - private Action delete; - private Text description; - - private ITaskActivityListener TASK_LIST_LISTENER = new ITaskActivityListener() { - public void taskActivated(ITask activeTask) { - if (task != null && !browse.isDisposed() && activeTask.getHandle().equals(task.getHandle())) { - browse.setEnabled(false); - } - } - - public void tasksActivated(List<ITask> tasks) { - for (ITask t : tasks) { - taskActivated(t); - } - } - - public void taskDeactivated(ITask deactiveTask) { - if (task != null && !browse.isDisposed() && deactiveTask.getHandle().equals(task.getHandle())) { - browse.setEnabled(true); - } - } - - public void taskPropertyChanged(ITask updatedTask, String property) { - if (task != null && updatedTask.getHandle().equals(task.getHandle())) { - if (property.equals("Description") && !description.isDisposed()) { - description.setText(task.getLabel()); - } else if (property.equals("Path") && !pathText.isDisposed()) { - pathText.setText("<Mylar_Dir>/" + task.getPath()); - } - } - } - }; - /** - * - */ - public TaskSummaryEditor() { - super(); - - cutAction = new RetargetAction(ActionFactory.CUT.getId(), - WorkbenchMessages.Workbench_cut); - cutAction.setToolTipText( - WorkbenchMessages.Workbench_cutToolTip); - cutAction.setImageDescriptor(WorkbenchImages.getImageDescriptor( - ISharedImages.IMG_TOOL_CUT)); - cutAction.setHoverImageDescriptor(WorkbenchImages.getImageDescriptor( - ISharedImages.IMG_TOOL_CUT)); - cutAction.setDisabledImageDescriptor(WorkbenchImages.getImageDescriptor( - ISharedImages.IMG_TOOL_CUT_DISABLED)); - cutAction.setAccelerator(SWT.CTRL | 'x'); - cutAction.setActionDefinitionId(cutActionDefId); - - pasteAction = new RetargetAction(ActionFactory.PASTE.getId(), - WorkbenchMessages.Workbench_paste); - pasteAction.setToolTipText( - WorkbenchMessages.Workbench_pasteToolTip); - pasteAction.setImageDescriptor(WorkbenchImages.getImageDescriptor( - ISharedImages.IMG_TOOL_PASTE)); - pasteAction.setHoverImageDescriptor(WorkbenchImages.getImageDescriptor( - ISharedImages.IMG_TOOL_PASTE)); - pasteAction.setDisabledImageDescriptor(WorkbenchImages.getImageDescriptor( - ISharedImages.IMG_TOOL_PASTE_DISABLED)); - pasteAction.setAccelerator(SWT.CTRL | 'v'); - pasteAction.setActionDefinitionId(pasteActionDefId); - - copyAction = new TaskEditorCopyAction(); - copyAction.setText( - WorkbenchMessages.Workbench_copy); - copyAction.setImageDescriptor(WorkbenchImages.getImageDescriptor( - ISharedImages.IMG_TOOL_COPY)); - copyAction.setHoverImageDescriptor(WorkbenchImages.getImageDescriptor( - ISharedImages.IMG_TOOL_COPY)); - copyAction.setDisabledImageDescriptor(WorkbenchImages.getImageDescriptor( - ISharedImages.IMG_TOOL_COPY_DISABLED)); - copyAction.setAccelerator(SWT.CTRL | 'c'); - - copyAction.setEnabled(false); - MylarTasksPlugin.getTaskListManager().addListener(TASK_LIST_LISTENER); - } - @Override - public void doSave(IProgressMonitor monitor) { - // don't support saving - } - @Override - public void doSaveAs() { - // don't support saving - } - @Override - public void init(IEditorSite site, IEditorInput input) throws PartInitException { - if (!(input instanceof TaskEditorInput)) { - throw new PartInitException("Invalid Input: Must be TaskEditorInput"); - } - setSite(site); - setInput(input); - editorInput = (TaskEditorInput)input; - setPartName(editorInput.getLabel()); - } - @Override - public boolean isDirty() { - return false; - } - @Override - public boolean isSaveAsAllowed() { - return false; - } - - @Override - public void createPartControl(Composite parent) { -// ManagedForm form = new ManagedForm(parent); -// FormToolkit toolkit = form.getToolkit(); -// editorComposite = form.getForm(); - FormToolkit toolkit = new FormToolkit(parent.getDisplay()); - sform = toolkit.createScrolledForm(parent); - sform.getBody().setLayout(new TableWrapLayout()); - editorComposite = sform.getBody(); - - - TableWrapLayout layout = new TableWrapLayout(); - layout.bottomMargin = 10; - layout.topMargin = 10; - layout.leftMargin = 10; - layout.rightMargin = 10; - layout.numColumns = 1; - layout.makeColumnsEqualWidth = true; - layout.verticalSpacing = 20; - layout.horizontalSpacing = 10; - editorComposite.setLayout(layout); - //editorComposite.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); - - // Put the info onto the editor - createContent(editorComposite, toolkit); - } - - @Override - public void setFocus() { - // don't care when the focus is set - } - - /** - * @return Returns the editorComposite. - */ - public Composite getEditorComposite() { - return editorComposite; - } - - public Control getControl() { - return sform; - } - - public void setTask(ITask task) throws Exception { - if (task == null) - throw new Exception("ITask object is null."); - this.task = task; - } - - private Composite createContent(Composite parent, FormToolkit toolkit) { - TaskEditorInput taskEditorInput = (TaskEditorInput)getEditorInput(); - - task = taskEditorInput.getTask(); - if (task == null) { - MessageDialog.openError(parent.getShell(), "No such task", "No task exists with this id"); - return null; - } - - try { - createTaskSection(parent, toolkit); - createNotesSection(parent, toolkit); - createPlanningGameSection(parent, toolkit); - createRelatedLinksSection(parent, toolkit); - createDetailsSection(parent, toolkit); - } catch (SWTException e) { - MylarPlugin.log(e, "content failed"); - } - return null; - } - - private void createTaskSection(Composite parent, FormToolkit toolkit) { - Section section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR); - section.setText("Mylar Task Description"); - section.setLayout(new TableWrapLayout()); - section.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); - section.addExpansionListener(new IExpansionListener() { - public void expansionStateChanging(ExpansionEvent e) { - sform.reflow(true); - } - public void expansionStateChanged(ExpansionEvent e) { - sform.reflow(true); - } - }); - - Composite container = toolkit.createComposite(section); - section.setClient(container); - TableWrapLayout layout = new TableWrapLayout(); - layout.numColumns = 3; - container.setLayout(layout); - - Label l = toolkit.createLabel(container, "Description:"); - l.setForeground(toolkit.getColors().getColor(FormColors.TITLE)); - description = toolkit.createText(container,task.getLabel(), SWT.BORDER); - TableWrapData td = new TableWrapData(TableWrapData.FILL_GRAB); - td.colspan = 2; - description.setLayoutData(td); - description.addFocusListener(new FocusListener() { - public void focusGained(FocusEvent e) { - // don't care about focus gained - } - - public void focusLost(FocusEvent e) { - String label = description.getText(); - task.setLabel(label); - refreshTaskListView(task); - } - }); - } - -// private String formatPath(String path) { -// if (path == null) return ""; -// StringBuffer result = new StringBuffer(path.length() + 10); -// for (int i = 0; i < path.length(); i++) { -// if (path.charAt(i) == '\\'){ -// result.append('/'); -// } else { -// result.append(path.charAt(i)); -// } -// } -// -// return result.toString(); -// } - - private void createNotesSection(Composite parent, FormToolkit toolkit) { - Section section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR); - section.setText("Notes"); - section.setLayout(new TableWrapLayout()); - section.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); - section.addExpansionListener(new IExpansionListener() { - public void expansionStateChanging(ExpansionEvent e) { - sform.reflow(true); - } - - public void expansionStateChanged(ExpansionEvent e) { - sform.reflow(true); - } - }); - Composite container = toolkit.createComposite(section); - section.setClient(container); - TableWrapLayout layout = new TableWrapLayout(); - layout.numColumns = 2; - container.setLayout(layout); - - final Text text = toolkit.createText(container, task.getNotes(), SWT.BORDER | SWT.MULTI); - TableWrapData tablewrap = new TableWrapData(TableWrapData.FILL_GRAB); - tablewrap.heightHint = 100; - text.setLayoutData(tablewrap); - text.addFocusListener(new FocusListener() { - public void focusGained(FocusEvent e) { - // don't care about focus gained - } - - public void focusLost(FocusEvent e) { - String notes = text.getText(); - task.setNotes(notes); - } - }); - } - - private void createPlanningGameSection(Composite parent, FormToolkit toolkit) { - Section section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR | Section.TWISTIE); - section.setText("Planning Game"); - section.setLayout(new TableWrapLayout()); - section.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); - section.addExpansionListener(new IExpansionListener() { - public void expansionStateChanging(ExpansionEvent e) { - sform.reflow(true); - } - - public void expansionStateChanged(ExpansionEvent e) { - sform.reflow(true); - } - }); - Composite container = toolkit.createComposite(section); - section.setClient(container); - TableWrapLayout layout = new TableWrapLayout(); - layout.numColumns = 2; - container.setLayout(layout); - - Label l = toolkit.createLabel(container, "Estimated Time:"); - l.setForeground(toolkit.getColors().getColor(FormColors.TITLE)); - final Text text = toolkit.createText(container,task.getEstimatedTime(), SWT.BORDER); - text.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); - - text.addFocusListener(new FocusListener() { - public void focusGained(FocusEvent e) { - // don't care about focus gained - } - - public void focusLost(FocusEvent e) { - String estimate = text.getText(); - task.setEstimatedTime(estimate); - } - }); - - l = toolkit.createLabel(container, "Elapsed Time:"); - l.setForeground(toolkit.getColors().getColor(FormColors.TITLE)); - Text text2 = toolkit.createText(container,task.getElapsedTime(), SWT.BORDER); - text2.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); - text2.setEditable(false); - text2.setEnabled(false); - //text2.setForeground(background); - } - - private void createRelatedLinksSection(Composite parent, FormToolkit toolkit) { - Section section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR | Section.TWISTIE); - section.setText("Related Links"); - section.setLayout(new TableWrapLayout()); - section.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); - section.addExpansionListener(new IExpansionListener() { - public void expansionStateChanging(ExpansionEvent e) { - sform.reflow(true); - } - - public void expansionStateChanged(ExpansionEvent e) { - sform.reflow(true); - } - }); - Composite container = toolkit.createComposite(section); - section.setClient(container); - TableWrapLayout layout = new TableWrapLayout(); - layout.numColumns = 2; - container.setLayout(layout); - - Label l = toolkit.createLabel(container, "Related Links:"); - l.setForeground(toolkit.getColors().getColor(FormColors.TITLE)); - toolkit.createLabel(container, ""); - - createTable(container, toolkit); - createTableViewer(container, toolkit); - toolkit.paintBordersFor(container); - createAddDeleteButtons(container, toolkit); - } - - private void createTable(Composite parent, FormToolkit toolkit) { - table = toolkit.createTable(parent, SWT.NONE ); - TableColumn col1 = new TableColumn(table, SWT.NULL); - TableLayout tlayout = new TableLayout(); - tlayout.addColumnData(new ColumnWeightData(0,0,false)); - table.setLayout(tlayout); - TableWrapData wd = new TableWrapData(TableWrapData.FILL_GRAB); - wd.heightHint = 100; - wd.grabVertical = true; - table.setLayoutData(wd); - table.setHeaderVisible(false); - col1.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - tableViewer.setSorter(new RelatedLinksTableSorter( - RelatedLinksTableSorter.LABEL)); - } - }); - table.addMouseTrackListener(new MouseTrackListener() { - public void mouseEnter(MouseEvent e) { - if(!((RelatedLinksContentProvider)tableViewer.getContentProvider()).isEmpty()) { - Cursor hyperlinkCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND); - Display.getCurrent().getCursorControl().setCursor(hyperlinkCursor); - } - } - - public void mouseExit(MouseEvent e) { - Cursor pointer = new Cursor(Display.getCurrent(), SWT.CURSOR_ARROW); - Display.getCurrent().getCursorControl().setCursor(pointer); - } - - public void mouseHover(MouseEvent e){ - if(!((RelatedLinksContentProvider)tableViewer.getContentProvider()).isEmpty()) { - Cursor hyperlinkCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND); - Display.getCurrent().getCursorControl().setCursor(hyperlinkCursor); - } - } - }); - } - - private void createTableViewer(Composite parent, FormToolkit toolkit) { - String[] columnNames = {"Links"}; - tableViewer = new TableViewer(table); - tableViewer.setColumnProperties(columnNames); - - CellEditor[] editors = new CellEditor[columnNames.length]; - - TextCellEditor textEditor = new TextCellEditor(table); - ((Text) textEditor.getControl()).setTextLimit(50); - ((Text) textEditor.getControl()).setOrientation(SWT.LEFT_TO_RIGHT); - editors[0] = textEditor; - - tableViewer.setCellEditors(editors); - tableViewer.setCellModifier(new RelatedLinksCellModifier()); - contentProvider = new RelatedLinksContentProvider(); - tableViewer.setContentProvider(contentProvider); - tableViewer.setLabelProvider(new RelatedLinksLabelProvider()); - links = task.getRelatedLinks(); - tableViewer.setInput(links); - defineActions(); - hookContextMenu(); - } - private void createAddDeleteButtons(Composite parent, FormToolkit toolkit) { - Composite container = toolkit.createComposite(parent); - container.setLayout(new GridLayout(1, true)); - Button addButton = toolkit.createButton(container, " Add ", SWT.PUSH | SWT.CENTER); - //add.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); - addButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - addLink(); - } - }); - - Button deleteButton = toolkit.createButton(container, "Delete", SWT.PUSH | SWT.CENTER); - deleteButton.setText("Delete"); - //delete.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); - deleteButton.addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent e) { - removeLink(); - } - }); - } - - private void createDetailsSection(Composite parent, FormToolkit toolkit) { - Section section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR | Section.TWISTIE); - section.setText("Mylar Task Details"); - section.setLayout(new TableWrapLayout()); - section.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); - section.addExpansionListener(new IExpansionListener() { - public void expansionStateChanging(ExpansionEvent e) { - sform.reflow(true); - } - public void expansionStateChanged(ExpansionEvent e) { - sform.reflow(true); - } - }); - - Composite container = toolkit.createComposite(section); - section.setClient(container); - TableWrapLayout layout = new TableWrapLayout(); - layout.numColumns = 3; - container.setLayout(layout); - - Label l = toolkit.createLabel(container, "Task Handle:"); - l.setForeground(toolkit.getColors().getColor(FormColors.TITLE)); - Text handle = toolkit.createText(container, task.getHandle(), SWT.BORDER); - TableWrapData td = new TableWrapData(TableWrapData.FILL_GRAB); - td.colspan = 2; - handle.setLayoutData(td); - handle.setEditable(false); - handle.setEnabled(false); - - - Label l2 = toolkit.createLabel(container, "Task context path:"); - l2.setForeground(toolkit.getColors().getColor(FormColors.TITLE)); - pathText = toolkit.createText(container, "<Mylar_Dir>/"+task.getPath()+".xml", SWT.BORDER); - pathText.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); - pathText.setEditable(false); - pathText.setEnabled(false); - - browse = toolkit.createButton(container, "Change", SWT.PUSH | SWT.CENTER); - if (task.isActive()) { - browse.setEnabled(false); - } else { - browse.setEnabled(true); - } - browse.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - - if (task.isActive()) { - MessageDialog.openInformation( - Display.getDefault().getActiveShell(), - "Task Message", - "Task can not be active when changing taskscape"); - } else { - FileDialog dialog = new FileDialog(Display.getDefault() - .getActiveShell(), SWT.OPEN); - String[] ext = { "*.xml" }; - dialog.setFilterExtensions(ext); - - String mylarDir = MylarPlugin.getTaskscapeManager() - .getMylarDir() - + "/"; - mylarDir = mylarDir.replaceAll("\\\\", "/"); - // mylarDir = formatPath(mylarDir); - dialog.setFilterPath(mylarDir); - - String res = dialog.open(); - if (res != null) { - res = res.replaceAll("\\\\", "/"); - res = RelativePathUtil.findRelativePath(mylarDir, res); - pathText.setText("<MylarDir>/" + res + ".xml"); - task.setPath(res); - } - } - } - }); - toolkit.createLabel(container, ""); - l = toolkit.createLabel(container, "Go to Mylar Preferences to change <Mylar_Dir>"); - l.setForeground(toolkit.getColors().getColor(FormColors.TITLE)); - } - - private void refreshTaskListView(ITask task) { - if (TaskListView.getDefault() != null) TaskListView.getDefault().notifyTaskDataChanged(task); - } - private class RelatedLinksCellModifier implements ICellModifier, IColorProvider { - RelatedLinksCellModifier() { - super(); - - } - public boolean canModify(Object element, String property) { - return true; - } - public Object getValue(Object element, String property) { - Object res = null; - if (element instanceof String) { - String url = (String) element; - try { - IWebBrowser b = null; - int flags = 0; - if (WorkbenchBrowserSupport.getInstance() - .isInternalWebBrowserAvailable()) { - flags = WorkbenchBrowserSupport.AS_EDITOR - | WorkbenchBrowserSupport.LOCATION_BAR - | WorkbenchBrowserSupport.NAVIGATION_BAR; - - } else { - flags = WorkbenchBrowserSupport.AS_EXTERNAL - | WorkbenchBrowserSupport.LOCATION_BAR - | WorkbenchBrowserSupport.NAVIGATION_BAR; - } - b = WorkbenchBrowserSupport.getInstance().createBrowser( - flags, "org.eclipse.mylar.tasks", "Task", "tasktooltip"); - b.openURL(new URL((String) element)); - } catch (PartInitException e) { - MessageDialog.openError( Display.getDefault().getActiveShell(), - "URL not found", url + " could not be opened"); - } catch (MalformedURLException e) { - MessageDialog.openError( Display.getDefault().getActiveShell(), - "URL not found", url + " could not be opened"); - } - res = (String) element; - } - return res; - } - public void modify(Object element, String property, Object value) { - return; - } - - public Color getForeground(Object element) { - return MylarUiPlugin.getDefault().getColorMap().HYPERLINK; - } - - public Color getBackground(Object element) { - return null; - } - } - - private class RelatedLinksLabelProvider extends LabelProvider implements - ITableLabelProvider, IColorProvider { - - public RelatedLinksLabelProvider() { - // don't have any initialization to do - } - public String getColumnText(Object obj, int columnIndex) { - String result = ""; - if (obj instanceof String) { - switch (columnIndex) { - case 0: - result = (String) obj; - break; - default: - break; - } - } - return result; - } - public Image getColumnImage(Object obj, int columnIndex) { - return null; - } - public Color getForeground(Object element) { - return MylarUiPlugin.getDefault().getColorMap().HYPERLINK; - } - - public Color getBackground(Object element) { - return null; - } - } - - private class RelatedLinksContentProvider implements - IStructuredContentProvider { - - public Object[] getElements(Object inputElement) { - return links.getLinks().toArray(); - } - public void dispose() { - // don't care if we are disposed - } - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - // don't care if the input chages - } - public boolean isEmpty() { - return links.getLinks().isEmpty(); - } - } - - private class RelatedLinksTableSorter extends ViewerSorter { - - public final static int LABEL = 1; - private int criteria; - - public RelatedLinksTableSorter(int criteria) { - super(); - this.criteria = criteria; - } - - @Override - public int compare(Viewer viewer, Object o1, Object o2) { - String s1 = (String) o1; - String s2 = (String) o2; - switch (criteria) { - case LABEL: - return compareLabel(s1, s2); - default: - return 0; - } - } - protected int compareLabel(String s1, String s2) { - return s1.compareTo(s2); - } - public int getCriteria() { - return criteria; - } - } - - private void addLink() { - InputDialog dialog = new InputDialog(Display.getDefault().getActiveShell(), "New related link", - "Enter new related link for this task", "", null); - dialog.open(); - String url = null; - String link = dialog.getValue(); - if (!(link.startsWith("http://") || link.startsWith("https://"))) { - url = "http://" + link; - } else { - url = link; - } - links.add(url); - tableViewer.add(url); - } - - private void removeLink() { - String url = (String) ((IStructuredSelection) tableViewer - .getSelection()).getFirstElement(); - if (url != null) { - links.remove(url); - tableViewer.remove(url); - } - } - private void defineActions() { - delete = new Action() { - @Override - public void run() { - removeLink(); - } - }; - delete.setText("Delete"); - delete.setToolTipText("Delete"); - delete.setImageDescriptor(MylarImages.REMOVE); - - add = new Action() { - @Override - public void run() { - addLink(); - } - }; - add.setText("Add"); - add.setToolTipText("Add"); - //add.setImageDescriptor(MylarImages.REMOVE); - } - - private void hookContextMenu() { - MenuManager menuMgr = new MenuManager("#PopupMenu"); - menuMgr.setRemoveAllWhenShown(true); - menuMgr.addMenuListener(new IMenuListener() { - public void menuAboutToShow(IMenuManager manager) { - manager.add(add); - manager.add(delete); - } - }); - Menu menu = menuMgr.createContextMenu(tableViewer.getControl()); - tableViewer.getControl().setMenu(menu); - //getSite().registerContextMenu(menuMgr, tableViewer); - } - - - - - - - // Eric's Old Code... - // - - //private StringBuffer sb; - //private MenuManager contextMenuManager; - //private final String VALUE = "VALUE"; - //private final String PROPERTY = "PROPERTY"; - //private final String HEADER = "HEADER"; - //private Color foreground; - //private StringBuffer commentBuffer; - //private int index; - //private ArrayList<StyledText> texts = new ArrayList<StyledText>(); - //private StyledText currentSelectedText; - //private Font titleFont; - //private Font textFont; - //private int scrollIncrement; - //private int scrollVertPageIncrement; - //private int scrollHorzPageIncrement; - //private ScrolledComposite scrolledComposite; - //private Display display; - //private CLabel titleLabel; - //private Composite infoArea; - //private final int HORZ_INDENT = 0; - //private final int HORZ_TABLE_SPACING = 10; - -// -// private void focusOn(StyledText newText, int caretOffset) { -// if (newText == null) -// return; -// newText.setFocus(); -// newText.setCaretOffset(caretOffset); -// scrolledComposite.setOrigin(0, newText.getLocation().y); -// } -// -// /** -// * Find the next text -// */ -// private StyledText nextText(StyledText text) { -// int index = 0; -// if (text == null) -// return texts.get(0); -// else -// index = texts.indexOf(text); -// -// //If we are not at the end.... -// if (index < texts.size() - 1) -// return texts.get(index + 1); -// else -// return texts.get(index); -// } -// -// /** -// * Find the previous text -// */ -// private StyledText previousText(StyledText text) { -// int index = 0; -// if (text == null) -// return texts.get(0); -// else -// index = texts.indexOf(text); -// -// //If we are not at the end.... -// if (index == 0) -// return texts.get(0); -// else -// return texts.get(index - 1); -// } -// -// protected StyledText getCurrentText() { -// return currentSelectedText; -// } -// -// protected TaskEditorCopyAction getCopyAction() { -// return copyAction; -// } -// -// private void addTextListeners(StyledText styledText) { -// styledText.addTraverseListener(new TraverseListener() { -// public void keyTraversed(TraverseEvent e) { -// StyledText text = (StyledText) e.widget; -// -// switch (e.detail) { -// case SWT.TRAVERSE_ESCAPE : -// e.doit = true; -// break; -// case SWT.TRAVERSE_TAB_NEXT : -// -// text.setSelection(0); -// StyledText nextText = nextText(text); -// focusOn(nextText, 0); -// -// e.detail = SWT.TRAVERSE_NONE; -// e.doit = true; -// break; -// -// case SWT.TRAVERSE_TAB_PREVIOUS : -// -// text.setSelection(text.getSelection()); -// StyledText previousText = previousText(text); -// focusOn(previousText, 0); -// -// e.detail = SWT.TRAVERSE_NONE; -// e.doit = true; -// break; -// -// default: -// break; -// } -// } -// }); -// -// styledText.addKeyListener(new KeyListener() { -// public void keyReleased(KeyEvent e) { -// //Ignore a key release -// } -// -// public void keyPressed(KeyEvent event) { -// StyledText text = (StyledText) event.widget; -// if (event.character == ' ' || event.character == SWT.CR) { -// return; -// } -// -// if (event.keyCode == SWT.PAGE_DOWN) { -// -// scrolledComposite.setOrigin(0, -// scrolledComposite.getOrigin().y -// + scrollVertPageIncrement); -// return; -// } -// if (event.keyCode == SWT.ARROW_DOWN) { -// scrolledComposite.setOrigin(0, -// scrolledComposite.getOrigin().y + scrollIncrement); -// } -// if (event.keyCode == SWT.PAGE_UP) { -// int origin = scrolledComposite.getOrigin().y; -// int scrollAmount = origin - scrollVertPageIncrement; -// if (scrollAmount <= 0) { -// scrolledComposite.setOrigin(0, 0); -// } else { -// scrolledComposite.setOrigin(0, scrollAmount); -// } -// return; -// } -// if (event.keyCode == SWT.ARROW_UP) { -// scrolledComposite.setOrigin(0, -// scrolledComposite.getOrigin().y - scrollIncrement); -// } -// } -// }); -// -// styledText.addFocusListener(new FocusAdapter() { -// -// @Override -// public void focusLost(FocusEvent e) { -// StyledText text = (StyledText) e.widget; -// text.setSelection(text.getSelection().x); -// } -// }); -// } - -// public void createLayouts(Composite composite, ITask task) { -// SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm"); -// String title = "Task #" + task.getId(); -// newLayout(composite, 4, title, HEADER); -// titleLabel.setText(title); -// } -// -// public void displayArtifact(Composite composite) { -// TaskEditorInput editorInput = (TaskEditorInput) getEditorInput(); -// background = JFaceColors.getBannerBackground(composite.getParent() -// .getParent().getDisplay()); -// composite.setBackground(background); -// -// // Get the background color for the info area -// composite.setBackground(background); -// -// // The entire info area is 4 columns in width -// // all headers take up all 4, values take up 1 -// GridLayout infoLayout = new GridLayout(); -// infoLayout.numColumns = 4; -// infoLayout.marginHeight = 10; -// infoLayout.verticalSpacing = 6; -// -// infoLayout.marginWidth = 5; -// infoLayout.horizontalSpacing = HORZ_TABLE_SPACING; -// composite.setLayout(infoLayout); -// GridData infoData = new GridData(GridData.FILL_BOTH); -// composite.setLayoutData(infoData); -// -// // Create the page with the task's contents -// task = editorInput.getTask(); -// if (task != null) { -// createLayouts(composite, task); -// } else { -// MessageDialog.openError(composite.getShell(), "No such task", -// "No task exists with this id"); -// return; -// } -// } -// -// /** -// * Make sure that a String that is <code>null</code> is changed to a null -// * string -// * -// * @param text -// * The text to check if it is null or not -// * @return -// */ -// public String checkText(String text) { -// if (text == null) -// return ""; -// else -// return text; -// } -// -// -// // -//// public void newLayout(Composite composite, int colSpan, String text, String style) { -//// GridData data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); -//// data.horizontalSpan = colSpan; -//// if (style.equalsIgnoreCase(VALUE)) { -//// StyledText styledText = new StyledText(composite, SWT.MULTI | SWT.READ_ONLY); -//// styledText.setFont(textFont); -//// styledText.setText(checkText(text)); -//// styledText.setBackground(background); -//// data.horizontalIndent = HORZ_INDENT; -//// -//// styledText.setLayoutData(data); -//// styledText.addSelectionListener(new SelectionAdapter() { -//// -//// @Override -//// public void widgetSelected(SelectionEvent e) { -//// StyledText c = (StyledText) e.widget; -//// if (c != null && c.getSelectionCount() > 0) { -//// if (currentSelectedText != null) { -//// if (!c.equals(currentSelectedText)) { -//// currentSelectedText.setSelectionRange(0, 0); -//// } -//// } -//// } -//// currentSelectedText = c; -//// } -//// }); -//// -//// styledText.setMenu(contextMenuManager.createContextMenu(styledText)); -//// -//// styledText.setEditable(false); -//// -//// if (styledText.getText().trim().length() > 0) { -//// texts.add(index, styledText); -//// index++; -//// addTextListeners(styledText); -//// } -//// } else if (style.equalsIgnoreCase(PROPERTY)) { -//// StyledText styledText = new StyledText(composite, SWT.MULTI | SWT.READ_ONLY); -//// styledText.setFont(textFont); -//// styledText.setText(checkText(text)); -//// styledText.setBackground(background); -//// data.horizontalIndent = HORZ_INDENT; -//// styledText.setLayoutData(data); -//// StyleRange sr = new StyleRange( -//// styledText.getOffsetAtLine(0), -//// text.length(), -//// foreground, -//// background, -//// SWT.BOLD); -//// styledText.setStyleRange(sr); -//// styledText.setEnabled(false); -//// styledText.setMenu(contextMenuManager.createContextMenu(styledText)); -//// } else { -//// Composite generalTitleGroup = new Composite(composite, SWT.NONE); -//// generalTitleGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); -// generalTitleGroup.setLayoutData(data); -// GridLayout generalTitleLayout = new GridLayout(); -// generalTitleLayout.numColumns = 2; -// generalTitleLayout.marginWidth = 0; -// generalTitleLayout.marginHeight = 9; -// generalTitleGroup.setLayout(generalTitleLayout); -// generalTitleGroup.setBackground(background); -// -// Label image = new Label(generalTitleGroup, SWT.NONE); -// image.setBackground(background); -// image.setImage( -// WorkbenchImages.getImage(IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_ITEM)); -// GridData gd = new GridData(GridData.FILL_VERTICAL); -// gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING; -// image.setLayoutData(gd); -// StyledText generalTitleText = new StyledText(generalTitleGroup, SWT.MULTI | SWT.READ_ONLY); -// generalTitleText.setText(checkText(text)); -// generalTitleText.setBackground(background); -// StyleRange sr = new StyleRange( -// generalTitleText.getOffsetAtLine(0), -// text.length(), -// foreground, -// background, -// SWT.BOLD); -// generalTitleText.setStyleRange(sr); -// generalTitleText.setEditable(false); -// -// generalTitleText.addSelectionListener(new SelectionAdapter() { -// -// @Override -// public void widgetSelected(SelectionEvent e) { -// StyledText c = (StyledText) e.widget; -// if (c != null && c.getSelectionCount() > 0) { -// if (currentSelectedText != null) { -// if (!c.equals(currentSelectedText)) { -// currentSelectedText.setSelectionRange(0, 0); -// } -// } -// } -// currentSelectedText = c; -// } -// }); -// -// // create context menu -// generalTitleGroup.setMenu(contextMenuManager.createContextMenu(generalTitleGroup)); -// generalTitleText.setMenu(contextMenuManager.createContextMenu(generalTitleText)); -// image.setMenu(contextMenuManager.createContextMenu(image)); -// } -// } - -// private Composite createTitleArea(Composite parent) { - // -// // Get the background color for the title area -// display = parent.getDisplay(); -// Color background = JFaceColors.getBannerBackground(display); -// Color foreground = JFaceColors.getBannerForeground(display); -// -// // Create the title area which will contain -// // a title, message, and image. -// Composite titleArea = new Composite(parent, SWT.NO_FOCUS); -// GridLayout layout = new GridLayout(); -// layout.marginHeight = 0; -// layout.marginWidth = 0; -// layout.verticalSpacing = 0; -// layout.horizontalSpacing = 0; -// layout.numColumns = 2; -// titleArea.setLayout(layout); -// titleArea.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); -// titleArea.setBackground(background); -// -// // Message label -// titleLabel = new CLabel(titleArea, SWT.LEFT); -// JFaceColors.setColors(titleLabel, foreground, background); -// titleLabel.setFont(titleFont); -// final IPropertyChangeListener fontListener = new IPropertyChangeListener() { -// public void propertyChange(PropertyChangeEvent event) { -// if (JFaceResources.HEADER_FONT.equals(event.getProperty())) { -// titleLabel.setFont(titleFont); -// } -// } -// }; -// titleLabel.addDisposeListener(new DisposeListener() { -// public void widgetDisposed(DisposeEvent event) { -// JFaceResources.getFontRegistry().removeListener(fontListener); -// } -// }); -// JFaceResources.getFontRegistry().addListener(fontListener); -// GridData gd = new GridData(GridData.FILL_BOTH); -// titleLabel.setLayoutData(gd); - // -// // Title image -// Label titleImage = new Label(titleArea, SWT.LEFT); -// titleImage.setBackground(background); -// titleImage.setImage( -// WorkbenchImages.getImage( -// IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_BANNER)); -// gd = new GridData(); -// gd.horizontalAlignment = GridData.END; -// titleImage.setLayoutData(gd); -// return titleArea; -// } - // -// private Composite createInfoArea(Composite parent) { -// // Create the title area which will contain a title, message, and image. -// scrolledComposite = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL); -// scrolledComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); -// infoArea = new Composite(this.scrolledComposite, SWT.NONE); -// scrolledComposite.setMinSize(infoArea.computeSize(SWT.DEFAULT, SWT.DEFAULT)); - // -// contextMenuManager = new MenuManager("#TaskSummaryEditor"); -// contextMenuManager.setRemoveAllWhenShown(true); -// contextMenuManager.addMenuListener(new IMenuListener() { -// public void menuAboutToShow(IMenuManager manager) { -// manager.add(cutAction); -// manager.add(copyAction); -// manager.add(pasteAction); -// manager.add(new Separator()); -// manager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); -// if (currentSelectedText == null || -// currentSelectedText.getSelectionText().length() == 0) { -// copyAction.setEnabled(false); -// } -// else { -// copyAction.setEnabled(true); -// } -// } -// }); -// getSite().registerContextMenu( -// "#TaskSummaryEditor", -// contextMenuManager, -// getSite().getSelectionProvider()); - // -// displayArtifact(infoArea); -// this.scrolledComposite.setContent(infoArea); -// Point p = infoArea.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); -// this.scrolledComposite.setMinHeight(p.y); -// this.scrolledComposite.setMinWidth(p.x); -// this.scrolledComposite.setExpandHorizontal(true); -// this.scrolledComposite.setExpandVertical(true); - // -// // Add the focus listener to the scrolled composite -// scrolledComposite.addMouseListener(new MouseAdapter() { -// -// @Override -// public void mouseUp(MouseEvent e) { -// if (!texts.isEmpty()) { -// StyledText target = texts.get(0); -// target.setFocus(); -// } else { -// scrolledComposite.setFocus(); -// } -// } -// }); - // -// scrolledComposite.addControlListener(new ControlListener() { -// public void controlMoved(ControlEvent e) { -// // don't care if a control is moved -// } -// public void controlResized(ControlEvent e) { -// scrolledComposite.getVerticalBar().setIncrement(scrollIncrement); -// scrolledComposite.getHorizontalBar().setIncrement(scrollIncrement); -// scrollVertPageIncrement = scrolledComposite.getClientArea().height; -// scrollHorzPageIncrement = scrolledComposite.getClientArea().width; -// scrolledComposite.getVerticalBar().setPageIncrement(scrollVertPageIncrement); -// scrolledComposite.getHorizontalBar().setPageIncrement(scrollHorzPageIncrement); -// } -// }); -// return infoArea; -// } -} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/ClearContextAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/ClearContextAction.java deleted file mode 100644 index a22ab1538..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/ClearContextAction.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ - -package org.eclipse.mylar.tasks.ui.actions; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.BugzillaHit; -import org.eclipse.mylar.tasks.BugzillaTask; -import org.eclipse.mylar.tasks.ITask; -import org.eclipse.mylar.tasks.Task; -import org.eclipse.mylar.tasks.ui.views.TaskListView; -import org.eclipse.mylar.ui.MylarImages; - -/** - * @author Mik Kersten and Ken Sueda - */ -public class ClearContextAction extends Action { - - public static final String ID = "org.eclipse.mylar.tasks.actions.context.clear"; - - private final TaskListView view; - - public ClearContextAction(TaskListView view) { - this.view = view; - setText("Clear Task Context"); - setToolTipText("Clear Task Context"); - setId(ID); - setImageDescriptor(MylarImages.ERASE_TASKSCAPE); - } - @Override - public void run() { - MylarPlugin.getDefault().actionObserved(this); - Object selectedObject = ((IStructuredSelection)this.view.getViewer().getSelection()).getFirstElement(); - if (selectedObject != null && selectedObject instanceof ITask) { - MylarPlugin.getTaskscapeManager().taskDeleted(((ITask)selectedObject).getHandle(), ((Task)selectedObject).getPath()); - this.view.getViewer().refresh(); - } else if (selectedObject != null && selectedObject instanceof BugzillaHit) { - BugzillaTask task = ((BugzillaHit)selectedObject).getAssociatedTask(); - if(task != null){ - MylarPlugin.getTaskscapeManager().taskDeleted(task.getHandle(), task.getPath()); - } - this.view.getViewer().refresh(); - } - } -}
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/CreateBugzillaQueryCategoryAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/CreateBugzillaQueryCategoryAction.java deleted file mode 100644 index 1faac748a..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/CreateBugzillaQueryCategoryAction.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ - -package org.eclipse.mylar.tasks.ui.actions; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.BugzillaQueryCategory; -import org.eclipse.mylar.tasks.MylarTasksPlugin; -import org.eclipse.mylar.tasks.ui.views.BugzillaQueryDialog; -import org.eclipse.mylar.tasks.ui.views.TaskListView; -import org.eclipse.mylar.ui.MylarImages; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.WorkspaceModifyOperation; -import org.eclipse.ui.progress.IProgressService; - -/** - * @author Mik Kersten and Ken Sueda - */ -public class CreateBugzillaQueryCategoryAction extends Action { - - public static final String ID = "org.eclipse.mylar.tasks.actions.create.bug.query"; - - private final TaskListView view; - - public CreateBugzillaQueryCategoryAction(TaskListView view) { - this.view = view; - setText("Add Bugzilla Query"); - setToolTipText("Add Bugzilla Query"); - setId(ID); - setImageDescriptor(MylarImages.CATEGORY_QUERY_NEW); - } - - @Override - public void run() { - - // ask the user for the query string and a name - MylarPlugin.getDefault().actionObserved(this); - BugzillaQueryDialog sqd = new BugzillaQueryDialog(Display.getCurrent().getActiveShell()); - if(sqd.open() == Dialog.OK){ - final BugzillaQueryCategory queryCategory = new BugzillaQueryCategory(sqd.getName(), sqd.getUrl()); - - MylarTasksPlugin.getTaskListManager().getTaskList().addCategory(queryCategory); - WorkspaceModifyOperation op = new WorkspaceModifyOperation() { - protected void execute(IProgressMonitor monitor) throws CoreException { - queryCategory.refreshBugs(); - } - }; - - IProgressService service = PlatformUI.getWorkbench().getProgressService(); - try { - service.run(true, true, op); - } catch (Exception e) { - MylarPlugin.log(e, "There was a problem executing the query refresh"); - } - this.view.getViewer().refresh(); - } - } -}
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/CreateBugzillaTaskAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/CreateBugzillaTaskAction.java deleted file mode 100644 index 8005d4a1c..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/CreateBugzillaTaskAction.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ - -package org.eclipse.mylar.tasks.ui.actions; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.BugzillaTask; -import org.eclipse.mylar.tasks.ITask; -import org.eclipse.mylar.tasks.MylarTasksPlugin; -import org.eclipse.mylar.tasks.TaskCategory; -import org.eclipse.mylar.tasks.ui.views.TaskListView; -import org.eclipse.mylar.ui.MylarImages; - -/** - * @author Mik Kersten and Ken Sueda - */ -public class CreateBugzillaTaskAction extends Action { - - public static final String ID = "org.eclipse.mylar.tasks.actions.create.bug"; - - private final TaskListView view; - - public CreateBugzillaTaskAction(TaskListView view) { - this.view = view; - setText("Add Bugzilla Report"); - setToolTipText("Add Bugzilla Report"); - setId(ID); - setImageDescriptor(MylarImages.TASK_BUGZILLA_NEW); - } - - @Override - public void run() { - MylarPlugin.getDefault().actionObserved(this); - String bugIdString = this.view.getBugIdFromUser(); - int bugId = -1; - try { - if (bugIdString != null) { - bugId = Integer.parseInt(bugIdString); - } else { - return; - } - } catch (NumberFormatException nfe) { - this.view.showMessage("Please enter a valid report number"); - return; - } - - // XXX we don't care about duplicates since we use a registrey - // Check the existing tasks to see if the id is used already. - // This is to prevent the creation of mutliple Bugzilla tasks - // for the same Bugzilla report. -// boolean doesIdExistAlready = false; -// doesIdExistAlready = lookForId("Bugzilla-" + bugId); -// if (doesIdExistAlready) { -// showMessage("A Bugzilla task with ID Bugzilla-" + bugId + " already exists."); -// return; -// } - - ITask newTask = new BugzillaTask("Bugzilla-"+bugId, "<bugzilla info>"); - Object selectedObject = ((IStructuredSelection)this.view.getViewer().getSelection()).getFirstElement(); - if (selectedObject instanceof TaskCategory){ - ((TaskCategory)selectedObject).addTask(newTask); - } else { - MylarTasksPlugin.getTaskListManager().getTaskList().addRootTask(newTask); - } - this.view.getViewer().refresh(); - } -}
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/CreateCategoryAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/CreateCategoryAction.java deleted file mode 100644 index 7c56fe2f1..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/CreateCategoryAction.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ - -package org.eclipse.mylar.tasks.ui.actions; - -import org.eclipse.jface.action.Action; -import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.MylarTasksPlugin; -import org.eclipse.mylar.tasks.TaskCategory; -import org.eclipse.mylar.tasks.ui.views.TaskListView; -import org.eclipse.mylar.ui.MylarImages; - -/** - * @author Mik Kersten and Ken Sueda - */ -public class CreateCategoryAction extends Action { - - public static final String ID = "org.eclipse.mylar.tasks.actions.create.category"; - - private final TaskListView view; - - public CreateCategoryAction(TaskListView view) { - this.view = view; - setText("Add Category"); - setToolTipText("Add Category"); - setId(ID); - setImageDescriptor(MylarImages.CATEGORY_NEW); - } - - @Override - public void run() { - MylarPlugin.getDefault().actionObserved(this); - String label = this.view.getLabelNameFromUser("Category"); - if(label == null) return; - TaskCategory cat = new TaskCategory(label); - MylarTasksPlugin.getTaskListManager().getTaskList().addCategory(cat); - this.view.getViewer().refresh(); - } -}
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/CreateTaskAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/CreateTaskAction.java deleted file mode 100644 index eb849dcbd..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/CreateTaskAction.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ - -package org.eclipse.mylar.tasks.ui.actions; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.MylarTasksPlugin; -import org.eclipse.mylar.tasks.Task; -import org.eclipse.mylar.tasks.TaskCategory; -import org.eclipse.mylar.tasks.ui.views.TaskListView; -import org.eclipse.mylar.ui.MylarImages; -import org.eclipse.mylar.ui.MylarUiPlugin; - -/** - * @author Mik Kersten and Ken Sueda - */ -public class CreateTaskAction extends Action { - - public static final String ID = "org.eclipse.mylar.tasks.actions.create.task"; - - private final TaskListView view; - - public CreateTaskAction(TaskListView view) { - this.view = view; - setText("Add Task"); - setToolTipText("Add Task"); - setId(ID); - setImageDescriptor(MylarImages.TASK_NEW); - } - - @Override - public void run() { - MylarPlugin.getDefault().actionObserved(this); - String label = this.view.getLabelNameFromUser("task"); - if(label == null) return; - Task newTask = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), label); - - Object selectedObject = ((IStructuredSelection)this.view.getViewer().getSelection()).getFirstElement(); - if (selectedObject instanceof TaskCategory){ - newTask.setCategory((TaskCategory)selectedObject); - ((TaskCategory)selectedObject).addTask(newTask); - } -// else if (selectedObject instanceof Task) { -// ITask t = (ITask) selectedObject; -// newTask.setParent(t); -// t.addSubTask(newTask); -// } - else { - MylarTasksPlugin.getTaskListManager().getTaskList().addRootTask(newTask); - } - MylarUiPlugin.getDefault().setHighlighterMapping( - newTask.getHandle(), - MylarUiPlugin.getDefault().getDefaultHighlighter().getName()); - this.view.getViewer().refresh(); - } -}
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/DeleteAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/DeleteAction.java deleted file mode 100644 index 56248b78e..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/DeleteAction.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ - -package org.eclipse.mylar.tasks.ui.actions; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.BugzillaQueryCategory; -import org.eclipse.mylar.tasks.ITask; -import org.eclipse.mylar.tasks.MylarTasksPlugin; -import org.eclipse.mylar.tasks.Task; -import org.eclipse.mylar.tasks.TaskCategory; -import org.eclipse.mylar.tasks.ui.views.TaskListView; -import org.eclipse.mylar.ui.MylarImages; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.internal.Workbench; - -/** - * @author Mik Kersten and Ken Sueda - */ -public class DeleteAction extends Action { - - public static final String ID = "org.eclipse.mylar.tasks.actions.delete"; - - private final TaskListView view; - - public DeleteAction(TaskListView view) { - this.view = view; - setText("Delete"); - setId(ID); - setImageDescriptor(MylarImages.REMOVE); - } - - @Override - public void run() { - MylarPlugin.getDefault().actionObserved(this); - boolean deleteConfirmed = MessageDialog.openQuestion( - Workbench.getInstance().getActiveWorkbenchWindow().getShell(), - "Confirm delete", - "Delete selected item?"); - if (!deleteConfirmed) { - return; - } else { - Object selectedObject = ((IStructuredSelection)this.view.getViewer().getSelection()).getFirstElement(); - if (selectedObject instanceof Task) { - MylarTasksPlugin.getTaskListManager().deleteTask((Task)selectedObject); - MylarPlugin.getTaskscapeManager().taskDeleted(((Task)selectedObject).getHandle(), ((Task)selectedObject).getPath()); - IWorkbenchPage page = MylarTasksPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage(); - - // if we couldn't get the page, get out of here - if (page == null) - return; - try{ - this.view.closeTaskEditors((ITask)selectedObject, page); - }catch(Exception e){ - MylarPlugin.log(e, " deletion failed"); - } - } else if (selectedObject instanceof TaskCategory) { - TaskCategory cat = (TaskCategory) selectedObject; - for (ITask task : cat.getChildren()) { - MylarPlugin.getTaskscapeManager().taskDeleted(task.getHandle(), task.getPath()); - IWorkbenchPage page = MylarTasksPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage(); - if (page == null) - return; - try{ - this.view.closeTaskEditors(task, page); - }catch(Exception e){ - MylarPlugin.log(e, " deletion failed"); - } - } - MylarTasksPlugin.getTaskListManager().deleteCategory((TaskCategory)selectedObject); - } else if (selectedObject instanceof BugzillaQueryCategory) { - BugzillaQueryCategory cat = (BugzillaQueryCategory) selectedObject; - MylarTasksPlugin.getTaskListManager().deleteCategory(cat); - } - } - this.view.getViewer().refresh(); - } -}
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/FilterCompletedTasksAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/FilterCompletedTasksAction.java deleted file mode 100644 index 598764552..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/FilterCompletedTasksAction.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ - -package org.eclipse.mylar.tasks.ui.actions; - -import org.eclipse.jface.action.Action; -import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.MylarTasksPlugin; -import org.eclipse.mylar.tasks.ui.views.TaskListView; -import org.eclipse.mylar.ui.MylarImages; - -/** - * @author Mik Kersten and Ken Sueda - */ -public class FilterCompletedTasksAction extends Action { - - public static final String ID = "org.eclipse.mylar.tasks.actions.filter.completed"; - - private final TaskListView view; - - public FilterCompletedTasksAction(TaskListView view) { - this.view = view; - setText("Filter Completed Tasks"); - setToolTipText("Filter Completed Tasks"); - setId(ID); - setImageDescriptor(MylarImages.FILTER_COMPLETE); - setChecked(MylarTasksPlugin.getDefault().isFilterCompleteMode()); - } - @Override - public void run() { - MylarPlugin.getDefault().actionObserved(this); - MylarTasksPlugin.getDefault().setFilterCompleteMode(isChecked()); - if (isChecked()) { - this.view.getViewer().addFilter(this.view.getCompleteFilter()); -// filterInCompleteTask.setChecked(false); -// viewer.removeFilter(inCompleteFilter); - } else { - this.view.getViewer().removeFilter(this.view.getCompleteFilter()); - } - this.view.getViewer().refresh(); - } -}
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/MarkTaskCompleteAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/MarkTaskCompleteAction.java deleted file mode 100644 index 19dc18e6d..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/MarkTaskCompleteAction.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ - -package org.eclipse.mylar.tasks.ui.actions; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.Task; -import org.eclipse.mylar.tasks.ui.views.TaskListView; -import org.eclipse.mylar.ui.MylarImages; - -/** - * @author Mik Kersten and Ken Sueda - */ -public class MarkTaskCompleteAction extends Action { - - public static final String ID = "org.eclipse.mylar.tasks.actions.mark.completed"; - - private final TaskListView view; - - public MarkTaskCompleteAction(TaskListView view) { - this.view = view; - setText("Mark Complete"); - setToolTipText("Mark Complete"); - setId(ID); - setImageDescriptor(MylarImages.TASK_COMPLETE); - } - @Override - public void run() { - MylarPlugin.getDefault().actionObserved(this); - Object selectedObject = ((IStructuredSelection)this.view.getViewer().getSelection()).getFirstElement(); - if (selectedObject instanceof Task){ - ((Task)selectedObject).setCompleted(true); - - } - this.view.getViewer().refresh(); - } -}
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/MarkTaskIncompleteAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/MarkTaskIncompleteAction.java deleted file mode 100644 index ac0562c54..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/MarkTaskIncompleteAction.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ - -package org.eclipse.mylar.tasks.ui.actions; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.Task; -import org.eclipse.mylar.tasks.ui.views.TaskListView; -import org.eclipse.mylar.ui.MylarImages; - -/** - * @author Mik Kersten and Ken Sueda - */ -public class MarkTaskIncompleteAction extends Action { - - public static final String ID = "org.eclipse.mylar.tasks.actions.mark.incomplete"; - - private final TaskListView view; - - public MarkTaskIncompleteAction(TaskListView view) { - this.view = view; - setText("Mark Incomplete"); - setToolTipText("Mark Incomplete"); - setId(ID); - setImageDescriptor(MylarImages.TASK_INCOMPLETE); - } - @Override - public void run() { - MylarPlugin.getDefault().actionObserved(this); - Object selectedObject = ((IStructuredSelection)this.view.getViewer().getSelection()).getFirstElement(); - if (selectedObject instanceof Task){ - ((Task)selectedObject).setCompleted(false); - } - this.view.getViewer().refresh(); - } -}
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/MoveTaskToRootAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/MoveTaskToRootAction.java deleted file mode 100644 index cb49a7c8e..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/MoveTaskToRootAction.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ - -package org.eclipse.mylar.tasks.ui.actions; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.mylar.tasks.ITask; -import org.eclipse.mylar.tasks.MylarTasksPlugin; -import org.eclipse.mylar.tasks.TaskCategory; -import org.eclipse.mylar.tasks.ui.views.TaskListView; - -/** - * @author Mik Kersten and Ken Sueda - */ -public class MoveTaskToRootAction extends Action { - - public static final String ID = "org.eclipse.mylar.tasks.actions.move.toroot"; - - private final TaskListView view; - public MoveTaskToRootAction(TaskListView view) { - this.view = view; - setText("Move Task to Root"); - setToolTipText("Move Task to Root"); - setId(ID); - } - @Override - public void run() { - ISelection selection = this.view.getViewer().getSelection(); - Object obj = ((IStructuredSelection)selection).getFirstElement(); - if (obj instanceof ITask) { - ITask t = (ITask) obj; - TaskCategory cat = t.getCategory(); - if (cat != null) { - cat.removeTask(t); - t.setCategory(null); - t.setParent(null); - MylarTasksPlugin.getTaskListManager().getTaskList().addRootTask(t); - this.view.getViewer().refresh(); - } else if (t.getParent() != null) { - t.getParent().removeSubTask(t); - t.setParent(null); - MylarTasksPlugin.getTaskListManager().getTaskList().addRootTask(t); - this.view.getViewer().refresh(); - } - } - } -}
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/OpenTaskEditorAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/OpenTaskEditorAction.java deleted file mode 100644 index 1d891c504..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/OpenTaskEditorAction.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ - -package org.eclipse.mylar.tasks.ui.actions; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.mylar.bugzilla.ui.BugzillaOpenStructure; -import org.eclipse.mylar.bugzilla.ui.ViewBugzillaAction; -import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.BugzillaHit; -import org.eclipse.mylar.tasks.BugzillaQueryCategory; -import org.eclipse.mylar.tasks.ITask; -import org.eclipse.mylar.tasks.ui.views.BugzillaQueryDialog; -import org.eclipse.mylar.tasks.ui.views.TaskListView; -import org.eclipse.swt.widgets.Display; - -/** - * @author Mik Kersten and Ken Sueda - */ -public class OpenTaskEditorAction extends Action { - - public static final String ID = "org.eclipse.mylar.tasks.actions.open"; - - private final TaskListView view; - - /** - * @param view - */ - public OpenTaskEditorAction(TaskListView view) { - this.view = view; - setId(ID); - } - - @Override - public void run() { - MylarPlugin.getDefault().actionObserved(this); - ISelection selection = this.view.getViewer().getSelection(); - Object obj = ((IStructuredSelection)selection).getFirstElement(); - if (obj instanceof ITask) { - ((ITask)obj).openTaskInEditor(); - } else if (obj instanceof BugzillaQueryCategory){ - - BugzillaQueryDialog sqd = new BugzillaQueryDialog(Display.getCurrent().getActiveShell()); - if(sqd.open() == Dialog.OK){ - BugzillaQueryCategory queryCategory = (BugzillaQueryCategory)obj; - queryCategory.setDescription(sqd.getName()); - queryCategory.setUrl(sqd.getUrl()); - - queryCategory.refreshBugs(); - this.view.getViewer().refresh(); - } - } else if(obj instanceof BugzillaHit){ - BugzillaHit hit = (BugzillaHit)obj; - if(hit.isTask()){ - hit.getAssociatedTask().openTaskInEditor(); - } else { - BugzillaOpenStructure open = new BugzillaOpenStructure(((BugzillaHit)obj).getServerName(), ((BugzillaHit)obj).getID(),-1); - List<BugzillaOpenStructure> selectedBugs = new ArrayList<BugzillaOpenStructure>(); - selectedBugs.add(open); - ViewBugzillaAction viewBugs = new ViewBugzillaAction("Display bugs in editor", selectedBugs); - viewBugs.schedule(); - } - } - this.view.getViewer().refresh(obj); - } -}
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/RefreshBugzillaReportsAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/RefreshBugzillaReportsAction.java deleted file mode 100644 index 794519baf..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/RefreshBugzillaReportsAction.java +++ /dev/null @@ -1,127 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ - -package org.eclipse.mylar.tasks.ui.actions; - -import java.lang.reflect.InvocationTargetException; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.action.Action; -import org.eclipse.mylar.bugzilla.core.BugReport; -import org.eclipse.mylar.bugzilla.core.BugzillaRepository; -import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.AbstractCategory; -import org.eclipse.mylar.tasks.BugzillaQueryCategory; -import org.eclipse.mylar.tasks.BugzillaTask; -import org.eclipse.mylar.tasks.ITask; -import org.eclipse.mylar.tasks.MylarTasksPlugin; -import org.eclipse.mylar.tasks.TaskCategory; -import org.eclipse.mylar.tasks.bugzilla.BugzillaStructureBridge; -import org.eclipse.mylar.tasks.ui.views.TaskListView; -import org.eclipse.mylar.ui.MylarImages; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.WorkspaceModifyOperation; -import org.eclipse.ui.progress.IProgressService; - -/** - * @author Mik Kersten and Ken Sueda - */ -public class RefreshBugzillaReportsAction extends Action { - - public static final String ID = "org.eclipse.mylar.tasks.actions.refresh.bugdb"; - - private final TaskListView view; - - public RefreshBugzillaReportsAction(TaskListView view) { - this.view = view; - setText("Refresh Bugzilla reports"); - setToolTipText("Refresh Bugzilla reports"); - setId(ID); - setImageDescriptor(MylarImages.TASK_BUG_REFRESH); - } - - @Override - public void run() { - MylarPlugin.getDefault().actionObserved(this); - // TODO background? - // perform the update in an operation so that we get a progress monitor - // update the structure bridge cache with the reference provider cached bugs - WorkspaceModifyOperation op = new WorkspaceModifyOperation() { - protected void execute(IProgressMonitor monitor) throws CoreException { - - List<ITask> tasks = MylarTasksPlugin.getTaskListManager().getTaskList().getRootTasks(); - - for (ITask task : tasks) { - if (task instanceof BugzillaTask) { - ((BugzillaTask)task).refresh(); - } - } - for (AbstractCategory cat : MylarTasksPlugin.getTaskListManager().getTaskList().getCategories()) { - if (cat instanceof TaskCategory) { - for (ITask task : ((TaskCategory)cat).getChildren()) { - if (task instanceof BugzillaTask) { - ((BugzillaTask)task).refresh(); - } - } - RefreshBugzillaReportsAction.this.view.refreshChildren(((TaskCategory)cat).getChildren()); - } - else if (cat instanceof BugzillaQueryCategory) { - final BugzillaQueryCategory bqc = (BugzillaQueryCategory) cat; - PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { - - public void run() { - bqc.refreshBugs(); - RefreshBugzillaReportsAction.this.view.getViewer().refresh(); - } - }); - } - } - - // clear the caches - Set<String> cachedHandles = new HashSet<String>(); - cachedHandles.addAll(MylarTasksPlugin.getDefault().getStructureBridge().getCachedHandles()); - cachedHandles.addAll(MylarTasksPlugin.getReferenceProvider().getCachedHandles()); - MylarTasksPlugin.getDefault().getStructureBridge().clearCache(); - MylarTasksPlugin.getReferenceProvider().clearCachedReports(); - - BugzillaStructureBridge bridge = MylarTasksPlugin.getDefault().getStructureBridge(); - monitor.beginTask("Downloading Bugs" , cachedHandles.size()); - for(String key: cachedHandles){ - try { - String [] parts = key.split(";"); - final int id = Integer.parseInt(parts[1]); - BugReport bug = BugzillaRepository.getInstance().getCurrentBug(id); - if(bug != null) - bridge.cache(key, bug); - }catch(Exception e){} - - monitor.worked(1); - } - monitor.done(); - RefreshBugzillaReportsAction.this.view.getViewer().refresh(); - } - }; - - // Use the progess service to execute the runnable - IProgressService service = PlatformUI.getWorkbench().getProgressService(); - try { - service.run(true, false, op); - } catch (InvocationTargetException e) { - // Operation was canceled - } catch (InterruptedException e) { - // Handle the wrapped exception - } - } -}
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/TaskActivateAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/TaskActivateAction.java deleted file mode 100644 index 2de5f7c82..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/TaskActivateAction.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ - -package org.eclipse.mylar.tasks.ui.actions; - -import org.eclipse.jface.action.Action; -import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.ITask; -import org.eclipse.mylar.tasks.MylarTasksPlugin; - -/** - * @author Mik Kersten and Ken Sueda - */ -public class TaskActivateAction extends Action { - - public static final String ID = "org.eclipse.mylar.tasks.actions.context.activate"; - - private ITask task; - - public TaskActivateAction(ITask task) { - this.task = task; - setId(ID); - } - - public void run() { - MylarPlugin.getDefault().actionObserved(this); - MylarTasksPlugin.getTaskListManager().activateTask(task); - } -}
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/TaskDeactivateAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/TaskDeactivateAction.java deleted file mode 100644 index 6d1c4e021..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/TaskDeactivateAction.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ - -package org.eclipse.mylar.tasks.ui.actions; - -import org.eclipse.jface.action.Action; -import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.ITask; -import org.eclipse.mylar.tasks.MylarTasksPlugin; - -/** - * @author Mik Kersten and Ken Sueda - */ -public class TaskDeactivateAction extends Action { - - public static final String ID = "org.eclipse.mylar.tasks.actions.context.deactivate"; - - private ITask task; - - public TaskDeactivateAction(ITask task) { - this.task = task; - setId(ID); - } - - public void run() { - MylarPlugin.getDefault().actionObserved(this); - MylarTasksPlugin.getTaskListManager().deactivateTask(task); - } -}
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/ToggleIntersectionModeAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/ToggleIntersectionModeAction.java deleted file mode 100644 index f80225f4d..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/ToggleIntersectionModeAction.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on May 11, 2005 - */ -package org.eclipse.mylar.tasks.ui.actions; - -import org.eclipse.jface.action.Action; -import org.eclipse.mylar.core.ITaskscapeListener; -import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.ui.MylarImages; -import org.eclipse.mylar.ui.MylarUiPlugin; - -/** - * @author Mik Kersten - */ -public class ToggleIntersectionModeAction extends Action { - - public ToggleIntersectionModeAction() { - super(); - setText("Intersect Tasskscapes"); - setToolTipText("Intersect Taskscapes"); - setImageDescriptor(MylarImages.MYLAR); - setActionDefinitionId("org.eclipse.mylar.ui.interest.intersection"); - setChecked(MylarUiPlugin.getDefault().isGlobalFilteringEnabled()); - } - - @Override - public void run() { - setChecked(!isChecked()); - MylarUiPlugin.getDefault().setIntersectionMode(isChecked()); - MylarPlugin.getTaskscapeManager().notifyActivePresentationSettingsChange(ITaskscapeListener.UpdateKind.HIGHLIGHTER); - } -} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/BugzillaQueryDialog.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/BugzillaQueryDialog.java deleted file mode 100644 index 3ce476e95..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/BugzillaQueryDialog.java +++ /dev/null @@ -1,225 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -package org.eclipse.mylar.tasks.ui.views; - -import java.io.UnsupportedEncodingException; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.IInputValidator; -import org.eclipse.jface.dialogs.InputDialog; -import org.eclipse.jface.operation.IRunnableContext; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.mylar.bugzilla.saveQuery.GetQueryDialog; -import org.eclipse.mylar.bugzilla.saveQuery.SaveQueryDialog; -import org.eclipse.mylar.bugzilla.search.BugzillaSearchPage; -import org.eclipse.search.ui.ISearchPageContainer; -import org.eclipse.swt.SWT; -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.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkingSet; - -/** - * @author Shawn Minto - */ -public class BugzillaQueryDialog extends Dialog { - - private String url; - private String name; - private BugzillaSearchOptionPage searchOptionPage; - - public BugzillaQueryDialog(Shell parentShell) { - super(parentShell); - searchOptionPage = new BugzillaSearchOptionPage(); - - } - - public String getName() { - return name; - } - - public String getUrl() { - return url; - } - - @Override - protected Control createContents(Composite parent) { - searchOptionPage.createControl(parent); - searchOptionPage.setVisible(true); // called to initialize the values - return super.createContents(parent); - } - - @Override - protected void okPressed(){ - url = searchOptionPage.getSearchURL(); - if(url == null || url.equals("")){ - /* - * Should never get here. Every implementation of the Java platform is required - * to support the standard charset "UTF-8" - */ - return; - } - InputDialog getNameDialog = new InputDialog(Display.getCurrent().getActiveShell(), "Bugzilla Query Category Name", "Please enter a name for the bugzilla query category","", new IInputValidator(){ - - public String isValid(String newText) { - if(newText != null && !newText.equals("")){ - return null; - } else { - return "You must enter a name for the category"; - } - } - - }); - getNameDialog.setBlockOnOpen(true); - if(getNameDialog.open() == InputDialog.OK){ - name = getNameDialog.getValue(); - - super.okPressed(); - } else { - super.cancelPressed(); - } - } - - private class BugzillaSearchOptionPage extends BugzillaSearchPage{ - - public BugzillaSearchOptionPage(){ - scontainer = new ISearchPageContainer(){ - public ISelection getSelection() { - // TODO Auto-generated method stub - return null; - } - - public IRunnableContext getRunnableContext() { - return null; - } - - public void setPerformActionEnabled(boolean state) { - Button ok = BugzillaQueryDialog.this.getButton(Dialog.OK); - if(ok != null) - ok.setEnabled(state); - } - - public int getSelectedScope() { - return 0; - } - - public void setSelectedScope(int scope) {} - - public boolean hasValidScope() { - return true; - } - - public IWorkingSet[] getSelectedWorkingSets() { - return null; - } - - public void setSelectedWorkingSets(IWorkingSet[] workingSets) {} - }; - } - - public String getSearchURL() { - try{ - if(rememberedQuery){ - return getQueryURL(new StringBuffer(input.getQueryParameters(selIndex))); - } else { - return getQueryURL(getQueryParameters()); - } - } catch (UnsupportedEncodingException e){ - /* - * Do nothing. Every implementation of the Java platform is required - * to support the standard charset "UTF-8" - */ - } - return ""; - } - - @Override - protected Control createSaveQuery(Composite control) { - GridLayout layout; - GridData gd; - - Group group = new Group(control, SWT.NONE); - layout = new GridLayout(3, false); - group.setLayout(layout); - group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - gd = new GridData(GridData.BEGINNING | GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); - gd.horizontalSpan = 2; - group.setLayoutData(gd); - - loadButton = new Button(group, SWT.PUSH | SWT.LEFT); - loadButton.setText("Saved Queries..."); - loadButton.addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent event) { - GetQueryDialog qd = new GetQueryDialog(getShell(), - "Saved Queries", input){ - @Override - protected void createButtonsForButtonBar(Composite parent) { - super.createButtonsForButtonBar(parent); - Button okButton = super.getButton(IDialogConstants.OK_ID); - if(okButton != null) - okButton.setText("Select"); - } - }; - - if (qd.open() == InputDialog.OK) { - selIndex = qd.getSelected(); - if (selIndex != -1) { - rememberedQuery = true; - } - } else { - rememberedQuery = false; - } - } - }); - loadButton.setEnabled(true); - loadButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); - - saveButton = new Button(group, SWT.PUSH | SWT.LEFT); - saveButton.setText("Remember..."); - saveButton.addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent event) { - SaveQueryDialog qd = new SaveQueryDialog(getShell(), - "Remember Query"); - if (qd.open() == InputDialog.OK) { - String qName = qd.getText(); - if (qName != null && qName.compareTo("") != 0) { - try { - input.add(getQueryParameters().toString(), qName, summaryPattern.getText()); - } - catch (UnsupportedEncodingException e) { - /* - * Do nothing. Every implementation of the Java platform is required - * to support the standard charset "UTF-8" - */ - } - } - } - } - }); - saveButton.setEnabled(true); - saveButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); - - return group; - } - } -} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListLabelProvider.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListLabelProvider.java deleted file mode 100644 index c3af29a34..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListLabelProvider.java +++ /dev/null @@ -1,235 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on Feb 18, 2005 - */ -package org.eclipse.mylar.tasks.ui.views; - -import org.eclipse.jface.viewers.IColorProvider; -import org.eclipse.jface.viewers.IFontProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.mylar.tasks.AbstractCategory; -import org.eclipse.mylar.tasks.BugzillaHit; -import org.eclipse.mylar.tasks.BugzillaQueryCategory; -import org.eclipse.mylar.tasks.BugzillaTask; -import org.eclipse.mylar.tasks.ITask; -import org.eclipse.mylar.tasks.ITaskListElement; -import org.eclipse.mylar.tasks.TaskCategory; -import org.eclipse.mylar.ui.MylarUiPlugin; -import org.eclipse.mylar.ui.internal.UiUtil; -import org.eclipse.mylar.ui.internal.views.Highlighter; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Image; - -/** - * @author Mik Kersten - */ -public class TaskListLabelProvider extends LabelProvider implements ITableLabelProvider, IColorProvider, IFontProvider { - - private Color backgroundColor = null; - - public String getColumnText(Object obj, int columnIndex) { - if (obj instanceof ITaskListElement) { - ITaskListElement element = (ITaskListElement) obj; - switch (columnIndex) { - case 0: - return ""; - case 1: - return ""; - case 2: - return element.getPriority(); - case 3: - return element.getDescription(true); - case 4: - return element.getHandle(); - } - } - System.out.println("Not TaskListElement"); - return ""; - } - - public Font getFont(Object element) { - if (element instanceof ITask) { - ITask task = (ITask)element; - if (task.isActive()) return UiUtil.BOLD; - if (task.isCompleted()) return UiUtil.ITALIC; - for (ITask child : task.getChildren()) { - if (child.isActive()) - return UiUtil.BOLD; - } - } else if (element instanceof TaskCategory) { - TaskCategory cat = (TaskCategory) element; - for (ITask child : cat.getChildren()) { - if (child.isActive()) - return UiUtil.BOLD; - } - }else if (element instanceof BugzillaHit) { - BugzillaHit hit = (BugzillaHit)element; - BugzillaTask task = hit.getAssociatedTask(); - if(task != null){ - if (task.isActive()) return UiUtil.BOLD; - if (task.isCompleted()) return UiUtil.ITALIC; - } - } else if (element instanceof BugzillaQueryCategory) { - BugzillaQueryCategory cat = (BugzillaQueryCategory) element; - for (ITaskListElement child : cat.getHits()) { - if (child instanceof BugzillaHit){ - BugzillaHit hit = (BugzillaHit) child; - BugzillaTask task = hit.getAssociatedTask(); - if(task != null && task.isActive()){ - return UiUtil.BOLD; - } - } - } - } - return null; - } - - public Image getColumnImage(Object element, int columnIndex) { - - if (! (element instanceof ITaskListElement)) { - return null; - } - if (columnIndex == 0) { - return ((ITaskListElement)element).getStatusIcon(); - } else if (columnIndex == 1) { - return ((ITaskListElement)element).getIcon(); - } else { - return null; - } - } - - public Color getBackground(Object element) { - if (element instanceof ITask) { - ITask task = (ITask)element; - Highlighter highlighter = MylarUiPlugin.getDefault().getHighlighterForTaskId("" + task.getHandle()); - if (highlighter != null) return highlighter.getHighlightColor(); - } else if (element instanceof BugzillaHit) { - BugzillaHit hit = (BugzillaHit)element; - BugzillaTask task = hit.getAssociatedTask(); - if(task != null){ - Highlighter highlighter = MylarUiPlugin.getDefault().getHighlighterForTaskId("" + task.getHandle()); - if (highlighter != null) return highlighter.getHighlightColor(); - } - }else if (element instanceof AbstractCategory) { - return backgroundColor; - } - return null; - } - - public Color getForeground(Object element) { - if (element instanceof ITask) { - ITask task = (ITask)element; - if (task.isCompleted()) return MylarUiPlugin.getDefault().getColorMap().GRAY_VERY_LIGHT; - } else if (element instanceof BugzillaHit) { - BugzillaHit hit = (BugzillaHit)element; - BugzillaTask task = hit.getAssociatedTask(); - if (task != null && task.isCompleted()) return MylarUiPlugin.getDefault().getColorMap().GRAY_VERY_LIGHT; - } - return null; - } - - public void setBackgroundColor(Color c) { - this.backgroundColor = c; - } -} - -//public Image getColumnImage(Object obj, int columnIndex) { -//if (obj instanceof Highlighter) { -// Highlighter h = (Highlighter) obj; -// switch (columnIndex) { -// case 1: -// HighlighterImageDescriptor des; -// if (h.isGradient()) { -// des = new HighlighterImageDescriptor(h.getBase(), h -// .getLandmarkColor()); -// } else { -// des = new HighlighterImageDescriptor(h -// .getLandmarkColor(), h.getLandmarkColor()); -// } -// return des.getImage(); -// default: -// break; -// } -// } -// return null; -//} - -//public Color getBackground(Object element) { -//if (element instanceof Task) { -// Task task = (Task)element; -// if (task.isActive()) { -// Highlighter highlighter = MylarUiPlugin.getDefault().getHighlighterForTaskId(((Task)task).getId()); -// if (highlighter != null) { -// return highlighter.getHighlightColor(); -// } else { -// return null; -// } -// } -//} -//return null; -//} - -//public class TaskListLabelProvider extends LabelProvider implements IColorProvider, IFontProvider { -// -// public String getText(Object obj) { -// if (obj instanceof BugzillaTask) { -// String desc = MylarTasksPlugin.getDefault().getBugzillaProvider().getBugzillaDescription( -// ((BugzillaTask)obj)); -// return desc; -// } else if (obj instanceof Task) { -// Task task = (Task)obj; -// return task.toString();// + " [" + task.getId() + "]"; -// } else { -// return obj.toString(); -// } -// } -// -// public Image getImage(Object obj) { -// String imageKey = ISharedImages.IMG_OBJ_ELEMENT; -// if (obj instanceof BugzillaTask) { -// return MylarImages.getImage(MylarImages.TASK_BUGZILLA); -// } else if (obj instanceof Task) { -// return MylarImages.getImage(MylarImages.TASK); -// } else { -// return null; -// } -// } -// public Color getForeground(Object element) { -// return null; -// } -// -// public Color getBackground(Object element) { -// if (element instanceof Task) { -// Task task = (Task)element; -// if (task.isActive()) { -// Highlighter highlighter = MylarUiPlugin.getDefault().getHighlighterForTaskId(((Task)task).getId()); -// if (highlighter != null) { -// return highlighter.getHighlightColor(); -// } else { -// return null; -// } -// } -// } -// return null; -// } -// -// public Font getFont(Object element) { -// if (element instanceof Task) { -// if (((Task)element).isActive()) { -// return UiUtil.BOLD; -// } -// } -// return null; -// } -//}
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListView.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListView.java deleted file mode 100644 index 02b0857f6..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListView.java +++ /dev/null @@ -1,1307 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ - -package org.eclipse.mylar.tasks.ui.views; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; - -import javax.security.auth.login.LoginException; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.ActionContributionItem; -import org.eclipse.jface.action.IMenuCreator; -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.dialogs.InputDialog; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.CheckboxCellEditor; -import org.eclipse.jface.viewers.ComboBoxCellEditor; -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.ICellModifier; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TextCellEditor; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerDropAdapter; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.jface.window.Window; -import org.eclipse.mylar.core.ITaskscapeListener; -import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.dt.MylarWebRef; -import org.eclipse.mylar.tasks.AbstractCategory; -import org.eclipse.mylar.tasks.BugzillaHit; -import org.eclipse.mylar.tasks.BugzillaQueryCategory; -import org.eclipse.mylar.tasks.BugzillaTask; -import org.eclipse.mylar.tasks.ITask; -import org.eclipse.mylar.tasks.ITaskListElement; -import org.eclipse.mylar.tasks.MylarTasksPlugin; -import org.eclipse.mylar.tasks.Task; -import org.eclipse.mylar.tasks.TaskCategory; -import org.eclipse.mylar.tasks.MylarTasksPlugin.Priority_Level; -import org.eclipse.mylar.tasks.ui.BugzillaTaskEditorInput; -import org.eclipse.mylar.tasks.ui.TaskEditorInput; -import org.eclipse.mylar.tasks.ui.actions.ClearContextAction; -import org.eclipse.mylar.tasks.ui.actions.CreateBugzillaQueryCategoryAction; -import org.eclipse.mylar.tasks.ui.actions.CreateBugzillaTaskAction; -import org.eclipse.mylar.tasks.ui.actions.CreateCategoryAction; -import org.eclipse.mylar.tasks.ui.actions.CreateTaskAction; -import org.eclipse.mylar.tasks.ui.actions.DeleteAction; -import org.eclipse.mylar.tasks.ui.actions.FilterCompletedTasksAction; -import org.eclipse.mylar.tasks.ui.actions.MarkTaskCompleteAction; -import org.eclipse.mylar.tasks.ui.actions.MarkTaskIncompleteAction; -import org.eclipse.mylar.tasks.ui.actions.MoveTaskToRootAction; -import org.eclipse.mylar.tasks.ui.actions.OpenTaskEditorAction; -import org.eclipse.mylar.tasks.ui.actions.RefreshBugzillaReportsAction; -import org.eclipse.mylar.tasks.ui.actions.TaskActivateAction; -import org.eclipse.mylar.tasks.ui.actions.TaskDeactivateAction; -import org.eclipse.mylar.ui.MylarImages; -import org.eclipse.mylar.ui.MylarUiPlugin; -import org.eclipse.mylar.ui.internal.views.Highlighter; -import org.eclipse.mylar.ui.internal.views.HighlighterImageDescriptor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.dnd.DND; -import org.eclipse.swt.dnd.DragSourceEvent; -import org.eclipse.swt.dnd.DragSourceListener; -import org.eclipse.swt.dnd.TextTransfer; -import org.eclipse.swt.dnd.Transfer; -import org.eclipse.swt.dnd.TransferData; -import org.eclipse.swt.events.ControlEvent; -import org.eclipse.swt.events.ControlListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.Text; -import org.eclipse.swt.widgets.TreeColumn; -import org.eclipse.swt.widgets.TreeItem; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IMemento; -import org.eclipse.ui.IViewSite; -import org.eclipse.ui.IWorkbenchActionConstants; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.internal.Workbench; -import org.eclipse.ui.part.DrillDownAdapter; -import org.eclipse.ui.part.ViewPart; - -/** - * @author Mik Kersten - */ -public class TaskListView extends ViewPart { - - private static TaskListView INSTANCE; - - TreeViewer viewer; - private DrillDownAdapter drillDownAdapter; - - private RefreshBugzillaReportsAction refresh; - private CreateTaskAction createTask; - private CreateCategoryAction createCategory; - private CreateBugzillaQueryCategoryAction createBugzillaQueryCategory; - private CreateBugzillaTaskAction createBugzillaTask; -// private RenameAction rename; - private DeleteAction delete; - private OpenTaskEditorAction doubleClickAction; - private ClearContextAction clearSelectedTaskscapeAction; - - //private Action toggleIntersectionModeAction = new ToggleIntersectionModeAction(); -// private Action toggleFilteringAction = new ToggleGlobalInterestFilteringAction(); - - private MarkTaskCompleteAction completeTask; - private MarkTaskIncompleteAction incompleteTask; - private FilterCompletedTasksAction filterCompleteTask; -// private FilterIncompleteTasksAction filterInCompleteTask; - private PriorityDropDownAction filterOnPriority; - private Action moveTaskToRoot; - private PriorityFilter priorityFilter = new PriorityFilter(); - - protected String[] columnNames = new String[] { "", ".", "!", "Description", "handle" }; - protected int[] columnWidths = new int[] { 70, 20, 20, 120, 70 }; - private TreeColumn[] columns; - private IMemento taskListMemento; - public static final String columnWidthIdentifier = "org.eclipse.mylar.tasks.ui.views.tasklist.columnwidth"; - public static final String tableSortIdentifier = "org.eclipse.mylar.tasks.ui.views.tasklist.sortIndex"; - private int sortIndex = 2; - - private String[] PRIORITY_LEVELS = { "P1", "P2", "P3", "P4", "P5" }; - - private final class PriorityDropDownAction extends Action implements IMenuCreator { - private Menu dropDownMenu = null; - - public PriorityDropDownAction() { - super(); - setText("Display Priorities"); - setToolTipText("Show Tasks with Priority Levels"); - setImageDescriptor(MylarImages.FILTER_PRIORITY); - setMenuCreator(this); - } - - public void dispose() { - if (dropDownMenu != null) { - dropDownMenu.dispose(); - dropDownMenu = null; - } - } - - public Menu getMenu(Control parent) { - if (dropDownMenu != null) { - dropDownMenu.dispose(); - } - dropDownMenu = new Menu(parent); - addActionsToMenu(); - return dropDownMenu; - } - - public Menu getMenu(Menu parent) { - if (dropDownMenu != null) { - dropDownMenu.dispose(); - } - dropDownMenu = new Menu(parent); - addActionsToMenu(); - return dropDownMenu; - } - - public void addActionsToMenu() { - Action P1 = new Action(PRIORITY_LEVELS[0], AS_CHECK_BOX) { - @Override - public void run() { - MylarTasksPlugin.setPriorityLevel(MylarTasksPlugin.Priority_Level.P1, isChecked()); - if (isChecked()) { - priorityFilter.displayPriority(PRIORITY_LEVELS[0]); - } else { - priorityFilter.hidePriority(PRIORITY_LEVELS[0]); - } - viewer.refresh(); - } - }; - P1.setEnabled(true); - P1.setChecked(MylarTasksPlugin.getPriorityLevel(MylarTasksPlugin.Priority_Level.P1)); - P1.setToolTipText(PRIORITY_LEVELS[0]); - ActionContributionItem item= new ActionContributionItem(P1); - item.fill(dropDownMenu, -1); - - Action P2 = new Action(PRIORITY_LEVELS[1], AS_CHECK_BOX) { - @Override - public void run() { - MylarTasksPlugin.setPriorityLevel(MylarTasksPlugin.Priority_Level.P2, isChecked()); - if (isChecked()) { - priorityFilter.displayPriority(PRIORITY_LEVELS[1]); - } else { - priorityFilter.hidePriority(PRIORITY_LEVELS[1]); - } - viewer.refresh(); - } - }; - P2.setEnabled(true); - P2.setChecked(MylarTasksPlugin.getPriorityLevel(MylarTasksPlugin.Priority_Level.P2)); - P2.setToolTipText(PRIORITY_LEVELS[1]); - item= new ActionContributionItem(P2); - item.fill(dropDownMenu, -1); - - Action P3 = new Action(PRIORITY_LEVELS[2], AS_CHECK_BOX) { - @Override - public void run() { - MylarTasksPlugin.setPriorityLevel(MylarTasksPlugin.Priority_Level.P3, isChecked()); - if (isChecked()) { - priorityFilter.displayPriority(PRIORITY_LEVELS[2]); - } else { - priorityFilter.hidePriority(PRIORITY_LEVELS[2]); - } - viewer.refresh(); - } - }; - P3.setEnabled(true); - P3.setChecked(MylarTasksPlugin.getPriorityLevel(MylarTasksPlugin.Priority_Level.P3)); - P3.setToolTipText(PRIORITY_LEVELS[2]); - item= new ActionContributionItem(P3); - item.fill(dropDownMenu, -1); - - Action P4 = new Action(PRIORITY_LEVELS[3], AS_CHECK_BOX) { - @Override - public void run() { - MylarTasksPlugin.setPriorityLevel(MylarTasksPlugin.Priority_Level.P4, isChecked()); - if (isChecked()) { - priorityFilter.displayPriority(PRIORITY_LEVELS[3]); - } else { - priorityFilter.hidePriority(PRIORITY_LEVELS[3]); - } - viewer.refresh(); - } - }; - P4.setEnabled(true); - P4.setChecked(MylarTasksPlugin.getPriorityLevel(MylarTasksPlugin.Priority_Level.P4)); - P4.setToolTipText(PRIORITY_LEVELS[3]); - item= new ActionContributionItem(P4); - item.fill(dropDownMenu, -1); - - Action P5 = new Action(PRIORITY_LEVELS[4], AS_CHECK_BOX) { - @Override - public void run() { - MylarTasksPlugin.setPriorityLevel(MylarTasksPlugin.Priority_Level.P5, isChecked()); - if (isChecked()) { - priorityFilter.displayPriority(PRIORITY_LEVELS[4]); - } else { - priorityFilter.hidePriority(PRIORITY_LEVELS[4]); - } - viewer.refresh(); - } - }; - P5.setEnabled(true); - P5.setChecked(MylarTasksPlugin.getPriorityLevel(MylarTasksPlugin.Priority_Level.P5)); - P5.setToolTipText(PRIORITY_LEVELS[4]); - item= new ActionContributionItem(P5); - item.fill(dropDownMenu, -1); - } - public void run() { - this.setChecked(isChecked()); - } - } - - private ViewerFilter completeFilter = new ViewerFilter(){ - @Override - public boolean select(Viewer viewer, Object parentElement, Object element) { - if (element instanceof ITask) { - return !((ITask)element).isCompleted(); - } else { - return true; - } - } - }; - - private ViewerFilter inCompleteFilter = new ViewerFilter(){ - @Override - public boolean select(Viewer viewer, Object parentElement, Object element) { - if (element instanceof ITask) { - return ((ITask)element).isCompleted(); - } else { - return true; - } - } - }; - - public class PriorityFilter extends ViewerFilter { - // list of priorities that will be shown in the tasklistview - private List<String> priorities = new ArrayList<String>(); - - public PriorityFilter() { - for (Priority_Level level : MylarTasksPlugin.getPriorityLevels()) { - displayPriority(level.toString()); - } - } - - public void displayPriority(String p) { - if (!priorities.contains(p)) { - priorities.add(p); - } - } - - public void hidePriority(String p) { - priorities.remove(p); - } - @Override - public boolean select(Viewer viewer, Object parentElement, Object element) { - if (element instanceof ITask) { - ITask task = (ITask) element; - if (priorities.size() == PRIORITY_LEVELS.length) { - return true; - } else { - for (String filter : priorities) { - if (task.getPriority().equals(filter)) { - return true; - } - } - return false; - } - } else { - return true; - } - } - - }; - - class TaskListContentProvider implements IStructuredContentProvider, ITreeContentProvider { - public void inputChanged(Viewer v, Object oldInput, Object newInput) { - // don't care if the input changes - } - public void dispose() { - // don't care if we are disposed - } - public Object[] getElements(Object parent) { - if (parent.equals(getViewSite())) { - return MylarTasksPlugin.getTaskListManager().getTaskList().getRoots().toArray(); - } - return getChildren(parent); - } - public Object getParent(Object child) { - if (child instanceof ITask) { - if (((ITask)child).getParent() != null) { - return ((ITask)child).getParent(); - } else { - return ((ITask)child).getCategory(); - } - - } - return null; - } - public Object [] getChildren(Object parent) { - if (parent instanceof TaskCategory) { - return ((TaskCategory)parent).getChildren().toArray(); - } else if (parent instanceof Task) { - return ((Task)parent).getChildren().toArray(); - } else if (parent instanceof BugzillaQueryCategory) { - return ((BugzillaQueryCategory) parent).getHits().toArray(); - } - return new Object[0]; - } - public boolean hasChildren(Object parent) { - if (parent instanceof TaskCategory) { - TaskCategory cat = (TaskCategory)parent; - return cat.getChildren() != null && cat.getChildren().size() > 0; - } else if (parent instanceof Task) { - Task t = (Task) parent; - return t.getChildren() != null && t.getChildren().size() > 0; - } else if (parent instanceof BugzillaQueryCategory) { - BugzillaQueryCategory cat = (BugzillaQueryCategory)parent; - return cat.getHits() != null && cat.getHits().size() > 0; - } - return false; - } - } - - public TaskListView() { - INSTANCE = this; - } - - class TaskListCellModifier implements ICellModifier { - - public boolean canModify(Object element, String property) { - int columnIndex = Arrays.asList(columnNames).indexOf(property); - if (element instanceof ITask) { - ITask task = (ITask) element; - switch (columnIndex) { - case 0: return true; - case 1: return false; - case 2: return !(task instanceof BugzillaTask); - case 3: return !(task instanceof BugzillaTask); - case 4: return false; - } - } else if (element instanceof AbstractCategory) { - switch (columnIndex) { - case 0: - case 1: - case 2: - return false; - case 3: return true; - case 4: return false; - } - } else if (element instanceof BugzillaHit){ - if (columnIndex == 0) { - return true; - }else { - return false; - } - } - return false; - } - - public Object getValue(Object element, String property) { - int columnIndex = Arrays.asList(columnNames).indexOf(property); - if (element instanceof ITask) { - ITask task = (ITask) element; - switch (columnIndex) { - case 0: - return new Boolean(task.isCompleted()); - case 1: - return ""; - case 2: - String priorityString = task.getPriority().substring(1); - return new Integer(priorityString); - case 3: - return task.getLabel(); - case 4: - return task.getHandle(); - } - } else if (element instanceof AbstractCategory) { - AbstractCategory cat = (AbstractCategory) element; - switch (columnIndex) { - case 0: - return new Boolean(false); - case 1: - return ""; - case 2: - return ""; - case 3: - return cat.getDescription(true); - case 4: - return ""; - } - } else if (element instanceof BugzillaHit) { - BugzillaHit hit = (BugzillaHit) element; - ITask task = hit.getAssociatedTask(); - switch (columnIndex) { - case 0: - if(task == null){ - return new Boolean(true); - } else { - return new Boolean(task.isCompleted()); - } - case 1: - return ""; - case 2: - String priorityString = hit.getPriority().substring(1); - return new Integer(priorityString); - case 3: - return hit.getDescription(true); - case 4: - return hit.getHandle(); - } - } - return ""; - } - - public void modify(Object element, String property, Object value) { - int columnIndex = -1; - try { - columnIndex = Arrays.asList(columnNames).indexOf(property); - if (((TreeItem) element).getData() instanceof ITask) { - - final ITask task = (ITask) ((TreeItem) element).getData(); - switch (columnIndex) { - case 0: - if (task.isActive()) { - new TaskDeactivateAction(task).run(); - } else { - new TaskActivateAction(task).run(); - } - viewer.setSelection(null); - break; - case 1: - break; - case 2: - Integer intVal = (Integer) value; - task.setPriority("P" + (intVal + 1)); - viewer.setSelection(null); - break; - case 3: - task.setLabel(((String) value).trim()); - MylarTasksPlugin.getTaskListManager() - .taskPropertyChanged(task, columnNames[3]); - viewer.setSelection(null); - break; - case 4: - break; - } - } else if (((TreeItem) element).getData() instanceof AbstractCategory) { - AbstractCategory cat = (AbstractCategory)((TreeItem) element).getData(); - switch (columnIndex) { - case 0: - viewer.setSelection(null); - break; - case 1: - break; - case 2: - break; - case 3: - cat.setDescription(((String) value).trim()); - viewer.setSelection(null); - break; - case 4: - break; - } - } else if (((TreeItem) element).getData() instanceof BugzillaHit) { - BugzillaHit hit = (BugzillaHit)((TreeItem) element).getData(); - switch (columnIndex) { - case 0: - BugzillaTask task = hit.getAssociatedTask(); - if(task == null){ - task = new BugzillaTask(hit); - hit.setAssociatedTask(task); - MylarTasksPlugin.getTaskListManager().getTaskList().addToBugzillaTaskRegistry(task); - // TODO move the task to a special folder - } - if (task.isActive()) { - MylarTasksPlugin.getTaskListManager() - .deactivateTask(task); - } else { - MylarTasksPlugin.getTaskListManager().activateTask( - task); - } - viewer.setSelection(null); - break; - case 1: - break; - case 2: - break; - case 3: - viewer.setSelection(null); - break; - case 4: - break; - } - } - viewer.refresh(); - } catch (Exception e) { - MylarPlugin.log(e, e.getMessage()); - } - } - } - - private class TaskListTableSorter extends ViewerSorter { - - private String column; - - public TaskListTableSorter(String column) { - super(); - this.column = column; - } - - /** - * compare - invoked when column is selected calls the actual comparison - * method for particular criteria - */ - @Override - public int compare(Viewer compareViewer, Object o1, Object o2) { - if (o1 instanceof AbstractCategory) { - if (o2 instanceof AbstractCategory) { - return 0; - } else { - return -1; - } - } else if(o1 instanceof ITask){ - if (o2 instanceof AbstractCategory) { - return -1; - } else if(o2 instanceof ITask) { - - ITask task1 = (ITask) o1; - ITask task2 = (ITask) o2; - - if (task1.isCompleted()) return 1; - if (task2.isCompleted()) return -1; - if (column == columnNames[1]) { - if (task1 instanceof BugzillaTask && !(task2 instanceof BugzillaTask)) { - return 1; - } else { - return -1; - } - } else if (column == columnNames[2]) { - return task1.getPriority().compareTo(task2.getPriority()); - } else if (column == columnNames[3]) { - return task1.getLabel().compareTo(task2.getLabel()); - } else if (column == columnNames[4]){ - return task1.getPath().compareTo(task2.getPath()); - } else { - return 0; - } - } - } else if(o1 instanceof BugzillaHit && o2 instanceof BugzillaHit){ - BugzillaHit task1 = (BugzillaHit) o1; - BugzillaHit task2 = (BugzillaHit) o2; - - if (column == columnNames[1]) { - return 0; - } else if (column == columnNames[2]) { - return task1.getPriority().compareTo(task2.getPriority()); - } else if (column == columnNames[3]) { - return task1.getDescription(false).compareTo(task2.getDescription(false)); - } else if (column == columnNames[4]){ - return task1.getHandle().compareTo(task2.getHandle()); - } else { - return 0; - } - } else{ - return 0; - } - return 0; - } - } - - @Override - public void init(IViewSite site,IMemento memento) throws PartInitException { - init(site); - this.taskListMemento = memento; - } - - @Override - public void saveState(IMemento memento) { - IMemento colMemento = memento.createChild(columnWidthIdentifier); - - for (int i = 0; i < columnWidths.length; i++) { - IMemento m = colMemento.createChild("col"+i); - m.putInteger("width", columnWidths[i]); - } - - IMemento sorter = memento.createChild(tableSortIdentifier); - IMemento m = sorter.createChild("sorter"); - m.putInteger("sortIndex", sortIndex); - } - - private void restoreState() { - if (taskListMemento == null) - return; - IMemento taskListWidth = taskListMemento.getChild(columnWidthIdentifier); - if (taskListWidth != null) { - for (int i = 0; i < columnWidths.length; i++) { - IMemento m = taskListWidth.getChild("col"+i); - if (m != null) { - int width = m.getInteger("width"); - columnWidths[i] = width; - columns[i].setWidth(width); - } - } - } - IMemento sorterMemento = taskListMemento.getChild(tableSortIdentifier); - if (sorterMemento != null) { - IMemento m = sorterMemento.getChild("sorter"); - if (m != null) { - sortIndex = m.getInteger("sortIndex"); - } else { - sortIndex = 2; - } - } else { - sortIndex = 2; // default priority - } - viewer.setSorter(new TaskListTableSorter(columnNames[sortIndex])); - viewer.addFilter(priorityFilter); - if(MylarTasksPlugin.getDefault().isFilterInCompleteMode()) viewer.addFilter(inCompleteFilter); - if(MylarTasksPlugin.getDefault().isFilterCompleteMode()) viewer.addFilter(completeFilter); - viewer.refresh(); - } - - /** - * This is a callback that will allow us - * to create the viewer and initialize it. - */ - @Override - public void createPartControl(Composite parent) { - viewer = new TreeViewer(parent, SWT.VERTICAL | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION); - viewer.getTree().setHeaderVisible(true); - viewer.getTree().setLinesVisible(true); - viewer.setColumnProperties(columnNames); - viewer.setUseHashlookup(true); - - columns = new TreeColumn[columnNames.length]; - for (int i = 0; i < columnNames.length; i++) { - columns[i] = new TreeColumn(viewer.getTree(), 0); // SWT.LEFT - columns[i].setText(columnNames[i]); - columns[i].setWidth(columnWidths[i]); - final int index = i; - columns[i].addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent e) { - sortIndex = index; - viewer.setSorter(new TaskListTableSorter(columnNames[sortIndex])); - } - }); - columns[i].addControlListener(new ControlListener () { - public void controlResized(ControlEvent e) { - for (int j = 0; j < columnWidths.length; j++) { - if (columns[j].equals(e.getSource())) { - columnWidths[j] = columns[j].getWidth(); - } - } - } - public void controlMoved(ControlEvent e) { - // don't care if the control is moved - } - }); - } - - CellEditor[] editors = new CellEditor[columnNames.length]; - TextCellEditor textEditor = new TextCellEditor(viewer.getTree()); - ((Text) textEditor.getControl()).setOrientation(SWT.LEFT_TO_RIGHT); - editors[0] = new CheckboxCellEditor(); - editors[1] = textEditor; - editors[2] = new ComboBoxCellEditor(viewer.getTree(), PRIORITY_LEVELS, SWT.READ_ONLY); - editors[3] = textEditor; - viewer.setCellEditors(editors); - viewer.setCellModifier(new TaskListCellModifier()); - viewer.setSorter(new TaskListTableSorter(columnNames[sortIndex])); - - drillDownAdapter = new DrillDownAdapter(viewer); - viewer.setContentProvider(new TaskListContentProvider()); - TaskListLabelProvider lp = new TaskListLabelProvider(); - lp.setBackgroundColor(parent.getBackground()); - viewer.setLabelProvider(lp); - viewer.setInput(getViewSite()); - - makeActions(); - hookContextMenu(); - hookDoubleClickAction(); - contributeToActionBars(); - ToolTipHandler toolTipHandler = new ToolTipHandler(viewer.getControl().getShell()); - toolTipHandler.activateHoverHelp(viewer.getControl()); - - initDragAndDrop(parent); - expandToActiveTasks(); - restoreState(); - } - - @MylarWebRef(name="Drag and drop article", url="http://www.eclipse.org/articles/Article-Workbench-DND/drag_drop.html") - private void initDragAndDrop(Composite parent) { - Transfer[] types = new Transfer[] { TextTransfer.getInstance() }; - - viewer.addDragSupport(DND.DROP_MOVE, types, new DragSourceListener() { - - public void dragStart(DragSourceEvent event) { - if (((StructuredSelection) viewer.getSelection()).isEmpty()) { - event.doit = false; - } - } - - public void dragSetData(DragSourceEvent event) { - StructuredSelection selection = (StructuredSelection) viewer.getSelection(); - if (!selection.isEmpty()) { - event.data = "" + ((ITask) selection.getFirstElement()).getHandle(); - } else { - event.data = "null"; - } - } - - public void dragFinished(DragSourceEvent event) { - // don't care if the drag is done - } - }); - - viewer.addDropSupport(DND.DROP_MOVE, types, new ViewerDropAdapter(viewer) { - { - setFeedbackEnabled(false); - } - - @Override - public boolean performDrop(Object data) { - Object selectedObject = ((IStructuredSelection) ((TreeViewer) getViewer()) - .getSelection()).getFirstElement(); - if (selectedObject instanceof ITask) { - ITask source = (ITask) selectedObject; - if (source.getCategory() != null) { - source.getCategory().removeTask(source); - } else if (source.getParent() != null) { - source.getParent().removeSubTask(source); - } else { - MylarTasksPlugin.getTaskListManager().getTaskList().getRootTasks().remove(source); - } - - if (getCurrentTarget() instanceof TaskCategory) { - ((TaskCategory) getCurrentTarget()).addTask(source); - source.setCategory((TaskCategory)getCurrentTarget()); - } else if (getCurrentTarget() instanceof ITask) { - ITask target = (ITask) getCurrentTarget(); - source.setCategory(null); - target.addSubTask(source); - source.setParent(target); - } - viewer.setSelection(null); - viewer.refresh(); - return true; - } - return false; - } - - @Override - public boolean validateDrop(Object targetObject, int operation, - TransferData transferType) { - Object selectedObject = ((IStructuredSelection) ((TreeViewer) getViewer()) - .getSelection()).getFirstElement(); - if (selectedObject instanceof ITask) { - if (getCurrentTarget() != null && - (getCurrentTarget() instanceof ITask || getCurrentTarget() instanceof TaskCategory)) { - return true; - } else { - return false; - } - } - return TextTransfer.getInstance().isSupportedType(transferType); - } - - }); - } - - private void expandToActiveTasks() { - List<ITask> activeTasks = MylarTasksPlugin.getTaskListManager().getTaskList().getActiveTasks(); - for (ITask t : activeTasks) { - viewer.expandToLevel(t, 0); - } - } - - private void hookContextMenu() { - MenuManager menuMgr = new MenuManager("#PopupMenu"); - menuMgr.setRemoveAllWhenShown(true); - menuMgr.addMenuListener(new IMenuListener() { - public void menuAboutToShow(IMenuManager manager) { - TaskListView.this.fillContextMenu(manager); - } - }); - Menu menu = menuMgr.createContextMenu(viewer.getControl()); - viewer.getControl().setMenu(menu); - getSite().registerContextMenu(menuMgr, viewer); - } - - private void contributeToActionBars() { - IActionBars bars = getViewSite().getActionBars(); - fillLocalPullDown(bars.getMenuManager()); - fillLocalToolBar(bars.getToolBarManager()); - } - - private void fillLocalPullDown(IMenuManager manager) { - drillDownAdapter.addNavigationActions(manager); -// manager.add(createCategory); -// manager.add(new Separator()); -// manager.add(createTask); - } - - void fillContextMenu(IMenuManager manager) { - manager.add(completeTask); - manager.add(incompleteTask); -// manager.add(new Separator()); - manager.add(createTask); - manager.add(createBugzillaTask); -// manager.add(rename); - manager.add(delete); - manager.add(clearSelectedTaskscapeAction); - manager.add(moveTaskToRoot); - manager.add(new Separator()); - MenuManager subMenuManager = new MenuManager("Choose Highlighter"); - final Object selectedObject = ((IStructuredSelection)viewer.getSelection()).getFirstElement(); - for (Iterator<Highlighter> it = MylarUiPlugin.getDefault().getHighlighters().iterator(); it.hasNext();) { - final Highlighter highlighter = it.next(); - if (selectedObject instanceof Task){ - Action action = new Action() { - - @Override - public void run() { - Task task = (Task)selectedObject; - MylarUiPlugin.getDefault().setHighlighterMapping(task.getHandle(), highlighter.getName()); - TaskListView.this.viewer.refresh(); - MylarPlugin.getTaskscapeManager().notifyPostPresentationSettingsChange(ITaskscapeListener.UpdateKind.HIGHLIGHTER); -// taskscapeComponent.getTableViewer().refresh(); - } - }; - if (highlighter.isGradient()) { - action.setImageDescriptor(new HighlighterImageDescriptor(highlighter.getBase(), highlighter.getLandmarkColor())); - } else { - action.setImageDescriptor(new HighlighterImageDescriptor(highlighter.getLandmarkColor(), highlighter.getLandmarkColor())); - } - action.setText(highlighter.toString()); - subMenuManager.add(action); - } else { -// showMessage("Select task before choosing highlighter"); - } - } - manager.add(subMenuManager); - manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); - updateActionEnablement(selectedObject); - } - - private void updateActionEnablement(Object sel){ - if(sel != null && sel instanceof ITaskListElement){ - if(sel instanceof BugzillaHit){ - BugzillaTask task = ((BugzillaHit)sel).getAssociatedTask(); - if(task == null){ - clearSelectedTaskscapeAction.setEnabled(false); - } else { - clearSelectedTaskscapeAction.setEnabled(true); - } - completeTask.setEnabled(false); - incompleteTask.setEnabled(false); - moveTaskToRoot.setEnabled(false); - delete.setEnabled(false); - } else if(sel instanceof BugzillaTask){ - completeTask.setEnabled(false); - incompleteTask.setEnabled(false); - } else if(sel instanceof AbstractCategory){ - clearSelectedTaskscapeAction.setEnabled(false); - moveTaskToRoot.setEnabled(false); - completeTask.setEnabled(false); - incompleteTask.setEnabled(false); - } else { - delete.setEnabled(true); - moveTaskToRoot.setEnabled(true); - completeTask.setEnabled(true); - incompleteTask.setEnabled(true); - clearSelectedTaskscapeAction.setEnabled(true); - } - - }else { - delete.setEnabled(true); - moveTaskToRoot.setEnabled(true); - clearSelectedTaskscapeAction.setEnabled(false); - } - } - - private void fillLocalToolBar(IToolBarManager manager) { - manager.add(createTask); - manager.add(createCategory); - manager.add(new Separator()); - manager.add(createBugzillaTask); - - manager.add(createBugzillaQueryCategory); - manager.add(refresh); - manager.add(new Separator()); - manager.add(filterCompleteTask); -// manager.add(filterInCompleteTask); - manager.add(filterOnPriority); - - } - - /** - * @see org.eclipse.pde.internal.ui.view.HistoryDropDownAction - * - */ - private void makeActions() { - refresh = new RefreshBugzillaReportsAction(this); - createTask = new CreateTaskAction(this); - createCategory = new CreateCategoryAction(this); - createBugzillaQueryCategory = new CreateBugzillaQueryCategoryAction(this); - createBugzillaTask = new CreateBugzillaTaskAction(this); - delete = new DeleteAction(this); - completeTask = new MarkTaskCompleteAction(this); - incompleteTask = new MarkTaskIncompleteAction(this); -// rename = new RenameAction(); - clearSelectedTaskscapeAction = new ClearContextAction(this); - moveTaskToRoot = new MoveTaskToRootAction(this); - doubleClickAction = new OpenTaskEditorAction(this); - filterCompleteTask = new FilterCompletedTasksAction(this); -// filterInCompleteTask = new FilterIncompleteTasksAction(); - filterOnPriority = new PriorityDropDownAction(); - } - - /** - * Recursive function that checks for the occurrence of a certain task id. - * All children of the supplied node will be checked. - * - * @param task - * The <code>ITask</code> object that is to be searched. - * @param taskId - * The id that is being searched for. - * @return <code>true</code> if the id was found in the node or any of its - * children - */ - protected boolean lookForId(String taskId) { - for (ITask task : MylarTasksPlugin.getTaskListManager().getTaskList().getRootTasks()) { - if (task.getHandle().equals(taskId)) { - return true; - } - } - for (TaskCategory cat : MylarTasksPlugin.getTaskListManager().getTaskList().getTaskCategories()) { - for (ITask task : cat.getChildren()) { - if (task.getHandle().equals(taskId)) { - return true; - } - } - } - return false; - } - - public void closeTaskEditors(ITask task, IWorkbenchPage page) throws LoginException, IOException{ - IEditorInput input = null; - if (task instanceof BugzillaTask) { - input = new BugzillaTaskEditorInput((BugzillaTask)task); - } else if (task instanceof Task) { - input = new TaskEditorInput((Task) task); - } - IEditorPart editor = page.findEditor(input); - - if (editor != null) { - page.closeEditor(editor, false); - } - } - - public void refreshChildren(List<ITask> children) { - if (children != null) { - for (ITask child : children) { - if (child instanceof BugzillaTask) { - ((BugzillaTask)child).refresh(); - } - } - } - } - - private void hookDoubleClickAction() { - viewer.addDoubleClickListener(new IDoubleClickListener() { - public void doubleClick(DoubleClickEvent event) { - doubleClickAction.run(); - } - }); - } - - public void showMessage(String message) { - MessageDialog.openInformation( - viewer.getControl().getShell(), - "Tasklist Message", - message); - } - - /** - * Passing the focus request to the viewer's control. - */ - @Override - public void setFocus() { - viewer.getControl().setFocus(); - //TODO: foo - } - - public String getBugIdFromUser() { - InputDialog dialog = new InputDialog( - Workbench.getInstance().getActiveWorkbenchWindow().getShell(), - "Enter Bugzilla ID", - "Enter the Bugzilla ID: ", - "", - null); - int dialogResult = dialog.open(); - if (dialogResult == Window.OK) { - return dialog.getValue(); - } else { - return null; - } - } - - public String getLabelNameFromUser(String kind) { - - InputDialog dialog = new InputDialog( - Workbench.getInstance().getActiveWorkbenchWindow().getShell(), - "Enter name", - "Enter a name for the " + kind + ": ", - "", - null); - int dialogResult = dialog.open(); - if (dialogResult == Window.OK) { - return dialog.getValue(); - } else { - return null; - } - } - - public void notifyTaskDataChanged(ITask task) { - if (viewer.getTree() != null && !viewer.getTree().isDisposed()) { - viewer.refresh(); - } - } - - public static TaskListView getDefault() { - return INSTANCE; - } - - public TreeViewer getViewer() { - return viewer; - } - - public ViewerFilter getCompleteFilter() { - return completeFilter; - } - - public ViewerFilter getInCompleteFilter() { - return inCompleteFilter; - } - - public PriorityFilter getPriorityFilter() { - return priorityFilter; - } -} - -//TextTransfer textTransfer = TextTransfer.getInstance(); -//DropTarget target = new DropTarget(viewer.getTree(), DND.DROP_MOVE); -//target.setTransfer(new Transfer[] { textTransfer }); -//target.addDropListener(new TaskListDropTargetListener(parent, null, textTransfer, true)); -// -//DragSource source = new DragSource(viewer.getTree(), DND.DROP_MOVE); -//source.setTransfer(types); - -//source.addDragListener(new DragSourceListener() { -//public void dragStart(DragSourceEvent event) { -// if (((StructuredSelection)viewer.getSelection()).isEmpty()) { -// event.doit = false; -// } -//} -//public void dragSetData(DragSourceEvent event) { -// StructuredSelection selection = (StructuredSelection) viewer.getSelection(); -// if (!selection.isEmpty()) { -// event.data = "" + ((ITask)selection.getFirstElement()).getId(); -// } else { -// event.data = "null"; -// } -//} -// -//public void dragFinished(DragSourceEvent event) { } -//}); - - -// public boolean getServerStatus() { -// return serverStatus; -// } -// -// /** -// * Sets whether or not we could connect to the Bugzilla server. If -// * necessary, the corresponding label in the view is updated. -// * -// * @param canRead -// * <code>true</code> if the Bugzilla server could be connected -// * to -// */ -// public void setServerStatus(boolean canRead) { -// if (serverStatus != canRead) { -// serverStatus = canRead; -// updateServerStatusLabel(); -// } -// } -// -// private void updateServerStatusLabel() { -// if (serverStatusLabel.isDisposed()) { -// return; -// } -// if (serverStatus) { -// serverStatusLabel.setText(CAN_READ_LABEL); -// } -// else { -// serverStatusLabel.setText(CANNOT_READ_LABEL); -// } -// } -// -// private class ServerPingJob extends Job { -// private boolean shouldCheckAgain = true; -// private int counter = 0; -// -// public ServerPingJob(String name) { -// super(name); -// } -// -// public void stopPinging() { -// shouldCheckAgain = false; -// } -// -// protected IStatus run(IProgressMonitor monitor) { -// while (shouldCheckAgain) { -// try { -// final boolean canReadFromServer = TaskListView.checkServer(); -// Workbench.getInstance().getDisplay().asyncExec(new Runnable() { -// public void run() { -// setServerStatus(canReadFromServer); -// } -// }); -// Thread.sleep(10000/*MylarPreferencePage.getServerPing()*5000*/); -// } catch (InterruptedException e) { -// break; -// } -// } -// return new Status(IStatus.OK, MylarPlugin.IDENTIFIER, IStatus.OK, "", null); -// } -// } -// -// /** -// * @return <code>true</code> if we could connect to the Bugzilla server -// */ -// public static boolean checkServer() { -// boolean canRead = true; -// BufferedReader in = null; -// -// // Call this function to intialize the Bugzilla url that the repository -// // is using. -// BugzillaRepository.getInstance(); -// -// try { -// // connect to the bugzilla server -// SSLContext ctx = SSLContext.getInstance("TLS"); -// javax.net.ssl.TrustManager[] tm = new javax.net.ssl.TrustManager[]{new TrustAll()}; -// ctx.init(null, tm, null); -// HttpsURLConnection.setDefaultSSLSocketFactory(ctx.getSocketFactory()); -// String urlText = ""; -// -// // use the usename and password to get into bugzilla if we have it -// if(BugzillaPreferences.getUserName() != null && !BugzillaPreferences.getUserName().equals("") && BugzillaPreferences.getPassword() != null && !BugzillaPreferences.getPassword().equals("")) -// { -// /* -// * The UnsupportedEncodingException exception for -// * URLEncoder.encode() should not be thrown, since every -// * implementation of the Java platform is required to support -// * the standard charset "UTF-8" -// */ -// try { -// urlText += "?GoAheadAndLogIn=1&Bugzilla_login=" + URLEncoder.encode(BugzillaPreferences.getUserName(), "UTF-8") + "&Bugzilla_password=" + URLEncoder.encode(BugzillaPreferences.getPassword(), "UTF-8"); -// } catch (UnsupportedEncodingException e) { } -// } -// -// URL url = new URL(BugzillaRepository.getURL() + "/enter_bug.cgi" + urlText); -// -// // create a new input stream for getting the bug -// in = new BufferedReader(new InputStreamReader(url.openStream())); -// } -// catch (Exception e) { -// // If there was an IOException, then there was a problem connecting. -// // If there was some other exception, then it was a problem not -// // related to the server. -// if (e instanceof IOException) { -// canRead = false; -// } -// } -// -// // Close the BufferedReader if we opened one. -// try { -// if (in != null) -// in.close(); -// } catch(IOException e) {} -// -// return canRead; -// } -// -// public void dispose() { -// if (serverPingJob != null) { -// serverPingJob.stopPinging(); -// } -// super.dispose(); -// } - -// source.addDragListener(new DragSourceListener() { -// -// public void dragStart(DragSourceEvent event) { -// if (((StructuredSelection) viewer.getSelection()).getFirstElement() == null) { -// event.doit = false; -// } -// } -// -// public void dragSetData(DragSourceEvent event) { -// StructuredSelection selection = (StructuredSelection)viewer.getSelection(); -// ITask task = (ITask) selection.getFirstElement(); -// if (task != null) { -// event.data = "" + task.getId(); -// } else { -// event.data = " "; -// } -// } -// -// public void dragFinished(DragSourceEvent event) { -// StructuredSelection selection = (StructuredSelection)viewer.getSelection(); -// if (selection.isEmpty()) { -// return; -// } else { -// ITask task = (ITask) selection.getFirstElement(); -// -// System.err.println(">>> got task: " + task + ">> " + ); -// -// } -// } -// -// }); diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/ToolTipHandler.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/ToolTipHandler.java deleted file mode 100644 index 5efee7529..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/ToolTipHandler.java +++ /dev/null @@ -1,240 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/** - * Copied from newsgroup, forwarded from Make Technologies - */ - -package org.eclipse.mylar.tasks.ui.views; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.mylar.tasks.ITask; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.layout.*; -import org.eclipse.swt.widgets.*; - - -public class ToolTipHandler { - private Shell parentShell; - - private Shell tipShell; - - private Label tipLabelImage; - private Label tipLabelText; - - private Widget tipWidget; // widget this tooltip is hovering over - - protected Point tipPosition; // the position being hovered over on the - // Entire display - - protected Point widgetPosition; // the position hovered over in the Widget; - - /** - * Creates a new tooltip handler - * - * @param parent - * the parent Shell - */ - public ToolTipHandler(Shell parent) { - final Display display = parent.getDisplay(); - this.parentShell = parent; - tipShell = new Shell(parent, SWT.NONE); - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 2; - gridLayout.marginWidth = 2; - gridLayout.marginHeight = 2; - tipShell.setLayout(gridLayout); - tipShell.setBackground(display - .getSystemColor(SWT.COLOR_INFO_BACKGROUND)); - - tipLabelImage = new Label(tipShell, SWT.NONE); - tipLabelImage.setForeground(display - .getSystemColor(SWT.COLOR_INFO_FOREGROUND)); - tipLabelImage.setBackground(display - .getSystemColor(SWT.COLOR_INFO_BACKGROUND)); - - GridData imageGridData = new GridData( - GridData.HORIZONTAL_ALIGN_BEGINNING - | GridData.VERTICAL_ALIGN_BEGINNING); - tipLabelImage.setLayoutData(imageGridData); - - tipLabelText = new Label(tipShell, SWT.NONE); - tipLabelText.setForeground(display - .getSystemColor(SWT.COLOR_INFO_FOREGROUND)); - tipLabelText.setBackground(display - .getSystemColor(SWT.COLOR_INFO_BACKGROUND)); - - GridData textGridData = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_CENTER); - tipLabelText.setLayoutData(textGridData); - } - - private ITask getTask(Object hoverObject) { - if (hoverObject instanceof Widget) { - Object data = ((Widget) hoverObject).getData(); - if (data != null) { - if (data instanceof ITask) { - return (ITask) data; - } else if (data instanceof IAdaptable) { - return (ITask) ((IAdaptable) data).getAdapter(ITask.class); - } - - } - } - return null; - } - - protected String getToolTipText(Object object) { - ITask task = getTask(object); - if (task != null) { - return task.getToolTipText(); - } - - if (object instanceof Control) { - return (String) ((Control) object).getData("TIP_TEXT"); - } - return null; - } - - protected Image getToolTipImage(Object object) { - ITask projectNode = getTask(object); - if (projectNode != null) { - // TODO Code for determining image - } - if (object instanceof Control) { - return (Image) ((Control) object).getData("TIP_IMAGE"); - } - return null; - } - - protected Object getToolTipHelp(Object object) { - if (object instanceof Control) { - return (String) ((Control) object).getData("TIP_HELPTEXT"); - } - return null; - } - - /** - * Enables customized hover help for a specified control - * - * @control the control on which to enable hoverhelp - */ - public void activateHoverHelp(final Control control) { - /* - * Get out of the way if we attempt to activate the control underneath - * the tooltip - */ - control.addMouseListener(new MouseAdapter() { - - @Override - public void mouseDown(MouseEvent e) { - if (tipShell.isVisible()) - tipShell.setVisible(false); - } - }); - /* - * Trap hover events to pop-up tooltip - */ - control.addMouseTrackListener(new MouseTrackAdapter() { - - @Override - public void mouseExit(MouseEvent e) { - if (tipShell.isVisible()) - tipShell.setVisible(false); - tipWidget = null; - } - - @Override - public void mouseHover(MouseEvent event) { - widgetPosition = new Point(event.x, event.y); - Widget widget = event.widget; - if (widget instanceof ToolBar) { - ToolBar w = (ToolBar) widget; - widget = w.getItem(widgetPosition); - } - if (widget instanceof Table) { - Table w = (Table) widget; - widget = w.getItem(widgetPosition); - } - if (widget instanceof Tree) { - Tree w = (Tree) widget; - widget = w.getItem(widgetPosition); - } - if (widget == null) { - tipShell.setVisible(false); - tipWidget = null; - return; - } - if (widget == tipWidget) - return; - tipWidget = widget; - tipPosition = control.toDisplay(widgetPosition); - String text = getToolTipText(widget); - Image image = getToolTipImage(widget); - if (text == null) { - return; - } - Control sourceControl = (Control) event.getSource(); - sourceControl.setFocus(); - tipLabelText.setText(text); - tipLabelImage.setImage(image); // accepts null - tipShell.pack(); - setHoverLocation(tipShell, tipPosition); - tipShell.setVisible(true); - } - }); - /* - * Trap F1 Help to pop up a custom help box - */ - control.addHelpListener(new HelpListener() { - public void helpRequested(HelpEvent event) { - if (tipWidget == null) - return; - Object help = getToolTipHelp(tipWidget); - if (help == null) - return; - if (help.getClass() != String.class) { - return; - } - if (tipShell.isVisible()) { - tipShell.setVisible(false); - Shell helpShell = new Shell(parentShell, SWT.SHELL_TRIM); - helpShell.setLayout(new FillLayout()); - Label label = new Label(helpShell, SWT.NONE); - label.setText((String) help); - helpShell.pack(); - setHoverLocation(helpShell, tipPosition); - helpShell.open(); - } - } - }); - } - - /** - * Sets the location for a hovering shell - * - * @param shell - * the object that is to hover - * @param position - * the position of a widget to hover over - * @return the top-left location for a hovering box - */ - private void setHoverLocation(Shell shell, Point position) { - Rectangle displayBounds = shell.getDisplay().getBounds(); - Rectangle shellBounds = shell.getBounds(); - shellBounds.x = Math.max(Math.min(position.x, displayBounds.width - - shellBounds.width), 0); - shellBounds.y = Math.max(Math.min(position.y + 16, displayBounds.height - - shellBounds.height), 0); - shell.setBounds(shellBounds); - } -}
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/RelativePathUtil.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/RelativePathUtil.java deleted file mode 100644 index b6105b6ed..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/RelativePathUtil.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -package org.eclipse.mylar.tasks.util; - -public class RelativePathUtil { - public static String findRelativePath(String baseDirectory, String filePath) { - if (filePath.startsWith(baseDirectory)) { - return filePath.substring(baseDirectory.length(), filePath.lastIndexOf('.')); - } else { - StringBuffer result = new StringBuffer(filePath.length()); - String[] rootFolders = baseDirectory.split("/"); - String[] pathFolders = filePath.split("/"); - int diff = 0; - for (int i = 0; i < pathFolders.length; i++) { - if (!rootFolders[i].equals(pathFolders[i])) { - diff = i; - while (i < rootFolders.length) { - result.append('.'); - result.append('.'); - result.append('/'); - i++; - } - while(diff < pathFolders.length - 1){ - result.append(pathFolders[diff]); - diff++; - } - result.append(pathFolders[diff].substring(0, pathFolders[diff].lastIndexOf('.'))); - } - } - return result.toString(); - } - } -} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/TaskTest.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/TaskTest.java deleted file mode 100644 index 1a67148a2..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/TaskTest.java +++ /dev/null @@ -1,146 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on Jan 24, 2005 - */ -package org.eclipse.mylar.tasks.util; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Shawn Minto - */ -public class TaskTest { - private int id = -1; - - private String name = ""; - - private List<String> categories = new ArrayList<String>(); - - private List<TaskTest> taskList = new ArrayList<TaskTest>(); - - @Override - public String toString() { - return "Task"; - } - - public boolean isEqual(TaskTest otherTask) { - - boolean result = true; - result = result && (this.id == otherTask.id); - int compare = (this.name.compareTo(otherTask.name)); - if (compare != 0) - result = false; - if (!result) - System.out.println("this: " + this.name + " otherName: " - + otherTask.name + " a"); - - if (this.categories.size() == otherTask.categories.size()) { - for (int i = 0; i < this.categories.size(); i++) { - compare = this.categories.get(i).compareTo( - otherTask.categories.get(i)); - if (compare != 0) { - System.err.println(this.categories.get(i) + " vs " - + otherTask.categories.get(i)); - result = false; - break; - } - } - } else { - System.err.println("Category length different"); - System.err.println("length: " + this.categories.size() - + " VS Length: " + otherTask.categories.size()); - result = false; - } - if (this.taskList.size() == otherTask.taskList.size()) { - for (int i = 0; i < this.taskList.size(); i++) { - result = result - && (this.taskList.get(i).isEqual(otherTask.taskList - .get(i))); - } - } else { - System.err.println("TaskList size is different!"); - result = false; - } - return result; - } - - public static void printTask(TaskTest t, String tab) { - System.out.println(tab + "TaskID: " + t.id); - System.out.println(tab + "Name: " + t.name); - System.out.println(tab + "Categories: "); - for (int i = 0; i < t.categories.size(); i++) { - System.out.println(tab + "\t " + t.categories.get(i)); - } - for (int i = 0; i < t.taskList.size(); i++) { - printTask(t.taskList.get(i), tab + "\t"); - } - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - // public List<String> getCategories() { - // return categories; - // } - // public void setCategories(List<String> categories) { - // this.categories = categories; - // } - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public void addCategory(String category) { - this.categories.add(category); - } - - /** - * @return Returns the categories. - */ - public List<String> getCategories() { - return categories; - } - - /** - * @param categories The categories to set. - */ - public void setCategories(List<String> categories) { - this.categories = categories; - } - - /** - * @return Returns the taskList. - */ - public List<TaskTest> getTaskList() { - return taskList; - } - - /** - * @param taskList The taskList to set. - */ - public void setTaskList(List<TaskTest> taskList) { - this.taskList = taskList; - } - - public void addSubTask(TaskTest sub) { - this.taskList.add(sub); - } -} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/XmlUtil.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/XmlUtil.java deleted file mode 100644 index 0ac234ab8..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/XmlUtil.java +++ /dev/null @@ -1,693 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 - 2005 University Of British Columbia 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: - * University Of British Columbia - initial API and implementation - *******************************************************************************/ -/* - * Created on Jan 17, 2005 - */ -package org.eclipse.mylar.tasks.util; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.TransformerFactoryConfigurationError; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.AbstractCategory; -import org.eclipse.mylar.tasks.BugzillaQueryCategory; -import org.eclipse.mylar.tasks.BugzillaTask; -import org.eclipse.mylar.tasks.ITask; -import org.eclipse.mylar.tasks.Task; -import org.eclipse.mylar.tasks.TaskCategory; -import org.eclipse.mylar.tasks.TaskList; -import org.eclipse.mylar.tasks.BugzillaTask.BugTaskState; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - - -/** - * @author Ken Sueda - */ -public class XmlUtil { - - private static String readVersion = ""; - - /** - * - * @param tlist - * @param outFile - */ - public static void writeTaskList(TaskList tlist, File outFile) { - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - DocumentBuilder db; - Document doc = null; - - try { - db = dbf.newDocumentBuilder(); - doc = db.newDocument(); - } catch (ParserConfigurationException e) { - e.printStackTrace(); - } - - Element root = doc.createElement("TaskList"); - root.setAttribute("Version", "1.0.1"); - - writeBugzillaRegistry(tlist.getBugzillaTaskRegistry(), doc, root); - - // iterate through each subtask and externalize those - // - for (AbstractCategory cat : tlist.getCategories()) { - if (cat instanceof TaskCategory) { - writeTaskCategory((TaskCategory)cat, doc, root); - } else if (cat instanceof BugzillaQueryCategory) { - writeQueryCategory((BugzillaQueryCategory)cat, doc, root); - } - } - for (ITask task : tlist.getRootTasks()) { - writeTask(task, doc, root); - } - doc.appendChild(root); - writeDOMtoFile(doc, outFile); - return; - } - - private static void writeBugzillaRegistry(Map<String, BugzillaTask> bugzillaTaskRegistry, Document doc, Element parent) { - Element node = doc.createElement("BugzillaTaskRegistry"); - - for (BugzillaTask t : bugzillaTaskRegistry.values()) { - writeTask(t, doc, node); - } - parent.appendChild(node); - } - - /** - * Writes an XML file from a DOM. - * - * doc - the document to write - * file - the file to be written to - */ - private static void writeDOMtoFile(Document doc, File file) { - try { - // A file output stream is an output stream for writing data to a File - // - OutputStream outputStream = new FileOutputStream(file); - writeDOMtoStream(doc, outputStream); - outputStream.flush(); - outputStream.close(); - } catch (Exception fnfe) { - MylarPlugin.log(fnfe, "Tasklist could not be found"); - } - } - - /** - * Writes the provided XML document out to the specified output stream. - * - * doc - the document to be written - * outputStream - the stream to which the document is to be written - */ - private static void writeDOMtoStream(Document doc, OutputStream outputStream) { - // Prepare the DOM document for writing - // DOMSource - Acts as a holder for a transformation Source tree in the - // form of a Document Object Model (DOM) tree - // - Source source = new DOMSource(doc); - - // StreamResult - Acts as an holder for a XML transformation result - // Prepare the output stream - // - Result result = new StreamResult(outputStream); - - // An instance of this class can be obtained with the - // TransformerFactory.newTransformer method. This instance may - // then be used to process XML from a variety of sources and write - // the transformation output to a variety of sinks - // - - Transformer xformer = null; - try { - xformer = TransformerFactory.newInstance().newTransformer(); - //Transform the XML Source to a Result - // - xformer.transform(source, result); - } catch (TransformerConfigurationException e) { - e.printStackTrace(); - } catch (TransformerFactoryConfigurationError e) { - e.printStackTrace(); - } catch (TransformerException e1) { - e1.printStackTrace(); - } - } - -// /** -// * Method deprecated until subtasks are introduced again. -// * @param t -// * @param doc -// * @param root -// */ -// private static void writeTaskAndSubTasks(ITask t, Document doc, Element root) { -// -// // create node and set attributes -// // -// Element node = doc.createElement("Task"); -// node.setAttribute("Path", t.getPath()); -// node.setAttribute("Label", t.getLabel()); -// node.setAttribute("Handle", t.getHandle()); -// node.setAttribute("Priority", t.getPriority()); -// -// if (t.isCategory()) { -// node.setAttribute("IsCategory", "true"); -// } else { -// node.setAttribute("IsCategory", "false"); -// } -// if (t.isCompleted()) { -// node.setAttribute("Complete", "true"); -// } else { -// node.setAttribute("Complete", "false"); -// } -// if (t.isActive()) { -// node.setAttribute("Active", "true"); -// } else { -// node.setAttribute("Active", "false"); -// } -// if (t instanceof BugzillaTask) { -// BugzillaTask bt = (BugzillaTask) t; -// node.setAttribute("Bugzilla", "true"); -// node.setAttribute("LastDate", new Long(bt.getLastRefreshTime() -// .getTime()).toString()); -// if (bt.isDirty()) { -// node.setAttribute("Dirty", "true"); -// } else { -// node.setAttribute("Dirty", "false"); -// } -// bt.saveBugReport(false); -// } else { -// node.setAttribute("Bugzilla", "false"); -// } -// node.setAttribute("Notes", t.getNotes()); -// node.setAttribute("Elapsed", t.getElapsedTime()); -// node.setAttribute("Estimated", t.getEstimatedTime()); -// List<String> rl = t.getRelatedLinks().getLinks(); -// int i = 0; -// for (String link : rl) { -// node.setAttribute("link"+i, link); -// i++; -// } -// -// List<ITask> children = t.getChildren(); -// -// i = 0; -// for (i = 0; i < children.size(); i++) { -// writeTaskAndSubTasks(children.get(i), doc, node); -// } -// -// // append new node to root node -// // -// root.appendChild(node); -// return; -// } - - private static void writeTaskCategory(TaskCategory cat, Document doc, Element parent) { - Element node = doc.createElement("TaskCategory"); - node.setAttribute("Name", cat.getDescription(false)); - - for (ITask t : cat.getChildren()) { - writeTask(t, doc, node); - } - parent.appendChild(node); - } - - private static void writeQueryCategory(BugzillaQueryCategory cat, Document doc, Element parent) { - Element node = doc.createElement("QueryCategory"); - node.setAttribute("Description", cat.getDescription(false)); - node.setAttribute("URL", cat.getUrl()); - parent.appendChild(node); - } - - private static void writeTask(ITask task, Document doc, Element parent) { - Element node = doc.createElement("Task"); - node.setAttribute("Path", task.getPath()); - node.setAttribute("Label", task.getLabel()); - node.setAttribute("Handle", task.getHandle()); - node.setAttribute("Priority", task.getPriority()); - - if (task.isCompleted()) { - node.setAttribute("Complete", "true"); - } else { - node.setAttribute("Complete", "false"); - } - if (task.isActive()) { - node.setAttribute("Active", "true"); - } else { - node.setAttribute("Active", "false"); - } - if (task instanceof BugzillaTask) { - BugzillaTask bt = (BugzillaTask) task; - node.setAttribute("Bugzilla", "true"); - node.setAttribute("LastDate", new Long(bt.getLastRefreshTime() - .getTime()).toString()); - if (bt.isDirty()) { - node.setAttribute("Dirty", "true"); - } else { - node.setAttribute("Dirty", "false"); - } - bt.saveBugReport(false); - } else { - node.setAttribute("Bugzilla", "false"); - } - node.setAttribute("Notes", task.getNotes()); - node.setAttribute("Elapsed", task.getElapsedTime()); - node.setAttribute("Estimated", task.getEstimatedTime()); - List<String> rl = task.getRelatedLinks().getLinks(); - int i = 0; - for (String link : rl) { - node.setAttribute("link"+i, link); - i++; - } - - for (ITask t : task.getChildren()) { - writeTask(t, doc, node); - } - parent.appendChild(node); - return; - } - - public static void readTaskList(TaskList tlist, File inFile) { - try { - // parse file - // - Document doc = openAsDOM(inFile); - - // read root node to get version number - // - Element root = doc.getDocumentElement(); - readVersion = root.getAttribute("Version"); - - if (readVersion.equals("1.0.0")) { - NodeList list = root.getChildNodes(); - for (int i = 0; i < list.getLength(); i++) { - Node child = list.item(i); - readTasksToNewFormat(child, tlist); - //tlist.addRootTask(readTaskAndSubTasks(child, null, tlist)); - } - } else { - NodeList list = root.getChildNodes(); - for (int i = 0; i < list.getLength(); i++) { - Node child = list.item(i); - if (child.getNodeName().equals("Category") || - child.getNodeName().equals("TaskCategory")) { - readTaskCategory(child, tlist); - } else if (child.getNodeName().equals("BugzillaTaskRegistry")) { - readBugzillaRegistry(child, tlist); - } else if (child.getNodeName().equals("QueryCategory")) { - readQueryCategory(child, tlist); - } else { - tlist.addRootTask(readTask(child, tlist, null, null)); - } - } - } - } catch (Exception e) { - String name = inFile.getAbsolutePath(); - name = name.substring(0, name.lastIndexOf('.')) + "-save.xml"; - inFile.renameTo(new File(name)); - MylarPlugin.log(e, "XmlUtil"); - } - } - - private static void readBugzillaRegistry(Node node, TaskList tlist) { - NodeList list = node.getChildNodes(); - for (int i = 0; i < list.getLength(); i++) { - Node child = list.item(i); - ITask task = readTask(child, tlist, null, null); - if(task instanceof BugzillaTask){ - tlist.addToBugzillaTaskRegistry((BugzillaTask)task); - } - } - } - - /** - * Opens the specified XML file and parses it into a DOM Document. - * - * Filename - the name of the file to open - * Return - the Document built from the XML file - * Throws - XMLException if the file cannot be parsed as XML - * - IOException if the file cannot be opened - */ - private static Document openAsDOM(File inputFile) throws IOException { - - // A factory API that enables applications to obtain a parser - // that produces DOM object trees from XML documents - // - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - - // Using DocumentBuilder, obtain a Document from XML file. - // - DocumentBuilder builder = null; - Document document = null; - try { - // create new instance of DocumentBuilder - // - builder = factory.newDocumentBuilder(); - } catch (ParserConfigurationException pce) { - inputFile.renameTo(new File(inputFile.getName() + "save.xml")); - MylarPlugin.log(pce, "Failed to load XML file"); - } - try { - // Parse the content of the given file as an XML document - // and return a new DOM Document object. Also throws IOException - document = builder.parse(inputFile); - } catch (SAXException se) { - inputFile.renameTo(new File(inputFile.getName() + "save.xml")); - MylarPlugin.log(se, "Failed to parse XML file"); - } - return document; - } - -// private static ITask readTaskAndSubTasks(Node node, ITask root, TaskList tlist) { -// //extract node and create new sub task -// // -// Element e = (Element) node; -// ITask t; -// String handle = ""; -// if (e.hasAttribute("ID")) { -// handle = e.getAttribute("ID"); -// } else { -// handle = e.getAttribute("Handle"); -// } -// -// String label = e.getAttribute("Label"); -// String priority = e.getAttribute("Priority"); -// -// if (e.getAttribute("Bugzilla").compareTo("true") == 0) { -// t = new BugzillaTask(handle, label, true); -// BugzillaTask bt = (BugzillaTask) t; -// bt.setState(BugTaskState.FREE); -// bt.setLastRefresh(new Date(new Long(e.getAttribute("LastDate")) -// .longValue())); -// if (e.getAttribute("Dirty").compareTo("true") == 0) { -// bt.setDirty(true); -// } else { -// bt.setDirty(false); -// } -// if (bt.readBugReport() == false) { -// MylarPlugin.log("Failed to read bug report", null); -// } -// } else { -// t = new Task(handle, label); -// } -// t.setPriority(priority); -// t.setPath(e.getAttribute("Path")); -// -// if (e.getAttribute("Active").compareTo("true") == 0) { -// t.setActive(true); -// tlist.setActive(t, true); -// } else { -// t.setActive(false); -// } -// -// if (e.getAttribute("Complete").compareTo("true") == 0) { -// t.setCompleted(true); -// } else { -// t.setCompleted(false); -// } -// if (e.getAttribute("IsCategory").compareTo("true") == 0) { -// t.setIsCategory(true); -// } else { -// t.setIsCategory(false); -// } -// -// if (e.hasAttribute("Notes")) { -// t.setNotes(e.getAttribute("Notes")); -// } else { -// t.setNotes(""); -// } -// if (e.hasAttribute("Elapsed")) { -// t.setElapsedTime(e.getAttribute("Elapsed")); -// } else { -// t.setElapsedTime(""); -// } -// if (e.hasAttribute("Estimated")) { -// t.setEstimatedTime(e.getAttribute("Estimated")); -// } else { -// t.setEstimatedTime(""); -// } -// -// int i = 0; -// while (e.hasAttribute("link"+i)) { -// t.getRelatedLinks().add(e.getAttribute("link"+i)); -// i++; -// } -// -// if (!readVersion.equals("1.0.0")) { -// // for newer revisions -// } -// -// i = 0; -// NodeList list = e.getChildNodes(); -// for (i = 0; i < list.getLength(); i++) { -// Node child = list.item(i); -// t.addSubTask(readTaskAndSubTasks(child, t, tlist)); -// } -// if (root != null) { -// t.setParent(root); -// } -// return t; -// } - - private static void readTaskCategory(Node node, TaskList tlist) { - Element e = (Element) node; - TaskCategory cat = new TaskCategory(e.getAttribute("Name")); - tlist.addCategory(cat); - NodeList list = node.getChildNodes(); - for (int i = 0; i < list.getLength(); i++) { - Node child = list.item(i); - cat.addTask(readTask(child, tlist, cat, null)); - } - } - - private static void readQueryCategory(Node node, TaskList tlist) { - Element e = (Element) node; - BugzillaQueryCategory cat = new BugzillaQueryCategory(e.getAttribute("Description"), e.getAttribute("URL")); - tlist.addCategory(cat); - } - - private static ITask readTask(Node node, TaskList tlist, TaskCategory cat, ITask parent) { - Element e = (Element) node; - ITask t; - String handle = e.getAttribute("Handle"); - String label = e.getAttribute("Label"); - String priority = e.getAttribute("Priority"); - - if (e.getAttribute("Bugzilla").compareTo("true") == 0) { - t = new BugzillaTask(handle, label, true); - BugzillaTask bt = (BugzillaTask) t; - bt.setState(BugTaskState.FREE); - bt.setLastRefresh(new Date(new Long(e.getAttribute("LastDate")) - .longValue())); - if (e.getAttribute("Dirty").compareTo("true") == 0) { - bt.setDirty(true); - } else { - bt.setDirty(false); - } - if (bt.readBugReport() == false) { - MylarPlugin.log("Failed to read bug report", null); - } - } else { - t = new Task(handle, label); - } - t.setPriority(priority); - t.setPath(e.getAttribute("Path")); - - if (e.getAttribute("Active").compareTo("true") == 0) { - t.setActive(true); - tlist.setActive(t, true); - } else { - t.setActive(false); - } - if (e.getAttribute("Complete").compareTo("true") == 0) { - t.setCompleted(true); - } else { - t.setCompleted(false); - } - if (e.hasAttribute("Notes")) { - t.setNotes(e.getAttribute("Notes")); - } else { - t.setNotes(""); - } - if (e.hasAttribute("Elapsed")) { - t.setElapsedTime(e.getAttribute("Elapsed")); - } else { - t.setElapsedTime(""); - } - if (e.hasAttribute("Estimated")) { - t.setEstimatedTime(e.getAttribute("Estimated")); - } else { - t.setEstimatedTime(""); - } - - int i = 0; - while (e.hasAttribute("link"+i)) { - t.getRelatedLinks().add(e.getAttribute("link"+i)); - i++; - } - t.setCategory(cat); - t.setParent(parent); - NodeList list = e.getChildNodes(); - for (i = 0; i < list.getLength(); i++) { - Node child = list.item(i); - t.addSubTask(readTask(child, tlist, null, t)); - } - return t; - } - - private static void readTasksToNewFormat(Node node, TaskList tlist) { - Element e = (Element) node; - ITask t; - String handle = e.getAttribute("Handle"); - String label = e.getAttribute("Label"); - - if (e.getAttribute("IsCategory").compareTo("true") == 0) { - TaskCategory c = new TaskCategory(label); - NodeList list = e.getChildNodes(); - for (int i = 0; i < list.getLength(); i++) { - Node child = list.item(i); - readSubTasksToNewFormat(child, tlist, c); - } - tlist.addCategory(c); - } else { - String priority = e.getAttribute("Priority"); - if (e.getAttribute("Bugzilla").compareTo("true") == 0) { - t = new BugzillaTask(handle, label, true); - BugzillaTask bt = (BugzillaTask) t; - bt.setState(BugTaskState.FREE); - bt.setLastRefresh(new Date(new Long(e.getAttribute("LastDate")) - .longValue())); - if (e.getAttribute("Dirty").compareTo("true") == 0) { - bt.setDirty(true); - } else { - bt.setDirty(false); - } - if (bt.readBugReport() == false) { - MylarPlugin.log("Failed to read bug report", null); - } - } else { - t = new Task(handle, label); - } - t.setPriority(priority); - t.setPath(e.getAttribute("Path")); - t.setNotes(e.getAttribute("Notes")); - t.setElapsedTime(e.getAttribute("Elapsed")); - t.setEstimatedTime(e.getAttribute("Estimated")); - - if (e.getAttribute("Active").compareTo("true") == 0) { - t.setActive(true); - tlist.setActive(t, true); - } else { - t.setActive(false); - } - if (e.getAttribute("Complete").compareTo("true") == 0) { - t.setCompleted(true); - } else { - t.setCompleted(false); - } - - int i = 0; - while (e.hasAttribute("link" + i)) { - t.getRelatedLinks().add(e.getAttribute("link" + i)); - i++; - } - tlist.addRootTask(t); - i = 0; - NodeList list = e.getChildNodes(); - for (i = 0; i < list.getLength(); i++) { - Node child = list.item(i); - readSubTasksToNewFormat(child, tlist, null); - } - } - } - private static void readSubTasksToNewFormat(Node node, TaskList tlist, TaskCategory cat) { - Element e = (Element) node; - ITask t; - String handle = e.getAttribute("Handle"); - String label = e.getAttribute("Label"); - String priority = e.getAttribute("Priority"); - if (e.getAttribute("Bugzilla").compareTo("true") == 0) { - t = new BugzillaTask(handle, label, true); - BugzillaTask bt = (BugzillaTask) t; - bt.setState(BugTaskState.FREE); - bt.setLastRefresh(new Date(new Long(e.getAttribute("LastDate")) - .longValue())); - if (e.getAttribute("Dirty").compareTo("true") == 0) { - bt.setDirty(true); - } else { - bt.setDirty(false); - } - if (bt.readBugReport() == false) { - MylarPlugin.log("Failed to read bug report", null); - } - } else { - t = new Task(handle, label); - } - t.setPriority(priority); - t.setPath(e.getAttribute("Path")); - t.setNotes(e.getAttribute("Notes")); - t.setElapsedTime(e.getAttribute("Elapsed")); - t.setEstimatedTime(e.getAttribute("Estimated")); - - if (e.getAttribute("Active").compareTo("true") == 0) { - t.setActive(true); - tlist.setActive(t, true); - } else { - t.setActive(false); - } - if (e.getAttribute("Complete").compareTo("true") == 0) { - t.setCompleted(true); - } else { - t.setCompleted(false); - } - - int i = 0; - while (e.hasAttribute("link" + i)) { - t.getRelatedLinks().add(e.getAttribute("link" + i)); - i++; - } - if (cat == null) { - tlist.addRootTask(t); - } else { - cat.addTask(t); - t.setCategory(cat); - } - - i = 0; - NodeList list = e.getChildNodes(); - for (i = 0; i < list.getLength(); i++) { - Node child = list.item(i); - readSubTasksToNewFormat(child, tlist, cat); - } - } -} - |