Search in sources :

Example 11 with Listitem

use of org.zkoss.zul.Listitem in project spatial-portal by AtlasOfLivingAustralia.

the class ActiveLayerDNDEventListener method reorderList.

public void reorderList(MapComposer mapComposer, DropEvent dropEvent) {
    Listitem dragged = (Listitem) dropEvent.getDragged();
    Listitem dropped = (Listitem) dropEvent.getTarget();
    mapComposer.reorderList(dragged, dropped);
}
Also used : Listitem(org.zkoss.zul.Listitem)

Example 12 with Listitem

use of org.zkoss.zul.Listitem 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 13 with Listitem

use of org.zkoss.zul.Listitem 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 14 with Listitem

use of org.zkoss.zul.Listitem in project adempiere by adempiere.

the class WAcctViewer method actionTable.

// actionDocument
/**
	 *  Save Table selection (reset Record selection)
	 */
private void actionTable() {
    Listitem listitem = selTable.getSelectedItem();
    ValueNamePair vp = null;
    if (listitem != null)
        vp = (ValueNamePair) listitem.getValue();
    else
        return;
    m_data.AD_Table_ID = ((Integer) m_data.tableInfo.get(vp.getValue())).intValue();
    log.config(vp.getValue() + " = " + m_data.AD_Table_ID);
    //  Reset Record
    m_data.Record_ID = 0;
    selRecord.setLabel("");
    selRecord.setName(vp.getValue() + "_ID");
}
Also used : Listitem(org.zkoss.zul.Listitem) ValueNamePair(org.compiere.util.ValueNamePair)

Example 15 with Listitem

use of org.zkoss.zul.Listitem in project adempiere by adempiere.

the class WAcctViewer method actionAcctSchema.

// onEvent
/**
	 * 	New Acct Schema
	 */
private void actionAcctSchema() {
    Listitem listitem = selAcctSchema.getSelectedItem();
    KeyNamePair kp = null;
    if (listitem != null)
        kp = (KeyNamePair) listitem.getValue();
    if (kp == null)
        return;
    m_data.C_AcctSchema_ID = kp.getKey();
    m_data.ASchema = MAcctSchema.get(Env.getCtx(), m_data.C_AcctSchema_ID);
    log.info(m_data.ASchema.toString());
    //  Sort Options
    sortBy1.getChildren().clear();
    sortBy2.getChildren().clear();
    sortBy3.getChildren().clear();
    sortBy4.getChildren().clear();
    sortAddItem(new ValueNamePair("", ""));
    sortAddItem(new ValueNamePair("DateAcct", Msg.translate(Env.getCtx(), "DateAcct")));
    sortAddItem(new ValueNamePair("DateTrx", Msg.translate(Env.getCtx(), "DateTrx")));
    sortAddItem(new ValueNamePair("C_Period_ID", Msg.translate(Env.getCtx(), "C_Period_ID")));
    Label[] labels = new Label[] { lsel1, lsel2, lsel3, lsel4, lsel5, lsel6, lsel7, lsel8 };
    Button[] buttons = new Button[] { sel1, sel2, sel3, sel4, sel5, sel6, sel7, sel8 };
    int selectionIndex = 0;
    MAcctSchemaElement[] elements = m_data.ASchema.getAcctSchemaElements();
    for (int i = 0; i < elements.length && selectionIndex < labels.length; i++) {
        MAcctSchemaElement acctSchemaElement = elements[i];
        String columnName = acctSchemaElement.getColumnName();
        String displayColumnName;
        if (columnName.equals("User1_ID") || columnName.equals("User2_ID") || columnName.equals("User3_ID") || columnName.equals("User4_ID"))
            displayColumnName = acctSchemaElement.getName();
        else
            displayColumnName = acctSchemaElement.getDisplayColumnName();
        //  Add Sort Option
        sortAddItem(new ValueNamePair(columnName, Msg.translate(Env.getCtx(), displayColumnName)));
        if (!acctSchemaElement.isElementType(X_C_AcctSchema_Element.ELEMENTTYPE_Organization) && !acctSchemaElement.isElementType(X_C_AcctSchema_Element.ELEMENTTYPE_Account)) {
            labels[selectionIndex].setValue(Msg.translate(Env.getCtx(), displayColumnName));
            labels[selectionIndex].setVisible(true);
            // actionCommand
            buttons[selectionIndex].setName(columnName);
            buttons[selectionIndex].addEventListener(Events.ON_CLICK, this);
            buttons[selectionIndex].setImage(ServletFns.resolveThemeURL("~./images/Find16.png"));
            buttons[selectionIndex].setLabel("");
            buttons[selectionIndex].setVisible(true);
            selectionIndex++;
        }
    }
    while (selectionIndex < labels.length) {
        labels[selectionIndex].setVisible(false);
        buttons[selectionIndex++].setVisible(false);
    }
}
Also used : Button(org.adempiere.webui.component.Button) Listitem(org.zkoss.zul.Listitem) Label(org.adempiere.webui.component.Label) KeyNamePair(org.compiere.util.KeyNamePair) ValueNamePair(org.compiere.util.ValueNamePair) MAcctSchemaElement(org.compiere.model.MAcctSchemaElement)

Aggregations

Listitem (org.zkoss.zul.Listitem)24 Component (org.zkoss.zk.ui.Component)7 MapComposer (au.org.emii.portal.composer.MapComposer)6 KeyNamePair (org.compiere.util.KeyNamePair)5 MapLayer (au.org.emii.portal.menu.MapLayer)4 SQLException (java.sql.SQLException)3 ValueNamePair (org.compiere.util.ValueNamePair)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 AdempiereException (org.adempiere.exceptions.AdempiereException)2 ListItem (org.adempiere.webui.component.ListItem)2 TableValueChangeEvent (org.adempiere.webui.event.TableValueChangeEvent)2 IDColumn (org.compiere.minigrid.IDColumn)2 MAcctSchemaElement (org.compiere.model.MAcctSchemaElement)2 MPrintFormat (org.compiere.print.MPrintFormat)2 AMedia (org.zkoss.util.media.AMedia)2 Decimalbox (org.zkoss.zul.Decimalbox)2 ScatterplotDataDTO (au.org.ala.spatial.dto.ScatterplotDataDTO)1 Query (au.org.ala.spatial.util.Query)1 PortalSession (au.org.emii.portal.session.PortalSession)1