Revision: 197
http://mantisconnect.svn.sourceforge.net/mantisconnect/?rev=197&view=rev
Author: planser
Date: 2008-07-14 00:37:55 -0700 (Mon, 14 Jul 2008)
Log Message:
-----------
Added possibility to paste attachments from clipboard
Modified Paths:
--------------
mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/DefaultSubmitter.java
mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/messages.properties
mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/messages_de.properties
mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/swing/AttachmentsPart.java
mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/swing/GeneralPart.java
mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/swing/IssueSubmitFrame.java
Added Paths:
-----------
mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/icons/paste-16.png
mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/ByteArrayIssueAttachment.java
mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/ILocalIssueAttachment.java
mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/LocalFileIssueAttachment.java
Added: mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/icons/paste-16.png
===================================================================
(Binary files differ)
Property changes on: mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/icons/paste-16.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/ByteArrayIssueAttachment.java
===================================================================
--- mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/ByteArrayIssueAttachment.java (rev 0)
+++ mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/ByteArrayIssueAttachment.java 2008-07-14 07:37:55 UTC (rev 197)
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2008 Peter Lanser.
+ *
+ * MantisConnect is copyrighted to Victor Boctor.
+ *
+ * This library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program.
+ * If not, see http://www.gnu.org/licenses/.
+ */
+package org.mantisbt.connect.ui;
+
+import java.io.IOException;
+import java.util.Date;
+
+import org.apache.axis.types.URI;
+
+/**
+ * @author Peter Lanser, planser@...
+ */
+public class ByteArrayIssueAttachment implements ILocalIssueAttachment {
+
+ private byte[] data;
+
+ private String filename;
+
+ private String contentType;
+
+ public ByteArrayIssueAttachment(byte[] data, String filename, String contentType) {
+ this.data = data;
+ this.filename = filename;
+ this.contentType = contentType;
+ }
+
+ public byte[] getData() throws IOException {
+ return data;
+ }
+
+ public String getContentType() {
+ return contentType;
+ }
+
+ public Date getDateSubmitted() {
+ return null;
+ }
+
+ public URI getDownloadUri() {
+ return null;
+ }
+
+ public String getFilename() {
+ return filename;
+ }
+
+ public long getId() {
+ return 0;
+ }
+
+ public long getSize() {
+ return data.length;
+ }
+
+}
Property changes on: mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/ByteArrayIssueAttachment.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/DefaultSubmitter.java
===================================================================
--- mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/DefaultSubmitter.java 2008-05-31 15:29:23 UTC (rev 196)
+++ mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/DefaultSubmitter.java 2008-07-14 07:37:55 UTC (rev 197)
@@ -70,13 +70,29 @@
return addAttachment(session, issueId, data, filename);
} catch (IOException e) {
throw new MCException(e);
- }
+ }
}
public long submitAttachment(IMCSession session, long issueId, IIssueAttachment attachment) throws MCException {
- return submitAttachment(session, issueId, new File(attachment.getFilename()));
+ if (attachment instanceof ILocalIssueAttachment) {
+ try {
+ byte[] data = ((ILocalIssueAttachment) attachment).getData();
+ String filename = null;
+ if (doCompress(attachment.getFilename())) {
+ filename = getCompressedFilename(attachment.getFilename());
+ data = compress(data, attachment.getFilename());
+ } else {
+ filename = attachment.getFilename();
+ }
+ return addAttachment(session, issueId, data, filename);
+ } catch (IOException e) {
+ throw new MCException(e);
+ }
+ } else {
+ return submitAttachment(session, issueId, new File(attachment.getFilename()));
+ }
}
-
+
protected long addAttachment(IMCSession session, long issueId, byte[] data,
String filename) throws MCException {
return session.addIssueAttachment(issueId, filename, Utilities
@@ -94,17 +110,26 @@
}
protected String getCompressedFilename(File file) {
- String filename;
- filename = file.getName() + ".zip";
- return filename;
+ return getCompressedFilename(file.getName());
}
+
+ protected String getCompressedFilename(String filename) {
+ return filename + ".zip";
+ }
public boolean doCompress(File file) {
return (!isCompressed(file) && compressAttachments);
}
+
+ public boolean doCompress(String filename) {
+ return (!isCompressed(filename) && compressAttachments);
+ }
protected boolean isCompressed(File file) {
- String filename = file.getName();
+ return isCompressed(file.getName());
+ }
+
+ protected boolean isCompressed(String filename) {
int lastSeparator = filename.lastIndexOf('.');
if (lastSeparator > 0 && lastSeparator < filename.length()) {
String type = filename.substring(lastSeparator + 1).toLowerCase();
Added: mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/ILocalIssueAttachment.java
===================================================================
--- mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/ILocalIssueAttachment.java (rev 0)
+++ mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/ILocalIssueAttachment.java 2008-07-14 07:37:55 UTC (rev 197)
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2008 Peter Lanser.
+ *
+ * MantisConnect is copyrighted to Victor Boctor.
+ *
+ * This library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program.
+ * If not, see http://www.gnu.org/licenses/.
+ */
+package org.mantisbt.connect.ui;
+
+import java.io.IOException;
+
+import org.mantisbt.connect.model.IIssueAttachment;
+
+/**
+ * @author Peter Lanser, planser@...
+ */
+public interface ILocalIssueAttachment extends IIssueAttachment {
+
+ public byte[] getData() throws IOException;
+
+}
Property changes on: mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/ILocalIssueAttachment.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/LocalFileIssueAttachment.java
===================================================================
--- mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/LocalFileIssueAttachment.java (rev 0)
+++ mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/LocalFileIssueAttachment.java 2008-07-14 07:37:55 UTC (rev 197)
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2008 Peter Lanser.
+ *
+ * MantisConnect is copyrighted to Victor Boctor.
+ *
+ * This library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program.
+ * If not, see http://www.gnu.org/licenses/.
+ */
+package org.mantisbt.connect.ui;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Date;
+
+import org.apache.axis.types.URI;
+import org.mantisbt.connect.Utilities;
+
+/**
+ * @author Peter Lanser, planser@...
+ */
+public class LocalFileIssueAttachment implements ILocalIssueAttachment {
+
+ private File file;
+
+ public LocalFileIssueAttachment(File file) {
+ this.file = file;
+ }
+
+ public byte[] getData() throws IOException {
+ return Utilities.readFile(file);
+ }
+
+ public String getContentType() {
+ return Utilities.getMimeType(file);
+ }
+
+ public Date getDateSubmitted() {
+ return null;
+ }
+
+ public URI getDownloadUri() {
+ return null;
+ }
+
+ public String getFilename() {
+ return file.getName();
+ }
+
+ public long getId() {
+ return 0;
+ }
+
+ public long getSize() {
+ return file.length();
+ }
+
+}
Property changes on: mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/LocalFileIssueAttachment.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/messages.properties
===================================================================
--- mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/messages.properties 2008-05-31 15:29:23 UTC (rev 196)
+++ mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/messages.properties 2008-07-14 07:37:55 UTC (rev 197)
@@ -42,7 +42,13 @@
AttachmentsPart.Title=Attachments
AttachmentsPart.Button.Add=Add
AttachmentsPart.Button.Remove=Remove
+AttachmentsPart.Button.Clipboard=Paste
AttachmentsPart.Message.WillBeCompressed=(will be compressed)
+AttachmentsPart.Message.Clipboard.Text=The contents from the clipboard will be treated as text.\nPlease provide an appropriate filename for the attachment.
+AttachmentsPart.Message.Clipboard.Image=The contents from the clipboard will be treated as an image.\nPlease provide an appropriate filename for the attachment.
+AttachmentsPart.Message.NoValidData=Cannot paste contents from clipboard.\nOnly text an images can be pasted.
+AttachmentsPart.Message.InvalidName=The provided name is not valid.
+AttachmentsPart.Message.AttachmentExists=An attachment with this name already exists.
IssueSubmitPanel.Message.IssueAdded=Issue was added successfully.
IssueSubmitPanel.Message.LoadingInitialData=Loading initial data
Modified: mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/messages_de.properties
===================================================================
--- mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/messages_de.properties 2008-05-31 15:29:23 UTC (rev 196)
+++ mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/messages_de.properties 2008-07-14 07:37:55 UTC (rev 197)
@@ -41,7 +41,13 @@
AttachmentsPart.Title=Anlagen
AttachmentsPart.Button.Add=Hinzuf\xFCgen
AttachmentsPart.Button.Remove=Entfernen
+AttachmentsPart.Button.Clipboard=Einf\xFCgen
AttachmentsPart.Message.WillBeCompressed=(wird komprimiert)
+AttachmentsPart.Message.Clipboard.Text=Der Inhalt der Zwischenablage wird als Text behandelt.\nBitte geben sie einen entsprechenden Dateinamen f\xFCr die Anlage an.
+AttachmentsPart.Message.Clipboard.Image=Der Inhalt der Zwischenablage wird als Bild behandelt.\nBitte geben sie einen entsprechenden Dateinamen f\xFCr die Anlage an.
+AttachmentsPart.Message.NoValidData=Der Inhalt der Zwischenablage kann nicht eingef\xFCgt werden.\nEs muss sich um Text oder um ein Bild handeln.
+AttachmentsPart.Message.InvalidName=Der angegebene Name ist ung\xFCltig.
+AttachmentsPart.Message.AttachmentExists=Es existiert bereits eine Anlage mit diesem Namen.
IssueSubmitPanel.Message.IssueAdded=Das Problem wurde erfolgreich hinzugef\xFCgt.
IssueSubmitPanel.Message.LoadingInitialData=Lade initiale Daten
Modified: mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/swing/AttachmentsPart.java
===================================================================
--- mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/swing/AttachmentsPart.java 2008-05-31 15:29:23 UTC (rev 196)
+++ mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/swing/AttachmentsPart.java 2008-07-14 07:37:55 UTC (rev 197)
@@ -23,24 +23,34 @@
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
+import java.awt.Toolkit;
+import java.awt.datatransfer.Clipboard;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.Transferable;
import java.awt.event.ActionEvent;
+import java.awt.image.RenderedImage;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
+import javax.imageio.ImageIO;
import javax.swing.AbstractAction;
import javax.swing.DefaultListCellRenderer;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JList;
+import javax.swing.JOptionPane;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
+import org.mantisbt.connect.Utilities;
import org.mantisbt.connect.model.IIssue;
import org.mantisbt.connect.model.IIssueAttachment;
-import org.mantisbt.connect.model.IssueAttachment;
+import org.mantisbt.connect.ui.ByteArrayIssueAttachment;
import org.mantisbt.connect.ui.ISubmitter;
+import org.mantisbt.connect.ui.LocalFileIssueAttachment;
import org.mantisbt.connect.ui.Messages;
/**
@@ -55,7 +65,7 @@
protected JList attachments;
private ISubmitter submitter;
-
+
public AttachmentsPart(Component parent, ISubmitter submitter) {
super(parent);
this.submitter = submitter;
@@ -68,20 +78,16 @@
this.setLayout(gb);
// list
c.fill = GridBagConstraints.BOTH;
- c.gridx = 0;
- c.gridy = 0;
- c.gridheight = 2;
- c.weightx = 1;
- c.weighty = 1;
+ c.gridx = 0; c.gridy = 0;
+ c.gridheight = 3;
+ c.weightx = 1; c.weighty = 1;
attachments = makeList(this, gb, c, new AttachmentRenderer());
// add button
c.anchor = GridBagConstraints.NORTH;
c.fill = GridBagConstraints.HORIZONTAL;
- c.gridx = 1;
- c.gridy = 0;
+ c.gridx = 1; c.gridy = 0;
c.gridheight = 1;
- c.weightx = 0;
- c.weighty = 0;
+ c.weightx = 0; c.weighty = 0;
makeButton(this, new AddAttachmentAction(), gb, c);
// remove button
c.gridy = 1;
@@ -92,7 +98,9 @@
remove.setEnabled(attachments.getSelectedIndex() >= 0);
}
});
-
+ // paste button
+ c.gridy = 2;
+ makeButton(this, new AddClipboardContentsAction(), gb, c);
}
public void commit(IIssue issue) {
@@ -131,7 +139,107 @@
protected ISubmitter getSubmitter() {
return submitter;
}
+
+ protected String getInitialFileName(String prefix, String suffix) {
+ int counter = 1;
+ while (attachmentExists(prefix + counter + suffix)) {
+ counter += 1;
+ }
+ return prefix + counter + suffix;
+ }
+
+ public boolean attachmentExists(String filename) {
+ DefaultListModel model = (DefaultListModel) attachments.getModel();
+ for (int i = 0; i < model.getSize(); i++) {
+ if (((IIssueAttachment) model.getElementAt(i)).getFilename().equals(filename)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void addAttachment(IIssueAttachment attachment) {
+ ((DefaultListModel) attachments.getModel()).addElement(attachment);
+ }
+ protected boolean isValidFilename(String filename) {
+ return filename.indexOf('.') > 0;
+ }
+
+ protected boolean hasSuffix(String filename, String suffix) {
+ return filename.length() > suffix.length()
+ && filename.substring(filename.length() - suffix.length())
+ .equalsIgnoreCase(suffix);
+ }
+
+ private class AddClipboardContentsAction extends AbstractAction {
+
+ private static final long serialVersionUID = 4555789380983118942L;
+
+ public AddClipboardContentsAction() {
+ super(
+ Messages.getString("AttachmentsPart.Button.Clipboard"), SwingUtilities.loadImageIcon("icons/paste-16.png")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void actionPerformed(ActionEvent event) {
+ Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
+ Transferable contents = clipboard.getContents(null);
+ try {
+ if (contents != null) {
+ String message = null;
+ String initialSelection = null;
+ String suffix = null;
+ byte[] data = null;
+ if (contents.isDataFlavorSupported(DataFlavor.stringFlavor)) {
+ message = Messages.getString("AttachmentsPart.Message.Clipboard.Text"); //$NON-NLS-1$
+ initialSelection = getInitialTextName();
+ suffix = ".txt";
+ data = ((String) contents.getTransferData(DataFlavor.stringFlavor)).getBytes();
+ } else if (contents.isDataFlavorSupported(DataFlavor.imageFlavor)) {
+ message = Messages.getString("AttachmentsPart.Message.Clipboard.Image"); //$NON-NLS-1$
+ initialSelection = getInitialImageName();
+ suffix = ".png";
+ RenderedImage image = (RenderedImage) contents.getTransferData(DataFlavor.imageFlavor);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ImageIO.write(image, "png", baos);
+ data = baos.toByteArray();
+ } else {
+ SwingUtilities.showInfo(getOwner(), Messages.getString("AttachmentsPart.Message.NoValidData")); //$NON-NLS-1$
+ return;
+ }
+ String filename = JOptionPane.showInputDialog(getOwner(), message, initialSelection);
+ if (filename != null) {
+ filename = filename.trim();
+ if (! hasSuffix(filename, suffix)) {
+ filename += suffix;
+ }
+ if (! isValidFilename(filename)) {
+ SwingUtilities.showError(getOwner(), Messages.getString("AttachmentsPart.Message.InvalidName")); //$NON-NLS-1$
+ return;
+ }
+ if (attachmentExists(filename)) {
+ SwingUtilities.showError(getOwner(), Messages.getString("AttachmentsPart.Message.AttachmentExists")); //$NON-NLS-1$
+ } else if (filename != null) {
+ ByteArrayIssueAttachment attachment = new ByteArrayIssueAttachment(data, filename, Utilities.getMimeType(filename));
+ addAttachment(attachment);
+ }
+ }
+ }
+ } catch (Exception e) {
+ SwingUtilities.showError(getOwner(), e.getMessage());
+ }
+ }
+
+ private String getInitialImageName() {
+ return getInitialFileName("Image", ".png");
+ }
+
+ private String getInitialTextName() {
+ return getInitialFileName("Text", ".txt");
+ }
+
+ }
+
private class AddAttachmentAction extends AbstractAction {
private static final long serialVersionUID = -969508350501534323L;
@@ -144,11 +252,11 @@
public void actionPerformed(ActionEvent arg0) {
JFileChooser chooser = getFileChooser();
if (chooser.showOpenDialog(getOwner()) == JFileChooser.APPROVE_OPTION) {
- DefaultListModel model = (DefaultListModel) attachments.getModel();
- IssueAttachment attachment = new IssueAttachment();
- attachment.setFilename(chooser.getSelectedFile().toString());
- if (!model.contains(attachment)) {
- ((DefaultListModel) attachments.getModel()).addElement(attachment);
+ if (! attachmentExists(chooser.getSelectedFile().getName())) {
+ LocalFileIssueAttachment attachment = new LocalFileIssueAttachment(chooser.getSelectedFile());
+ addAttachment(attachment);
+ } else {
+ SwingUtilities.showError(getOwner(), Messages.getString("AttachmentsPart.Message.AttachmentExists")); //$NON-NLS-1$
}
}
}
Modified: mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/swing/GeneralPart.java
===================================================================
--- mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/swing/GeneralPart.java 2008-05-31 15:29:23 UTC (rev 196)
+++ mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/swing/GeneralPart.java 2008-07-14 07:37:55 UTC (rev 197)
@@ -47,6 +47,8 @@
public class GeneralPart extends AbstractIssueUiPart {
private static final long serialVersionUID = 3180009603418066347L;
+
+ private static String NO_VERSION = "";
protected JComboBox project;
@@ -228,7 +230,11 @@
public void commit(IIssue issue) {
issue.setProject((IMCAttribute) project.getSelectedItem());
issue.setCategory((String) category.getSelectedItem());
- issue.setVersion((String) version.getSelectedItem());
+ if (version.getSelectedIndex() == 0) {
+ issue.setVersion(null);
+ } else {
+ issue.setVersion((String) version.getSelectedItem());
+ }
issue.setReproducibility((IMCAttribute) reproducibility.getSelectedItem());
issue.setSeverity((IMCAttribute) severity.getSelectedItem());
issue.setPriority((IMCAttribute) priority.getSelectedItem());
@@ -335,6 +341,7 @@
IProjectVersion[] versions = getSession().getReleasedVersions(
selection.getId());
if (versions != null) {
+ version.addItem(NO_VERSION);
for (int i = 0; i < versions.length; i++) {
version.addItem(versions[i].getName());
}
Modified: mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/swing/IssueSubmitFrame.java
===================================================================
--- mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/swing/IssueSubmitFrame.java 2008-05-31 15:29:23 UTC (rev 196)
+++ mantisconnect/branches/clients/java/client-api/REL_BRANCH_1_1_1_0/src/main/org/mantisbt/connect/ui/swing/IssueSubmitFrame.java 2008-07-14 07:37:55 UTC (rev 197)
@@ -25,6 +25,8 @@
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
import javax.swing.AbstractAction;
import javax.swing.Action;
@@ -206,6 +208,11 @@
frame = new IssueSubmitFrame();
}
frame.setVisible(true);
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosed(WindowEvent e) {
+ System.exit(0);
+ }
+ });
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|