Search in sources :

Example 1 with CloneConstructor

use of com.biglybt.ui.swt.pifimpl.UISWTViewCoreEventListenerEx.CloneConstructor in project BiglyBT by BiglySoftware.

the class BaseMdiEntry method exportStandAlone.

public Map<String, Object> exportStandAlone() {
    Map<String, Object> result = new HashMap<>();
    result.put("mdi", (this instanceof SideBarEntrySWT) ? "sidebar" : "tabbed");
    String title = null;
    ViewTitleInfo vti = getViewTitleInfo();
    if (vti != null) {
        title = (String) vti.getTitleInfoProperty(ViewTitleInfo.TITLE_TEXT);
    }
    if (title == null || title.length() == 0) {
        title = getFullTitle();
    }
    result.put("title", title);
    result.put("skin_ref", getSkinRef());
    result.put("skin_id", skin.getSkinID());
    result.put("parent_id", getParentID());
    result.put("id", id);
    Object data_source = getDatasourceCore();
    if (data_source == null) {
        data_source = getInitialDataSource();
    }
    if (data_source != null) {
        if (data_source instanceof String) {
            result.put("data_source", data_source);
        } else if (data_source instanceof Integer) {
            List l = new ArrayList();
            l.add("i");
            l.add(((Integer) data_source).longValue());
            result.put("data_source", l);
        } else {
            result.put("data_source", DataSourceResolver.exportDataSource(data_source));
        }
    }
    result.put("control_type", getControlType());
    UISWTViewEventListener listener = getEventListener();
    if (listener instanceof UISWTViewCoreEventListenerEx) {
        CloneConstructor cc = ((UISWTViewCoreEventListenerEx) listener).getCloneConstructor();
        String name = cc.getCloneClass().getName();
        Map<String, Object> map = new HashMap<>();
        map.put("name", name);
        List<Object> params = cc.getParameters();
        if (params != null) {
            List p_types = new ArrayList<>();
            List p_vals = new ArrayList<>();
            map.put("p_types", p_types);
            map.put("p_vals", p_vals);
            for (Object p : params) {
                if (p instanceof Boolean) {
                    p_types.add("bool");
                    p_vals.add(new Long(((Boolean) p) ? 1 : 0));
                } else if (p instanceof Long) {
                    p_types.add("long");
                    p_vals.add(p);
                } else if (p instanceof String) {
                    p_types.add("string");
                    p_vals.add(p);
                } else {
                    Debug.out("Unsupported param type: " + p);
                }
            }
        }
        result.put("event_listener", map);
    } else if (listener instanceof UISWTViewEventListenerEx) {
        com.biglybt.ui.swt.pif.UISWTViewEventListenerEx.CloneConstructor cc = ((UISWTViewEventListenerEx) listener).getCloneConstructor();
        PluginInterface pi = cc.getPluginInterface();
        Map<String, Object> map = new HashMap<>();
        map.put("plugin_id", pi.getPluginID());
        map.put("plugin_name", pi.getPluginName());
        map.put("ipc_method", cc.getIPCMethod());
        List<Object> params = cc.getIPCParameters();
        if (params != null) {
            List p_types = new ArrayList<>();
            List p_vals = new ArrayList<>();
            map.put("p_types", p_types);
            map.put("p_vals", p_vals);
            for (Object p : params) {
                if (p instanceof Boolean) {
                    p_types.add("bool");
                    p_vals.add(new Long(((Boolean) p) ? 1 : 0));
                } else if (p instanceof Long) {
                    p_types.add("long");
                    p_vals.add(p);
                } else if (p instanceof String) {
                    p_types.add("string");
                    p_vals.add(p);
                } else {
                    Debug.out("Unsupported param type: " + p);
                }
            }
        }
        result.put("event_listener", map);
    }
    return (result);
}
Also used : PluginInterface(com.biglybt.pif.PluginInterface) SideBarEntrySWT(com.biglybt.ui.swt.views.skin.sidebar.SideBarEntrySWT) UISWTViewEventListener(com.biglybt.ui.swt.pif.UISWTViewEventListener) UISWTViewEventListenerEx(com.biglybt.ui.swt.pif.UISWTViewEventListenerEx) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) PluginUISWTSkinObject(com.biglybt.ui.swt.pif.PluginUISWTSkinObject) List(java.util.List) CloneConstructor(com.biglybt.ui.swt.pifimpl.UISWTViewCoreEventListenerEx.CloneConstructor) ViewTitleInfo(com.biglybt.ui.common.viewtitleinfo.ViewTitleInfo)

Aggregations

PluginInterface (com.biglybt.pif.PluginInterface)1 ViewTitleInfo (com.biglybt.ui.common.viewtitleinfo.ViewTitleInfo)1 PluginUISWTSkinObject (com.biglybt.ui.swt.pif.PluginUISWTSkinObject)1 UISWTViewEventListener (com.biglybt.ui.swt.pif.UISWTViewEventListener)1 UISWTViewEventListenerEx (com.biglybt.ui.swt.pif.UISWTViewEventListenerEx)1 CloneConstructor (com.biglybt.ui.swt.pifimpl.UISWTViewCoreEventListenerEx.CloneConstructor)1 SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)1 SideBarEntrySWT (com.biglybt.ui.swt.views.skin.sidebar.SideBarEntrySWT)1 List (java.util.List)1