Delete Selection (more than one entry). Better icons needed - I'm not a designer...
This commit is contained in:
parent
856517415d
commit
ae24088ba2
|
@ -48,8 +48,18 @@ INSERT INTO ad_message
|
|||
'I', 'D'
|
||||
);
|
||||
|
||||
INSERT INTO ad_message
|
||||
(ad_message_id, ad_client_id, ad_org_id, isactive, created,
|
||||
createdby, updated, updatedby, VALUE, msgtext,
|
||||
msgtype, entitytype
|
||||
)
|
||||
VALUES (50005, 0, 0, 'Y', SYSDATE,
|
||||
0, SYSDATE, 0, 'DeleteSelection', 'Delete Selected Items',
|
||||
'I', 'D'
|
||||
);
|
||||
|
||||
UPDATE ad_sequence
|
||||
SET currentnextsys = 50005
|
||||
SET currentnextsys = 50006
|
||||
WHERE NAME = 'AD_Message';
|
||||
|
||||
COMMIT ;
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.compiere.model;
|
|||
|
||||
import java.beans.*;
|
||||
import java.io.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
|
@ -26,6 +27,11 @@ import java.util.logging.*;
|
|||
import javax.swing.event.*;
|
||||
import org.compiere.util.*;
|
||||
|
||||
import de.schaeffer.compiere.constants.Constants;
|
||||
import de.schaeffer.compiere.tools.BPartnerSelection;
|
||||
import de.schaeffer.compiere.tools.CustomValueComparison;
|
||||
import de.schaeffer.compiere.tools.OrderWeightCheck;
|
||||
|
||||
/**
|
||||
* Tab Model.
|
||||
* - a combination of AD_Tab (the display attributes) and AD_Table information.
|
||||
|
@ -2124,6 +2130,24 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
|
|||
if (status == null || status.length() == 0)
|
||||
m_DataStatusEvent.setInfo("NavigateOrUpdate", null, false,false);
|
||||
fireDataStatusChanged(m_DataStatusEvent);
|
||||
|
||||
// CHANGED: Vergleich von fpa und selected values BPartnerSelection
|
||||
if (getName().equalsIgnoreCase("BPartner Selection")) {
|
||||
BPartnerSelection.compareWithFpaValues(this, null);
|
||||
return m_currentRow;
|
||||
}// ende changed
|
||||
// CHANGED: Vergleich von actual und customer values in OrderLine
|
||||
else if (getName().equalsIgnoreCase("Order Line")) {
|
||||
CustomValueComparison.compare(this);
|
||||
return m_currentRow;
|
||||
}// ende changed
|
||||
// CHANGED: checks the total order weight
|
||||
else if (getName().equalsIgnoreCase("Purchase Order")) {
|
||||
//besser mit ID - getAD_Tab_ID()
|
||||
OrderWeightCheck.compare(this);
|
||||
return m_currentRow;
|
||||
}// ende changed
|
||||
|
||||
return m_currentRow;
|
||||
} // setCurrentRow
|
||||
|
||||
|
@ -2443,4 +2467,84 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
|
|||
m_listenerList.add(DataStatusListener.class, l);
|
||||
}
|
||||
|
||||
// CHANGED: Eigene Methode - für das Umsortieren der Tabellenzeilen
|
||||
/**
|
||||
* Vertauscht zwei Zeilen einer Tabelle.
|
||||
*
|
||||
* @author Karsten Thiemann
|
||||
* @param from
|
||||
* Index der Zeile die verschoben wird
|
||||
* @param to
|
||||
* Index der Zielzeile
|
||||
*/
|
||||
public void moveRow(int from, int to) {
|
||||
// nothing to do
|
||||
if (from == to) {
|
||||
log.fine("nothing to do - from == to");
|
||||
return;
|
||||
}
|
||||
|
||||
// Row range check
|
||||
int nextRow = verifyRow(to);
|
||||
if (nextRow == -1) {
|
||||
log.fine("Row range check - return");
|
||||
return;
|
||||
}
|
||||
// Check, if we have old uncommitted data
|
||||
m_mTable.dataSave(nextRow, false);
|
||||
|
||||
int lineCol = m_mTable.findColumn("Line");
|
||||
if (lineCol == -1) {
|
||||
lineCol = m_mTable.findColumn("SeqNo");
|
||||
}
|
||||
Integer lineNoCurrentRow = null;
|
||||
Integer lineNoNextRow = null;
|
||||
if (m_mTable.getValueAt(from, lineCol) instanceof Integer) {
|
||||
// die verschiedenen Ansichten (Tabelle/Grid) liefern verschiedene
|
||||
// Typen...
|
||||
lineNoCurrentRow = (Integer) m_mTable.getValueAt(from, lineCol);
|
||||
lineNoNextRow = (Integer) m_mTable.getValueAt(nextRow, lineCol);
|
||||
} else if (m_mTable.getValueAt(from, lineCol) instanceof BigDecimal) {
|
||||
lineNoCurrentRow = new Integer(((BigDecimal) m_mTable.getValueAt(from, lineCol))
|
||||
.intValue());
|
||||
lineNoNextRow = new Integer(((BigDecimal) m_mTable.getValueAt(nextRow, lineCol))
|
||||
.intValue());
|
||||
} else {
|
||||
log.fine("unknown value format - return");
|
||||
return;
|
||||
}
|
||||
if (lineNoCurrentRow == Constants.FREIGHTCOST_LINENO
|
||||
|| lineNoNextRow == Constants.FREIGHTCOST_LINENO) {
|
||||
return; // Versandkosten nicht mitsortieren!
|
||||
}
|
||||
log.fine("LineIndex from: " + from + " LineIndex to: " + nextRow);
|
||||
log.fine("lineNoCurrentRow: " + lineNoCurrentRow + " lineNoNextRow: " + lineNoNextRow);
|
||||
// switch the lineNo's
|
||||
m_mTable.setValueAt(new Integer(-10), from, lineCol); // wegen der
|
||||
// Dateiumbenennung
|
||||
// (als
|
||||
// Zwischenspeicher)
|
||||
log.fine("LineNo der Zeile " + from + " auf -10 gesetzt.");
|
||||
log.fine("aktueller Wert von LineNo: " + m_mTable.getValueAt(from, lineCol).toString());
|
||||
setCurrentRow(nextRow, false);// speichert alle Werte der Zeile
|
||||
// (fehlerfrei!)
|
||||
m_mTable.dataSave(true);
|
||||
m_mTable.setValueAt(lineNoCurrentRow, nextRow, lineCol);
|
||||
log.fine("LineNo der Zeile " + nextRow + " auf " + lineNoCurrentRow + " gesetzt.");
|
||||
log.fine("aktueller Wert von LineNo: " + m_mTable.getValueAt(nextRow, lineCol).toString());
|
||||
setCurrentRow(from, false);
|
||||
m_mTable.dataSave(true);
|
||||
m_mTable.setValueAt(lineNoNextRow, from, lineCol);
|
||||
log.fine("LineNo der Zeile " + from + " auf " + lineNoNextRow + " gesetzt.");
|
||||
log.fine("aktueller Wert von LineNo: " + m_mTable.getValueAt(from, lineCol).toString());
|
||||
setCurrentRow(nextRow, false);
|
||||
m_mTable.dataSave(true);
|
||||
m_mTable.sort(lineCol, true);
|
||||
navigate(nextRow);
|
||||
}
|
||||
|
||||
public void setCurrentRow(int row){
|
||||
setCurrentRow(row, false);
|
||||
}
|
||||
|
||||
} // MTab
|
||||
|
|
|
@ -164,7 +164,7 @@ public final class APanel extends CPanel
|
|||
// Local (added to toolbar)
|
||||
private AppsAction aReport, aEnd, aHome, aHelp, aProduct,
|
||||
aAccount, aCalculator, aCalendar, aEditor, aPreference, aScript,
|
||||
aOnline, aMailSupport, aAbout, aPrintScr, aScrShot, aExit, aBPartner;
|
||||
aOnline, aMailSupport, aAbout, aPrintScr, aScrShot, aExit, aBPartner, aDeleteSelection;
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
|
@ -195,6 +195,7 @@ public final class APanel extends CPanel
|
|||
mEdit.addSeparator();
|
||||
aCopy = addAction("Copy", mEdit, KeyStroke.getKeyStroke(KeyEvent.VK_F2, Event.SHIFT_MASK), false);
|
||||
aDelete = addAction("Delete", mEdit, KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0), false);
|
||||
aDeleteSelection = addAction("DeleteSelection", mEdit, KeyStroke.getKeyStroke(KeyEvent.VK_D, Event.CTRL_MASK), false);
|
||||
aIgnore = addAction("Ignore", mEdit, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), false);
|
||||
aRefresh = addAction("Refresh", mEdit, KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0), false);
|
||||
mEdit.addSeparator();
|
||||
|
@ -276,6 +277,7 @@ public final class APanel extends CPanel
|
|||
toolBar.add(aHelp.getButton()); // F1
|
||||
toolBar.add(aNew.getButton());
|
||||
toolBar.add(aDelete.getButton());
|
||||
toolBar.add(aDeleteSelection.getButton());
|
||||
toolBar.add(aSave.getButton());
|
||||
toolBar.addSeparator();
|
||||
toolBar.add(aRefresh.getButton()); // F5
|
||||
|
@ -822,10 +824,12 @@ public final class APanel extends CPanel
|
|||
aSave.setEnabled(changed && !readOnly);
|
||||
//
|
||||
// No Rows
|
||||
if (e.getTotalRows() == 0 && insertRecord)
|
||||
{
|
||||
if (e.getTotalRows() == 0 && insertRecord) {
|
||||
aNew.setEnabled(true);
|
||||
aDelete.setEnabled(false);
|
||||
aDeleteSelection.setEnabled(false);
|
||||
} else {
|
||||
aDeleteSelection.setEnabled(true);
|
||||
}
|
||||
|
||||
// Single-Multi
|
||||
|
@ -1049,6 +1053,7 @@ public final class APanel extends CPanel
|
|||
{
|
||||
aSave.setEnabled(false);
|
||||
aDelete.setEnabled(false);
|
||||
aDeleteSelection.setEnabled(false);
|
||||
}
|
||||
m_curTab.navigateCurrent(); // updates counter
|
||||
m_curGC.dynamicDisplay(0);
|
||||
|
@ -1081,6 +1086,7 @@ public final class APanel extends CPanel
|
|||
aMulti.setEnabled(false);
|
||||
aNew.setEnabled(false);
|
||||
aDelete.setEnabled(false);
|
||||
aDeleteSelection.setEnabled(false);
|
||||
aFind.setEnabled(false);
|
||||
aRefresh.setEnabled(false);
|
||||
aAttachment.setEnabled(false);
|
||||
|
@ -1176,6 +1182,8 @@ public final class APanel extends CPanel
|
|||
cmd_new(true);
|
||||
else if (cmd.equals(aDelete.getName()))
|
||||
cmd_delete();
|
||||
else if (cmd.equals(aDeleteSelection.getName()))
|
||||
cmd_deleteSelection();
|
||||
else if (cmd.equals(aIgnore.getName()))
|
||||
cmd_ignore();
|
||||
else if (cmd.equals(aRefresh.getName()))
|
||||
|
@ -1289,6 +1297,70 @@ public final class APanel extends CPanel
|
|||
m_curGC.dynamicDisplay(0);
|
||||
} // cmd_delete
|
||||
|
||||
/**
|
||||
* Show a list to select one or more items to delete.
|
||||
*/
|
||||
private void cmd_deleteSelection(){
|
||||
if (m_curTab.isReadOnly())
|
||||
return;
|
||||
//show table with deletion rows -> value, name...
|
||||
JPanel messagePanel = new JPanel();
|
||||
JList list = new JList();
|
||||
JScrollPane scrollPane = new JScrollPane(list);
|
||||
Vector<String> data = new Vector<String>();
|
||||
int noOfRows = m_curTab.getRowCount();
|
||||
for(int i=0; i<noOfRows; i++){
|
||||
StringBuffer displayValue = new StringBuffer();
|
||||
displayValue = displayValue.append(m_curTab.getValue(i,m_curTab.getKeyColumnName()));
|
||||
if(m_curTab.getField("DocumentNo")!=null){
|
||||
displayValue = displayValue.append(" | ").append(m_curTab.getValue(i, "DocumentNo"));
|
||||
}
|
||||
if(m_curTab.getField("Line")!=null){
|
||||
displayValue = displayValue.append(" | ").append(m_curTab.getValue(i, "Line"));
|
||||
}
|
||||
if(m_curTab.getField("Value")!=null){
|
||||
displayValue = displayValue.append(" | ").append(m_curTab.getValue(i, "Value"));
|
||||
}
|
||||
if(m_curTab.getField("Name")!=null){
|
||||
displayValue = displayValue.append(" | ").append(m_curTab.getValue(i, "Name"));
|
||||
}
|
||||
data.add(displayValue.toString());
|
||||
}
|
||||
list.setListData(data);
|
||||
|
||||
list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
||||
messagePanel.add(scrollPane);
|
||||
|
||||
final JOptionPane pane = new JOptionPane(
|
||||
messagePanel, // message
|
||||
JOptionPane.QUESTION_MESSAGE, // messageType
|
||||
JOptionPane.OK_CANCEL_OPTION); // optionType
|
||||
final JDialog deleteDialog = pane.createDialog(this.getParent(), Msg.getMsg(m_ctx, "DeleteSelection"));
|
||||
deleteDialog.setVisible(true);
|
||||
Integer okCancel = (Integer) pane.getValue();
|
||||
if(okCancel!=null && okCancel==JOptionPane.OK_OPTION){
|
||||
log.fine("ok");
|
||||
Object[] selectedValues = list.getSelectedValues();
|
||||
for (int i = 0; i < selectedValues.length; i++) {
|
||||
log.fine(selectedValues[i].toString());
|
||||
}
|
||||
int[] indices = list.getSelectedIndices();
|
||||
Arrays.sort(indices);
|
||||
int offset = 0;
|
||||
for (int i = 0; i < indices.length; i++) {
|
||||
m_curTab.setCurrentRow(indices[i]-offset);
|
||||
int keyID = m_curTab.getRecord_ID();
|
||||
if (m_curTab.dataDelete()){
|
||||
m_curGC.rowChanged(false, keyID);
|
||||
offset++;
|
||||
}
|
||||
}
|
||||
m_curGC.dynamicDisplay(0);
|
||||
} else {
|
||||
log.fine("cancel");
|
||||
}
|
||||
}//cmd_deleteSelection
|
||||
|
||||
/**
|
||||
* If required ask if you want to save and save it
|
||||
* @param manualCmd true if invoked manually (i.e. force)
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 352 B |
Binary file not shown.
After Width: | Height: | Size: 1016 B |
Loading…
Reference in New Issue