/** * Closes the given MapDust bug. If the entered informations are invalid a corresponding warning * message will be displayed. * * @param event The action event which fires this action */ @Override public void actionPerformed(ActionEvent event) { if (event.getSource() instanceof JButton) { JButton btn = (JButton) event.getSource(); if (btn.getText().equals("OK")) { /* the OK button was pressed */ ChangeBugStatusDialog issueDialog = (ChangeBugStatusDialog) getDialog(); String nickname = issueDialog.getTxtNickname().getText(); String commentText = issueDialog.getTxtDescription().getText(); /* validate nickname & comment text */ String errorMessage = validate(nickname, commentText); if (errorMessage != null) { /* invalid input data */ JOptionPane.showMessageDialog( Main.parent, tr(errorMessage), tr("Missing input data"), JOptionPane.WARNING_MESSAGE); return; } /* valid input data */ Main.pref.put("mapdust.nickname", nickname); MapdustBug selectedBug = mapdustGUI.getSelectedBug(); MapdustComment comment = new MapdustComment(selectedBug.getId(), commentText, nickname); String pluginState = Main.pref.get("mapdust.pluginState"); if (pluginState.equals(MapdustPluginState.OFFLINE.getValue())) { /* offline state, put to the actions list */ selectedBug.setStatus(Status.FIXED); String iconPath = getIconPath(selectedBug); MapdustAction mapdustAction = new MapdustAction( MapdustServiceCommand.CHANGE_BUG_STATUS, iconPath, selectedBug, comment, 2); /* destroy dialog */ enableFiredButton(issueDialog.getFiredButton()); mapdustGUI.enableBtnPanel(true); issueDialog.dispose(); if (getMapdustGUI().getActionPanel() != null) { notifyObservers(mapdustAction); } } else { /* online state, execute Mapdust service method */ MapdustServiceHandler handler = new MapdustServiceHandler(); Long id = null; try { id = handler.changeBugStatus(2, comment); } catch (MapdustServiceHandlerException e) { errorMessage = "There was a Mapdust service error."; JOptionPane.showMessageDialog( Main.parent, tr(errorMessage), tr("Error"), JOptionPane.ERROR_MESSAGE); } if (id != null) { // success MapdustBug newMapdustBug = null; try { newMapdustBug = handler.getBug(selectedBug.getId(), null); } catch (MapdustServiceHandlerException e) { errorMessage = "There was a Mapdust service error."; JOptionPane.showMessageDialog( Main.parent, tr(errorMessage), tr("Error"), JOptionPane.ERROR_MESSAGE); } /* destroy dialog */ enableFiredButton(issueDialog.getFiredButton()); mapdustGUI.enableBtnPanel(false); issueDialog.dispose(); if (newMapdustBug != null) { notifyObservers(newMapdustBug); } } } } } }