diff --git a/migration/i2.0/oracle/201311061603_IDEMPIERE-583.sql b/migration/i2.0/oracle/201311061603_IDEMPIERE-583.sql new file mode 100644 index 0000000000..48f04e20e9 --- /dev/null +++ b/migration/i2.0/oracle/201311061603_IDEMPIERE-583.sql @@ -0,0 +1,11 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- Nov 6, 2013 11:59:02 PM MYT +-- IDEMPIERE-583 Delete Selection Panel improvement. +UPDATE AD_ToolBarButton SET IsActive='N',Updated=TO_DATE('2013-11-06 23:59:02','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ToolBarButton_ID=200034 +; + +SELECT register_migration_script('201311061603_IDEMPIERE-583.sql') FROM dual +; + diff --git a/migration/i2.0/postgresql/201311061603_IDEMPIERE-583.sql b/migration/i2.0/postgresql/201311061603_IDEMPIERE-583.sql new file mode 100644 index 0000000000..67fea77a84 --- /dev/null +++ b/migration/i2.0/postgresql/201311061603_IDEMPIERE-583.sql @@ -0,0 +1,9 @@ +-- Nov 6, 2013 11:59:02 PM MYT +-- IDEMPIERE-583 Delete Selection Panel improvement. +UPDATE AD_ToolBarButton SET IsActive='N',Updated=TO_TIMESTAMP('2013-11-06 23:59:02','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ToolBarButton_ID=200034 +; + +SELECT register_migration_script('201311061603_IDEMPIERE-583.sql') FROM dual +; + + diff --git a/org.adempiere.base/src/org/compiere/model/GridTab.java b/org.adempiere.base/src/org/compiere/model/GridTab.java index cafb28ba93..610015248f 100644 --- a/org.adempiere.base/src/org/compiere/model/GridTab.java +++ b/org.adempiere.base/src/org/compiere/model/GridTab.java @@ -3239,7 +3239,8 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable } public void addToSelection(int rowIndex) { - selection.add(rowIndex); + if (!selection.contains(rowIndex)) + selection.add(rowIndex); } public boolean removeFromSelection(int rowIndex) { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java index 8b8a4e47f9..43a6cb37b2 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java @@ -79,7 +79,7 @@ public class ADWindowToolbar extends FToolbar implements EventListener private ToolBarButton btnIgnore; - private ToolBarButton btnHelp, btnNew, btnCopy, btnDelete, btnDeleteSelection, btnSave; + private ToolBarButton btnHelp, btnNew, btnCopy, btnDelete, btnSave; private ToolBarButton btnSaveAndCreate; // Elaine 2009/03/02 - Save & Create @@ -155,7 +155,6 @@ public class ADWindowToolbar extends FToolbar implements EventListener btnCopy.setTooltiptext(btnCopy.getTooltiptext()+ " Alt+C"); btnDelete = createButton("Delete", "Delete", "Delete"); btnDelete.setTooltiptext(btnDelete.getTooltiptext()+ " Alt+D"); - btnDeleteSelection = createButton("DeleteSelection", "DeleteSelection", "DeleteSelection"); btnSave = createButton("Save", "Save", "Save"); btnSave.setTooltiptext(btnSave.getTooltiptext()+ " Alt+S"); btnSaveAndCreate = createButton("SaveCreate", "SaveCreate", "SaveCreate"); @@ -429,11 +428,6 @@ public class ADWindowToolbar extends FToolbar implements EventListener return !btnDelete.isDisabled(); } - public void enableDeleteSelection(boolean enabled) - { - this.btnDeleteSelection.setDisabled(!enabled); - } - public void enableIgnore(boolean enabled) { this.btnIgnore.setDisabled(!enabled); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java index cc2dd3a7a0..b63b5009bb 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java @@ -959,14 +959,6 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements //Deepak-Enabling customize button IDEMPIERE-364 if(!(adTabbox.getSelectedTabpanel() instanceof ADSortTab)) toolbar.enableCustomize(((ADTabpanel)adTabbox.getSelectedTabpanel()).isGridView()); - if (adTabbox.getSelectedTabpanel().isGridView()) - { - toolbar.enableDeleteSelection(toolbar.isDeleteEnable()); - } - else - { - toolbar.enableDeleteSelection(false); - } focusToActivePanel(); } @@ -1445,7 +1437,6 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements toolbar.enableCopy(!changed && insertRecord && !tabPanel.getGridTab().isSortTab() && adTabbox.getSelectedGridTab().getRowCount()>0); toolbar.enableRefresh(!changed); toolbar.enableDelete(!changed && !readOnly && !tabPanel.getGridTab().isSortTab() && !processed); - toolbar.enableDeleteSelection(!changed && !readOnly && !tabPanel.getGridTab().isSortTab() && !processed && tabPanel.isGridView()); // if (readOnly && adTabbox.getSelectedGridTab().isAlwaysUpdateField()) { @@ -1491,7 +1482,6 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements toolbar.enableNew(true); toolbar.enableCopy(false); toolbar.enableDelete(false); - toolbar.enableDeleteSelection(false); } // Transaction info @@ -1669,7 +1659,6 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements toolbar.enableNew(false); toolbar.enableCopy(false); toolbar.enableDelete(false); - toolbar.enableDeleteSelection(false); breadCrumb.enableFirstNavigation(adTabbox.getSelectedGridTab().getCurrentRow() > 0); breadCrumb.enableLastNavigation(adTabbox.getSelectedGridTab().getCurrentRow() + 1 < adTabbox.getSelectedGridTab().getRowCount()); toolbar.enableTabNavigation(breadCrumb.hasParentLink(), adTabbox.getSelectedDetailADTabpanel() != null); @@ -1718,7 +1707,6 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements toolbar.enableNew(false); toolbar.enableCopy(false); toolbar.enableDelete(false); - toolbar.enableDeleteSelection(false); breadCrumb.enableFirstNavigation(adTabbox.getSelectedGridTab().getCurrentRow() > 0); breadCrumb.enableLastNavigation(adTabbox.getSelectedGridTab().getCurrentRow() + 1 < adTabbox.getSelectedGridTab().getRowCount()); toolbar.enableTabNavigation(false); @@ -2047,6 +2035,14 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements { return; } + + //delete selected if it is grid view and row selection + final int[] indices = adTabbox.getSelectedGridTab().getSelection(); + if (indices.length > 0 && adTabbox.getSelectedTabpanel().isGridView()) + { + onDeleteSelected(); + return; + } FDialog.ask(curWindowNo, null, "DeleteRecord?", new Callback() { @@ -2067,10 +2063,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements } // Elaine 2008/12/01 - /** - * @see ToolbarListener#onDelete() - */ - public void onDeleteSelection() + private void onDeleteSelected() { if (adTabbox.getSelectedGridTab().isReadOnly() || !adTabbox.getSelectedTabpanel().isGridView()) { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/CompositeADTabbox.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/CompositeADTabbox.java index 5400928da6..74c107b1ec 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/CompositeADTabbox.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/CompositeADTabbox.java @@ -18,6 +18,7 @@ package org.adempiere.webui.adwindow; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; @@ -144,24 +145,66 @@ public class CompositeADTabbox extends AbstractADTabbox }); } else if (DetailPane.ON_DELETE_EVENT.equals(event.getName())) { - if (headerTab.getGridTab().isNew()) return; - - final IADTabpanel tabPanel = getSelectedDetailADTabpanel(); - if (tabPanel != null && tabPanel.getGridTab().getRowCount() > 0 - && tabPanel.getGridTab().getCurrentRow() >= 0) { - FDialog.ask(tabPanel.getGridTab().getWindowNo(), null, "DeleteRecord?", new Callback() { + onDelete(); + } + } - @Override - public void onCallback(Boolean result) { - if (!result) return; - if (!tabPanel.getGridTab().dataDelete()) { - showLastError(); - } else { - adWindowPanel.onRefresh(false); - } + private void onDelete() { + if (headerTab.getGridTab().isNew()) return; + + final IADTabpanel tabPanel = getSelectedDetailADTabpanel(); + if (tabPanel != null && tabPanel.getGridTab().getSelection().length > 0) { + onDeleteSelected(tabPanel); + } + else if (tabPanel != null && tabPanel.getGridTab().getRowCount() > 0 + && tabPanel.getGridTab().getCurrentRow() >= 0) { + FDialog.ask(tabPanel.getGridTab().getWindowNo(), null, "DeleteRecord?", new Callback() { + + @Override + public void onCallback(Boolean result) { + if (!result) return; + if (!tabPanel.getGridTab().dataDelete()) { + showLastError(); + } else { + adWindowPanel.onRefresh(false); } - }); - } + } + }); + } + } + + private void onDeleteSelected(final IADTabpanel tabPanel) { + if (tabPanel == null || tabPanel.getGridTab() == null) return; + + final int[] indices = tabPanel.getGridTab().getSelection(); + if(indices.length > 0) { + StringBuilder sb = new StringBuilder(); + sb.append(Env.getContext(Env.getCtx(), tabPanel.getGridTab().getWindowNo(), "_WinInfo_WindowName", false)).append(" - ") + .append(indices.length).append(" ").append(Msg.getMsg(Env.getCtx(), "Selected")); + FDialog.ask(sb.toString(), tabPanel.getGridTab().getWindowNo(), null,"DeleteSelection", new Callback() { + @Override + public void onCallback(Boolean result) { + if(result){ + tabPanel.getGridTab().clearSelection(); + Arrays.sort(indices); + int offset = 0; + int count = 0; + for (int i = 0; i < indices.length; i++) + { + tabPanel.getGridTab().navigate(indices[i]-offset); + if (tabPanel.getGridTab().dataDelete()) + { + offset++; + count++; + } + } + + tabPanel.refresh(); + tabPanel.dynamicDisplay(0); + adWindowPanel.getStatusBar().setStatusLine(Msg.getMsg(Env.getCtx(), "Deleted")+": "+count, false); + } + } + }); } } }); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridView.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridView.java index 6e527719ef..f6aa691d8d 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridView.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridView.java @@ -309,6 +309,8 @@ public class GridView extends Vbox implements EventListener, IdSpace, IFi listbox.setModel(listModel); updateListIndex(); refreshing = false; + if (gridTab.getRowCount() == 0 && selectAll.isChecked()) + selectAll.setChecked(false); } } @@ -867,6 +869,9 @@ public class GridView extends Vbox implements EventListener, IdSpace, IFi boolean noData = gridTab.getRowCount() == 0; List list = renderer.getEditors(); dynamicDisplayEditors(noData, list); // all components + + if (gridTab.getRowCount() == 0 && selectAll.isChecked()) + selectAll.setChecked(false); } private void dynamicDisplayEditors(boolean noData, List list) { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/event/ToolbarListener.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/event/ToolbarListener.java index 491e9706f5..60ef194abd 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/event/ToolbarListener.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/event/ToolbarListener.java @@ -95,11 +95,6 @@ public interface ToolbarListener */ public void onDelete(); - /** - * Delete selected record(s) - */ - public void onDeleteSelection(); - /** * Save current record */