Search in sources :

Example 41 with Component

use of org.zkoss.zk.ui.Component in project spatial-portal by AtlasOfLivingAustralia.

the class ActiveLayersLegendEventListener method onEvent.

@Override
public void onEvent(Event event) throws Exception {
    MapComposer mapComposer = getMapComposer(event);
    if (mapComposer != null && mapComposer.safeToPerformMapAction()) {
        // get reference to the label/image the user clicked on 
        Component target = event.getTarget();
        Listitem listItem = (Listitem) target.getParent().getParent();
        listItem.setSelected(true);
    } else {
        LOGGER.debug("MapController reports unsafe to perform action");
    }
}
Also used : MapComposer(au.org.emii.portal.composer.MapComposer) Listitem(org.zkoss.zul.Listitem) Component(org.zkoss.zk.ui.Component)

Example 42 with Component

use of org.zkoss.zk.ui.Component in project spatial-portal by AtlasOfLivingAustralia.

the class ActiveLayerDNDEventListener method onEvent.

@Override
public void onEvent(Event event) throws Exception {
    LOGGER.debug("active layers item drop received");
    MapComposer mapComposer = getMapComposer(event);
    if (mapComposer != null && mapComposer.safeToPerformMapAction()) {
        LOGGER.debug("inside ActiveLayerDNDEventListener.onEvent()");
        if (event instanceof DropEvent) {
            DropEvent dragEvent = (DropEvent) event;
            // we support the treechildren and other list items...
            Component eventType = dragEvent.getDragged();
            if (eventType instanceof Listitem) {
                reorderList(mapComposer, dragEvent);
            } else {
                LOGGER.debug("unsupported dnd event " + eventType.getClass().getName());
            }
        } else {
            LOGGER.debug("event is not a DropEvent instance: " + event.getClass().getName());
        }
    }
}
Also used : DropEvent(org.zkoss.zk.ui.event.DropEvent) MapComposer(au.org.emii.portal.composer.MapComposer) Listitem(org.zkoss.zul.Listitem) Component(org.zkoss.zk.ui.Component)

Example 43 with Component

use of org.zkoss.zk.ui.Component in project spatial-portal by AtlasOfLivingAustralia.

the class ActiveLayersInfoEventListener method onEvent.

@Override
public void onEvent(Event event) throws Exception {
    MapComposer mapComposer = getMapComposer(event);
    if (mapComposer != null && mapComposer.safeToPerformMapAction()) {
        // get reference to the label/image the user clicked on
        Component target = event.getTarget();
        Listitem listItem = (Listitem) target.getParent().getParent();
        MapLayer activeLayer = listItem.getValue();
        if (activeLayer != null) {
            if (activeLayer.getSpeciesQuery() != null) {
                Query q = activeLayer.getSpeciesQuery();
                Events.echoEvent(StringConstants.OPEN_HTML, mapComposer, q.getMetadataHtml());
            } else if (activeLayer.getMapLayerMetadata().getMoreInfo() != null && activeLayer.getMapLayerMetadata().getMoreInfo().startsWith("http://")) {
                String infourl = activeLayer.getMapLayerMetadata().getMoreInfo().replace("__", ".");
                if (activeLayer.getSubType() == LayerUtilitiesImpl.SCATTERPLOT) {
                    ScatterplotDataDTO data = activeLayer.getScatterplotDataDTO();
                    infourl += "?dparam=X-Layer:" + data.getLayer1Name();
                    infourl += "&dparam=Y-Layer:" + data.getLayer2Name();
                }
                // send the user to the BIE page for the species
                LOGGER.debug("opening the following url " + infourl);
                Events.echoEvent(StringConstants.OPEN_URL, mapComposer, activeLayer.getMapLayerMetadata().getMoreInfo().replace("__", "."));
            } else if (activeLayer.getMapLayerMetadata().getMoreInfo() != null && activeLayer.getMapLayerMetadata().getMoreInfo().length() > 0) {
                LOGGER.debug("performing a MapComposer.showMessage for following content " + activeLayer.getMapLayerMetadata().getMoreInfo());
                String metadata = activeLayer.getMapLayerMetadata().getMoreInfo();
                Events.echoEvent(StringConstants.OPEN_HTML, mapComposer, metadata);
            } else if (activeLayer.getType() == LayerUtilitiesImpl.MAP) {
                String metaurl = "http://www.google.com/intl/en_au/help/terms_maps.html";
                if ("outline".equalsIgnoreCase(mapComposer.getPortalSession().getBaseLayer())) {
                    metaurl = "openstreetmap_metadata.html";
                } else if ("minimal".equalsIgnoreCase(mapComposer.getPortalSession().getBaseLayer())) {
                    metaurl = "http://www.naturalearthdata.com/about/terms-of-use";
                }
                LOGGER.debug("opening base map metadata for: " + mapComposer.getPortalSession().getBaseLayer() + ", url:" + metaurl);
                Events.echoEvent(StringConstants.OPEN_URL, mapComposer, metaurl);
            } else {
                LOGGER.debug("no metadata is available for current layer");
                mapComposer.showMessage("Metadata currently unavailable");
            }
        }
    } else {
        LOGGER.debug("MapController reports unsafe to perform action");
    }
}
Also used : ScatterplotDataDTO(au.org.ala.spatial.dto.ScatterplotDataDTO) MapComposer(au.org.emii.portal.composer.MapComposer) Query(au.org.ala.spatial.util.Query) MapLayer(au.org.emii.portal.menu.MapLayer) Listitem(org.zkoss.zul.Listitem) Component(org.zkoss.zk.ui.Component)

Example 44 with Component

use of org.zkoss.zk.ui.Component in project adempiere by adempiere.

the class DynamicDashBoard method createRows.

/**
	 * 
	 * @return Rows <BR>
	 * 
	 * 
	 *         This method creates the Rows
	 */
public Rows createRows() {
    Vbox msgbox = new Vbox();
    Label rowItem = null;
    Rows rows = new Rows();
    ResultSet rs = null;
    if (rows.getChildren() != null) {
        List<Component> childs = rows.getChildren();
        for (Component cmp : childs) {
            rows.removeChild(cmp);
        }
    }
    PreparedStatement pstmt = null;
    pstmt = DB.prepareStatement(sqlQuery.toString(), null);
    try {
        rs = pstmt.executeQuery();
        try {
            if (rs.next()) {
                grid.setVisible(true);
                msgbox.setVisible(false);
                prepareRow(rs, lable, rows);
                while (rs.next()) {
                    prepareRow(rs, lable, rows);
                }
            } else {
                vbox.removeChild(msgbox);
                grid.setVisible(false);
                msgbox.setVisible(true);
                if (msgbox != null && msgbox.getChildren().size() > 0) {
                    msgbox.removeChild(rowItem);
                }
                grid.setVisible(false);
                msgbox.setVisible(true);
                String msg = Msg.getMsg(Env.getCtx(), "NO_DATA");
                rowItem = new Label(msg);
                rowItem.setParent(msgbox);
                msgbox.setParent(vbox);
            }
        } catch (SQLException e) {
            logger.log(Level.SEVERE, "SQL  faile");
        }
    } catch (Exception e) {
        logger.log(Level.SEVERE, e.toString() + "  Check for configured Zoom Tab having Primary key of Table:" + table.getTableName());
    } finally {
        if (rs != null) {
            try {
                rs.close();
            } catch (SQLException e) {
                logger.log(Level.SEVERE, "Unable to close Resultset:" + e);
            }
        }
    }
    return rows;
}
Also used : SQLException(java.sql.SQLException) Label(org.adempiere.webui.component.Label) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) Component(org.zkoss.zk.ui.Component) Vbox(org.zkoss.zul.Vbox) SQLException(java.sql.SQLException) Rows(org.zkoss.zul.Rows)

Example 45 with Component

use of org.zkoss.zk.ui.Component in project adempiere by adempiere.

the class DynamicDashBoard method onEvent.

public void onEvent(Event event) throws Exception {
    Component comp = event.getTarget();
    Row row = (Row) comp;
    int recordId = new Integer(row.getId());
    MQuery query = new MQuery();
    query.setZoomValue(recordId);
    query.setZoomTableName(zoomTableName);
    query.setZoomColumnName(zoomTableColumnName);
    query.setRecordCount(1);
    query.addRestriction(zoomTableColumnName, MQuery.EQUAL, new Integer(recordId));
    AEnv.zoom(zoomWindowId, query);
}
Also used : MQuery(org.compiere.model.MQuery) Row(org.zkoss.zul.Row) Component(org.zkoss.zk.ui.Component)

Aggregations

Component (org.zkoss.zk.ui.Component)70 IOException (java.io.IOException)8 HtmlBasedComponent (org.zkoss.zk.ui.HtmlBasedComponent)8 Checkbox (org.adempiere.webui.component.Checkbox)7 ToolBarButton (org.adempiere.webui.component.ToolBarButton)7 Div (org.zkoss.zul.Div)7 Listitem (org.zkoss.zul.Listitem)7 MapLayer (au.org.emii.portal.menu.MapLayer)6 Button (org.adempiere.webui.component.Button)6 Tabpanel (org.adempiere.webui.component.Tabpanel)6 WEditor (org.adempiere.webui.editor.WEditor)6 ParseException (org.json.simple.parser.ParseException)6 Event (org.zkoss.zk.ui.event.Event)6 MapComposer (au.org.emii.portal.composer.MapComposer)5 PreparedStatement (java.sql.PreparedStatement)5 ResultSet (java.sql.ResultSet)5 DashboardPanel (org.adempiere.webui.dashboard.DashboardPanel)5 HeaderPanel (org.adempiere.webui.panel.HeaderPanel)5 SidePanel (org.adempiere.webui.panel.SidePanel)5 UiException (org.zkoss.zk.ui.UiException)5