use of org.adempiere.webui.component.ListModelTable in project adempiere by adempiere.
the class WWFActivity method loadActivities.
/**
* Load Activities
* @return int
*/
public int loadActivities() {
long start = System.currentTimeMillis();
int MAX_ACTIVITIES_IN_LIST = MSysConfig.getIntValue("MAX_ACTIVITIES_IN_LIST", 200, Env.getAD_Client_ID(Env.getCtx()));
model = new ListModelTable();
ArrayList<MWFActivity> list = new ArrayList<MWFActivity>();
String sql = "SELECT * FROM AD_WF_Activity a " + "WHERE a.Processed='N' AND a.WFState='OS' AND (" + // Owner of Activity
" a.AD_User_ID=?" + // Invoker (if no invoker = all)
" OR EXISTS (SELECT * FROM AD_WF_Responsible r WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID" + // #2
" AND COALESCE(r.AD_User_ID,0)=0 AND COALESCE(r.AD_Role_ID,0)=0 AND (a.AD_User_ID=? OR a.AD_User_ID IS NULL))" + // Responsible User
" OR EXISTS (SELECT * FROM AD_WF_Responsible r WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID" + // #3
" AND r.AD_User_ID=?)" + // Responsible Role
" OR EXISTS (SELECT * FROM AD_WF_Responsible r INNER JOIN AD_User_Roles ur ON (r.AD_Role_ID=ur.AD_Role_ID)" + // #4
" WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID AND ur.AD_User_ID=?)" + //
") ORDER BY a.Priority DESC, Created";
int AD_User_ID = Env.getAD_User_ID(Env.getCtx());
MRole role = MRole.get(Env.getCtx(), Env.getAD_Role_ID(Env.getCtx()));
sql = role.addAccessSQL(sql, "a", true, false);
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_User_ID);
pstmt.setInt(2, AD_User_ID);
pstmt.setInt(3, AD_User_ID);
pstmt.setInt(4, AD_User_ID);
rs = pstmt.executeQuery();
while (rs.next()) {
MWFActivity activity = new MWFActivity(Env.getCtx(), rs, null);
list.add(activity);
List<Object> rowData = new ArrayList<Object>();
rowData.add(activity.getPriority());
rowData.add(activity.getNodeName());
rowData.add(activity.getSummary());
model.add(rowData);
if (list.size() > MAX_ACTIVITIES_IN_LIST && MAX_ACTIVITIES_IN_LIST > 0) {
log.warning("More then 200 Activities - ignored");
break;
}
}
} catch (Exception e) {
log.log(Level.SEVERE, sql, e);
} finally {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
m_activities = new MWFActivity[list.size()];
list.toArray(m_activities);
//
log.fine("#" + m_activities.length + "(" + (System.currentTimeMillis() - start) + "ms)");
m_index = 0;
String[] columns = new String[] { Msg.translate(Env.getCtx(), "Priority"), Msg.translate(Env.getCtx(), "AD_WF_Node_ID"), Msg.translate(Env.getCtx(), "Summary") };
WListItemRenderer renderer = new WListItemRenderer(Arrays.asList(columns));
ListHeader header = new ListHeader();
header.setWidth("30px");
renderer.setListHeader(0, header);
renderer.addTableValueChangeListener(listbox);
model.setNoColumns(columns.length);
listbox.setModel(model);
listbox.setItemRenderer(renderer);
listbox.repaint();
listbox.setFixedLayout(true);
return m_activities.length;
}
use of org.adempiere.webui.component.ListModelTable in project adempiere by adempiere.
the class WAcctViewer method onEvent.
// stateChanged
/**
* Event Performed (Event Listener)
* @param e Event
*/
public void onEvent(Event e) throws Exception {
// log.info(e.getActionCommand());
iframe.setContent(null);
Object source = e.getTarget();
if (source == tabResult)
stateChanged();
else if (source == tabQuery)
stateChanged();
else if (source == selAcctSchema)
actionAcctSchema();
else if (source == bQuery)
actionQuery();
else if (source == selDocument)
actionDocument();
else if (source == selTable)
actionTable();
else if (source == bRePost)
actionRePost();
else if (//FR[3435028]
source == bExport)
actionExportExcel();
else if (source == bPrint)
//PrintScreenPainter.printScreen(this);
;
else // InfoButtons
if (source == bExport)
// Export the table.
actionExportExcel();
else if (source instanceof Button)
actionButton((Button) source);
else if (source == paging) {
int pgno = paging.getActivePage();
int start = pgno * PAGE_SIZE;
int end = start + PAGE_SIZE;
if (end > paging.getTotalSize())
end = paging.getTotalSize();
List<ArrayList<Object>> list = m_queryData.subList(start, end);
ListModelTable model = new ListModelTable(list);
table.setModel(model);
}
}
use of org.adempiere.webui.component.ListModelTable in project adempiere by adempiere.
the class WScanBarUI method cleanFields.
private void cleanFields() {
productTable.clear();
ListModelTable model = new ListModelTable(getDataModel());
productTable.setData(model, getColumnNames());
upcField.setValue("");
qtyCountField.setValue(null);
qtyCountField.setVisible(false);
lotField.setValue("");
lotField.setVisible(false);
serNoField.setValue("");
serNoField.setVisible(false);
upcField.getComponent().setFocus(true);
}
use of org.adempiere.webui.component.ListModelTable in project adempiere by adempiere.
the class WExpressReceiptScanBarUI method cleanFields.
private void cleanFields() {
productTable.clear();
ListModelTable model = new ListModelTable(getDataModel());
productTable.setData(model, getColumnNames());
upcField.setValue("");
qtyCountField.setValue(null);
qtyCountField.setVisible(false);
lotField.setValue("");
lotField.setVisible(false);
serNoField.setValue("");
serNoField.setVisible(false);
upcField.getComponent().setFocus(true);
}
use of org.adempiere.webui.component.ListModelTable in project adempiere by adempiere.
the class InfoPanel method onEvent.
// getAD_Window_ID
public void onEvent(Event event) {
if (!p_loadedOK)
// We aren't ready
return;
if (m_busy)
// We're busy. Ignore events.
return;
if (event != null) {
if (event.getName().equals("onOK")) {
// The enter key was pressed in a criteria field. Ignore it. The key click will trigger
// other events that will be trapped.
event.stopPropagation();
return;
}
Component component = event.getTarget();
if (component != null) {
// Generic components in the criteria fields
if (component instanceof Textbox) {
Textbox tb = ((Textbox) component);
if (tb.hasChanged()) {
p_triggerRefresh = true;
} else {
// if the dialog was opened from a menu.
if (isModal())
// Save the selection and close;
dispose(true);
else
return;
}
} else if (component instanceof Checkbox) {
// Check box changes generally always cause a refresh
// Capture changes that don't in a specific event handler
p_triggerRefresh = true;
Checkbox cb = (Checkbox) component;
if (cb.getName() != null && cb.getName().equals("AutoQuery")) {
// Only trigger a refresh if the check box is selected
if (!cb.isSelected()) {
return;
}
}
} else {
// Assume another type of component
if (event.getName().equals("onChange")) {
if (component instanceof Combobox) {
if (// Test for meaningful changes. Null == " ".
hasOutstandingChanges())
p_triggerRefresh = true;
} else
p_triggerRefresh = true;
}
}
// Buttons
if (component.equals(confirmPanel.getButton(ConfirmPanel.A_OK))) {
// VLookup fields in the criteria
if (hasOutstandingChanges()) {
return;
} else {
// We might close
p_triggerRefresh = false;
}
onOk();
} else if (component == p_table && event.getName().equals(Events.ON_DOUBLE_CLICK)) {
onDoubleClick();
} else if (component.equals(confirmPanel.getButton(ConfirmPanel.A_RESET))) {
// Created by the reset button, if used, to reset the criteria panel.
// Go back to the defaults
// Prevent other actions
m_busy = true;
// Should be overridden in the subordinate class
initInfo();
m_busy = false;
p_triggerRefresh = true;
// Ignore the autoQuery value and refresh now.
p_refreshNow = true;
} else if (component.equals(confirmPanel.getButton(ConfirmPanel.A_REFRESH))) {
// Refresh always causes a requery in case there are
// changes to the underlying tables - even if the
// criteria haven't changed.
p_resetColumns = true;
p_triggerRefresh = true;
p_refreshNow = true;
} else if (component.equals(confirmPanel.getButton(ConfirmPanel.A_CANCEL))) {
m_cancel = true;
// close
dispose(false);
} else // Elaine 2008/12/16
if (component.equals(confirmPanel.getButton(ConfirmPanel.A_HISTORY))) {
if (!p_table.getChildren().isEmpty() && p_table.getSelectedRowKey() != null) {
showHistory();
}
return;
} else if (component.equals(confirmPanel.getButton(ConfirmPanel.A_CUSTOMIZE))) {
if (!p_table.getChildren().isEmpty() && p_table.getSelectedRowKey() != null) {
customize();
}
return;
} else //
if (component.equals(confirmPanel.getButton(ConfirmPanel.A_ZOOM))) {
if (!p_table.getChildren().isEmpty() && p_table.getSelectedRowKey() != null) {
zoom();
if (isModal())
this.detach();
}
return;
} else if (component == paging) {
int pgNo = paging.getActivePage();
if (pageNo != pgNo) {
p_table.clearSelection();
pageNo = pgNo;
int start = pageNo * PAGE_SIZE;
int end = start + PAGE_SIZE;
List<Object> subList = readLine(start, end);
model = new ListModelTable(subList);
model.setSorter(this);
model.addTableModelListener(this);
p_table.setData(model, null);
p_table.setSelectedIndex(0);
}
}
}
// All events, unless trapped above, will get here.
// Check if we need to reset the table. The flag is reset when
// the table is reset. The first change triggers the reset.
p_resetColumns = p_resetColumns || columnIsDynamic(component);
// Refresh if the autoquery feature is selected or the refresh button is clicked.
if ((p_triggerRefresh && autoQuery()) || p_refreshNow) {
prepareAndExecuteQuery();
p_refreshNow = false;
}
}
}
Aggregations