Example #1
0
 /**
  * Constructor
  *
  * @param editable Table editable instance
  */
 public ActionRemoveRow(
     TableEditableElement editable, TableEditor tableEditor, WpsServer wpsServer) {
   super(I18N.tr("Delete selected rows"), TableEditorIcon.getIcon("delete_row"));
   this.tableEditor = tableEditor;
   putValue(ActionTools.LOGICAL_GROUP, TableEditorActions.LGROUP_MODIFICATION_GROUP);
   putValue(ActionTools.MENU_ID, TableEditorActions.A_REMOVE_ROW);
   this.editable = editable;
   updateEnabledState();
   editable.addPropertyChangeListener(
       EventHandler.create(PropertyChangeListener.class, this, "onEditableUpdate", ""));
   this.wpsServer = wpsServer;
 }
Example #2
0
 private void updateEnabledState() {
   setEnabled(editable.isEditing() && !editable.getSelection().isEmpty());
 }
Example #3
0
 @Override
 public void actionPerformed(ActionEvent actionEvent) {
   if (editable.isEditing()) {
     Set<Long> selectedRows = editable.getSelection();
     int response =
         JOptionPane.showConfirmDialog(
             tableEditor,
             I18N.tr("Are you sure to remove the {0} selected rows ?", selectedRows.size()),
             I18N.tr("Delete selected rows"),
             JOptionPane.YES_NO_CANCEL_OPTION,
             JOptionPane.QUESTION_MESSAGE);
     if (response == JOptionPane.YES_OPTION) {
       if (wpsServer != null) {
         /** Would be updates later once the WPS client will be fully updated * */
         /*Process p = null;
         for(ProcessIdentifier pi : wpsService.getCapabilities()){
             if(pi.getProcess().getTitle().equals(PROCESS_TITLE)){
                 p = pi.getProcess();
                 break;
             }
         }
         if(p != null){
             try(Connection connection = editable.getDataManager().getDataSource().getConnection()) {
                 //Gets the pk column name
                 int columnId = JDBCUtilities.getIntegerPrimaryKey(connection, editable.getTableReference());
                 String pkColumnName = JDBCUtilities.getFieldName(connection.getMetaData(), editable.getTableReference(), columnId);
                 //Gets the pk list as a String[]
                 String[] pkList = new String[editable.getSelection().size()];
                 SortedSet<Long> selection = editable.getSelection();
                 int i = 0;
                 for (Long l : selection) {
                     pkList[i] = l.toString();
                     i++;
                 }
                 //Build the dataMap
                 Map<URI, Object> dataMap = new HashMap<>();
                 for (Input input : p.getInput()) {
                     if (input.getTitle().equals(INPUT_TABLE)) {
                         URI uri = DataStoreOld.buildUriDataStore(DataStoreOld.DATASTORE_TYPE_GEOCATALOG,
                                 editable.getTableReference(),
                                 editable.getTableReference());
                         dataMap.put(input.getIdentifier(), uri);
                     }
                     if (input.getTitle().equals(INPUT_PK_ARRAY)) {
                         dataMap.put(input.getIdentifier(), pkList);
                     }
                     if (input.getTitle().equals(INPUT_PK_FIELD)) {
                         dataMap.put(input.getIdentifier(), pkColumnName);
                     }
                 }
                 //Run the service
                 wpsService.execute(p, dataMap, null);
                 //Indicates to the tableEditor that a change occurred.
                 tableEditor.tableChange(new TableEditEvent(editable.getTableReference(),
                         TableModelEvent.ALL_COLUMNS,
                         null,
                         null,
                         TableModelEvent.UPDATE));
             } catch (SQLException e) {
                 LOGGER.error(I18N.tr("Unable to get the connection to remove rows.\n")+e.getMessage());
             }
         }
         else{
             LOGGER.error(I18N.tr("Unable to get the process '{0}' from the WpsService.", PROCESS_TITLE));
         }*/
       }
     }
   }
 }