IDEMPIERE-377 Improve current search dialog box / Remove history button from toolbar and implement the same options into search box

This commit is contained in:
Kirit Thummar 2012-08-29 12:59:41 -05:00
parent cf2bc53017
commit 27696117cb
6 changed files with 132 additions and 100 deletions

View File

@ -0,0 +1,15 @@
-- Aug 27, 2012 9:48:50 PM IST
-- Add search sequence support for search dialog
UPDATE AD_Message SET MsgText='History records',Updated=TO_DATE('2012-08-27 21:48:50','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=292
;
-- Aug 27, 2012 9:48:50 PM IST
-- Add search sequence support for search dialog
UPDATE AD_Message_Trl SET IsTranslated='N' WHERE AD_Message_ID=292
;
UPDATE AD_System
SET LastMigrationScriptApplied='895_IDEMPIERE-377_History_Trl.sql'
WHERE LastMigrationScriptApplied<'895_IDEMPIERE-377_History_Trl.sql'
OR LastMigrationScriptApplied IS NULL
;

View File

@ -0,0 +1,15 @@
-- Aug 27, 2012 9:48:50 PM IST
-- Add search sequence support for search dialog
UPDATE AD_Message SET MsgText='History records',Updated=TO_TIMESTAMP('2012-08-27 21:48:50','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=292
;
-- Aug 27, 2012 9:48:50 PM IST
-- Add search sequence support for search dialog
UPDATE AD_Message_Trl SET IsTranslated='N' WHERE AD_Message_ID=292
;
UPDATE AD_System
SET LastMigrationScriptApplied='895_IDEMPIERE-377_History_Trl.sql'
WHERE LastMigrationScriptApplied<'895_IDEMPIERE-377_History_Trl.sql'
OR LastMigrationScriptApplied IS NULL
;

View File

@ -57,7 +57,7 @@ public class CWindowToolbar extends FToolbar implements EventListener<Event>
/**
*
*/
private static final long serialVersionUID = -8640626174604214333L;
private static final long serialVersionUID = 904447827065380369L;
private static final String BTNPREFIX = "Btn";
@ -75,7 +75,7 @@ public class CWindowToolbar extends FToolbar implements EventListener<Event>
private ToolBarButton btnGridToggle;
private ToolBarButton btnHistoryRecords, btnParentRecord, btnDetailRecord;
private ToolBarButton btnParentRecord, btnDetailRecord;
private ToolBarButton btnFirst, btnPrevious, btnNext, btnLast;
@ -154,7 +154,6 @@ public class CWindowToolbar extends FToolbar implements EventListener<Event>
btnAttachment = createButton("Attachment", "Attachment", "Attachment");
btnChat = createButton("Chat", "Chat", "Chat");
btnGridToggle = createButton("Toggle", "Multi", "Multi");
btnHistoryRecords = createButton("HistoryRecords", "HistoryX", "History");
addSeparator();
btnParentRecord = createButton("ParentRecord", "Parent", "Parent");
btnDetailRecord = createButton("DetailRecord", "Detail", "Detail");
@ -203,7 +202,6 @@ public class CWindowToolbar extends FToolbar implements EventListener<Event>
btnParentRecord.setVisible(false);
btnDetailRecord.setVisible(false);
btnActiveWorkflows.setVisible(false);
btnHistoryRecords.setVisible(false);
btnProductInfo.setVisible(false);
setAlign("end");
setWidth("100%");
@ -288,7 +286,6 @@ public class CWindowToolbar extends FToolbar implements EventListener<Event>
keyMap.put(KeyEvent.F6, btnFind);
keyMap.put(KeyEvent.F7, btnAttachment);
keyMap.put(KeyEvent.F8, btnGridToggle);
keyMap.put(KeyEvent.F9, btnHistoryRecords);
keyMap.put(KeyEvent.F11, btnReport);
keyMap.put(KeyEvent.F12, btnPrint);
@ -401,11 +398,6 @@ public class CWindowToolbar extends FToolbar implements EventListener<Event>
this.event = null;
}
public void enableHistoryRecords(boolean enabled)
{
this.btnHistoryRecords.setDisabled(!enabled);
}
public void enableNavigation(boolean enabled)
{
this.btnFirst.setDisabled(!enabled);

View File

@ -115,11 +115,6 @@ public interface ToolbarListener
*/
public void onAttachment();
/**
* Open the history dialog
*/
public void onHistoryRecords();
/**
* Open the archive dialog
*/

View File

@ -160,8 +160,6 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
private boolean boolChanges = false;
private int m_onlyCurrentDays = 0;
private Component parent;
private boolean m_findCancelled;
@ -363,11 +361,6 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
toolbar.enableFind(true);
adTab.evaluate(null);
if (gridWindow.isTransaction())
{
toolbar.enableHistoryRecords(true);
}
if (detailQuery != null && zoomToDetailTab(detailQuery))
{
return true;
@ -378,7 +371,6 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
curTabIndex = embeddedTabindex;
toolbar.enableTabNavigation(false);
toolbar.enableFind(true);
toolbar.enableHistoryRecords(false);
}
updateToolbar();
@ -647,7 +639,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
}
private void initFirstTabpanel() {
curTabpanel.query(m_onlyCurrentRows, m_onlyCurrentDays, MRole.getDefault().getMaxQueryRecords());
curTabpanel.query(m_onlyCurrentRows, 0, MRole.getDefault().getMaxQueryRecords());
curTabpanel.activate(true);
}
@ -918,57 +910,6 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
} // lock
//
/**
* @see ToolbarListener#onHistoryRecords()
*/
public void onHistoryRecords()
{
logger.info("");
if (gridWindow.isTransaction())
{
Callback<Boolean> callback = new Callback<Boolean>() {
@Override
public void onCallback(Boolean result) {
if (result) {
final WOnlyCurrentDays ocd = new WOnlyCurrentDays();
ocd.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
m_onlyCurrentDays = ocd.getCurrentDays();
history(m_onlyCurrentDays);
focusToActivePanel();
}
});
AEnv.showWindow(ocd);
}
}
};
saveAndNavigate(callback);
}
}
private void history(int onlyCurrentDays)
{
if (onlyCurrentDays == 1) // Day
{
m_onlyCurrentRows = true;
onlyCurrentDays = 0; // no Created restriction
}
else
m_onlyCurrentRows = false;
curTab.setQuery(null); // reset previous queries
MRole role = MRole.getDefault();
int maxRows = role.getMaxQueryRecords();
logger.config("OnlyCurrent=" + m_onlyCurrentRows
+ ", Days=" + m_onlyCurrentDays
+ ", MaxRows=" + maxRows);
curTab.query(m_onlyCurrentRows, onlyCurrentDays, maxRows);
}
/**
* @see ToolbarListener#onAttachment()
@ -1252,10 +1193,6 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
toolbar.getButton("Attachment").setPressed(curTab.hasAttachment());
toolbar.getButton("Chat").setPressed(curTab.hasChat());
if (isFirstTab())
{
toolbar.getButton("HistoryRecords").setPressed(!curTab.isOnlyCurrentRows());
}
toolbar.getButton("Find").setPressed(curTab.isQueryActive());
if (toolbar.isPersonalLock)
@ -1265,14 +1202,6 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
toolbar.enablePrint(curTab.isPrinted());
if (gridWindow.isTransaction() && isFirstTab())
{
toolbar.enableHistoryRecords(true);
}
else
{
toolbar.enableHistoryRecords(false);
}
//Deepak-Enabling customize button IDEMPIERE-364
if(!(curTabpanel instanceof ADSortTab))
toolbar.enableCustomize(((ADTabpanel)curTabpanel).isGridView());
@ -1403,12 +1332,6 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
toolbar.enableDelete(false);
}
// History (on first Tab only)
if (isFirstTab())
{
toolbar.getButton("HistoryRecords").setPressed(!curTab.isOnlyCurrentRows());
}
// Transaction info
String trxInfo = curTab.getTrxInfo();
if (trxInfo != null)
@ -1663,7 +1586,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
{
m_onlyCurrentRows = false; // search history too
curTab.setQuery(query);
curTabpanel.query(m_onlyCurrentRows, m_onlyCurrentDays, MRole.getDefault().getMaxQueryRecords()); // autoSize
curTabpanel.query(m_onlyCurrentRows, 0, MRole.getDefault().getMaxQueryRecords()); // autoSize
}
if (findWindow.isCreateNew())

View File

@ -34,6 +34,8 @@ import java.util.Vector;
import java.util.logging.Level;
import java.util.regex.Pattern;
import jxl.biff.drawing.ComboBox;
import org.adempiere.webui.AdempiereIdGenerator;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.component.Button;
@ -110,7 +112,15 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
/**
*
*/
private static final long serialVersionUID = 4937678675702382252L;
private static final long serialVersionUID = -5352467965724233821L;
// values and label for history combo
private static final String HISTORY_DAY_ALL = "All";
private static final String HISTORY_DAY_YEAR = "Year";
private static final String HISTORY_DAY_MONTH = "Month";
private static final String HISTORY_DAY_WEEK = "Week";
private static final String HISTORY_DAY_DAY = "Day";
private static final String HISTORY_LABEL= "History";
/** Main Window for the Lookup Panel */
private MultiTabPart winMain;
/** Simple Window Tab */
@ -175,6 +185,9 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
private static final String FIELD_SEPARATOR = "<^>";
private static final String SEGMENT_SEPARATOR = "<~>";
Combobox historyCombo = new Combobox();
/**
* FindPanel Constructor
@ -469,16 +482,24 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
fQueryName.setValue("");
fQueryName.addEventListener(Events.ON_SELECT, this);
// adding history combo
prepareHistoryCombo();
Label labelHistory = new Label(Msg.getMsg(Env.getCtx(), HISTORY_LABEL));
div.appendChild(labelHistory);
div.appendChild(historyCombo);
historyCombo.setStyle("margin-left: 3px; margin-right: 3px; position: relative;");
Label label = new Label(Msg.getMsg(Env.getCtx(), "SavedQuery"));
div.appendChild(label);
div.appendChild(fQueryName);
div.appendChild(btnSave);
// div.appendChild(new Separator());
fQueryName.setStyle("margin-left: 3px; margin-right: 3px; position: relative;");
msgLabel = new Label("");
msgLabel.setStyle("margin-left: 10px");
div.appendChild(msgLabel);
fQueryName.setStyle("margin-left: 3px; margin-right: 3px; position: relative;");
winMain = new MultiTabPart();
winMain.createPart(layout);
winMain.getComponent().setStyle("width: 100%; position: relative;");
@ -498,6 +519,23 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
initAdvanced();
} // initPanel
/**
* preparing combo of history
*/
private void prepareHistoryCombo()
{
historyCombo.setAutodrop(true);
historyCombo.setAutocomplete(false);
historyCombo.setButtonVisible(true);
historyCombo.setReadonly(true);
historyCombo.appendItem((Msg.getMsg(Env.getCtx(), HISTORY_DAY_ALL)),HISTORY_DAY_ALL);
historyCombo.appendItem((Msg.getMsg(Env.getCtx(), HISTORY_DAY_YEAR)), HISTORY_DAY_YEAR);
historyCombo.appendItem((Msg.getMsg(Env.getCtx(), HISTORY_DAY_MONTH)), HISTORY_DAY_MONTH);
historyCombo.appendItem((Msg.getMsg(Env.getCtx(), HISTORY_DAY_WEEK)), HISTORY_DAY_WEEK);
historyCombo.appendItem((Msg.getMsg(Env.getCtx(), HISTORY_DAY_DAY)), HISTORY_DAY_DAY);
}
/**
* Dynamic Init.6
@ -576,7 +614,7 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
// adding sorted columns
for(GridField field:gridFieldList){
addSelectionColumn (field);
}
}
gridFieldList = null;
m_total = getNoOfRecords(null, false);
@ -664,6 +702,7 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
for (int c = 0; c < m_findFields.length; c++)
{
GridField field = m_findFields[c];
String columnName = field.getColumnName();
String header = field.getHeader();
if (header == null || header.length() == 0)
@ -1441,6 +1480,7 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
m_query.addRestriction(getSubCategoryWhereClause(((Integer) value).intValue()));
else
m_query.addRestriction(ColumnSQL, MQuery.EQUAL, value, ColumnName, wed.getDisplay());
/*
if (value.toString().indexOf('%') != -1)
m_query.addRestriction(ColumnName, MQuery.LIKE, value, ColumnName, ved.getDisplay());
@ -1450,9 +1490,55 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
// end globalqss patch
}
} // editors
if(historyCombo.getSelectedItem()!=null)
{
addHistoryRestriction(historyCombo.getSelectedItem());
}
m_isCancel = false; // teo_sarca [ 1708717 ]
} // cmd_ok_Simple
/**
* Get days from selected values of history combo
* @param selectedItem
* @return
*/
private int getHistoryDays(String selectedItem)
{
int retDays = 0;
if (selectedItem.equals(HISTORY_DAY_DAY))
retDays = 1;
else if (selectedItem.equals(HISTORY_DAY_WEEK))
retDays = 7;
else if (selectedItem.equals(HISTORY_DAY_MONTH))
retDays = 31;
else if (selectedItem.equals(HISTORY_DAY_YEAR))
retDays = 365;
return retDays;
}
/**
* Adding where clause from history data
* @param selectedHistoryItem
*/
private void addHistoryRestriction(Comboitem selectedHistoryItem)
{
String selectedHistoryValue = historyCombo.getSelectedItem().getValue();
log.info("History combo selected value =" +selectedHistoryValue);
if (null!=selectedHistoryItem && selectedHistoryItem.toString().length() > 0 && getHistoryDays(selectedHistoryValue) > 0)
{
StringBuffer where = new StringBuffer();
where.append("Created >= ");
where.append("SysDate-").append(getHistoryDays(selectedHistoryValue));
m_query.addRestriction(where.toString());
}
}
public void dispose()
{
@ -1569,8 +1655,14 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
m_query.addRestriction(ColumnSQL, Operator, parsedValue,
infoName, infoDisplay);
}
if(historyCombo.getSelectedItem()!=null)
{
addHistoryRestriction(historyCombo.getSelectedItem());
}
} // cmd_save
/**
* Get the number of records of target tab
* @param query where clause for target tab