IDEMPIERE-583 Delete Selection Panel improvement. Drop the delete selection button and just leave the delete button which will work on actual record on form mode and on selected records on grid mode (or actual if none selected).
This commit is contained in:
parent
460b21ffa7
commit
3870b1380d
|
@ -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
|
||||
;
|
||||
|
|
@ -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
|
||||
;
|
||||
|
||||
|
|
@ -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) {
|
||||
|
|
|
@ -79,7 +79,7 @@ public class ADWindowToolbar extends FToolbar implements EventListener<Event>
|
|||
|
||||
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<Event>
|
|||
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<Event>
|
|||
return !btnDelete.isDisabled();
|
||||
}
|
||||
|
||||
public void enableDeleteSelection(boolean enabled)
|
||||
{
|
||||
this.btnDeleteSelection.setDisabled(!enabled);
|
||||
}
|
||||
|
||||
public void enableIgnore(boolean enabled)
|
||||
{
|
||||
this.btnIgnore.setDisabled(!enabled);
|
||||
|
|
|
@ -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<Boolean>() {
|
||||
|
||||
|
@ -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())
|
||||
{
|
||||
|
|
|
@ -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<Boolean>() {
|
||||
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<Boolean>() {
|
||||
|
||||
@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<Boolean>() {
|
||||
@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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -309,6 +309,8 @@ public class GridView extends Vbox implements EventListener<Event>, 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<Event>, IdSpace, IFi
|
|||
boolean noData = gridTab.getRowCount() == 0;
|
||||
List<WEditor> list = renderer.getEditors();
|
||||
dynamicDisplayEditors(noData, list); // all components
|
||||
|
||||
if (gridTab.getRowCount() == 0 && selectAll.isChecked())
|
||||
selectAll.setChecked(false);
|
||||
}
|
||||
|
||||
private void dynamicDisplayEditors(boolean noData, List<WEditor> list) {
|
||||
|
|
|
@ -95,11 +95,6 @@ public interface ToolbarListener
|
|||
*/
|
||||
public void onDelete();
|
||||
|
||||
/**
|
||||
* Delete selected record(s)
|
||||
*/
|
||||
public void onDeleteSelection();
|
||||
|
||||
/**
|
||||
* Save current record
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue