use of org.zkoss.zk.ui.event.Event in project adempiere by adempiere.
the class CWindowToolbar method onCtrlKeyEvent.
private void onCtrlKeyEvent(KeyEvent keyEvent) {
ToolBarButton btn = null;
if (keyEvent.isAltKey() && !keyEvent.isCtrlKey() && !keyEvent.isShiftKey()) {
if (keyEvent.getKeyCode() == VK_X) {
if (windowNo > 0) {
prevKeyEventTime = System.currentTimeMillis();
prevKeyEvent = keyEvent;
keyEvent.stopPropagation();
SessionManager.getAppDesktop().closeWindow(windowNo);
}
} else {
btn = altKeyMap.get(keyEvent.getKeyCode());
}
} else if (!keyEvent.isAltKey() && keyEvent.isCtrlKey() && !keyEvent.isShiftKey())
btn = ctrlKeyMap.get(keyEvent.getKeyCode());
else if (!keyEvent.isAltKey() && !keyEvent.isCtrlKey() && !keyEvent.isShiftKey())
btn = keyMap.get(keyEvent.getKeyCode());
if (btn != null) {
prevKeyEventTime = System.currentTimeMillis();
prevKeyEvent = keyEvent;
keyEvent.stopPropagation();
if (!btn.isDisabled() && btn.isVisible()) {
Events.sendEvent(btn, new Event(Events.ON_CLICK, btn));
}
}
}
use of org.zkoss.zk.ui.event.Event in project adempiere by adempiere.
the class DefaultDesktop method doCreatePart.
protected Component doCreatePart(Component parent) {
SidePanel pnlSide = new SidePanel();
HeaderPanel pnlHead = new HeaderPanel();
pnlSide.getMenuPanel().addMenuListener(this);
layout = new Borderlayout();
if (parent != null) {
layout.setParent(parent);
layout.setWidth("100%");
layout.setHeight("100%");
layout.setStyle("position: absolute");
} else
layout.setPage(page);
dashboardRunnable = new DashboardRunnable(layout.getDesktop(), this);
North n = new North();
n.setSplittable(true);
n.setCollapsible(false);
layout.appendChild(n);
pnlHead.setParent(n);
West w = new West();
layout.appendChild(w);
w.setWidth("300px");
w.setCollapsible(true);
w.setSplittable(true);
w.setTitle(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Menu")));
w.setFlex(true);
w.addEventListener(Events.ON_OPEN, new EventListener() {
@Override
public void onEvent(Event event) throws Exception {
OpenEvent oe = (OpenEvent) event;
UserPreference pref = SessionManager.getSessionApplication().getUserPreference();
pref.setProperty(UserPreference.P_MENU_COLLAPSED, !oe.isOpen());
pref.savePreference();
}
});
UserPreference pref = SessionManager.getSessionApplication().getUserPreference();
boolean menuCollapsed = pref.isPropertyBool(UserPreference.P_MENU_COLLAPSED);
w.setOpen(!menuCollapsed);
pnlSide.setParent(w);
windowArea = new Center();
windowArea.setParent(layout);
windowArea.setFlex(true);
windowContainer.createPart(windowArea);
createHomeTab();
return layout;
}
use of org.zkoss.zk.ui.event.Event in project adempiere by adempiere.
the class WChartEditor method render.
private void render(JFreeChart chart) {
ChartRenderingInfo info = new ChartRenderingInfo();
int width = 400;
int height = chartModel.getWinHeight();
BufferedImage bi = chart.createBufferedImage(width, height, BufferedImage.TRANSLUCENT, info);
try {
byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true);
AImage image = new AImage("", bytes);
Imagemap myImage = new Imagemap();
Panel panel = getComponent();
myImage.setContent(image);
if (panel.getPanelchildren() != null) {
panel.getPanelchildren().getChildren().clear();
panel.getPanelchildren().appendChild(myImage);
} else {
Panelchildren pc = new Panelchildren();
panel.appendChild(pc);
pc.appendChild(myImage);
}
int count = 0;
for (Iterator<?> it = info.getEntityCollection().getEntities().iterator(); it.hasNext(); ) {
ChartEntity entity = (ChartEntity) it.next();
String key = null;
String seriesName = null;
if (entity instanceof CategoryItemEntity) {
CategoryItemEntity item = ((CategoryItemEntity) entity);
Comparable<?> colKey = item.getColumnKey();
Comparable<?> rowKey = item.getRowKey();
if (colKey != null && rowKey != null) {
key = colKey.toString();
seriesName = rowKey.toString();
}
} else if (entity instanceof PieSectionEntity) {
Comparable<?> sectionKey = ((PieSectionEntity) entity).getSectionKey();
if (sectionKey != null) {
key = sectionKey.toString();
}
}
if (entity instanceof XYItemEntity) {
XYItemEntity item = ((XYItemEntity) entity);
if (item.getDataset() instanceof TimeSeriesCollection) {
TimeSeriesCollection data = (TimeSeriesCollection) item.getDataset();
TimeSeries series = data.getSeries(item.getSeriesIndex());
TimeSeriesDataItem dataitem = series.getDataItem(item.getItem());
seriesName = series.getKey().toString();
key = dataitem.getPeriod().toString();
}
}
if (key == null)
continue;
Area area = new Area();
myImage.appendChild(area);
area.setCoords(entity.getShapeCoords());
area.setShape(entity.getShapeType());
area.setTooltiptext(entity.getToolTipText());
area.setId(count + "_WG__" + seriesName + "__" + key);
count++;
}
myImage.addEventListener(Events.ON_CLICK, new EventListener() {
public void onEvent(Event event) throws Exception {
MouseEvent me = (MouseEvent) event;
String areaId = me.getArea();
if (areaId != null) {
String[] strs = areaId.split("__");
if (strs.length == 3) {
chartMouseClicked(strs[2], strs[1]);
}
}
}
});
} catch (Exception e) {
log.log(Level.SEVERE, "", e);
}
}
use of org.zkoss.zk.ui.event.Event in project adempiere by adempiere.
the class InfoPanel method valueChange.
// onEvent
/**
* Capture value changes in WSearchEditor components specifically.
* Copy and override as required.
* @param evt
*/
public void valueChange(ValueChangeEvent evt) {
Object c = null;
if (evt.getSource() instanceof WSearchEditor)
c = ((WSearchEditor) evt.getSource()).getComponent();
else if (evt.getSource() instanceof WPAttributeEditor)
c = ((WPAttributeEditor) evt.getSource()).getComponent();
if (c == null)
return;
// Pass it off to the event handler to process.
Event e = new Event("onChange", (Component) c);
onEvent(e);
}
use of org.zkoss.zk.ui.event.Event in project adempiere by adempiere.
the class InfoBPartnerPanel method statInit.
private void statInit() {
initComponents();
fieldValue.setWidth("100%");
fieldContact.setWidth("100%");
fieldPhone.setWidth("100%");
fieldName.setWidth("100%");
fieldEMail.setWidth("100%");
fieldPostal.setWidth("100%");
Rows rows = new Rows();
Row row = new Row();
rows.appendChild(row);
row.appendChild(labelValue.rightAlign());
row.appendChild(fieldValue);
row.appendChild(labelContact.rightAlign());
row.appendChild(fieldContact);
row.appendChild(labelPhone.rightAlign());
row.appendChild(fieldPhone);
row.appendChild(checkCustomer);
row = new Row();
rows.appendChild(row);
row.appendChild(labelName.rightAlign());
row.appendChild(fieldName);
row.appendChild(labelEMail.rightAlign());
row.appendChild(fieldEMail);
row.appendChild(labelPostal.rightAlign());
row.appendChild(fieldPostal);
row.appendChild(checkAND);
statusBar.setEastVisibility(false);
// Contact Tab
ColumnInfo[] s_layoutContact = new ColumnInfo[] { new ColumnInfo(" ", "AD_User_ID", IDColumn.class), new ColumnInfo(Msg.translate(Env.getCtx(), "C_Greeting_ID"), "(SELECT g.Greeting from C_Greeting g WHERE g.C_Greeting_ID = AD_User.C_Greeting_ID)", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Name"), "Name", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Title"), "Title", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "C_Location_ID"), "(SELECT a.Name from C_BPartner_Location a WHERE AD_User.C_BPartner_Location_ID=a.C_BPartner_Location_ID)", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Phone"), "Phone", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Phone2"), "Phone2", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Fax"), "Fax", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "EMail"), "EMail", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "LastContact"), "LastContact", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "LastResult"), "LastResult", String.class) };
// From Clause
String s_sqlFrom = "AD_User";
// Where Clause
String s_sqlWhere = "C_BPartner_ID = ? and IsActive = 'Y'";
m_sqlContact = contactTbl.prepareTable(s_layoutContact, s_sqlFrom, s_sqlWhere, false, "AD_User");
contactTbl.setMultiSelection(false);
contactTbl.autoSize();
contactTbl.getModel().addTableModelListener(this);
contactTbl.setAttribute("zk_component_ID", "Lookup_Data_Contact");
// Location Tab
ColumnInfo[] s_layoutAddress = new ColumnInfo[] { new ColumnInfo(" ", "l.C_BPartner_Location_ID", IDColumn.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Name"), "l.Name", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Phone"), "l.Phone", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Phone2"), "l.Phone2", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Fax"), "l.Fax", String.class), // Replaced with parsed value
new ColumnInfo(Msg.translate(Env.getCtx(), "Address"), "a.Address1", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "IsShipTo"), "l.IsShipTo", Boolean.class), new ColumnInfo(Msg.translate(Env.getCtx(), "IsBillTo"), "l.IsBillTo", Boolean.class), new ColumnInfo(Msg.translate(Env.getCtx(), "IsRemitTo"), "l.IsRemitTo", Boolean.class), new ColumnInfo(Msg.translate(Env.getCtx(), "IsPayFrom"), "l.IsPayFrom", Boolean.class) };
ADDRESS_INDEX = 5;
/** From Clause */
String s_locationFrom = "C_BPartner_Location l" + " LEFT OUTER JOIN C_Location a ON (l.C_Location_ID=a.C_Location_ID)";
/** Where Clause */
String s_locationWhere = "l.C_BPartner_ID = ? and l.IsActive = 'Y'";
m_sqlAddress = addressTbl.prepareTable(s_layoutAddress, s_locationFrom, s_locationWhere, false, "l");
addressTbl.setMultiSelection(false);
addressTbl.autoSize();
addressTbl.getModel().addTableModelListener(this);
addressTbl.setAttribute("zk_component_ID", "Lookup_Data_Address");
//
detailTabBox.setHeight("100%");
Tabpanels tabPanels = new Tabpanels();
detailTabBox.appendChild(tabPanels);
Tabs tabs = new Tabs();
detailTabBox.appendChild(tabs);
Tab tab = new Tab(Util.cleanAmp(Msg.translate(Env.getCtx(), "Contact")));
tab.addEventListener(Events.ON_SELECT, this);
tabs.appendChild(tab);
Tabpanel desktopTabPanel = new Tabpanel();
desktopTabPanel.setHeight("100%");
desktopTabPanel.appendChild(contactTbl);
tabPanels.appendChild(desktopTabPanel);
tab = new Tab(Msg.translate(Env.getCtx(), "Location"));
tab.addEventListener(Events.ON_SELECT, this);
tabs.appendChild(tab);
desktopTabPanel = new Tabpanel();
desktopTabPanel.setHeight("100%");
desktopTabPanel.appendChild(addressTbl);
tabPanels.appendChild(desktopTabPanel);
tabs.setAttribute("zk_component_ID", "Subordinate_Tabs");
Borderlayout southSP = new Borderlayout();
Center center = new Center();
North north = new North();
center.appendChild(detailTabBox);
southSP.appendChild(north);
southSP.appendChild(center);
p_centerSouth.setTitle(Msg.translate(Env.getCtx(), "ContactAndAddress"));
p_centerSouth.setTooltiptext(Msg.translate(Env.getCtx(), "ContactAndAddress"));
p_centerSouth.appendChild(southSP);
p_criteriaGrid.appendChild(rows);
super.setSizes();
contactTbl.addActionListener(new EventListener<Event>() {
public void onEvent(Event event) throws Exception {
int leadRowKey = 0;
if (contactTbl != null || contactTbl.getRowCount() > 0)
leadRowKey = contactTbl.getLeadRowKey();
if (m_AD_User_ID != leadRowKey) {
// From the contact table
m_AD_User_ID = leadRowKey;
}
}
});
addressTbl.addActionListener(new EventListener<Event>() {
public void onEvent(Event event) throws Exception {
int leadRowKey = 0;
if (addressTbl != null || addressTbl.getRowCount() > 0)
leadRowKey = addressTbl.getLeadRowKey();
if (m_C_BPartner_Location_ID != leadRowKey) {
// From the main table
m_C_BPartner_Location_ID = leadRowKey;
}
}
});
}
Aggregations