diff options
8 files changed, 49 insertions, 50 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCorePlugin.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCorePlugin.java index 296ac4d5c..c2ffdc646 100644 --- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCorePlugin.java +++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCorePlugin.java @@ -335,7 +335,7 @@ public class BugzillaCorePlugin extends Plugin { if (bugzillaPlatform != null && platformAttribute != null) { platformAttribute.setValue(bugzillaPlatform); - } else if (platformAttribute != null && platformAttribute.getOptionParameter(OPTION_ALL) != null) { + } else if (opSysAttribute != null && platformAttribute != null && platformAttribute.getOptionParameter(OPTION_ALL) != null) { opSysAttribute.setValue(OPTION_ALL); } diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java index 76d036160..feb63711f 100644 --- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java @@ -879,7 +879,7 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage implements L } i--; } - if (i >= 0) { + if (i >= 0 && match != null) { match.operation = operation.getSelectionIndex(); // remove - will be added last (see below) previousSearchQueryData.remove(match); diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/StackTrace.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/StackTrace.java index 16b8d2781..8db86466a 100644 --- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/StackTrace.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/StackTrace.java @@ -31,8 +31,7 @@ public class StackTrace { private String stackTrace; /** - * This is the comment that the stack trace appeared in. String if - * desciption else Comment + * This is the comment that the stack trace appeared in. String if desciption else Comment */ private Object comment; @@ -85,8 +84,7 @@ public class StackTrace { /** * 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 summary + * @return Returns the Comment if it was a comment else a String if it was the summary */ public Object getComment() { return comment; @@ -163,11 +161,10 @@ public class StackTrace { // 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)); + stackTraces.add(getStackTrace(stackTrace, charStackStart, charPos[0] - charStackStart, comment)); } stackTrace = null; - } else { + } else if (stackTrace != null) { // we had one, so add it to this stack trace stackTrace.add(stack); @@ -194,8 +191,7 @@ public class StackTrace { } /** - * Get the next at clause from a potential stack trace -- looks ahead 4 - * lines + * 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 @@ -204,9 +200,8 @@ public class StackTrace { * @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 + * 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.*"; @@ -254,7 +249,7 @@ public class StackTrace { i[0] = index + 1; charPos[0] += l2.length() + 2; res += l2.trim(); - } else if (l3 != null && l3.trim().matches(regexEndString)) { + } else if (l2 != null && l3 != null && l3.trim().matches(regexEndString)) { // it was on the third line // update the current position and the result string @@ -262,7 +257,7 @@ public class StackTrace { charPos[0] += l2.length() + l3.length() + 4; res += l2.trim(); res += l3.trim(); - } else if (l4 != null && l4.trim().matches(regexEndString)) { + } else if (l2 != null && l3 != null && l4 != null && l4.trim().matches(regexEndString)) { // it was on the fourth line // update the current position and the result string diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskDataManager.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskDataManager.java index 00ff7912c..45526bb25 100644 --- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskDataManager.java +++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskDataManager.java @@ -67,7 +67,7 @@ public class TaskDataManager { public TaskDataManager(TaskRepositoryManager taskRepositoryManager, IPath path) { this.primaryPath = path.append(OFFLINE_REPORTS); - this.backupPath = path.append(OFFLINE_REPORTS+".bak"); + this.backupPath = path.append(OFFLINE_REPORTS + ".bak"); this.taskRepositoryManager = taskRepositoryManager; this.primaryFile = primaryPath.toFile(); this.backupFile = backupPath.toFile(); @@ -131,8 +131,8 @@ public class TaskDataManager { } /** - * Add a RepositoryTaskData to the offline reports file. Previously stored - * taskData is held and can be retrieved via getOldTaskData() + * Add a RepositoryTaskData to the offline reports file. Previously stored taskData is held and can be retrieved via + * getOldTaskData() */ public void setNewTaskData(String taskHandle, RepositoryTaskData newEntry) { if (taskHandle == null || newEntry == null) { @@ -177,9 +177,8 @@ public class TaskDataManager { } /** - * @return Get the next available temporary taskId. This taskId is given to - * new unsubmitted repository tasks. Incremented each time this - * method is called. + * @return Get the next available temporary taskId. This taskId is given to new unsubmitted repository tasks. + * Incremented each time this method is called. */ public synchronized String getNewRepositoryTaskId() { dataStateChanged(); @@ -285,8 +284,7 @@ public class TaskDataManager { } /** - * Public for testing only force a reset of all data maps Does not signal - * data changed (doesn't request save) + * Public for testing only force a reset of all data maps Does not signal data changed (doesn't request save) */ public void clear() { if (saverJob != null) { @@ -296,14 +294,12 @@ public class TaskDataManager { } /** - * After deserialization process the attributeFactory needs to be reset on - * each RepositoryTaskData. + * After deserialization process the attributeFactory needs to be reset on each RepositoryTaskData. */ private void updateAttributeFactory(RepositoryTaskData taskData) { if (taskData == null) return; - AbstractRepositoryConnector connector = taskRepositoryManager.getRepositoryConnector(taskData - .getRepositoryKind()); + AbstractRepositoryConnector connector = taskRepositoryManager.getRepositoryConnector(taskData.getRepositoryKind()); if (connector != null && connector.getTaskDataHandler() != null) { AbstractAttributeFactory factory = connector.getTaskDataHandler().getAttributeFactory(taskData); if (factory != null) { @@ -506,15 +502,19 @@ public class TaskDataManager { outputStream.writeObject(oldObj); outputStream.flush(); - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream - .toByteArray()); + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( + byteArrayOutputStream.toByteArray()); inputStream = new ObjectInputStream(byteArrayInputStream); return inputStream.readObject(); } catch (Exception e) { throw (e); } finally { - outputStream.close(); - inputStream.close(); + if (outputStream != null) { + outputStream.close(); + } + if (inputStream != null) { + inputStream.close(); + } } } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskPlanningEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskPlanningEditor.java index 431f8961e..62027feb0 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskPlanningEditor.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskPlanningEditor.java @@ -215,7 +215,7 @@ public class TaskPlanningEditor extends TaskFormPage { } } - if (!priorityCombo.isDisposed()) { + if (!priorityCombo.isDisposed() && updateTask != null) { PriorityLevel level = PriorityLevel.fromString(updateTask.getPriority()); if (level != null) { int prioritySelectionIndex = priorityCombo.indexOf(level.getDescription()); diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskListWriter.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskListWriter.java index c180c81ab..320fb9ae4 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskListWriter.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskListWriter.java @@ -110,6 +110,7 @@ public class TaskListWriter { doc = db.newDocument(); } catch (ParserConfigurationException e) { MylarStatusHandler.log(e, "could not create document"); + return; } Element root = doc.createElement(ELEMENT_TASK_LIST); @@ -212,8 +213,7 @@ public class TaskListWriter { /** * 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 + * doc - the document to be written outputStream - the stream to which the document is to be written */ private void writeDOMtoStream(Document doc, OutputStream outputStream) { // Prepare the DOM document for writing @@ -231,7 +231,7 @@ public class TaskListWriter { // the transformation output to a variety of sinks Transformer xformer = null; - try { + try { xformer = TransformerFactory.newInstance().newTransformer(); xformer.setOutputProperty(TRANSFORM_PROPERTY_VERSION, XML_VERSION); xformer.transform(source, result); @@ -286,12 +286,12 @@ public class TaskListWriter { try { if (!child.getNodeName().endsWith(DelegatingTaskExternalizer.KEY_CATEGORY) && !child.getNodeName().endsWith(DelegatingTaskExternalizer.KEY_QUERY)) { - + ITask task = delagatingExternalizer.readTask(child, taskList, null, null); if (task == null) { orphanedTaskNodes.add(child); } else { - if(child.getChildNodes() != null && child.getChildNodes().getLength() > 0) { + if (child.getChildNodes() != null && child.getChildNodes().getLength() > 0) { tasksWithSubtasks.put(task, child.getChildNodes()); } } @@ -307,7 +307,7 @@ public class TaskListWriter { handleException(inFile, child, e); } } - + for (ITask task : tasksWithSubtasks.keySet()) { NodeList nodes = tasksWithSubtasks.get(task); delagatingExternalizer.readSubTasks(task, nodes, taskList); @@ -330,7 +330,7 @@ public class TaskListWriter { for (int ii = 0; ii < queryChildren.getLength(); ii++) { Node queryNode = queryChildren.item(ii); try { - delagatingExternalizer.readQueryHit((Element)queryNode, taskList, query); + delagatingExternalizer.readQueryHit((Element) queryNode, taskList, query); } catch (TaskExternalizationException e) { hasCaughtException = true; } @@ -368,9 +368,8 @@ public class TaskListWriter { /** * 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 + * 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 Document openAsDOM(File inputFile) throws IOException { @@ -386,7 +385,9 @@ public class TaskListWriter { builder = factory.newDocumentBuilder(); } catch (ParserConfigurationException pce) { inputFile.renameTo(new File(inputFile.getName() + FILE_SUFFIX_SAVE)); - MylarStatusHandler.log(pce, "Failed to load XML file"); + IOException ioe = new IOException("Failed to load XML file"); + ioe.initCause(pce); + throw ioe; } try { // Parse the content of the given file as an XML document @@ -403,9 +404,8 @@ public class TaskListWriter { // document = builder.parse(inputFile); } catch (SAXException se) { // TODO: Use TaskListBackupManager to attempt restore from backup - MessageDialog - .openWarning(null, "Mylar task list corrupt", - "Unable to read the Mylar task list. Please restore from previous backup via File > Import > Mylar Task Data"); + MessageDialog.openWarning(null, "Mylar task list corrupt", + "Unable to read the Mylar task list. Please restore from previous backup via File > Import > Mylar Task Data"); // String message = "Restoring the tasklist failed. Would you like // to attempt to restore from the backup?\n\nTasklist XML File // location: " @@ -433,8 +433,8 @@ public class TaskListWriter { String name = inFile.getAbsolutePath(); Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat(); - sdf.applyPattern("yy-MM-dd-ss"); - name = name.substring(0, name.lastIndexOf('.')) + "-failed-"+sdf.format(date)+".zip"; + sdf.applyPattern("yy-MM-dd-ss"); + name = name.substring(0, name.lastIndexOf('.')) + "-failed-" + sdf.format(date) + ".zip"; File save = new File(name); if (save.exists()) { if (!save.delete()) { diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListDragSourceListener.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListDragSourceListener.java index 2fb07ebfd..eb64fc45f 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListDragSourceListener.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListDragSourceListener.java @@ -67,7 +67,7 @@ class TaskListDragSourceListener implements DragSourceListener { } } event.data = tasks.toArray(); - } else if (FileTransfer.getInstance().isSupportedType(event.dataType)) { + } else if (FileTransfer.getInstance().isSupportedType(event.dataType) && selectedElement != null) { File file = ContextCorePlugin.getContextManager().getFileForContext(selectedElement.getHandleIdentifier()); if (file != null) { event.data = new String[] { file.getAbsolutePath() }; diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiUtil.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiUtil.java index 365ea61f8..0b029d181 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiUtil.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiUtil.java @@ -464,6 +464,10 @@ public class TasksUiUtil { selection = (IStructuredSelection) windowSelection; } } + + if(selection == null) { + return null; + } Object element = selection.getFirstElement(); if (element instanceof TaskRepository) { |