[7315] | 1 | package org.greenstone.gatherer.feedback;
|
---|
| 2 |
|
---|
| 3 | import java.io.*;
|
---|
| 4 | import java.awt.*;
|
---|
| 5 | import java.awt.image.*;
|
---|
| 6 | import java.awt.event.*;
|
---|
| 7 | import javax.swing.*;
|
---|
| 8 | import javax.swing.border.*;
|
---|
| 9 | import java.util.*;
|
---|
| 10 | import java.net.*;
|
---|
| 11 | import java.rmi.server.*;
|
---|
| 12 | import javax.imageio.*;
|
---|
| 13 | import java.util.Locale;
|
---|
| 14 | import java.util.ResourceBundle;
|
---|
| 15 | import java.text.MessageFormat;
|
---|
| 16 | import com.sun.image.codec.jpeg.*;
|
---|
| 17 | import javax.swing.Timer;
|
---|
| 18 | import org.greenstone.gatherer.util.Utility;
|
---|
| 19 |
|
---|
| 20 | /**
|
---|
| 21 | * This class will show the FeedbackInterface form.
|
---|
| 22 | * It will allow user to described about the problem better.Here we will also take some more information available
|
---|
| 23 | * in the system such as the size of the memory available and the screen size.User also could take more screenshot
|
---|
| 24 | * so they will be able to say the sequence of events that lead up to the problem.
|
---|
| 25 | * <br>If the user don't want to send this form, then all the information taken from this form will be deleted
|
---|
| 26 | * and user will be quitted from the Reporting Feedback sequence.
|
---|
| 27 | *
|
---|
| 28 | * @author Veronica Liesaputra
|
---|
| 29 | */
|
---|
| 30 | public class FeedbackInterface extends JDialog
|
---|
| 31 | implements ActionListener
|
---|
| 32 | {
|
---|
| 33 | /**
|
---|
| 34 | * This is the button user need to pressed if they want to view the files.
|
---|
| 35 | * This button will be disabled when the timer is running and finish = false.
|
---|
| 36 | */
|
---|
| 37 | private JButton view_button;
|
---|
| 38 |
|
---|
| 39 | /**
|
---|
| 40 | * This button means that the user finished give the information and
|
---|
| 41 | * want to send it.
|
---|
| 42 | */
|
---|
| 43 | public JButton send_button;
|
---|
| 44 |
|
---|
| 45 | /**
|
---|
| 46 | * This button means that the user don't want to send information and
|
---|
| 47 | * back to normal application.
|
---|
| 48 | * All the data taken start from user choose to start doing the Feedback sequence
|
---|
| 49 | * up to this point will be delete.
|
---|
| 50 | */
|
---|
| 51 | private JButton notsend_button;
|
---|
| 52 |
|
---|
| 53 | /**
|
---|
| 54 | * This is the text area where user can explain more about the problem.
|
---|
| 55 | */
|
---|
| 56 | private JTextArea problem_details;
|
---|
| 57 |
|
---|
| 58 | /**
|
---|
| 59 | * This is the combo box that allow user to specify the poblem type.
|
---|
| 60 | */
|
---|
| 61 | private JComboBox problem_type;
|
---|
| 62 |
|
---|
| 63 | /**
|
---|
| 64 | * This is the combo box that allow user to specify the urgency of the problem.
|
---|
| 65 | */
|
---|
| 66 | private JComboBox problem_urgency;
|
---|
| 67 |
|
---|
| 68 | /**
|
---|
| 69 | * This combo box will ask whether or not user want to send the screenshot.
|
---|
| 70 | */
|
---|
| 71 | private JComboBox problem_screenshot;
|
---|
| 72 |
|
---|
| 73 | /**
|
---|
| 74 | * This text field allow user to type the smtp address of their email that
|
---|
| 75 | * they want this application to use to send all the data.
|
---|
| 76 | * If they don't fill this field then it will set to the same
|
---|
| 77 | * smtp adress of where the data will be send to.
|
---|
| 78 | */
|
---|
| 79 | private JTextField smtp_address;
|
---|
| 80 |
|
---|
| 81 | /**
|
---|
| 82 | * This text field allow user to type the email adress that they want this
|
---|
| 83 | * application to use to send all the data.
|
---|
| 84 | * If they don't fill this field then it will set to the same email
|
---|
| 85 | * adress of where the data will be send to.
|
---|
| 86 | */
|
---|
| 87 | private JTextField email_address;
|
---|
| 88 |
|
---|
| 89 | /**
|
---|
| 90 | * This is the name of the window the user lastly used.
|
---|
| 91 | * This is the name of the window where the user called to start the Feedback
|
---|
| 92 | * sequence.
|
---|
| 93 | */
|
---|
| 94 | private String frameName;
|
---|
| 95 |
|
---|
| 96 | /**
|
---|
| 97 | * This is the unique code generated for each time user start doing the Feedback
|
---|
| 98 | * sequence.
|
---|
| 99 | * This code will be used as reference to which feedback that the user send.
|
---|
| 100 | */
|
---|
| 101 | private static String code;
|
---|
| 102 |
|
---|
| 103 | /**
|
---|
| 104 | * This is the date when the user start open this FeedbackInterface form.
|
---|
| 105 | */
|
---|
| 106 | private Date curr_date;
|
---|
| 107 |
|
---|
| 108 | /**
|
---|
| 109 | * This is the special listener class that record all the action user did in application.
|
---|
| 110 | */
|
---|
| 111 | private static ActionRecorderDialog dialog;
|
---|
| 112 |
|
---|
| 113 | /**
|
---|
| 114 | * This variable will hold the resource of the words that is stored in Messages.properties file.
|
---|
| 115 | * The calling using messages.getString(someString) will caused someString to be translated
|
---|
| 116 | * into some other string that is hold in that file.usually it will caused it to be translated
|
---|
| 117 | * to the language that the user use or choose to have as stated in Locale.
|
---|
| 118 | */
|
---|
| 119 | private static ResourceBundle messages;
|
---|
| 120 |
|
---|
| 121 | /**
|
---|
| 122 | * This is the screen shot instance that will allow the application to take screen shot of the whole
|
---|
| 123 | * screen or only the window that the user currently doing their action.
|
---|
| 124 | */
|
---|
| 125 | private ScreenShot screen;
|
---|
| 126 |
|
---|
| 127 | /**
|
---|
| 128 | * This is the thread that allows the encoding of the image file to String and the saving of image to
|
---|
| 129 | * a jpeg file happens concurrently.
|
---|
| 130 | */
|
---|
| 131 | private Thread save;
|
---|
| 132 |
|
---|
| 133 | /**
|
---|
| 134 | * This is the hashmap that hold the screen shot and the panel where the screenshot is held.
|
---|
| 135 | */
|
---|
| 136 | private HashMap picAndPane;
|
---|
| 137 |
|
---|
| 138 | /**
|
---|
| 139 | * This is the panel that hold all the panels containing the screenshots taken.
|
---|
| 140 | */
|
---|
| 141 | private JPanel picture_scroll;
|
---|
| 142 |
|
---|
| 143 | /**
|
---|
| 144 | * This is how many rows of screenshots panel displayed at the moment.
|
---|
| 145 | */
|
---|
| 146 | private int row;
|
---|
| 147 |
|
---|
| 148 | /**
|
---|
| 149 | * This is the array list that hold all the screenshots panel displayed.
|
---|
| 150 | */
|
---|
| 151 | private ArrayList paneArray;
|
---|
| 152 |
|
---|
| 153 | /**
|
---|
| 154 | * This button will remove the last screenshot panels.
|
---|
| 155 | */
|
---|
| 156 | private JButton remove;
|
---|
| 157 |
|
---|
| 158 | /**
|
---|
| 159 | * This is a reference to feedback interface displayed at the moment.
|
---|
| 160 | */
|
---|
| 161 | private FeedbackInterface frame;
|
---|
| 162 |
|
---|
| 163 | /**
|
---|
| 164 | * This is the thread to send all the xml files back to the developer.
|
---|
| 165 | */
|
---|
| 166 | private Thread sendThread;
|
---|
| 167 |
|
---|
| 168 | /**
|
---|
| 169 | * This is the flag to tell whether or not the sending files finished or not.
|
---|
| 170 | * It is also flag to tell whether or not the viewing files finished or not.
|
---|
| 171 | */
|
---|
| 172 | private static boolean finish;
|
---|
| 173 |
|
---|
| 174 | /**
|
---|
| 175 | * This is the timer to displayed the progress bar to tell user to wait while
|
---|
| 176 | * we sending the files or while we generate the xml files to be viewed.
|
---|
| 177 | * If finish = false then wait cursor,progress bar and wait label will be displayed.
|
---|
| 178 | * If finish = true then default cursor will be displayed.
|
---|
| 179 | */
|
---|
| 180 | private Timer timer;
|
---|
| 181 |
|
---|
| 182 | /**
|
---|
| 183 | * Progress bar displayed when user sending or want to view details.
|
---|
| 184 | */
|
---|
| 185 | private JProgressBar progressBar;
|
---|
| 186 |
|
---|
| 187 | /**
|
---|
| 188 | * Label displayed to tell user to wait for a while.
|
---|
| 189 | */
|
---|
| 190 | private JLabel wait_lbl;
|
---|
| 191 |
|
---|
| 192 | /**
|
---|
| 193 | * This is the background colour for the window.
|
---|
| 194 | */
|
---|
| 195 | private Color bckcolor;
|
---|
| 196 |
|
---|
| 197 | /**
|
---|
| 198 | * This is the panel to displayed all descriptions panel.
|
---|
| 199 | */
|
---|
| 200 | private JPanel tempPane;
|
---|
| 201 |
|
---|
| 202 | /**
|
---|
| 203 | * This is the thread that will be running when user pressed the preview button.
|
---|
| 204 | * This thread will show the 6 xml files that are going to be send. It will run concurrently
|
---|
| 205 | * with the timer, if value of finish = true, this thread will be null-ed.
|
---|
| 206 | */
|
---|
| 207 | private Thread prevThread;
|
---|
| 208 |
|
---|
| 209 | /**
|
---|
| 210 | * This is the flag to say whether or not this window should be dispose when timer is stop
|
---|
| 211 | * and finish = true.
|
---|
| 212 | * If selected = true then this window should be dispose, otherwise don't dispose it.
|
---|
| 213 | */
|
---|
| 214 | private boolean selected = false;
|
---|
| 215 |
|
---|
| 216 | /**
|
---|
| 217 | * This is a blocker to say that user cannot do anything while waiting.
|
---|
| 218 | */
|
---|
| 219 | private MouseListener mouse_blocker_listener = new MouseAdapter() {};
|
---|
| 220 |
|
---|
| 221 | /**
|
---|
| 222 | * Will make a dialog window that allows people to write more about the problem that want
|
---|
| 223 | * to send.
|
---|
| 224 | * This is the GUI for user to write on Feedback form. It is also setting the up the appropriate
|
---|
| 225 | * data member with the value passed on to this constructor.
|
---|
| 226 | * (Precondition: (sh != null) && (dlg != null) && (msg != null))
|
---|
| 227 | * @param sh an instance of ScreenShot that will allow application to take screenshot.
|
---|
| 228 | * @param frame_name name of the window where user called Feedback form from.
|
---|
| 229 | * @param msg holding the resource of the words that is stored in Messages.properties file.
|
---|
| 230 | * @param dlg holding the special listener.
|
---|
| 231 | */
|
---|
| 232 | public FeedbackInterface(ScreenShot sh,String frame_name,
|
---|
| 233 | ResourceBundle msg,ActionRecorderDialog dlg)
|
---|
| 234 | {
|
---|
| 235 | super();
|
---|
| 236 |
|
---|
| 237 | frame = this;
|
---|
| 238 |
|
---|
| 239 | bckcolor = new Color(176,209,217);
|
---|
| 240 |
|
---|
| 241 | picAndPane = new HashMap();
|
---|
| 242 |
|
---|
| 243 | messages = msg;
|
---|
| 244 | frameName = frame_name;
|
---|
| 245 | dialog = dlg;
|
---|
| 246 |
|
---|
| 247 | FeedbackInterface.setDefaultLookAndFeelDecorated(true);
|
---|
| 248 | setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
|
---|
| 249 | setTitle(messages.getString("SendFeedbackForm"));
|
---|
| 250 |
|
---|
| 251 | screen = sh;
|
---|
| 252 | Container container;
|
---|
| 253 | container = getContentPane();
|
---|
| 254 | createUI(container);
|
---|
| 255 | curr_date = new Date();
|
---|
| 256 |
|
---|
| 257 | Toolkit kit;
|
---|
| 258 | kit = Toolkit.getDefaultToolkit();
|
---|
| 259 | Dimension screenSize;
|
---|
| 260 | screenSize = kit.getScreenSize();
|
---|
| 261 | int screenHeight;
|
---|
| 262 | screenHeight = screenSize.height;
|
---|
| 263 | int screenWidth;
|
---|
| 264 | screenWidth = screenSize.width;
|
---|
| 265 | Dimension size;
|
---|
| 266 | size = this.getSize();
|
---|
| 267 | setLocation((screenWidth - size.width - 500) ,
|
---|
| 268 | (screenHeight - size.height - 700));
|
---|
| 269 |
|
---|
| 270 | setBackground(bckcolor);
|
---|
| 271 | pack();
|
---|
| 272 | setModal(false);
|
---|
| 273 | setVisible(true);
|
---|
| 274 | }
|
---|
| 275 |
|
---|
| 276 | /**
|
---|
| 277 | * This method is setting up the content pane for the Feedback form window.
|
---|
| 278 | * (Precondition: (window != null))
|
---|
| 279 | * @param window the content pane of Feedback form window.
|
---|
| 280 | */
|
---|
| 281 | public void createUI(Container window)
|
---|
| 282 | {
|
---|
| 283 | JPanel container;
|
---|
| 284 | container = new JPanel();
|
---|
| 285 | container.setBackground(bckcolor);
|
---|
| 286 | container.setLayout(new BoxLayout(container,BoxLayout.PAGE_AXIS));
|
---|
| 287 |
|
---|
| 288 | String opening_text;
|
---|
| 289 | opening_text = messages.getString("FeedbackOpeningText");
|
---|
| 290 | JTextArea textArea;
|
---|
| 291 | textArea = new JTextArea(opening_text);
|
---|
| 292 | textArea.setMinimumSize(new Dimension(100,100));
|
---|
| 293 | textArea.setOpaque(false);
|
---|
| 294 | textArea.setEditable(false);
|
---|
| 295 | textArea.setLineWrap(true);
|
---|
| 296 | textArea.setWrapStyleWord(true);
|
---|
| 297 | textArea.setBorder(new EmptyBorder(10,10,0,10));
|
---|
| 298 | textArea.setBackground(bckcolor);
|
---|
| 299 | container.add(textArea);
|
---|
| 300 |
|
---|
| 301 | tempPane = new JPanel();
|
---|
| 302 | tempPane.setLayout(new BorderLayout());
|
---|
| 303 | tempPane.setBackground(new Color(176,208,176));
|
---|
| 304 |
|
---|
| 305 | paneArray = new ArrayList();
|
---|
| 306 | picture_scroll = new JPanel();
|
---|
| 307 | row = 1;
|
---|
| 308 | picture_scroll.setLayout(new GridLayout(0,1));
|
---|
| 309 | picture_scroll.setBackground(new Color(176,208,176));
|
---|
| 310 | tempPane.add(picture_scroll,BorderLayout.PAGE_START);
|
---|
| 311 |
|
---|
| 312 | JPanel btnPanel;
|
---|
| 313 | btnPanel = new JPanel();
|
---|
| 314 | btnPanel.setBackground(new Color(176,208,176));
|
---|
| 315 | remove = new JButton("Remove");
|
---|
| 316 | remove.setActionCommand("Remove");
|
---|
| 317 | remove.addActionListener(new ActionListener ()
|
---|
| 318 | {
|
---|
| 319 | public void actionPerformed(ActionEvent e)
|
---|
| 320 | {
|
---|
| 321 | Object obj;
|
---|
| 322 | JPanel pane;
|
---|
| 323 |
|
---|
| 324 | if (paneArray.size() == 0)
|
---|
| 325 | System.out.println("There is no panel here!!");
|
---|
| 326 | else
|
---|
| 327 | {
|
---|
| 328 | pane = (JPanel) paneArray.get((row - 2));
|
---|
| 329 | obj = picAndPane.get(pane);
|
---|
| 330 | obj = null;
|
---|
| 331 | picAndPane.remove(pane);
|
---|
| 332 | paneArray.remove((row - 2));
|
---|
| 333 |
|
---|
| 334 | if (paneArray.size() == 0)
|
---|
| 335 | remove.setVisible(false);
|
---|
| 336 |
|
---|
| 337 | picture_scroll.remove(pane);
|
---|
| 338 |
|
---|
| 339 | row--;
|
---|
| 340 |
|
---|
| 341 | picture_scroll.setSize(picture_scroll.getPreferredSize());
|
---|
| 342 | picture_scroll.revalidate();
|
---|
| 343 | picture_scroll.repaint();
|
---|
| 344 | tempPane.setSize(tempPane.getPreferredSize());
|
---|
| 345 | tempPane.revalidate();
|
---|
| 346 | tempPane.repaint();
|
---|
| 347 | }
|
---|
| 348 | }
|
---|
| 349 | });
|
---|
| 350 | remove.setToolTipText("Remove last thumbnail");
|
---|
| 351 | remove.setBackground(new Color(176,208,176));
|
---|
| 352 | remove.setVisible(false);
|
---|
| 353 | btnPanel.add(remove);
|
---|
| 354 | tempPane.add(btnPanel,BorderLayout.PAGE_END);
|
---|
| 355 |
|
---|
| 356 | JScrollPane pict_scroll;
|
---|
| 357 | pict_scroll = new JScrollPane(tempPane);
|
---|
| 358 | pict_scroll.setBackground(bckcolor);
|
---|
| 359 | pict_scroll.setPreferredSize(new Dimension(300,300));
|
---|
| 360 | pict_scroll.setBorder(new EmptyBorder(0,10,10,10));
|
---|
| 361 | container.add(pict_scroll);
|
---|
| 362 |
|
---|
| 363 | JPanel pane;
|
---|
| 364 | pane = new JPanel();
|
---|
| 365 | pane.setBackground(bckcolor);
|
---|
| 366 | pane.setLayout(new GridLayout(0,2));
|
---|
| 367 | pane.setBorder(new EmptyBorder(10,10,10,10));
|
---|
| 368 |
|
---|
| 369 | JLabel txt_type;
|
---|
| 370 | txt_type = new JLabel(messages.getString("Whatkindofproblemisit") + "? ");
|
---|
| 371 | txt_type.setBackground(bckcolor);
|
---|
| 372 | pane.add(txt_type);
|
---|
| 373 |
|
---|
| 374 | String [] type = {" ",messages.getString("ContentError"),
|
---|
| 375 | messages.getString("ImageNotShow"),
|
---|
| 376 | messages.getString("StrangeBehaviour"),
|
---|
| 377 | messages.getString("SomethingUnexpectedHappen"),
|
---|
| 378 | messages.getString("HardToUse"),
|
---|
| 379 | messages.getString("Other")};
|
---|
| 380 | problem_type = new JComboBox(type);
|
---|
| 381 | problem_type.addActionListener(this);
|
---|
| 382 | problem_type.setBackground(bckcolor);
|
---|
| 383 | pane.add(problem_type);
|
---|
| 384 |
|
---|
| 385 | JLabel txt_urgent;
|
---|
| 386 | txt_urgent = new JLabel(messages.getString("Howbadistheproblem")+"? ");
|
---|
| 387 | txt_urgent.setBackground(bckcolor);
|
---|
| 388 | pane.add(txt_urgent);
|
---|
| 389 |
|
---|
| 390 | String[] urgent = {" ",messages.getString("Critical"),
|
---|
| 391 | messages.getString("Serious"),
|
---|
| 392 | messages.getString("Medium"),messages.getString("Minor"),
|
---|
| 393 | messages.getString("Trivial")};
|
---|
| 394 | problem_urgency = new JComboBox(urgent);
|
---|
| 395 | problem_urgency.addActionListener(this);
|
---|
| 396 | problem_urgency.setBackground(bckcolor);
|
---|
| 397 | pane.add(problem_urgency);
|
---|
| 398 |
|
---|
| 399 | /*JLabel txt_screenshot;
|
---|
| 400 | txt_screenshot= new JLabel(messages.getString("Doyouwanttosendthescreenshot") + "? ");
|
---|
| 401 | txt_screenshot.setBackground(new Color(108,168,108));
|
---|
| 402 | pane.add(txt_screenshot);
|
---|
| 403 |
|
---|
| 404 | String[] screenshot = {messages.getString("Yes"),
|
---|
| 405 | messages.getString("No")};
|
---|
| 406 | problem_screenshot = new JComboBox(screenshot);
|
---|
| 407 | problem_screenshot.addActionListener(this);
|
---|
| 408 | problem_screenshot.setBackground(new Color(108,168,108));
|
---|
| 409 | pane.add(problem_screenshot);*/
|
---|
| 410 |
|
---|
| 411 |
|
---|
| 412 | /*JLabel txt_smtp;
|
---|
| 413 | txt_smtp = new JLabel(messages.getString("SMTPaddress") + "? ");
|
---|
| 414 | txt_smtp.setBackground(new Color(176,208,176));
|
---|
| 415 | pane.add(txt_smtp);
|
---|
| 416 |
|
---|
| 417 | smtp_address = new JTextField();
|
---|
| 418 | smtp_address.setBackground(new Color(224,240,224));
|
---|
| 419 | pane.add(smtp_address);*/
|
---|
| 420 |
|
---|
| 421 |
|
---|
| 422 | /*JLabel txt_email;
|
---|
| 423 | txt_email = new JLabel(messages.getString("Emailaddress") + "? ");
|
---|
| 424 | txt_email.setBackground(new Color(176,208,176));
|
---|
| 425 | pane.add(txt_email);
|
---|
| 426 |
|
---|
| 427 | email_address = new JTextField();
|
---|
| 428 | email_address.setBackground(new Color(224,240,224));
|
---|
| 429 | pane.add(email_address);*/
|
---|
| 430 |
|
---|
| 431 | JLabel empty;
|
---|
| 432 | empty = new JLabel (" ");
|
---|
| 433 | empty.setBackground(bckcolor);
|
---|
| 434 | pane.add(empty);
|
---|
| 435 | JLabel empty2;
|
---|
| 436 | empty2 = new JLabel (" ");
|
---|
| 437 | empty2.setBackground(bckcolor);
|
---|
| 438 | pane.add(empty2);
|
---|
| 439 | container.add(pane);
|
---|
| 440 |
|
---|
| 441 | JPanel panely;
|
---|
| 442 | panely = new JPanel();
|
---|
| 443 | panely.setLayout(new GridLayout(0,3));
|
---|
| 444 | panely.setBackground(bckcolor);
|
---|
| 445 | panely.setBorder(new EmptyBorder(new Insets(10,10,10,10)));
|
---|
| 446 |
|
---|
| 447 | view_button = new JButton("Details . . .");
|
---|
| 448 | view_button.setActionCommand(messages.getString("Preview"));
|
---|
| 449 | view_button.addActionListener(this);
|
---|
| 450 | view_button.setToolTipText(messages.getString("ConformationPreview"));
|
---|
| 451 | view_button.setBackground(bckcolor);
|
---|
| 452 | panely.add(view_button);
|
---|
| 453 |
|
---|
| 454 | send_button = new JButton(messages.getString("Send"));
|
---|
| 455 | send_button.setActionCommand(messages.getString("Send"));
|
---|
| 456 | send_button.addActionListener(this);
|
---|
| 457 | send_button.setDefaultCapable(true);
|
---|
| 458 | send_button.setToolTipText(messages.getString("FeedbackSendButton"));
|
---|
| 459 | send_button.setBackground(bckcolor);
|
---|
| 460 | panely.add(send_button);
|
---|
| 461 |
|
---|
| 462 | notsend_button = new JButton("Cancel");
|
---|
| 463 | notsend_button.setActionCommand(messages.getString("NotSend"));
|
---|
| 464 | notsend_button.addActionListener(this);
|
---|
| 465 | notsend_button.setToolTipText(messages.getString("FeedbackNotSendButton"));
|
---|
| 466 | notsend_button.setBackground(bckcolor);
|
---|
| 467 | panely.add(notsend_button);
|
---|
| 468 | container.add(panely);
|
---|
| 469 |
|
---|
| 470 | //Align the left edges of the components.
|
---|
| 471 | textArea.setAlignmentX(Component.LEFT_ALIGNMENT);
|
---|
| 472 | pict_scroll.setAlignmentX(Component.LEFT_ALIGNMENT);
|
---|
| 473 | pane.setAlignmentX(Component.LEFT_ALIGNMENT);
|
---|
| 474 | panely.setAlignmentX(Component.LEFT_ALIGNMENT);
|
---|
| 475 |
|
---|
| 476 | String about;
|
---|
| 477 | about = messages.getString("FeedbackAboutText");
|
---|
| 478 | JTextArea about_txt;
|
---|
| 479 | about_txt = new JTextArea(about);
|
---|
| 480 | about_txt.setEditable(false);
|
---|
| 481 | about_txt.setLineWrap(true);
|
---|
| 482 | about_txt.setWrapStyleWord(true);
|
---|
| 483 | about_txt.setBackground(bckcolor);
|
---|
| 484 | about_txt.setBorder(new EmptyBorder(10,10,10,10));
|
---|
| 485 |
|
---|
| 486 | String privacy;
|
---|
| 487 | privacy = messages.getString("FeedbackPrivacyText");
|
---|
| 488 | JTextArea privacy_txt;
|
---|
| 489 | privacy_txt = new JTextArea(privacy);
|
---|
| 490 | privacy_txt.setEditable(false);
|
---|
| 491 | privacy_txt.setLineWrap(true);
|
---|
| 492 | privacy_txt.setWrapStyleWord(true);
|
---|
| 493 | privacy_txt.setBackground(bckcolor);
|
---|
| 494 | privacy_txt.setBorder(new EmptyBorder(10,10,10,10));
|
---|
| 495 |
|
---|
| 496 | JTabbedPane tab;
|
---|
| 497 | tab = new JTabbedPane();
|
---|
| 498 | tab.setBackground(bckcolor);
|
---|
| 499 | tab.addTab(messages.getString("Form"),container);
|
---|
| 500 | tab.addTab(messages.getString("About"),about_txt);
|
---|
| 501 | tab.addTab(messages.getString("Privacy"),privacy_txt);
|
---|
| 502 | tab.setBorder(new EmptyBorder(5,5,5,5));
|
---|
| 503 |
|
---|
| 504 | JPanel panelx;
|
---|
| 505 | panelx = new JPanel();
|
---|
| 506 | panelx.setLayout(new BoxLayout(panelx,BoxLayout.PAGE_AXIS));
|
---|
| 507 | panelx.setBackground(bckcolor);
|
---|
| 508 | panelx.setBorder(new EmptyBorder(new Insets(10,10,10,10)));
|
---|
| 509 |
|
---|
| 510 | wait_lbl = new JLabel(messages.getString("Pleasewait"));
|
---|
| 511 | wait_lbl.setBackground(bckcolor);
|
---|
| 512 | wait_lbl.setVisible(false);
|
---|
| 513 | panelx.add(wait_lbl);
|
---|
| 514 |
|
---|
| 515 | progressBar = new JProgressBar ();
|
---|
| 516 | progressBar.setBackground(bckcolor);
|
---|
| 517 | progressBar.setVisible(false);
|
---|
| 518 | panelx.add(progressBar);
|
---|
| 519 |
|
---|
| 520 | JLabel emp2;
|
---|
| 521 | emp2 = new JLabel (" ");
|
---|
| 522 | emp2.setBackground(bckcolor);
|
---|
| 523 | panelx.add(emp2);
|
---|
| 524 |
|
---|
| 525 | wait_lbl.setAlignmentX(Component.CENTER_ALIGNMENT);
|
---|
| 526 | progressBar.setAlignmentX(Component.CENTER_ALIGNMENT);
|
---|
| 527 | emp2.setAlignmentX(Component.CENTER_ALIGNMENT);
|
---|
| 528 |
|
---|
| 529 | final String p1;
|
---|
| 530 | final String p2;
|
---|
| 531 | p1 = "Tab";
|
---|
| 532 | p2 = "ProgressBar";
|
---|
| 533 |
|
---|
| 534 | final JPanel cards;
|
---|
| 535 | cards = new JPanel(new CardLayout());
|
---|
| 536 | cards.setBackground(bckcolor);
|
---|
| 537 | cards.add(tab,p1);
|
---|
| 538 | cards.add(panelx,p2);
|
---|
| 539 |
|
---|
| 540 | window.add(cards);
|
---|
| 541 |
|
---|
| 542 |
|
---|
| 543 | timer = new Timer(1000, new ActionListener()
|
---|
| 544 | {
|
---|
| 545 | public void actionPerformed(ActionEvent evt)
|
---|
| 546 | {
|
---|
| 547 | if (finish == true)
|
---|
| 548 | {
|
---|
| 549 | if (sendThread != null)
|
---|
| 550 | {
|
---|
| 551 | sendThread.interrupt();
|
---|
| 552 | sendThread = null;
|
---|
| 553 | }
|
---|
| 554 |
|
---|
| 555 | if (prevThread != null)
|
---|
| 556 | {
|
---|
| 557 | prevThread.interrupt();
|
---|
| 558 | prevThread = null;
|
---|
| 559 | }
|
---|
| 560 |
|
---|
| 561 | Component glass_pane;
|
---|
| 562 | glass_pane = frame.getGlassPane();
|
---|
| 563 |
|
---|
| 564 | glass_pane.setVisible(false);
|
---|
| 565 | glass_pane.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
---|
| 566 | glass_pane.removeMouseListener(mouse_blocker_listener);
|
---|
| 567 |
|
---|
| 568 | wait_lbl.setVisible(false);
|
---|
| 569 | progressBar.setIndeterminate(false);
|
---|
| 570 | progressBar.setVisible(false);
|
---|
| 571 |
|
---|
| 572 | frame.setTitle(messages.getString("SendFeedbackForm"));
|
---|
| 573 |
|
---|
| 574 | CardLayout cl = (CardLayout)(cards.getLayout());
|
---|
| 575 | cl.show(cards,p1);
|
---|
| 576 |
|
---|
| 577 | if (selected == true)
|
---|
| 578 | frame.dispose();
|
---|
| 579 |
|
---|
| 580 | timer.stop();
|
---|
| 581 | }
|
---|
| 582 | else
|
---|
| 583 | {
|
---|
| 584 | Component glass_pane;
|
---|
| 585 | glass_pane = frame.getGlassPane();
|
---|
| 586 |
|
---|
| 587 | glass_pane.addMouseListener(mouse_blocker_listener);
|
---|
| 588 | glass_pane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
---|
| 589 | glass_pane.setVisible(true);
|
---|
| 590 |
|
---|
| 591 | frame.setTitle("Please wait...");
|
---|
| 592 |
|
---|
| 593 | CardLayout cl = (CardLayout)(cards.getLayout());
|
---|
| 594 | cl.show(cards,p2);
|
---|
| 595 |
|
---|
| 596 | wait_lbl.setVisible(true);
|
---|
| 597 | progressBar.setIndeterminate(true);
|
---|
| 598 | progressBar.setVisible(true);
|
---|
| 599 | }
|
---|
| 600 | }
|
---|
| 601 | });
|
---|
| 602 | }
|
---|
| 603 |
|
---|
| 604 | /**
|
---|
| 605 | * This method will set the finish variable values.
|
---|
| 606 | * When the sending files is finished, the sending application will set the finish value to true.
|
---|
| 607 | * @param fin whether or not the send files is finished.
|
---|
| 608 | */
|
---|
| 609 | public static void setFinish (boolean fin)
|
---|
| 610 | {
|
---|
| 611 | finish = fin;
|
---|
| 612 | }
|
---|
| 613 |
|
---|
| 614 | /**
|
---|
| 615 | * This is the class to represent the whole panel that hold the screenshot and the comments
|
---|
| 616 | * about the screenshot.
|
---|
| 617 | */
|
---|
| 618 | private class ThumbnailPic implements Serializable
|
---|
| 619 | {
|
---|
| 620 | /**
|
---|
| 621 | * This is the panel that hold a thumbnail for a screenshot and a comments text area.
|
---|
| 622 | */
|
---|
| 623 | private JPanel picpane;
|
---|
| 624 |
|
---|
| 625 | /**
|
---|
| 626 | * This hold the BufferedImages for the whole screen version of screenshot.
|
---|
| 627 | */
|
---|
| 628 | private BufferedImage[] screenimages;
|
---|
| 629 |
|
---|
| 630 | /**
|
---|
| 631 | * This hold the BufferedImages for the window version only.
|
---|
| 632 | */
|
---|
| 633 | private BufferedImage[] windowimages;
|
---|
| 634 |
|
---|
| 635 | /**
|
---|
| 636 | * This is the text area where user can enter their comments.
|
---|
| 637 | */
|
---|
| 638 | private JTextArea problem_details;
|
---|
| 639 |
|
---|
| 640 | /**
|
---|
| 641 | * This is a flag to tell us which image user wants to send.Its defaults value is false.
|
---|
| 642 | * If iswindow = true then it means user wants to send the window version only.
|
---|
| 643 | * If iswindow = false then it means user wants to send the whole screen version.
|
---|
| 644 | */
|
---|
| 645 | private boolean iswindow;
|
---|
| 646 |
|
---|
| 647 | /**
|
---|
| 648 | * This is the titles for the panel.
|
---|
| 649 | * Usually this is the title of the window where user wants to do the screenshot.
|
---|
| 650 | * If the title is more than 40 characters then we will trim it and add ... at the back of it.
|
---|
| 651 | */
|
---|
| 652 | private String titles;
|
---|
| 653 |
|
---|
| 654 | /**
|
---|
| 655 | * This is the width of the image user wants to send.
|
---|
| 656 | */
|
---|
| 657 | private String iw;
|
---|
| 658 |
|
---|
| 659 | /**
|
---|
| 660 | * This is the height of the image user wants to send.
|
---|
| 661 | */
|
---|
| 662 | private String ih;
|
---|
| 663 |
|
---|
| 664 | /**
|
---|
| 665 | * This is the x-coordinate where the window located inside the whole screen image.
|
---|
| 666 | */
|
---|
| 667 | private int xcoord;
|
---|
| 668 |
|
---|
| 669 | /**
|
---|
| 670 | * This is the y-coordinate where the window located inside the whole screen image.
|
---|
| 671 | */
|
---|
| 672 | private int ycoord;
|
---|
| 673 |
|
---|
| 674 | /**
|
---|
| 675 | * This is the width of the window inside the whole screen image.
|
---|
| 676 | */
|
---|
| 677 | private int width;
|
---|
| 678 |
|
---|
| 679 | /**
|
---|
| 680 | * This is the height of the window inside the whole screen image.
|
---|
| 681 | */
|
---|
| 682 | private int height;
|
---|
| 683 |
|
---|
| 684 | /**
|
---|
| 685 | * This is the constructor that will setup the panel that contains
|
---|
| 686 | * a thumbnail screenshot and a comments text area.
|
---|
| 687 | * @param image the whole screen screenshot image.
|
---|
| 688 | * @param text the title for this pane.
|
---|
| 689 | * @param x the x-coordinate of the window inside the whole screen image.
|
---|
| 690 | * @param y the y-coordinate of the window inside the whole screen image.
|
---|
| 691 | * @param w the width of the window inside the whole screen image.
|
---|
| 692 | * @param h the height of the window inside the whole screen image.
|
---|
| 693 | */
|
---|
| 694 | //public ThumbnailPic (BufferedImage screen,byte[] image,String text)
|
---|
| 695 | public ThumbnailPic (BufferedImage image,String text,int x,int y,int w,int h)
|
---|
| 696 | {
|
---|
| 697 | xcoord = x;
|
---|
| 698 | ycoord = y;
|
---|
| 699 | width = w;
|
---|
| 700 | height = h;
|
---|
| 701 | iswindow = false;
|
---|
| 702 | titles = text;
|
---|
| 703 | screenimages = new BufferedImage[3];
|
---|
| 704 | windowimages = new BufferedImage[3];
|
---|
| 705 | //screenimages[0] = screen;
|
---|
| 706 | screenimages[0] = image;
|
---|
| 707 | screenimages[1] = null;
|
---|
| 708 | screenimages[2] = null;
|
---|
| 709 | windowimages[0] = null;
|
---|
| 710 | windowimages[1] = null;
|
---|
| 711 | windowimages[2] = null;
|
---|
| 712 | addPanel(image);
|
---|
| 713 | }
|
---|
| 714 |
|
---|
| 715 | /**
|
---|
| 716 | * This method will setup the components inside the panel properly.
|
---|
| 717 | * @param image the whole screen screenshot image.
|
---|
| 718 | */
|
---|
| 719 | //public void addPanel (byte[] image)
|
---|
| 720 | public void addPanel (BufferedImage image)
|
---|
| 721 | {
|
---|
| 722 | picpane = new JPanel();
|
---|
| 723 | picpane.setLayout(new BorderLayout());
|
---|
| 724 |
|
---|
| 725 | final JButton picture;
|
---|
| 726 | picture = new JButton();
|
---|
| 727 |
|
---|
| 728 | int w;
|
---|
| 729 | int h;
|
---|
| 730 |
|
---|
| 731 | w = (int) (150/2);
|
---|
| 732 | h = (int) (150/2);
|
---|
| 733 |
|
---|
| 734 | iw = "" + image.getWidth();
|
---|
| 735 | ih = "" + image.getHeight();
|
---|
| 736 |
|
---|
| 737 | ImageIcon thumbnail;
|
---|
| 738 | thumbnail = new ImageIcon(image.getScaledInstance(w,h,Image.SCALE_SMOOTH));
|
---|
| 739 |
|
---|
| 740 | picture.setIcon(thumbnail);
|
---|
| 741 | picture.setText("Draw . . .");
|
---|
| 742 | picture.setActionCommand("Scribble");
|
---|
| 743 | picture.addActionListener(new ActionListener()
|
---|
| 744 | {
|
---|
| 745 | public void actionPerformed (ActionEvent e)
|
---|
| 746 | {
|
---|
| 747 | frame.addMouseListener(mouse_blocker_listener);
|
---|
| 748 | frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
---|
| 749 | SelectPicture select;
|
---|
| 750 | select = new SelectPicture(screenimages,windowimages,iswindow,problem_details.getText(),messages);
|
---|
| 751 | frame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
---|
| 752 | frame.removeMouseListener(mouse_blocker_listener);
|
---|
| 753 | select.setWindowBounds(xcoord,ycoord,width,height);
|
---|
| 754 |
|
---|
| 755 | iswindow = select.getIsWindow();
|
---|
| 756 |
|
---|
| 757 | screenimages[0] = select.getImage3();
|
---|
| 758 | screenimages[1] = select.getImage();
|
---|
| 759 | screenimages[2] = select.getImage2();
|
---|
| 760 |
|
---|
| 761 | if (iswindow == true)
|
---|
| 762 | {
|
---|
| 763 | windowimages[0] = select.getWindowImage3();
|
---|
| 764 | windowimages[1] = select.getWindowImage();
|
---|
| 765 | windowimages[2] = select.getWindowImage2();
|
---|
| 766 | }
|
---|
| 767 | else
|
---|
| 768 | {
|
---|
| 769 | windowimages[0] = null;
|
---|
| 770 | windowimages[1] = null;
|
---|
| 771 | windowimages[2] = null;
|
---|
| 772 | }
|
---|
| 773 |
|
---|
| 774 | problem_details.setText(select.getDetails());
|
---|
| 775 |
|
---|
| 776 | int w,h;
|
---|
| 777 | w = (int) (150/2);
|
---|
| 778 | h = (int) (150/2);
|
---|
| 779 |
|
---|
| 780 | ImageIcon thumbnail;
|
---|
| 781 |
|
---|
| 782 | if (iswindow == false)
|
---|
| 783 | thumbnail = new ImageIcon(screenimages[1].getScaledInstance(w,h,Image.SCALE_SMOOTH));
|
---|
| 784 | else
|
---|
| 785 | thumbnail = new ImageIcon(windowimages[1].getScaledInstance(w,h,Image.SCALE_SMOOTH));
|
---|
| 786 |
|
---|
| 787 | picture.setIcon(thumbnail);
|
---|
| 788 |
|
---|
| 789 | if (select.getSendNow() == true)
|
---|
| 790 | {
|
---|
| 791 | ActionEvent evt;
|
---|
| 792 | evt = new ActionEvent(send_button,ActionEvent.ACTION_PERFORMED,messages.getString("Send"));
|
---|
| 793 |
|
---|
| 794 | frame.actionPerformed(evt);
|
---|
| 795 | }
|
---|
| 796 | }
|
---|
| 797 | });
|
---|
| 798 | picture.setToolTipText("Click if you want to draw on it");
|
---|
| 799 | picture.setMargin(new Insets(5,5,5,5));
|
---|
| 800 | picture.setVerticalTextPosition(AbstractButton.BOTTOM);
|
---|
| 801 | picture.setHorizontalTextPosition(AbstractButton.CENTER);
|
---|
| 802 | picture.setBackground(new Color(176,208,176));
|
---|
| 803 | picpane.add(picture,BorderLayout.LINE_START);
|
---|
| 804 |
|
---|
| 805 | JPanel txtPane;
|
---|
| 806 | txtPane = new JPanel(new BorderLayout());
|
---|
| 807 | txtPane.setBackground(new Color(176,208,176));
|
---|
| 808 | txtPane.setBorder(new EmptyBorder(5,5,5,5));
|
---|
| 809 |
|
---|
| 810 | JLabel lbldesc = new JLabel("Comments :");
|
---|
| 811 | lbldesc.setBackground(new Color(176,208,176));
|
---|
| 812 | txtPane.add(lbldesc,BorderLayout.PAGE_START);
|
---|
| 813 |
|
---|
| 814 | problem_details = new JTextArea();
|
---|
| 815 | problem_details.setWrapStyleWord(true);
|
---|
| 816 | problem_details.setEditable(true);
|
---|
| 817 | problem_details.setBackground(new Color(224,240,224));
|
---|
| 818 |
|
---|
| 819 | JScrollPane scroll;
|
---|
| 820 | scroll = new JScrollPane(problem_details);
|
---|
| 821 | scroll.setBackground(new Color(176,208,176));
|
---|
| 822 | scroll.setPreferredSize(new Dimension(300,150));
|
---|
| 823 | txtPane.add(scroll,BorderLayout.LINE_START);
|
---|
| 824 |
|
---|
| 825 | picpane.setSize(new Dimension(150,150));
|
---|
| 826 | picpane.add(txtPane,BorderLayout.CENTER);
|
---|
| 827 | }
|
---|
| 828 |
|
---|
| 829 | /**
|
---|
| 830 | * This method will get the width of the image user wants to send.
|
---|
| 831 | * @return the width of the image.
|
---|
| 832 | */
|
---|
| 833 | public String getWidth()
|
---|
| 834 | {
|
---|
| 835 | if (iswindow == false)
|
---|
| 836 | return "" + screenimages[0].getWidth();
|
---|
| 837 | else
|
---|
| 838 | {
|
---|
| 839 | return "" + windowimages[0].getWidth();
|
---|
| 840 | }
|
---|
| 841 | }
|
---|
| 842 |
|
---|
| 843 | /**
|
---|
| 844 | * This method will get the height of the image user wants to send.
|
---|
| 845 | * @return the height of the image.
|
---|
| 846 | */
|
---|
| 847 | public String getHeight()
|
---|
| 848 | {
|
---|
| 849 | if (iswindow == false)
|
---|
| 850 | return "" + screenimages[0].getHeight();
|
---|
| 851 | else
|
---|
| 852 | {
|
---|
| 853 | return "" + windowimages[0].getHeight();
|
---|
| 854 | }
|
---|
| 855 | }
|
---|
| 856 |
|
---|
| 857 | /**
|
---|
| 858 | * This method will get the titles of this panel.
|
---|
| 859 | * @return the panel's title.
|
---|
| 860 | */
|
---|
| 861 | public String getTitles()
|
---|
| 862 | {
|
---|
| 863 | return titles;
|
---|
| 864 | }
|
---|
| 865 |
|
---|
| 866 | /**
|
---|
| 867 | * This method will get user comments inside the text area.
|
---|
| 868 | * @return the user's comments.
|
---|
| 869 | */
|
---|
| 870 | public String getProblemDetails ()
|
---|
| 871 | {
|
---|
| 872 | String txt;
|
---|
| 873 | txt = problem_details.getText();
|
---|
| 874 |
|
---|
| 875 | if (txt == null)
|
---|
| 876 | return " ";
|
---|
| 877 | else
|
---|
| 878 | return txt;
|
---|
| 879 | }
|
---|
| 880 |
|
---|
| 881 | /**
|
---|
| 882 | * This method will setting up the text inside the text area.
|
---|
| 883 | * @param comments the text set to the text area.
|
---|
| 884 | */
|
---|
| 885 | public void setComments (String comments)
|
---|
| 886 | {
|
---|
| 887 | problem_details.setText(comments);
|
---|
| 888 | }
|
---|
| 889 |
|
---|
| 890 | /**
|
---|
| 891 | * This method will get the image that user wants to send.
|
---|
| 892 | * @return image going to be send.
|
---|
| 893 | */
|
---|
| 894 | public BufferedImage[] getImages ()
|
---|
| 895 | {
|
---|
| 896 | if (iswindow == false)
|
---|
| 897 | return screenimages;
|
---|
| 898 | else
|
---|
| 899 | return windowimages;
|
---|
| 900 | }
|
---|
| 901 |
|
---|
| 902 | /**
|
---|
| 903 | * This method will get the non-scribble lines image that user wants to send.
|
---|
| 904 | * @return the string representation of the non-scribble lines image.
|
---|
| 905 | */
|
---|
| 906 | public String getScreenImage ()
|
---|
| 907 | {
|
---|
| 908 | if (iswindow == false)
|
---|
| 909 | return convert(screenimages[0]);
|
---|
| 910 | else
|
---|
| 911 | return convert(windowimages[1]);
|
---|
| 912 | }
|
---|
| 913 |
|
---|
| 914 | /**
|
---|
| 915 | * This method will get the scribble lines image that user wants to send.
|
---|
| 916 | * @return the string representation of the scribble lines image.
|
---|
| 917 | */
|
---|
| 918 | public String getScreenAndLineImage ()
|
---|
| 919 | {
|
---|
| 920 | if (iswindow == false)
|
---|
| 921 | {
|
---|
| 922 | if (screenimages[1]!= null)
|
---|
| 923 | return convert(screenimages[1]);
|
---|
| 924 | else
|
---|
| 925 | return convert(screenimages[0]);
|
---|
| 926 | }
|
---|
| 927 | else
|
---|
| 928 | {
|
---|
| 929 | if (windowimages[1]!= null)
|
---|
| 930 | return convert(windowimages[1]);
|
---|
| 931 | else
|
---|
| 932 | return convert(windowimages[0]);
|
---|
| 933 | }
|
---|
| 934 | }
|
---|
| 935 |
|
---|
| 936 | /**
|
---|
| 937 | * This method will get only scribble lines image that user wants to send.
|
---|
| 938 | * @return the string representation of the only scribble lines image.
|
---|
| 939 | */
|
---|
| 940 | public String getLineForScreenImage ()
|
---|
| 941 | {
|
---|
| 942 | if (iswindow == false)
|
---|
| 943 | {
|
---|
| 944 | if (screenimages[2] != null)
|
---|
| 945 | return convert(screenimages[2]);
|
---|
| 946 | else
|
---|
| 947 | return "";
|
---|
| 948 | }
|
---|
| 949 | else
|
---|
| 950 | {
|
---|
| 951 | if (windowimages[2] != null)
|
---|
| 952 | return convert(windowimages[2]);
|
---|
| 953 | else
|
---|
| 954 | return "";
|
---|
| 955 | }
|
---|
| 956 | }
|
---|
| 957 |
|
---|
| 958 | /**
|
---|
| 959 | * This method will get the panel that hold a thumbnail and a text area.
|
---|
| 960 | * @return panel that represent the thumbnail and the text area.
|
---|
| 961 | */
|
---|
| 962 | public JPanel getPanel()
|
---|
| 963 | {
|
---|
| 964 | return picpane;
|
---|
| 965 | }
|
---|
| 966 | }
|
---|
| 967 |
|
---|
| 968 | /**
|
---|
| 969 | * This method will setting up the comments to be displayed inside the latest added panel.
|
---|
| 970 | * So if the window where user wants to take the screenshot at the moment is a modal window
|
---|
| 971 | * then it will setting the comments to ask user to close the window before they can enter
|
---|
| 972 | * their comments there.
|
---|
| 973 | * @param modal the modality of the window where user wants to take the screenshot.
|
---|
| 974 | */
|
---|
| 975 | public void setComment (boolean modal)
|
---|
| 976 | {
|
---|
| 977 | if (paneArray.size() == 0)
|
---|
| 978 | System.out.println("There is no panel here!!");
|
---|
| 979 | else
|
---|
| 980 | {
|
---|
| 981 | JPanel pane;
|
---|
| 982 | pane = (JPanel) paneArray.get((row - 2));
|
---|
| 983 | ThumbnailPic obj;
|
---|
| 984 | obj = (ThumbnailPic) picAndPane.get(pane);
|
---|
| 985 | String text;
|
---|
| 986 | if (modal == true)
|
---|
| 987 | text = "Please close '" + obj.getTitles() + "' window \nbefore you can enter comments here.";
|
---|
| 988 | else
|
---|
| 989 | text = " ";
|
---|
| 990 | obj.setComments(text);
|
---|
| 991 | }
|
---|
| 992 | }
|
---|
| 993 |
|
---|
| 994 | /**
|
---|
| 995 | * This method will add a panel that contains the thumbnail button and the text area.
|
---|
| 996 | * @param title the window's title.
|
---|
| 997 | * @param image the whole screen image.
|
---|
| 998 | * @param x the window's x-coordinate in the image.
|
---|
| 999 | * @param y the window's y-coordinate in the image.
|
---|
| 1000 | * @param width the window's width in the image.
|
---|
| 1001 | * @param height the window's height in the image.
|
---|
| 1002 | */
|
---|
| 1003 | //public void addScreenPanel (String title,BufferedImage screen,byte[] image)
|
---|
| 1004 | public void addScreenPanel (String title,BufferedImage image,int x,int y,int width,int height)
|
---|
| 1005 | {
|
---|
| 1006 | final JPanel pane;
|
---|
| 1007 | pane = new JPanel();
|
---|
| 1008 | pane.setLayout(new BorderLayout());
|
---|
| 1009 | pane.setBackground(new Color(176,208,176));
|
---|
| 1010 |
|
---|
| 1011 | Border loweredetched;
|
---|
| 1012 | loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
|
---|
| 1013 |
|
---|
| 1014 | String ttl;
|
---|
| 1015 | if (title.length() > 41)
|
---|
| 1016 | ttl = title.substring(0,40) + " . . . ";
|
---|
| 1017 | else
|
---|
| 1018 | ttl = title;
|
---|
| 1019 |
|
---|
| 1020 | TitledBorder border;
|
---|
| 1021 | border = BorderFactory.createTitledBorder(loweredetched, title);
|
---|
| 1022 | border.setTitleJustification(TitledBorder.LEFT);
|
---|
| 1023 |
|
---|
| 1024 | pane.setBorder(BorderFactory.createCompoundBorder(new EmptyBorder(5,5,5,5),border));
|
---|
| 1025 |
|
---|
| 1026 | ThumbnailPic pic;
|
---|
| 1027 | //pic = new ThumbnailPic(screen,image,title);
|
---|
| 1028 | pic = new ThumbnailPic(image,title,x,y,width,height);
|
---|
| 1029 | picAndPane.put(pane,pic);
|
---|
| 1030 | pane.add(pic.getPanel(),BorderLayout.LINE_START);
|
---|
| 1031 |
|
---|
| 1032 | remove.setVisible(true);
|
---|
| 1033 | picture_scroll.add(pane);
|
---|
| 1034 | paneArray.add(pane);
|
---|
| 1035 | row++;
|
---|
| 1036 | picture_scroll.setSize(picture_scroll.getPreferredSize());
|
---|
| 1037 | picture_scroll.revalidate();
|
---|
| 1038 | picture_scroll.repaint();
|
---|
| 1039 | tempPane.setSize(tempPane.getPreferredSize());
|
---|
| 1040 | tempPane.revalidate();
|
---|
| 1041 | tempPane.repaint();
|
---|
| 1042 | }
|
---|
| 1043 |
|
---|
| 1044 | /**
|
---|
| 1045 | * This method will generate the unique code that will be used as the
|
---|
| 1046 | * reference number of the feedback that user are about to send.
|
---|
| 1047 | * @return the unique code.
|
---|
| 1048 | */
|
---|
| 1049 | public String getPrevData ()
|
---|
| 1050 | {
|
---|
| 1051 | try
|
---|
| 1052 | {
|
---|
| 1053 | UID id = new UID();
|
---|
| 1054 | code = "" + InetAddress.getLocalHost().hashCode() + id.hashCode();
|
---|
| 1055 | }
|
---|
| 1056 | catch (UnknownHostException exp) {}
|
---|
| 1057 | return code;
|
---|
| 1058 | }
|
---|
| 1059 |
|
---|
| 1060 | /**
|
---|
| 1061 | * This method allows another class to get the unique code that can be used as
|
---|
| 1062 | * the reference number of the feedback that user are about to send.
|
---|
| 1063 | * This method should be called only if
|
---|
| 1064 | * getPrevData() method already been called before.Otherwise it will return null.
|
---|
| 1065 | * @return the unique code
|
---|
| 1066 | */
|
---|
| 1067 | public static String getCode()
|
---|
| 1068 | {
|
---|
| 1069 | return code;
|
---|
| 1070 | }
|
---|
| 1071 |
|
---|
| 1072 | /**
|
---|
| 1073 | * This method will encode BufferedImage into their String representation using
|
---|
| 1074 | * Base64 encoder.
|
---|
| 1075 | * (Precondition: (image != null))
|
---|
| 1076 | * @param image is the image that we want to encode to String.
|
---|
| 1077 | */
|
---|
| 1078 | public String convert (BufferedImage image)
|
---|
| 1079 | {
|
---|
| 1080 | String txt;
|
---|
| 1081 | txt = null;
|
---|
| 1082 |
|
---|
| 1083 | try
|
---|
| 1084 | {
|
---|
| 1085 | ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
---|
| 1086 | ImageIO.write(image,"jpeg",stream);
|
---|
| 1087 | byte[] bytes = stream.toByteArray();
|
---|
| 1088 |
|
---|
| 1089 | txt = Base64.encodeBytes(bytes);
|
---|
| 1090 |
|
---|
| 1091 | }
|
---|
| 1092 | catch(IOException ex) {}
|
---|
| 1093 |
|
---|
| 1094 | return txt;
|
---|
| 1095 | }
|
---|
| 1096 |
|
---|
| 1097 | /**
|
---|
| 1098 | * This method is to make sure that there is no thread running at the moment.
|
---|
| 1099 | */
|
---|
| 1100 | private void ensureEventThread()
|
---|
| 1101 | {
|
---|
| 1102 | if(SwingUtilities.isEventDispatchThread())
|
---|
| 1103 | {
|
---|
| 1104 | return;
|
---|
| 1105 | }
|
---|
| 1106 | throw new RuntimeException(messages.getString("file"));
|
---|
| 1107 | }
|
---|
| 1108 |
|
---|
| 1109 | /**
|
---|
| 1110 | * This method will create all 6 xml files, jarred them into one file, deletes all xml files and
|
---|
| 1111 | * sending it.
|
---|
| 1112 | * The xml files for:
|
---|
| 1113 | * <br> 1.The history & information of all the actions done and windows opened by the application
|
---|
| 1114 | * after user choose to start the sequence of sending feedback.
|
---|
| 1115 | * <br> 2.The history of all the commands (actions) done by the user before choosing
|
---|
| 1116 | * after start the sequence of sending feedback.
|
---|
| 1117 | * <br> 3.The informations we get from the feedback interface form period.
|
---|
| 1118 | * <br> will be getting from vector and the temp_feedbackhist.log file.
|
---|
| 1119 | * (Precondition: (sx != null) && (vector != null) && (err_array != null))
|
---|
| 1120 | * @param sx the xml parser.
|
---|
| 1121 | * @param vector the vector that hold the history and information.
|
---|
| 1122 | * @param err_array the arrays of information we take from the feedback interface period.
|
---|
| 1123 | * @param imgFile the arrays of information we take from the panels inside feedback interface form.
|
---|
| 1124 | */
|
---|
| 1125 | private void sendState (SaveToXML sx,Vector vector,String[] err_array,String[] imgFile)
|
---|
| 1126 | {
|
---|
| 1127 | String dirname;
|
---|
| 1128 | dirname = "xmlfeedback/";
|
---|
| 1129 |
|
---|
| 1130 | File dir = new File("xmlfeedback");
|
---|
| 1131 | if (dir.isDirectory() == false)
|
---|
| 1132 | dir.mkdir();
|
---|
| 1133 |
|
---|
| 1134 | sx.saveFeedback(err_array,imgFile);
|
---|
| 1135 |
|
---|
| 1136 | sx.open(dirname + "feedbackcontent" + FeedbackInterface.getCode() + ".xml",
|
---|
| 1137 | "HISTORY");
|
---|
| 1138 | SaveToXML sx2;
|
---|
| 1139 | sx2 = new SaveToXML(messages);
|
---|
| 1140 | sx2.open(dirname + "feedbackcommand" + FeedbackInterface.getCode() + ".xml",
|
---|
| 1141 | "COMMANDS");
|
---|
| 1142 |
|
---|
| 1143 | for (int i = 0 ; i < vector.size() ; i++)
|
---|
| 1144 | {
|
---|
| 1145 | History log;
|
---|
| 1146 | log = (History) vector.get(i);
|
---|
| 1147 | log.sendXML(sx);
|
---|
| 1148 | log.sendXMLComm(sx2);
|
---|
| 1149 | }
|
---|
| 1150 |
|
---|
| 1151 | Vector stack;
|
---|
| 1152 | stack = getPrev_log();
|
---|
| 1153 | if (stack != null)
|
---|
| 1154 | {
|
---|
| 1155 | for (int i = 0 ; i < stack.size() ; i++)
|
---|
| 1156 | {
|
---|
| 1157 | History log;
|
---|
| 1158 | log = (History) stack.get(i);
|
---|
| 1159 | log.sendXML(sx);
|
---|
| 1160 | log.sendXMLComm(sx2);
|
---|
| 1161 | }
|
---|
| 1162 | stack.removeAllElements();
|
---|
| 1163 | System.gc();
|
---|
| 1164 | stack = null;
|
---|
| 1165 | }
|
---|
| 1166 |
|
---|
| 1167 | sx2.close("COMMANDS");
|
---|
| 1168 | sx.close("HISTORY");
|
---|
| 1169 |
|
---|
| 1170 | getHistPrev_log(sx,sx2);
|
---|
| 1171 |
|
---|
| 1172 | ZipFile zip;
|
---|
| 1173 | zip = new ZipFile();
|
---|
| 1174 | zip.sendZipXMLFile();
|
---|
| 1175 |
|
---|
| 1176 | File f;
|
---|
| 1177 | f = new File (dirname + "feedback" + FeedbackInterface.getCode() + ".xml");
|
---|
| 1178 | f.delete();
|
---|
| 1179 | f = new File (dirname + "feedbackcontent" + FeedbackInterface.getCode() + ".xml");
|
---|
| 1180 | f.delete();
|
---|
| 1181 | f = new File (dirname + "feedbackcommand" + FeedbackInterface.getCode() + ".xml");
|
---|
| 1182 | f.delete();
|
---|
| 1183 | /*f = new File (dirname + "content" + FeedbackInterface.getCode() + ".xml");
|
---|
| 1184 | f.delete();*/
|
---|
| 1185 | f = new File (dirname + "command" + FeedbackInterface.getCode() + ".xml");
|
---|
| 1186 | f.delete();
|
---|
| 1187 |
|
---|
| 1188 | String[] args = new String[5];
|
---|
| 1189 | args[0] = "[email protected]";
|
---|
| 1190 | args[1] = dirname + "Jar" + FeedbackInterface.getCode() + "File.jar";
|
---|
| 1191 | args[4] = "lib/parser.jar";
|
---|
| 1192 | args[2] = err_array[19];
|
---|
| 1193 | args[3] = err_array[20];
|
---|
| 1194 | SendHTTP sm = new SendHTTP();
|
---|
| 1195 | //SendMail sm = new SendMail();
|
---|
| 1196 | sm.sendMail(args,messages,FeedbackInterface.getCode());
|
---|
| 1197 | }
|
---|
| 1198 |
|
---|
| 1199 | /**
|
---|
| 1200 | * This method will create the 2 xml files.
|
---|
| 1201 | * The xml files are:
|
---|
| 1202 | * <br> 1.The history & information of all the actions done and windows opened by the application
|
---|
| 1203 | * before user choose to start the sequence of sending feedback.
|
---|
| 1204 | * <br> 2.The history of all the commands (actions) done by the user before choosing
|
---|
| 1205 | * to start the sequence of sending feedback.
|
---|
| 1206 | * <br> The information will be getting from history.log file and the temp_history.log file.
|
---|
| 1207 | * (Precondition: (sx != null) && (sx2 != null))
|
---|
| 1208 | * @param sx the xml parser for the history xml file.
|
---|
| 1209 | * @param sx2 the xml parser for the command xml file.
|
---|
| 1210 | */
|
---|
| 1211 | private void getHistPrev_log(SaveToXML sx,SaveToXML sx2)
|
---|
| 1212 | {
|
---|
| 1213 | Vector stack = null;
|
---|
| 1214 | try
|
---|
| 1215 | {
|
---|
| 1216 | File f = new File("history.log");
|
---|
| 1217 | if (f.exists() == true)
|
---|
| 1218 | {
|
---|
| 1219 | FileInputStream fis = new FileInputStream(f);
|
---|
| 1220 | ObjectInputStream ois = new ObjectInputStream(fis);
|
---|
| 1221 |
|
---|
| 1222 | stack = (Vector) ois.readObject();
|
---|
| 1223 |
|
---|
| 1224 | String dirname;
|
---|
| 1225 | dirname = "xmlfeedback/";
|
---|
| 1226 |
|
---|
| 1227 | /*sx.open(dirname + "content" + FeedbackInterface.getCode() + ".xml",
|
---|
| 1228 | "HISTORY");*/
|
---|
| 1229 | sx2.open(dirname + "command" + FeedbackInterface.getCode() + ".xml",
|
---|
| 1230 | "COMMANDS");
|
---|
| 1231 |
|
---|
| 1232 | if (stack != null)
|
---|
| 1233 | {
|
---|
| 1234 | for (int i = 0 ; i < stack.size() ; i++)
|
---|
| 1235 | {
|
---|
| 1236 | History log;
|
---|
| 1237 | log = (History) stack.get(i);
|
---|
| 1238 | //log.sendXML(sx);
|
---|
| 1239 | log.sendXMLComm(sx2);
|
---|
| 1240 | }
|
---|
| 1241 | stack.removeAllElements();
|
---|
| 1242 | System.gc();
|
---|
| 1243 | stack = null;
|
---|
| 1244 | }
|
---|
| 1245 |
|
---|
| 1246 | stack = (Vector) ois.readObject();
|
---|
| 1247 |
|
---|
| 1248 | if (stack != null)
|
---|
| 1249 | {
|
---|
| 1250 | for (int i = 0 ; i < stack.size() ; i++)
|
---|
| 1251 | {
|
---|
| 1252 | History log;
|
---|
| 1253 | log = (History) stack.get(i);
|
---|
| 1254 | //log.sendXML(sx);
|
---|
| 1255 | log.sendXMLComm(sx2);
|
---|
| 1256 | }
|
---|
| 1257 | stack.removeAllElements();
|
---|
| 1258 | System.gc();
|
---|
| 1259 | stack = null;
|
---|
| 1260 | }
|
---|
| 1261 |
|
---|
| 1262 | sx2.close("COMMANDS");
|
---|
| 1263 | //sx.close("HISTORY");
|
---|
| 1264 |
|
---|
| 1265 | ois.close();
|
---|
| 1266 | }
|
---|
| 1267 | }
|
---|
| 1268 | catch (IOException exp) {exp.printStackTrace();}
|
---|
| 1269 | catch (ClassNotFoundException exp2)
|
---|
| 1270 | {
|
---|
| 1271 | System.out.println("class exp");}
|
---|
| 1272 | }
|
---|
| 1273 |
|
---|
| 1274 | /**
|
---|
| 1275 | * This method will get the Vector stored in temp_feedbackhist.log file.
|
---|
| 1276 | * @return the vector stored in temp_feedbackhist.log file.
|
---|
| 1277 | */
|
---|
| 1278 | public Vector getPrev_log()
|
---|
| 1279 | {
|
---|
| 1280 | Vector stack = null;
|
---|
| 1281 | try
|
---|
| 1282 | {
|
---|
| 1283 | File f = new File("temp_feedbackhist.log");
|
---|
| 1284 | if (f.exists() == true)
|
---|
| 1285 | {
|
---|
| 1286 | FileInputStream fis = new FileInputStream(f);
|
---|
| 1287 | ObjectInputStream ois = new ObjectInputStream(fis);
|
---|
| 1288 | stack = (Vector) ois.readObject();
|
---|
| 1289 | ois.close();
|
---|
| 1290 | return stack;
|
---|
| 1291 | }
|
---|
| 1292 | else
|
---|
| 1293 | stack = null;
|
---|
| 1294 | }
|
---|
| 1295 | catch (IOException exp) {exp.printStackTrace();}
|
---|
| 1296 | catch (ClassNotFoundException exp2)
|
---|
| 1297 | {
|
---|
| 1298 | System.out.println("class exp");}
|
---|
| 1299 |
|
---|
| 1300 | return stack;
|
---|
| 1301 | }
|
---|
| 1302 |
|
---|
| 1303 | /**
|
---|
| 1304 | * This is the thread that will start when user click send button and it will
|
---|
| 1305 | * make 6 xml files,jarred them together into 1 jar file, deletes the 6 xml files and send it.
|
---|
| 1306 | * @param vector the vector stored the current actions history.
|
---|
| 1307 | * @param err_array the array that stored all the information took during feedback interface period.
|
---|
| 1308 | * @param imgFile the array of that stored all the information from all the panels inside feedback interface form.
|
---|
| 1309 | */
|
---|
| 1310 | public void sendMethod (final Vector vector,final String err_array[], final String imgFile[])
|
---|
| 1311 | {
|
---|
| 1312 | ensureEventThread();
|
---|
| 1313 | Runnable sendRun;
|
---|
| 1314 | sendRun = new Runnable()
|
---|
| 1315 | {
|
---|
| 1316 | public void run ()
|
---|
| 1317 | {
|
---|
| 1318 | finish = false;
|
---|
| 1319 | selected = true;
|
---|
| 1320 | SaveToXML sx;
|
---|
| 1321 | sx = new SaveToXML(messages);
|
---|
| 1322 | sendState(sx,vector,err_array,imgFile);
|
---|
| 1323 | finish = true;
|
---|
| 1324 | }
|
---|
| 1325 | };
|
---|
| 1326 | sendThread = new Thread(sendRun);
|
---|
| 1327 | sendThread.start();
|
---|
| 1328 | }
|
---|
| 1329 |
|
---|
| 1330 | /**
|
---|
| 1331 | * This method will called the window that will display the preview of all
|
---|
| 1332 | * the file going to be send.
|
---|
| 1333 | * @param vector the vector stored the current actions history.
|
---|
| 1334 | * @param err_array the array that stored all the information took during feedback interface period.
|
---|
| 1335 | * @param imgFile the array of that stored all the information from all the panels inside feedback interface form.
|
---|
| 1336 | */
|
---|
| 1337 | public void viewMethod (final Vector vector,final String err_array[], final String imgFile[])
|
---|
| 1338 | {
|
---|
| 1339 | ensureEventThread();
|
---|
| 1340 | Runnable prevRun;
|
---|
| 1341 | prevRun = new Runnable()
|
---|
| 1342 | {
|
---|
| 1343 | public void run ()
|
---|
| 1344 | {
|
---|
| 1345 | finish = false;
|
---|
| 1346 | selected = false;
|
---|
| 1347 | ReportDetails rd;
|
---|
| 1348 | rd = new ReportDetails(vector,err_array,imgFile,messages,true);
|
---|
| 1349 | finish = true;
|
---|
| 1350 | }
|
---|
| 1351 | };
|
---|
| 1352 |
|
---|
| 1353 | prevThread = new Thread(prevRun);
|
---|
| 1354 | prevThread.start();
|
---|
| 1355 | }
|
---|
| 1356 |
|
---|
| 1357 | /**
|
---|
| 1358 | * This method will save a BufferedImage to a jpeg file with the specified filename.
|
---|
| 1359 | * This method is a thread that will caused the thread save to be started and stop
|
---|
| 1360 | * if the saving process is finished.
|
---|
| 1361 | * (Precondition: (I != null))
|
---|
| 1362 | * @param I is the BufferedImage that we want to save.
|
---|
| 1363 | * @param picScreen name of the jpeg file where we want to store the BufferedImage
|
---|
| 1364 | */
|
---|
| 1365 | public void saveGraph(final BufferedImage I,final String picScreen)
|
---|
| 1366 | {
|
---|
| 1367 | ensureEventThread();
|
---|
| 1368 | Runnable saveRun;
|
---|
| 1369 | saveRun = new Runnable ()
|
---|
| 1370 | {
|
---|
| 1371 | public void run()
|
---|
| 1372 | {
|
---|
| 1373 | try
|
---|
| 1374 | {
|
---|
| 1375 | File file;
|
---|
| 1376 | file = new File(picScreen);
|
---|
| 1377 | FileOutputStream out;
|
---|
| 1378 | out = new FileOutputStream(file);
|
---|
| 1379 |
|
---|
| 1380 | JPEGImageEncoder encoder;
|
---|
| 1381 | encoder = JPEGCodec.createJPEGEncoder(out);
|
---|
| 1382 | JPEGEncodeParam param;
|
---|
| 1383 | param = encoder.getDefaultJPEGEncodeParam(I);
|
---|
| 1384 | param.setQuality(1.0f, false);
|
---|
| 1385 | encoder.setJPEGEncodeParam(param);
|
---|
| 1386 | encoder.encode(I);
|
---|
| 1387 | out.close();
|
---|
| 1388 | save = null;
|
---|
| 1389 | }
|
---|
| 1390 | catch (Exception ex) {}
|
---|
| 1391 | }
|
---|
| 1392 | };
|
---|
| 1393 |
|
---|
| 1394 | save = new Thread(saveRun);
|
---|
| 1395 | save.start();
|
---|
| 1396 | }
|
---|
| 1397 |
|
---|
| 1398 | /**
|
---|
| 1399 | * This method will get all the informations from the all the panels inside the feedback interface form.
|
---|
| 1400 | * @return the arrays of information from all the panels.
|
---|
| 1401 | */
|
---|
| 1402 | public String[] getimgFile()
|
---|
| 1403 | {
|
---|
| 1404 | String[] imgFile;
|
---|
| 1405 | imgFile = null;
|
---|
| 1406 |
|
---|
| 1407 | /*String answer;
|
---|
| 1408 | answer = (String) problem_screenshot.getSelectedItem();
|
---|
| 1409 | if(answer == messages.getString("Yes"))
|
---|
| 1410 | {*/
|
---|
| 1411 |
|
---|
| 1412 | if (paneArray.size() > 0)
|
---|
| 1413 | {
|
---|
| 1414 | imgFile = new String[(paneArray.size() * 10)];
|
---|
| 1415 |
|
---|
| 1416 | int step;
|
---|
| 1417 | for (step = 0 ; step < (paneArray.size()*10) ; step=step+10)
|
---|
| 1418 | {
|
---|
| 1419 | JPanel pane;
|
---|
| 1420 | ThumbnailPic obj;
|
---|
| 1421 | pane = (JPanel) paneArray.get((step/10));
|
---|
| 1422 | obj = (ThumbnailPic) picAndPane.get(pane);
|
---|
| 1423 |
|
---|
| 1424 | //obj.setSize();
|
---|
| 1425 |
|
---|
| 1426 | String title;
|
---|
| 1427 | title = obj.getTitles();
|
---|
| 1428 |
|
---|
| 1429 | imgFile[step+0] = title;
|
---|
| 1430 | imgFile[step+1] = obj.getScreenImage();
|
---|
| 1431 | title = "Window" + pane.hashCode() + "File";
|
---|
| 1432 | imgFile[step+2] = messages.getString("screen")+title+step+".jpg";
|
---|
| 1433 | imgFile[step+3] = obj.getScreenAndLineImage();
|
---|
| 1434 | imgFile[step+4] = messages.getString("ErrorLineAnd")+imgFile[step+2];
|
---|
| 1435 | imgFile[step+5] = obj.getLineForScreenImage();
|
---|
| 1436 | imgFile[step+6] = messages.getString("ErrorLineFor")+imgFile[step+2];
|
---|
| 1437 | imgFile[step+7] = obj.getWidth();
|
---|
| 1438 | imgFile[step+8] = obj.getHeight();
|
---|
| 1439 | imgFile[step+9] = obj.getProblemDetails();
|
---|
| 1440 | }
|
---|
| 1441 | }
|
---|
| 1442 |
|
---|
| 1443 | return imgFile;
|
---|
| 1444 | }
|
---|
| 1445 |
|
---|
| 1446 | /**
|
---|
| 1447 | * This method will get all the informations taken during feedback interface period, such as os version.
|
---|
| 1448 | * @return then arrays of informations.
|
---|
| 1449 | */
|
---|
| 1450 | public String[] geterr_array()
|
---|
| 1451 | {
|
---|
| 1452 | String[] err_array;
|
---|
| 1453 | err_array = null;
|
---|
| 1454 |
|
---|
| 1455 | String os_name;
|
---|
| 1456 | os_name = System.getProperty("os.name") + " " + System.getProperty("os.version")
|
---|
| 1457 | + " " + System.getProperty("os.arch");
|
---|
| 1458 |
|
---|
| 1459 | Date problem_date;
|
---|
| 1460 | String err_date,java_info,screen_res;
|
---|
| 1461 | problem_date = new Date();
|
---|
| 1462 | err_date = problem_date.toString();
|
---|
| 1463 | java_info = System.getProperty("java.vendor")+ " " + System.getProperty("java.class.version");
|
---|
| 1464 | Dimension dim;
|
---|
| 1465 | dim = Toolkit.getDefaultToolkit().getScreenSize();
|
---|
| 1466 | screen_res = "" + dim.width + "x" + dim.height;
|
---|
| 1467 |
|
---|
| 1468 | try
|
---|
| 1469 | {
|
---|
| 1470 | err_array = new String[24];
|
---|
| 1471 |
|
---|
| 1472 | err_array[0] = code;
|
---|
| 1473 | err_array[1] = frameName;
|
---|
| 1474 | err_array[2] = "";
|
---|
| 1475 | err_array[3] = (String) problem_type.getSelectedItem();
|
---|
| 1476 | err_array[4] = (String) problem_urgency.getSelectedItem();
|
---|
| 1477 | err_array[5] = System.getProperty("user.name");
|
---|
| 1478 | err_array[6] = System.getProperty("user.home");
|
---|
| 1479 | err_array[7] = System.getProperty("user.dir");
|
---|
| 1480 | err_array[8] = curr_date.toString();
|
---|
| 1481 | err_array[9] = err_date;
|
---|
| 1482 | err_array[10] = os_name;
|
---|
| 1483 | err_array[11] = java_info;
|
---|
| 1484 | err_array[12] = "" + Locale.getDefault();
|
---|
| 1485 | err_array[13] = Utility.PROGRAM_NAME + " " + Utility.PROGRAM_VERSION;
|
---|
| 1486 | err_array[14] = InetAddress.getLocalHost().getHostName();
|
---|
| 1487 | err_array[15] = InetAddress.getLocalHost().getHostAddress();
|
---|
| 1488 | err_array[16] = screen_res;
|
---|
| 1489 | err_array[17] = "";
|
---|
| 1490 |
|
---|
| 1491 | /*String test_txt;
|
---|
| 1492 | test_txt = smtp_address.getText();
|
---|
| 1493 | if ((test_txt == null)||(test_txt.length() < 5))*/
|
---|
| 1494 | err_array[19] = "mail.waikato.ac.nz";
|
---|
| 1495 | /*else
|
---|
| 1496 | err_array[19] = test_txt;
|
---|
| 1497 |
|
---|
| 1498 | test_txt = email_address.getText();
|
---|
| 1499 | if ((test_txt == null)||(test_txt.length() < 5))*/
|
---|
| 1500 | err_array[20] = "[email protected]";
|
---|
| 1501 | //else
|
---|
| 1502 | //err_array[20] = test_txt;
|
---|
| 1503 |
|
---|
| 1504 | Runtime run;
|
---|
| 1505 | run = Runtime.getRuntime();
|
---|
| 1506 | err_array[21] = formatFileSize(run.totalMemory());
|
---|
| 1507 | err_array[22] = formatFileSize(run.maxMemory());
|
---|
| 1508 | err_array[23] = formatFileSize(run.freeMemory());
|
---|
| 1509 | }
|
---|
| 1510 | catch(UnknownHostException exp) {}
|
---|
| 1511 |
|
---|
| 1512 | return err_array;
|
---|
| 1513 | }
|
---|
| 1514 |
|
---|
| 1515 | /**
|
---|
| 1516 | * This method will format the file size given into more elegant form,e.g. 2KB
|
---|
| 1517 | * @param length the file size.
|
---|
| 1518 | * @return the more elegant string representations of the file size.
|
---|
| 1519 | */
|
---|
| 1520 | public String formatFileSize(long length)
|
---|
| 1521 | {
|
---|
| 1522 | String BYTE_SUFFIX;
|
---|
| 1523 | BYTE_SUFFIX = " B";
|
---|
| 1524 | long GIGABYTE;
|
---|
| 1525 | GIGABYTE = 1024000000l;
|
---|
| 1526 | String GIGABYTE_SUFFIX;
|
---|
| 1527 | GIGABYTE_SUFFIX = " GB";
|
---|
| 1528 | long KILOBYTE;
|
---|
| 1529 | KILOBYTE = 1024l;
|
---|
| 1530 | String KILOBYTE_SUFFIX;
|
---|
| 1531 | KILOBYTE_SUFFIX = " KB";
|
---|
| 1532 | long MEGABYTE;
|
---|
| 1533 | MEGABYTE = 1024000l;
|
---|
| 1534 | String MEGABYTE_SUFFIX;
|
---|
| 1535 | MEGABYTE_SUFFIX = " MB";
|
---|
| 1536 |
|
---|
| 1537 | StringBuffer result;
|
---|
| 1538 | result = new StringBuffer("");
|
---|
| 1539 | float number;
|
---|
| 1540 | number = 0f;
|
---|
| 1541 | String suffix;
|
---|
| 1542 | suffix = null;
|
---|
| 1543 |
|
---|
| 1544 | if(length >= GIGABYTE)
|
---|
| 1545 | {
|
---|
| 1546 | number = (float) length / (float) GIGABYTE;
|
---|
| 1547 | suffix = GIGABYTE_SUFFIX;
|
---|
| 1548 | }
|
---|
| 1549 | else if(length >= MEGABYTE)
|
---|
| 1550 | {
|
---|
| 1551 | number = (float) length / (float) MEGABYTE;
|
---|
| 1552 | suffix = MEGABYTE_SUFFIX;
|
---|
| 1553 | }
|
---|
| 1554 | else if(length >= KILOBYTE)
|
---|
| 1555 | {
|
---|
| 1556 | number = (float) length / (float) KILOBYTE;
|
---|
| 1557 | suffix = KILOBYTE_SUFFIX;
|
---|
| 1558 | }
|
---|
| 1559 | else
|
---|
| 1560 | {
|
---|
| 1561 | return length + BYTE_SUFFIX;
|
---|
| 1562 | }
|
---|
| 1563 |
|
---|
| 1564 | String number_str;
|
---|
| 1565 | number_str = Float.toString(number);
|
---|
| 1566 | char number_char[] = number_str.toCharArray();
|
---|
| 1567 | int pos,i;
|
---|
| 1568 | pos = 0;
|
---|
| 1569 |
|
---|
| 1570 | while(number_char != null && pos < number_char.length && number_char[pos] != '.')
|
---|
| 1571 | {
|
---|
| 1572 | result.append(number_char[pos]);
|
---|
| 1573 | pos++;
|
---|
| 1574 | }
|
---|
| 1575 |
|
---|
| 1576 | if(pos < number_char.length)
|
---|
| 1577 | {
|
---|
| 1578 | result.append(number_char[pos]);
|
---|
| 1579 | pos++;
|
---|
| 1580 |
|
---|
| 1581 | for(i = 0; i < 2 && pos < number_char.length; i++, pos++)
|
---|
| 1582 | result.append(number_char[pos]);
|
---|
| 1583 |
|
---|
| 1584 | while(pos < number_char.length && number_char[pos] != 'E')
|
---|
| 1585 | pos++;
|
---|
| 1586 |
|
---|
| 1587 | while(pos < number_char.length)
|
---|
| 1588 | {
|
---|
| 1589 | result.append(number_char[pos]);
|
---|
| 1590 | pos++;
|
---|
| 1591 | }
|
---|
| 1592 | }
|
---|
| 1593 |
|
---|
| 1594 | result.append(suffix);
|
---|
| 1595 |
|
---|
| 1596 | return result.toString();
|
---|
| 1597 | }
|
---|
| 1598 |
|
---|
| 1599 | /**
|
---|
| 1600 | * This method will decide what action should be done if the user entered a button in
|
---|
| 1601 | * the Feedback form.
|
---|
| 1602 | * <br>If user click cancel button then all the information taken in this form will be deleted
|
---|
| 1603 | * and user will be quitted from the Reporting Feedback sequence.
|
---|
| 1604 | * <br>If user click the send button then all the information taken will be stored in array which
|
---|
| 1605 | * then will be saved into xml files and sent when user confirm to send all the files.
|
---|
| 1606 | * <br>If user click the details button then they can view all the xml files that are going to be send.
|
---|
| 1607 | * @param e the button that user clicked
|
---|
| 1608 | */
|
---|
| 1609 | public void actionPerformed (ActionEvent e)
|
---|
| 1610 | {
|
---|
| 1611 | getPrevData();
|
---|
| 1612 |
|
---|
| 1613 | if(messages.getString("Send").equals(e.getActionCommand()))
|
---|
| 1614 | {
|
---|
| 1615 | String[] imgFile;
|
---|
| 1616 | String[] err_array;
|
---|
| 1617 |
|
---|
| 1618 | imgFile = getimgFile();
|
---|
| 1619 | err_array = geterr_array();
|
---|
| 1620 |
|
---|
| 1621 | timer.start();
|
---|
| 1622 |
|
---|
| 1623 | sendMethod(dialog.getVector(),err_array,imgFile);
|
---|
| 1624 | }
|
---|
| 1625 |
|
---|
| 1626 | if(messages.getString("Preview").equals(e.getActionCommand()))
|
---|
| 1627 | {
|
---|
| 1628 | String[] imgFile;
|
---|
| 1629 | String[] err_array;
|
---|
| 1630 |
|
---|
| 1631 | imgFile = getimgFile();
|
---|
| 1632 | err_array = geterr_array();
|
---|
| 1633 |
|
---|
| 1634 | timer.start();
|
---|
| 1635 |
|
---|
| 1636 | viewMethod(dialog.getVector(),err_array,imgFile);
|
---|
| 1637 | }
|
---|
| 1638 |
|
---|
| 1639 | if(messages.getString("NotSend").equals(e.getActionCommand()))
|
---|
| 1640 | {
|
---|
| 1641 | dispose();
|
---|
| 1642 | }
|
---|
| 1643 | }
|
---|
| 1644 | }
|
---|
| 1645 |
|
---|
| 1646 |
|
---|
| 1647 |
|
---|
| 1648 |
|
---|
| 1649 |
|
---|
| 1650 |
|
---|
| 1651 |
|
---|
| 1652 |
|
---|
| 1653 |
|
---|
| 1654 |
|
---|