Example usage for com.google.gwt.user.client.ui HTML HTML

List of usage examples for com.google.gwt.user.client.ui HTML HTML

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui HTML HTML.

Prototype

protected HTML(Element element) 

Source Link

Document

This constructor may be used by subclasses to explicitly use an existing element.

Usage

From source file:com.eduworks.russel.ui.client.Constants.java

License:Apache License

/**
 * roundNumber Rounds number "num" to the number of "places" specified
 * //from w w  w.  j a v  a2  s  . co m
 * @param num
 * @param places
 * @return rounded result
 */
public static void logout() {
    loggedInCheck.cancel();
    AppSettings.dispatcher.clearHistory();
    Russel.screen.loadScreen(new LoginScreen(), true);
    final Element oldErrorDialog = (Element) Document.get().getElementById("errorDialog");
    if (oldErrorDialog != null)
        oldErrorDialog.removeFromParent();

    final HTML errorDialog = new HTML(((HtmlTemplates) AppSettings.templates).getErrorWidget().getText());
    RootPanel.get("errorContainer").add(errorDialog);
    ((Label) PageAssembler.elementToWidget("errorMessage", PageAssembler.LABEL)).setText(SESSION_EXPIRED);
    PageAssembler.attachHandler("errorClose", Event.ONMOUSEUP, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            errorDialog.removeFromParent();
        }
    });
}

From source file:com.eduworks.russel.ui.client.handler.ESBSearchHandler.java

License:Apache License

/**
 * buildTile0 Initiates a tile in the Alfresco results panel.
 * @param searchTermPacket ESBPacket Alfresco search results
 * @param index int Index in the search results for the tile to be created
 * @param objPanel String Name of target panel for the tile
 * @param td Element Container for the tile
 * @return TileHandler//from w w w .j  av  a  2s. com
 */
protected TileHandler buildTile0(final RUSSELFileRecord r, int screenPosition, String objPanel, Element td) {
    Vector<String> iDs = null;

    if ((td != null) && (searchType.equals(RECENT_TYPE)))
        iDs = PageAssembler.inject(td.getId(), "x", new HTML(templates.getObjectPanelWidget().getText()),
                false);
    else if (searchType.equals(COLLECTION_TYPE) || searchType.equals(SEARCH_TYPE)
            || searchType.equals(RusselApi.FLR_TYPE))
        iDs = PageAssembler.inject(objPanel, "x", new HTML(templates.getSearchPanelWidget().getText()), false);
    else if (searchType.equals(PROJECT_TYPE))
        iDs = PageAssembler.inject(objPanel, "x",
                new HTML(templates.getEPSSProjectObjectPanelWidget().getText()), false);
    else if ((td != null) && (searchType.equals(ASSET_TYPE)))
        iDs = PageAssembler.inject(td.getId(), "x",
                new HTML(templates.getEPSSAssetObjectPanelWidget().getText()), false);
    else if ((td != null) && (searchType.equals(NOTES_TYPE)))
        iDs = PageAssembler.inject(td.getId(), "x",
                new HTML(templates.getEPSSNoteAssetObjectWidget().getText()), false);
    else if ((td != null) && (searchType.equals(STRATEGY_TYPE))) {
        Window.alert("handling a strategy search");
        iDs = PageAssembler.inject(td.getId(), "x",
                new HTML(templates.getEPSSAssetObjectPanelWidget().getText()), false);
    }
    String idPrefix = iDs.firstElement().substring(0, iDs.firstElement().indexOf("-"));
    TileHandler th = new TileHandler(this, idPrefix, searchType, r);
    tileHandlers.add(th);
    return th;
}

From source file:com.eduworks.russel.ui.client.handler.ESBSearchHandler.java

License:Apache License

public void buildThumbnails(String objPanel, AjaxPacket searchTermPacket) {
    if (searchTermPacket != null) {
        RootPanel rp = RootPanel.get(objPanel);
        if (rp != null) {
            Element td = null;/*from   w  w w  .j ava 2 s .c  o  m*/
            tileIndex = 0;
            if (noResults != null)
                rp.remove(noResults);

            if (searchTermPacket.containsKey("obj")) {
                JSONObject jo = searchTermPacket.getObject("obj").isObject();
                if ((jo.containsKey("items") && jo.get("items").isArray().size() == 0)
                        || (jo.containsKey("hits")
                                && jo.get("hits").isObject().get("hits").isArray().size() == 0)) {
                    rp.getElement().setAttribute("style", "text-align:center");
                    noResults = new HTML(NO_SEARCH_RESULTS);
                    rp.add(noResults);
                } else
                    rp.getElement().setAttribute("style", "");

                if (searchType.equals(RusselApi.FLR_TYPE)) {
                    JSONArray ja = searchTermPacket.getObject("obj").get("hits").isObject().get("hits")
                            .isArray();
                    if (ja.size() == 0)
                        return;
                    RUSSELFileRecord[] fileSet = FLRResultExtractor.walkBasicSearch(ja);

                    int screenPosition = 0;
                    for (int x = 0; x < fileSet.length; x++) {
                        if (screenPosition % 2 == 0 && !doNotShow.contains(searchType)
                                && (showOnly.isEmpty() || showOnly.contains(searchType))) {
                            // SEARCH3DR_TYPE uses the vertStack style, and will not use the table-based layout that requires insertion of cell separators.
                            td = DOM.createTD();
                            td.setId(x + "-" + rp.getElement().getId());
                            rp.getElement().appendChild(td);
                        }
                        TileHandler th = buildTile0(fileSet[x], screenPosition++, objPanel, td);
                        th.fillTile(null);
                    }
                } else {
                    int screenPosition = 0;
                    for (int x = 0; x < searchTermPacket.getObject("obj").get("items").isArray().size(); x++) {
                        RUSSELFileRecord fr = new RUSSELFileRecord(new ESBPacket(searchTermPacket
                                .getObject("obj").isObject().get("items").isArray().get(x).isObject()));
                        if (filter != null)
                            if (filter.contains(fr.getGuid()))
                                continue;

                        if (screenPosition % 2 == 0 && !doNotShow.contains(searchType)
                                && (showOnly.isEmpty() || showOnly.contains(searchType))) {
                            // SEARCH3DR_TYPE uses the vertStack style, and will not use the table-based layout that requires insertion of cell separators.
                            td = DOM.createTD();
                            td.setId(x + "-" + rp.getElement().getId());
                            rp.getElement().appendChild(td);
                        }
                        buildTile0(fr, screenPosition++, objPanel, td);
                    }

                    processCallbacks();
                }
            }
        }
    }
}

From source file:com.eduworks.russel.ui.client.handler.StatusHandler.java

License:Apache License

/**
 * refreshMessages Refreshes the messages in the global status window
 *//*  w  w w  .ja  v a 2 s  .  co m*/
private static void refreshMessages() {
    int messageCount = messages.size();
    for (int messageIndex = 0; messageIndex < messageCount; messageIndex++) {
        if (!messages.get(messageIndex).getRendered()) {
            Vector<String> ids = PageAssembler.inject("statusList", "x", new HTML(statusItemTemplate), true);
            String idNumPrefix = ids.get(0).substring(0, ids.get(0).indexOf("-"));
            final StatusRecord message = messages.get(messageIndex);
            message.setGuid(idNumPrefix);
            PageAssembler.merge(idNumPrefix + "-statusMessage", "x",
                    new HTML(message.getMessage()).getElement());
            message.setRendered(true);
            if (message.getState() != "")
                DOM.getElementById(idNumPrefix + "-status").addClassName(message.getState());
            PageAssembler.attachHandler(idNumPrefix + "-statusClose", Event.ONCLICK, new EventCallback() {
                @Override
                public void onEvent(Event event) {
                    removeMessage(message);
                }
            });
        }
    }
    if (messageCount > 0) {
        DOM.getElementById("statusWindow").removeClassName("hidden");
        DOM.getElementById("count").setInnerText(String.valueOf(messageCount));
        DOM.getElementById("count").removeClassName("hidden");
    } else {
        DOM.getElementById("count").addClassName("hidden");
        DOM.getElementById("statusWindow").addClassName("hidden");
        hideStatusList0(DOM.getElementById("statusList"));
        DOM.getElementById("statusWindow").removeClassName("expand");
    }

    boolean hasError = false;
    boolean isBusy = false;
    for (int messageIndex = 0; messageIndex < messageCount; messageIndex++)
        if (messages.get(messageIndex).getState() == StatusRecord.ALERT_ERROR)
            hasError = true;
        else if (messages.get(messageIndex).getState() == StatusRecord.ALERT_BUSY)
            isBusy = true;
    DOM.getElementById("icon").removeClassName(StatusRecord.STATUS_BUSY);
    DOM.getElementById("icon").removeClassName(StatusRecord.STATUS_ERROR);
    DOM.getElementById("icon").removeClassName(StatusRecord.STATUS_DONE);
    if (hasError)
        DOM.getElementById("icon").addClassName(StatusRecord.STATUS_ERROR);
    else if (isBusy)
        DOM.getElementById("icon").addClassName(StatusRecord.STATUS_BUSY);
    else
        DOM.getElementById("icon").addClassName(StatusRecord.STATUS_DONE);
}

From source file:com.eduworks.russel.ui.client.pagebuilder.screen.DetailScreen.java

License:Apache License

/**
 * displayGuts Renders the guts of the DetailView and sets up handlers for the node record after it has been retrieved and is available
 *///from  ww  w .  j  a  v  a  2s. c  om
public void displayGuts() {

    if (fullScreen) {
        PageAssembler.ready(new HTML(Russel.htmlTemplates.getDetailPanel().getText()));
        PageAssembler.buildContents();
        DOM.getElementById("r-menuWorkspace").getParentElement().removeClassName("active");
        DOM.getElementById("r-menuCollections").getParentElement().removeClassName("active");
        DOM.getElementById("r-menuProjects").getParentElement().removeClassName("active");
        DOM.getElementById("r-fullScreen").setAttribute("style", "display:none");
        DOM.getElementById("r-metadata-hide").setAttribute("style", "display:none");
        DOM.getElementById("r-metadata-show").setAttribute("style", "");
    } else {
        DOM.getElementById("r-fullScreen").setAttribute("style", "");
        PageAssembler.attachHandler(PageAssembler.getElementByClass(".reveal-modal-bg"), Event.ONCLICK,
                new EventCallback() {
                    @Override
                    public void onEvent(Event event) {
                        if (tile != null)
                            tile.refreshTile(null);
                    }
                });

        PageAssembler.attachHandler(PageAssembler.getElementByClass(".close-reveal-modal"), Event.ONCLICK,
                new EventCallback() {
                    @Override
                    public void onEvent(Event event) {
                        if (tile != null)
                            tile.refreshTile(null);
                    }
                });
    }

    if (record.getFilename().substring(record.getFilename().lastIndexOf(".") + 1).equalsIgnoreCase("rpf")) {
        DOM.getElementById("r-editEPSSContainer").removeAttribute("style");
        PageAssembler.attachHandler("r-editEPSS", Event.ONCLICK, new EventCallback() {
            @Override
            public void onEvent(Event event) {
                RusselApi.getResource(tile.getSearchRecord().getGuid(), true, new ESBCallback<ESBPacket>() {
                    @Override
                    public void onSuccess(ESBPacket alfrescoPacket) {
                        ProjectRecord pr = new ProjectRecord(alfrescoPacket.getContentString(), record);
                        Russel.screen.loadScreen(new EPSSScreen(pr), true);
                    }

                    @Override
                    public void onFailure(Throwable caught) {
                        StatusHandler.createMessage(
                                StatusHandler.getProjectLoadMessageError(record.getFilename()),
                                StatusRecord.ALERT_ERROR);
                    }
                });
            }
        });
    } else
        DOM.getElementById("r-editEPSSContainer").setAttribute("style", "display:none");

    setDisplayIE(DOM.getElementById("r-metadata-hide"), "block");
    setDisplayIE(DOM.getElementById("r-metadata-show"), "none");
    setDisplayIE(DOM.getElementById("r-generalMetadata"), "block");
    setDisplayIE(DOM.getElementById("r-educationalMetadata"), "none");
    setDisplayIE(DOM.getElementById("r-technicalMetadata"), "none");
    setDisplayIE(DOM.getElementById("r-relatedMetadata"), "none");
    if (record.getGuid() == "" && record.getFilename().endsWith(".flr")) {
        setDisplayIE(DOM.getElementById("r-postFlr"), "none");
        setDisplayIE(DOM.getElementById("r-saveFromFlr"), "block");
        setDisplayIE(DOM.getElementById("r-detailGenerateMetadata"), "none");
    } else {
        setDisplayIE(DOM.getElementById("r-postFlr"), "block");
        setDisplayIE(DOM.getElementById("r-saveFromFlr"), "none");
        setDisplayIE(DOM.getElementById("r-detailGenerateMetadata"), "block");
    }
    ((Label) PageAssembler.elementToWidget("general-section", PageAssembler.LABEL))
            .removeStyleName("collapsed");
    ((Label) PageAssembler.elementToWidget("educational-section", PageAssembler.LABEL))
            .addStyleName("collapsed");
    ((Label) PageAssembler.elementToWidget("technical-section", PageAssembler.LABEL)).addStyleName("collapsed");
    ((Label) PageAssembler.elementToWidget("related-section", PageAssembler.LABEL)).addStyleName("collapsed");
    ((TextBox) PageAssembler.elementToWidget("input-comment", PageAssembler.TEXT)).setText("");

    DOM.getElementById("detailLevel1").setAttribute("disabled", "");
    DOM.getElementById("detailDistribution1").setAttribute("disabled", "");

    ((Label) PageAssembler.elementToWidget("r-detailIcon", PageAssembler.LABEL)).setStyleName("r-icon");
    ((Label) PageAssembler.elementToWidget("r-detailIcon", PageAssembler.LABEL))
            .addStyleName(AssetExtractor.getFileType(record.getFilename()));
    removeUnsavedEffects0();

    PageAssembler.attachHandler("r-saveFromFlr", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            RusselApi.uploadResource(record.getFileContents(), record.getFilename(),
                    new ESBCallback<ESBPacket>() {
                        @Override
                        public void onSuccess(ESBPacket esbPacket) {
                            record.setGuid(esbPacket.getPayloadString());
                            ESBPacket pack = new ESBPacket(record.toString());
                            pack.remove("uploadDate_l");
                            pack.remove("updatedDate_l");
                            RusselApi.updateResourceMetadata(record.getGuid(), pack,
                                    new ESBCallback<ESBPacket>() {
                                        @Override
                                        public void onSuccess(ESBPacket esbPacket) {
                                            PageAssembler.closePopup("objDetailModal");
                                        }

                                        @Override
                                        public void onFailure(Throwable caught) {

                                        }
                                    });
                        }

                        @Override
                        public void onFailure(Throwable caught) {
                        }
                    });
        }
    });

    PageAssembler.attachHandler("r-detailGenerateMetadata", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            final StatusRecord status = StatusHandler.createMessage(
                    StatusHandler.getGenerateMetaDataBusy(record.getFilename()), StatusRecord.ALERT_BUSY);

            final ESBCallback<ESBPacket> callback = new ESBCallback<ESBPacket>() {
                @Override
                public void onFailure(Throwable caught) {
                    status.setState(StatusRecord.ALERT_ERROR);
                    status.setMessage(StatusHandler.getGenerateMetaDataError(record.getFilename()));
                    StatusHandler.alterMessage(status);
                }

                @Override
                public void onSuccess(ESBPacket esbPacket) {
                    status.setState(StatusRecord.ALERT_SUCCESS);
                    status.setMessage(StatusHandler.getGenerateMetaDataDone(record.getFilename()));
                    StatusHandler.alterMessage(status);

                    final RUSSELFileRecord fr = new RUSSELFileRecord(esbPacket);
                    meta.addMetaDataFields(fr);
                    addUnsavedEffects0();
                }
            };

            RusselApi.generateResourceMetadata(record.getGuid(),
                    record.getFilename().endsWith(".rlk") ? true : false, callback);
        }
    });

    PageAssembler.attachHandler("r-detailEditUpdate", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            final StatusRecord status = StatusHandler.createMessage(
                    StatusHandler.getUpdateMetadataMessageBusy(record.getFilename()), StatusRecord.ALERT_BUSY);
            RusselApi.updateResourceMetadata(record.getGuid(), meta.buildMetaPacket(record).toObject(),
                    new ESBCallback<ESBPacket>() {
                        @Override
                        public void onSuccess(final ESBPacket nullPack) {
                            status.setMessage(StatusHandler.getUpdateMetadataMessageDone(record.getFilename()));
                            status.setState(StatusRecord.ALERT_SUCCESS);
                            StatusHandler.alterMessage(status);
                            RusselApi.getResourceMetadata(record.getGuid(), false,
                                    new ESBCallback<ESBPacket>() {
                                        @Override
                                        public void onSuccess(ESBPacket ap) {
                                            removeUnsavedEffects0();
                                            record.parseESBPacket(ap);
                                            meta.addMetaDataFields(record);
                                            Label title = ((Label) PageAssembler
                                                    .elementToWidget("r-detailTitle", PageAssembler.LABEL));
                                            if (tile != null)
                                                tile.fillTile(null);
                                            if (title.getText().equalsIgnoreCase("n/a"))
                                                title.setText(record.getFilename());
                                        }

                                        @Override
                                        public void onFailure(Throwable caught) {
                                            removeUnsavedEffects0();
                                        }
                                    });

                        }

                        @Override
                        public void onFailure(Throwable caught) {
                            status.setMessage(
                                    StatusHandler.getUpdateMetadataMessageError(record.getFilename()));
                            status.setState(StatusRecord.ALERT_ERROR);
                            StatusHandler.alterMessage(status);
                        }
                    });
        }
    });

    PageAssembler.attachHandler("r-fullScreen", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            PageAssembler.closePopup("objDetailModal");
            PageAssembler.removeElement("objDetailModal");
            PageAssembler.removeByClass("reveal-modal-bg");
            Russel.screen.loadScreen(new DetailScreen(record, FULL_SCREEN), false);
        }
    });

    PageAssembler.attachHandler("r-deleteDoc", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            if (Window.confirm("Are you sure you wish to delete this item?")) {
                final StatusRecord status = StatusHandler.createMessage(
                        StatusHandler.getDeleteMessageBusy(record.getFilename()), StatusRecord.ALERT_BUSY);
                RusselApi.deleteResource(record.getGuid(), new ESBCallback<ESBPacket>() {
                    @Override
                    public void onFailure(Throwable caught) {
                        status.setMessage(StatusHandler.getDeleteMessageError(record.getFilename()));
                        status.setState(StatusRecord.ALERT_ERROR);
                        StatusHandler.alterMessage(status);
                    }

                    @Override
                    public void onSuccess(ESBPacket result) {
                        status.setMessage(StatusHandler.getDeleteMessageDone(record.getFilename()));
                        status.setState(StatusRecord.ALERT_SUCCESS);
                        StatusHandler.alterMessage(status);
                        ((TextBox) PageAssembler.elementToWidget("r-menuSearchBar", PageAssembler.TEXT))
                                .setText("");
                        PageAssembler.closePopup("objDetailModal");
                        if (record instanceof RUSSELFileRecord) {
                            if (((RUSSELFileRecord) record).getFlrDocId() != "")
                                RusselApi
                                        .publishToFlr(record.getGuid(),
                                                FLRPacketGenerator
                                                        .buildFlrDeleteNsdlPacket(((RUSSELFileRecord) record)),
                                                new ESBCallback<ESBPacket>() {
                                                    @Override
                                                    public void onFailure(Throwable caught) {
                                                        StatusHandler.createMessage(
                                                                StatusHandler.getFLRDeleteMessageError(
                                                                        record.getFilename()),
                                                                StatusRecord.ALERT_ERROR);
                                                    }

                                                    @Override
                                                    public void onSuccess(ESBPacket esbPacket) {
                                                        final StatusRecord status = StatusHandler.createMessage(
                                                                StatusHandler.getFLRDeleteMessageDone(
                                                                        record.getFilename()),
                                                                StatusRecord.ALERT_SUCCESS);
                                                    }
                                                });
                            if (((RUSSELFileRecord) record).getFlrParadataId() != "")
                                RusselApi
                                        .publishToFlr(record.getGuid(),
                                                FLRPacketGenerator.buildFlrDeleteParadataPacket(
                                                        ((RUSSELFileRecord) record)),
                                                new ESBCallback<ESBPacket>() {
                                                    @Override
                                                    public void onFailure(Throwable caught) {
                                                        StatusHandler.createMessage(
                                                                StatusHandler.getFLRDeleteActivityError(
                                                                        record.getFilename()),
                                                                StatusRecord.ALERT_ERROR);
                                                    }

                                                    @Override
                                                    public void onSuccess(ESBPacket esbPacket) {
                                                        final StatusRecord status = StatusHandler.createMessage(
                                                                StatusHandler.getFLRDeleteParadataDone(
                                                                        record.getFilename()),
                                                                StatusRecord.ALERT_SUCCESS);

                                                    }
                                                });
                        }
                    }
                });
            }
        }
    });

    PageAssembler.attachHandler("comment-submit", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            final String comment = ((TextBox) PageAssembler.elementToWidget("input-comment",
                    PageAssembler.TEXT)).getText().trim();
            if (comment != null && comment.trim() != "" && !comment.equalsIgnoreCase("add comment")) {
                RusselApi.addComment(record.getGuid(), comment, new ESBCallback<ESBPacket>() {
                    @Override
                    public void onSuccess(ESBPacket esbPacket) {
                        esbPacket = esbPacket.getObject("obj");
                        record.parseESBPacket(esbPacket.getObject("m"));
                        CommentRecord commentRecord = new CommentRecord(
                                new ESBPacket(esbPacket.getString("c")));
                        fillComment0(commentRecord);
                        ((TextBox) PageAssembler.elementToWidget("input-comment", PageAssembler.TEXT))
                                .setText("");
                    }

                    @Override
                    public void onFailure(Throwable caught) {
                        ((TextBox) PageAssembler.elementToWidget("input-comment", PageAssembler.TEXT))
                                .setText("");
                        StatusHandler.createMessage(StatusHandler.getCommentMessageError(record.getFilename()),
                                StatusRecord.ALERT_ERROR);
                    }
                });
            }
        }
    });

    Document.get().getElementById("r-downloadDoc").setAttribute("href",
            RusselApi.downloadContentUrl(record.getGuid(), true));

    ((Label) PageAssembler.elementToWidget("r-rating-info", PageAssembler.LABEL)).setText("Current rating: "
            + MathUtil.roundNumber(record.getRating(), 2) + " (" + record.getVotes() + " votes)");
    DOM.getElementById("r-ratingLabel").setAttribute("style",
            "width: " + MathUtil.roundNumber((record.getRating() / 5.0) * 100, 2) + "%");

    fillComments0();

    ((Label) PageAssembler.elementToWidget("detailMetaFilename", PageAssembler.LABEL))
            .setText(record.getFilename());

    String ext = record.getFilename().substring(record.getFilename().lastIndexOf(".") + 1);
    if (ext.equalsIgnoreCase("png") || ext.equalsIgnoreCase("tiff") || ext.equalsIgnoreCase("tif")
            || ext.equalsIgnoreCase("bmp") || ext.equalsIgnoreCase("jpg") || ext.equalsIgnoreCase("jpeg")
            || ext.equalsIgnoreCase("gif")) {
        DOM.getElementById("r-preview").setInnerHTML("");
        RootPanel.get("r-preview").add(new Image(RusselApi.downloadContentUrl(record.getGuid(), false)));
    } else if (ext.equalsIgnoreCase("rlk")) {
        RusselApi.getResource(record.getGuid(), false, new ESBCallback<ESBPacket>() {
            @Override
            public void onSuccess(ESBPacket esbPacket) {
                record.setFileContents(esbPacket.getContentString());
                DOM.getElementById("r-preview").setInnerHTML("<a href=" + record.getFileContents()
                        + " target=\"_blank\">" + record.getFileContents().replaceAll("\"", "") + "</a>");
            }

            @Override
            public void onFailure(Throwable caught) {
            }
        });
    } else if (isTextFormat(ext)) {
        RusselApi.getResource(record.getGuid(), false, new ESBCallback<ESBPacket>() {
            @Override
            public void onSuccess(ESBPacket esbPacket) {
                record.setFileContents(esbPacket.getContentString());
                DOM.getElementById("r-preview").setInnerHTML(record.getFileContents());
            }

            @Override
            public void onFailure(Throwable caught) {
            }
        });
    } else if (ext.equalsIgnoreCase("Mp4") || ext.equalsIgnoreCase("WebM") || ext.equalsIgnoreCase("Ogg")) {
        String videoType = (ext.equalsIgnoreCase("Mp4")) ? "audio/mp4"
                : (ext.equalsIgnoreCase("WebM")) ? "audio/webm"
                        : (ext.equalsIgnoreCase("Ogg")) ? "audio/ogg" : "";
        String htmlString = "<video controls=\"controls\"><source src=\""
                + RusselApi.downloadContentUrl(record.getGuid(), false) + "\" type=\"" + videoType
                + "\"></source></video>";
        RootPanel.get("r-preview").getElement().setInnerHTML(htmlString);
    } else if (ext.equalsIgnoreCase("Mp3") || ext.equalsIgnoreCase("Wav") || ext.equalsIgnoreCase("Ogg")) {
        String audioType = (ext.equalsIgnoreCase("Mp3")) ? "audio/mp3"
                : (ext.equalsIgnoreCase("Wav")) ? "audio/wav"
                        : (ext.equalsIgnoreCase("Ogg")) ? "audio/ogg" : "";
        String htmlString = "<audio controls=\"controls\"><source src=\""
                + RusselApi.downloadContentUrl(record.getGuid(), false) + "\" type=\"" + audioType
                + "\"></source></audio>";
        RootPanel.get("r-preview").getElement().setInnerHTML(htmlString);
    } else if (ext.equalsIgnoreCase("swf")) {
        String htmlString = "<object id=\"FlashID\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" data=\""
                + RusselApi.downloadContentUrl(record.getGuid(), false) + "\" height=\"100%\" width=\"100%\">"
                + "<param name=\"movie\" value=\"" + RusselApi.downloadContentUrl(record.getGuid(), false)
                + "\">" + "<param name=\"quality\" value=\"high\">"
                + "<param name=\"wmode\" value=\"transparent\">" + "<param name=\"swfversion\" value=\"10.0\">"
                + "<param name=\"allowScriptAccess\" value=\"always\">"
                + "<param name=\"BGCOLOR\" value=\"#000000\">"
                + "<param name=\"expressinstall\" value=\"Scripts/expressInstall.swf\">" + "<!--[if !IE]>-->"
                + "<object id=\"FlashID2\" type=\"application/x-shockwave-flash\" data=\""
                + RusselApi.downloadContentUrl(record.getGuid(), false) + "\" height=\"100%\" width=\"100%\">"
                + "<!--<![endif]-->" + "<param name=\"movie\" value=\""
                + RusselApi.downloadContentUrl(record.getGuid(), false) + "\">"
                + "<param name=\"quality\" value=\"high\">" + "<param name=\"wmode\" value=\"transparent\">"
                + "<param name=\"swfversion\" value=\"10.0\">"
                + "<param name=\"allowScriptAccess\" value=\"always\">"
                + "<param name=\"BGCOLOR\" value=\"#000000\">"
                + "<param name=\"expressinstall\" value=\"Scripts/expressInstall.swf\">" + "<div>"
                + "<h4>Content on this page requires a newer version of Adobe Flash Player.</h4>"
                + "<p><a href=\"http://www.adobe.com/go/getflashplayer\"><img src=\"http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif\" alt=\"Get Adobe Flash player\" width=\"112\" height=\"33\" /></a></p>"
                + "</div>" + "<!--[if !IE]>-->" + "</object>" + "<!--<![endif]-->" + "</object>"
                + "<!--[if !IE]>-->" + "<script type=\"text/javascript\">"
                + "swfobject.registerObject(\"FlashID2\");" + "</script>" + "<!--<![endif]-->" + "<!--[if IE]>"
                + "<script type=\"text/javascript\">" + "swfobject.registerObject(\"FlashID\");" + "</script>"
                + "<![endif]-->";
        RootPanel.get("r-preview").getElement().setInnerHTML(htmlString);
    } else
        DOM.getElementById("r-preview").setInnerHTML("<p>No Preview Available</p>");

    meta.addMetaDataFields(record);
    if (record.getFOUO()) {
        ((Label) PageAssembler.elementToWidget("r-detailWarning", PageAssembler.LABEL)).setText(Constants.FOUO);
        ((Label) PageAssembler.elementToWidget("r-detailWarning", PageAssembler.LABEL))
                .setStyleName("r-warning");
    } else {
        ((Label) PageAssembler.elementToWidget("r-detailWarning", PageAssembler.LABEL)).setText("");
        ((Label) PageAssembler.elementToWidget("r-detailWarning", PageAssembler.LABEL))
                .setStyleName("r-warning hide");
    }
    if (DOM.getElementById("r-detailTitle").getInnerText().equalsIgnoreCase("n/a"))
        ((Label) PageAssembler.elementToWidget("r-detailTitle", PageAssembler.LABEL))
                .setText(record.getFilename());

    PageAssembler.attachHandler("r-postFlr", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            if (FLRApi.FLR_ACTIVITY_MODE.equals(FLRApi.FLR_ACTIVITY_ACTIONS_FEEDBACK)
                    || FLRApi.FLR_ACTIVITY_MODE.equals(FLRApi.FLR_ACTIVITY_ACTIONS_ISD)
                    || FLRApi.FLR_ACTIVITY_MODE.equals(FLRApi.FLR_ACTIVITY_ACTIONS_ALL)) {
                final StatusRecord flrStatus = StatusHandler.createMessage(
                        StatusHandler.getFLRActivityBusy(record.getFilename()), StatusRecord.ALERT_BUSY);
                if (record instanceof RUSSELFileRecord) {
                    RusselApi.publishToFlr(record.getGuid(),
                            FLRPacketGenerator.buildFlrParadataPacket(((RUSSELFileRecord) record)),
                            new ESBCallback<ESBPacket>() {
                                @Override
                                public void onFailure(Throwable caught) {
                                    flrStatus.setMessage(
                                            StatusHandler.getFLRActivityError(record.getFilename()));
                                    flrStatus.setState(StatusRecord.ALERT_ERROR);
                                    StatusHandler.alterMessage(flrStatus);
                                }

                                @Override
                                public void onSuccess(ESBPacket esbPacket) {
                                    flrStatus
                                            .setMessage(StatusHandler.getFLRActivityDone(record.getFilename()));
                                    flrStatus.setState(StatusRecord.ALERT_SUCCESS);
                                    StatusHandler.alterMessage(flrStatus);
                                    FLRPacket packet = new FLRPacket(esbPacket.getObject(ESBPacket.OBJECT));
                                    record.setFlrParadataId(packet.getResponseDocID());
                                    RusselApi.updateResourceMetadata(((RUSSELFileRecord) record).getGuid(),
                                            ((RUSSELFileRecord) record).toObject(),
                                            new ESBCallback<ESBPacket>() {
                                                @Override
                                                public void onSuccess(ESBPacket esbPacket) {
                                                    postFlrNsdl();
                                                }

                                                @Override
                                                public void onFailure(Throwable caught) {
                                                    StatusHandler.createMessage(
                                                            StatusHandler.getMetadataMessageError(
                                                                    record.getFilename()),
                                                            StatusRecord.ALERT_ERROR);
                                                }
                                            });
                                }
                            });
                }
            } else {
                StatusHandler.createMessage(StatusHandler.getFLRDisabledError("Activity Stream publish"),
                        StatusRecord.ALERT_WARNING);
            }
        }
    });

    attachRatingListeners0();
}

From source file:com.eduworks.russel.ui.client.pagebuilder.screen.DetailScreen.java

License:Apache License

/**
 * fillComment0 Displays a particular Alfresco comment in the list of comments
 * @param commentNode ESBPacket packet for a particular comment
 *///from w w  w  .  j a  v a  2  s  .co m
private void fillComment0(final CommentRecord commentNode) {
    Vector<String> iDs = PageAssembler.inject("r-commentArea", "x",
            new HTML(Russel.htmlTemplates.getDetailComment().getText()), true);
    final String iDPrefix = iDs.firstElement().substring(0, iDs.firstElement().indexOf("-"));
    ((Label) PageAssembler.elementToWidget(iDPrefix + "-comment-text", PageAssembler.LABEL))
            .setText(commentNode.getComment());
    ((Label) PageAssembler.elementToWidget(iDPrefix + "-comment-user", PageAssembler.LABEL))
            .setText(commentNode.getCreatedBy());
    PageAssembler.attachHandler(iDPrefix + "-comment-delete", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            RusselApi.deleteComment(record.getGuid(), commentNode.getGuid(), new ESBCallback<ESBPacket>() {
                @Override
                public void onSuccess(ESBPacket packet) {
                    record.parseESBPacket(packet.getObject("obj").getObject("m"));
                    DOM.getElementById(iDPrefix + "-comment").removeFromParent();
                }

                @Override
                public void onFailure(Throwable caught) {
                    StatusHandler.createMessage(
                            StatusHandler.getRemoveCommentMessageError(record.getFilename()),
                            StatusRecord.ALERT_ERROR);
                }
            });
        }
    });
}

From source file:com.eduworks.russel.ui.client.pagebuilder.screen.EditScreen.java

License:Apache License

/**
 * display Renders the EditScreen using appropriate templates and sets up handlers
 *//*from   w ww.  j av  a 2 s  . c  o m*/
public void display() {
    editIDs = new Vector<String>();
    thumbIDs = new HashMap<String, RUSSELFileRecord>();

    if (Browser.isBadIE()) {
        PageAssembler.ready(new HTML(Russel.htmlTemplates.getEditPanel().getText()));
        PageAssembler.buildContents();
    } else {
        final DropPanel dp = new DropPanel();
        dp.add(new HTML(Russel.htmlTemplates.getEditPanel().getText()));
        PageAssembler.ready(dp);
        PageAssembler.buildContents();
        hookDragDrop0(dp);
    }
    SearchHandler ash = new SearchHandler(this, false);

    PageAssembler.inject("flowContainer", "x", new HTML(Russel.htmlTemplates.getDetailModal().getText()), true);
    PageAssembler.inject("objDetailPanelWidget", "x", new HTML(Russel.htmlTemplates.getDetailPanel().getText()),
            true);

    ash.hookAndClear("r-menuSearchBar", "", SearchHandler.TYPE_EDIT);

    PageAssembler.attachHandler("r-editDelete", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            if (editIDs.size() == 1) {
                if (Window.confirm("Are you sure you wish to delete the selected item?"))
                    deleteObjects0();
            } else if (editIDs.size() >= 2) {
                if (Window.confirm("Are you sure you wish to delete " + editIDs.size() + " items?"))
                    deleteObjects0();
            }
        }
    });

    PageAssembler.attachHandler("r-editSelectAll", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            selectAllObjects0();
        }
    });

    PageAssembler.attachHandler("r-editSelectNone", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            selectionClear0();
        }
    });

    PageAssembler.attachHandler("r-editAddFile", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            Vector<String> iDs = PageAssembler.inject("r-previewArea", "x",
                    new HTML(Russel.htmlTemplates.getEditPanelWidget().getText()), true);
            final String idPrefix = iDs.firstElement().substring(0, iDs.firstElement().indexOf("-"));
            buildEmptyUploadTile0(idPrefix);
            PageAssembler.closePopup("addFileModal");

        }
    });

    PageAssembler.attachHandler("r-editAddFile-reset", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            doFileReset0();
        }
    });
    PageAssembler.attachHandler("r-editAddFile-cancel", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            doFileReset0();
            PageAssembler.closePopup("addFileModal");
        }
    });

    PageAssembler.attachHandler("r-editAddLink-reset", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            doLinkReset0();
        }
    });
    PageAssembler.attachHandler("r-editAddLink-cancel", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            doLinkReset0();
            PageAssembler.closePopup("addLinkModal");
        }
    });

    PageAssembler.attachHandler("r-permissionModal", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            if (editIDs.size() > 0)
                Russel.screen.loadScreen(new PermissionScreen(PermissionScreen.TYPE_RESOURCE,
                        thumbIDs.get(editIDs.get(0)).getGuid()), false);
        }
    });

    PageAssembler.attachHandler("r-editAddLink", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            final StatusRecord status = StatusHandler.createMessage(StatusHandler.getFileMessageBusy(""),
                    StatusRecord.ALERT_BUSY);
            if (((TextBox) PageAssembler.elementToWidget("editTitleLinkField", PageAssembler.TEXT))
                    .getText() != "") {
                String rawFilename = ((TextBox) PageAssembler.elementToWidget("editTitleLinkField",
                        PageAssembler.TEXT)).getText();
                String filenameRaw = "";
                for (int filenameIndex = 0; filenameIndex < rawFilename.length(); filenameIndex++)
                    if ((rawFilename.codePointAt(filenameIndex) >= 48
                            && rawFilename.codePointAt(filenameIndex) <= 57)
                            || (rawFilename.codePointAt(filenameIndex) >= 65
                                    && rawFilename.codePointAt(filenameIndex) <= 90)
                            || (rawFilename.codePointAt(filenameIndex) >= 97
                                    && rawFilename.codePointAt(filenameIndex) <= 122))
                        filenameRaw += rawFilename.charAt(filenameIndex);
                final String filename = filenameRaw;
                String urlBody = ((TextBox) PageAssembler.elementToWidget("editLinkField", PageAssembler.TEXT))
                        .getText();
                if (urlBody.indexOf("://") == -1)
                    urlBody = "http://" + urlBody;
                status.setMessage(StatusHandler.getFileMessageBusy(filename + ".rlk"));
                StatusHandler.alterMessage(status);
                RusselApi.uploadResource(urlBody, filename + ".rlk", new ESBCallback<ESBPacket>() {
                    @Override
                    public void onSuccess(final ESBPacket esbPacket) {
                        RUSSELFileRecord fr = new RUSSELFileRecord();
                        fr.setGuid(esbPacket.getPayloadString());
                        fr.setFilename(filename + ".rlk");
                        Vector<String> iDs = PageAssembler.inject("r-previewArea", "x",
                                new HTML(Russel.htmlTemplates.getEditPanelWidget().getText()), true);
                        final String idPrefix = iDs.firstElement().substring(0,
                                iDs.firstElement().indexOf("-"));
                        fillTemplateDetails0(fr, idPrefix);
                        PageAssembler.closePopup("addLinkModal");
                        status.setMessage(StatusHandler.getFileMessageDone(filename + ".rlk"));
                        status.setState(StatusRecord.ALERT_SUCCESS);
                        StatusHandler.alterMessage(status);
                    }

                    public void onFailure(Throwable caught) {
                        status.setMessage(StatusHandler.DUPLICATE_NAME);
                        status.setState(StatusRecord.ALERT_WARNING);
                        StatusHandler.alterMessage(status);
                    }
                });
            } else {
                status.setMessage(StatusHandler.INVALID_NAME);
                status.setState(StatusRecord.ALERT_WARNING);
                StatusHandler.alterMessage(status);
            }
        }
    });

    PageAssembler.attachHandler("r-editSave", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            new Timer() {
                @Override
                public void run() {
                    if (editIDs.size() > 0) {
                        final String idNumPrefix = editIDs.firstElement().substring(0,
                                editIDs.firstElement().indexOf("-"));
                        final String filename = DOM.getElementById(idNumPrefix + "-objectTitle").getInnerText();
                        final StatusRecord status = StatusHandler.createMessage(
                                StatusHandler.getUpdateMetadataMessageBusy(filename), StatusRecord.ALERT_BUSY);

                        meta.saveMetadata(thumbIDs.get(editIDs.firstElement()), new ESBCallback<ESBPacket>() {
                            @Override
                            public void onSuccess(ESBPacket esbPacket) {
                                status.setMessage(StatusHandler.getUpdateMetadataMessageDone(filename));
                                status.setState(StatusRecord.ALERT_SUCCESS);
                                StatusHandler.alterMessage(status);
                                refreshInformation0();
                            }

                            public void onFailure(Throwable caught) {
                                status.setMessage(StatusHandler.getUpdateMetadataMessageError(filename));
                                status.setState(StatusRecord.ALERT_ERROR);
                                StatusHandler.alterMessage(status);
                            }
                        });
                    }
                }
            }.schedule(100);
        }
    });

    while (passedInEdits.size() > 0) {
        Vector<String> iDs = PageAssembler.inject("r-previewArea", "x",
                new HTML(Russel.htmlTemplates.getEditPanelWidget().getText()), false);
        final String idPrefix = iDs.firstElement().substring(0, iDs.firstElement().indexOf("-"));
        fillTemplateDetails0(passedInEdits.remove(0), idPrefix);
    }
    refreshInformation0();
}

From source file:com.eduworks.russel.ui.client.pagebuilder.screen.EditScreen.java

License:Apache License

/**
 * processServerZipFiles0 Continues the processing of the list of pendingServerZipUploads
 *///from   w  w  w.  j a v a2s .  c o m
private void processServerZipFiles0() {
    final RUSSELFileRecord node = FileHandler.pendingServerZipUploads.remove(0);
    StatusHandler.createMessage(StatusHandler.getFileMessageDone(node.getFilename()),
            StatusRecord.ALERT_SUCCESS);
    if (DOM.getElementById("r-previewArea") != null) {
        Vector<String> iDs = PageAssembler.inject("r-previewArea", "x",
                new HTML(Russel.htmlTemplates.getEditPanelWidget().getText()), true);
        String idPrefix = iDs.firstElement().substring(0, iDs.firstElement().indexOf("-"));
        fillTemplateDetails0(node, idPrefix);
    }
    //      if (node.getFilename().substring(node.getFilename().lastIndexOf(".")+1).equalsIgnoreCase("rpf"))
    //         ProjectRecord.updatePfmNodeId(node);
    //checkIEAndPromptServerDisaggregation0(node);
    if (FileHandler.pendingServerZipUploads.size() != 0)
        processServerZipFiles0();
}

From source file:com.eduworks.russel.ui.client.pagebuilder.screen.EditScreen.java

License:Apache License

/**
 * doPendingUploads0 Continues to process all pendingZipUploads
 *//*from ww  w .  j  a  v  a  2 s .  com*/
private void doPendingUploads0() {
    if (FileHandler.pendingZipUploads.size() > 0) {
        ZipRecord zipEntry = FileHandler.pendingZipUploads.remove(0);
        Zip.inflateEntry(zipEntry, true, new AsyncCallback<ZipRecord>() {
            @Override
            public void onFailure(Throwable caught) {
            }

            @Override
            public void onSuccess(ZipRecord zipEntry) {
                String FullFilename = zipEntry.getFilename();
                if (FullFilename.lastIndexOf(".") != -1) {
                    final String filename = (FullFilename.lastIndexOf("/") != -1)
                            ? FullFilename.substring(FullFilename.lastIndexOf("/") + 1)
                            : FullFilename;
                    if (AssetExtractor.checkAsset(filename, zipEntry.getData())) {
                        final StatusRecord status = StatusHandler.createMessage(
                                StatusHandler.getFileMessageBusy(filename), StatusRecord.ALERT_BUSY);
                        if (filename.substring(filename.lastIndexOf(".") + 1).equalsIgnoreCase("zip")
                                && Window.confirm("Do you wish to disaggregate the zip "
                                        + zipEntry.getFilename() + " package?")) {
                            Zip.grabEntries(zipEntry.getData(), new AsyncCallback<Vector<ZipRecord>>() {
                                @Override
                                public void onFailure(Throwable caught) {
                                }

                                @Override
                                public void onSuccess(Vector<ZipRecord> zipEntries) {
                                    for (int x = 0; x < zipEntries.size(); x++) {
                                        FileHandler.pendingZipUploads.add(zipEntries.get(x));
                                    }
                                    doPendingUploads0();
                                }
                            });
                        }
                        if (DOM.getElementById("r-previewArea") != null) {
                            final Vector<String> iDs = PageAssembler.inject("r-previewArea", "x",
                                    new HTML(Russel.htmlTemplates.getEditPanelWidget().getText()), false);
                            final String idNumPrefix = iDs.get(0).substring(0, iDs.get(0).indexOf("-"));
                            RootPanel.get(idNumPrefix + "-objectDescription")
                                    .add(new Image("images/orbit/loading.gif"));
                            DOM.getElementById(idNumPrefix + "-objectTitle").setInnerText(filename);
                            DOM.getElementById(idNumPrefix + "-objectDetailButton").setAttribute("hidden",
                                    "hidden");
                            DOM.getElementById(idNumPrefix + "-objectDescription").setAttribute("style",
                                    "text-align:center");
                            RusselApi.uploadResource(zipEntry.getData(), filename,
                                    new ESBCallback<ESBPacket>() {
                                        @Override
                                        public void onFailure(Throwable caught) {
                                            status.setMessage(StatusHandler.getFileMessageError(filename));
                                            status.setState(StatusRecord.ALERT_ERROR);
                                            StatusHandler.alterMessage(status);
                                        }

                                        @Override
                                        public void onSuccess(ESBPacket esbPacket) {
                                            RUSSELFileRecord fr = new RUSSELFileRecord();
                                            fr.setGuid(esbPacket.getPayloadString());
                                            fr.setFilename(filename);
                                            status.setMessage(StatusHandler.getFileMessageDone(filename));
                                            status.setState(StatusRecord.ALERT_SUCCESS);
                                            StatusHandler.alterMessage(status);
                                            RootPanel.get(idNumPrefix + "-objectDescription").clear();
                                            DOM.getElementById(idNumPrefix + "-objectDetailButton")
                                                    .removeAttribute("hidden");
                                            DOM.getElementById(idNumPrefix + "-objectDescription")
                                                    .setAttribute("style", "");
                                            fillTemplateDetails0(fr, idNumPrefix);
                                            String filename = fr.getFilename();
                                            //                                                            if (filename.substring(filename.lastIndexOf(".")+1).equalsIgnoreCase("rpf")) {
                                            //                                                               ProjectRecord.updatePfmNodeId(fr);
                                            //                                                            }
                                            doPendingUploads0();
                                        }
                                    });
                        } else
                            RusselApi.uploadResource(zipEntry.getData(), filename,
                                    new ESBCallback<ESBPacket>() {
                                        @Override
                                        public void onFailure(Throwable caught) {
                                            status.setMessage(StatusHandler.getFileMessageError(filename));
                                            status.setState(StatusRecord.ALERT_ERROR);
                                            StatusHandler.alterMessage(status);
                                        }

                                        @Override
                                        public void onSuccess(ESBPacket esbPacket) {
                                            RUSSELFileRecord fr = new RUSSELFileRecord();
                                            fr.setGuid(esbPacket.getPayloadString());
                                            fr.setFilename(filename);
                                            status.setMessage(StatusHandler.getFileMessageDone(filename));
                                            status.setState(StatusRecord.ALERT_SUCCESS);
                                            StatusHandler.alterMessage(status);
                                            String filename = fr.getFilename();
                                            //                                                            if (filename.substring(filename.lastIndexOf(".")+1).equalsIgnoreCase("rpf")) {
                                            //                                                               ProjectRecord.updatePfmNodeId(fr);
                                            //                                                            }
                                            doPendingUploads0();
                                        }
                                    });
                    } else
                        doPendingUploads0();
                } else
                    doPendingUploads0();
            }
        });
        refreshInformation0();
    }
}

From source file:com.eduworks.russel.ui.client.pagebuilder.screen.EditScreen.java

License:Apache License

/**
 * hookDragDrop0 Hooks the status window to the drag and drop panel. Processes an upload.
 * @param w DropPanel/*  w ww  .  j  a v a  2s  . c  om*/
 */
private void hookDragDrop0(DropPanel w) {
    FileHandler.hookDropPanel(new DragDropHandler(w) {
        @Override
        public void run(final File file) {
            final String filename = file.getName();
            final StatusRecord status = StatusHandler.createMessage(StatusHandler.getFileMessageBusy(filename),
                    StatusRecord.ALERT_BUSY);
            if (filename.lastIndexOf(".") != -1
                    && filename.substring(filename.lastIndexOf(".") + 1).equalsIgnoreCase("zip")) {
                if (Window.confirm("Do you wish to disaggregate the zip " + filename + " package?")) {
                    Zip.grabEntries(file, new AsyncCallback<Vector<ZipRecord>>() {
                        @Override
                        public void onFailure(Throwable caught) {
                        }

                        @Override
                        public void onSuccess(Vector<ZipRecord> zipEntries) {
                            for (int x = 0; x < zipEntries.size(); x++) {
                                FileHandler.pendingZipUploads.add(zipEntries.get(x));
                            }
                            doPendingUploads0();
                        }
                    });
                }
            }

            if (DOM.getElementById("r-previewArea") != null) {
                final Vector<String> iDs = PageAssembler.inject("r-previewArea", "x",
                        new HTML(Russel.htmlTemplates.getEditPanelWidget().getText()), false);
                final String idNumPrefix = iDs.get(0).substring(0, iDs.get(0).indexOf("-"));
                RootPanel.get(idNumPrefix + "-objectDescription").add(new Image("images/orbit/loading.gif"));
                DOM.getElementById(idNumPrefix + "-objectTitle").setInnerText(file.getName());
                DOM.getElementById(idNumPrefix + "-objectDescription").setAttribute("style",
                        "text-align:center");
                DOM.getElementById(idNumPrefix + "-objectDetailButton").setAttribute("hidden", "hidden");

                RusselApi.uploadResource(file, file.getName(), new ESBCallback<ESBPacket>() {
                    @Override
                    public void onFailure(Throwable caught) {
                        status.setMessage(StatusHandler.getFileMessageError(filename));
                        status.setState(StatusRecord.ALERT_ERROR);
                        StatusHandler.alterMessage(status);
                    }

                    @Override
                    public void onSuccess(ESBPacket result) {
                        RUSSELFileRecord fr = new RUSSELFileRecord();
                        fr.setGuid(result.getPayloadString());
                        fr.setFilename(filename);
                        status.setMessage(StatusHandler.getFileMessageDone(filename));
                        status.setState(StatusRecord.ALERT_SUCCESS);
                        StatusHandler.alterMessage(status);
                        if (DOM.getElementById(idNumPrefix + "-objectDescription") != null) {
                            RootPanel.get(idNumPrefix + "-objectDescription").clear();
                            DOM.getElementById(idNumPrefix + "-objectDetailButton").removeAttribute("hidden");
                            DOM.getElementById(idNumPrefix + "-objectDescription").setAttribute("style", "");
                            fillTemplateDetails0(fr, idNumPrefix);
                        }
                        String filename = fr.getFilename();
                        //                                             if (filename.substring(filename.lastIndexOf(".")+1).equalsIgnoreCase("rpf")) {
                        //                                                ProjectRecord.updatePfmNodeId(fr);
                        //                                             }
                        thumbIDs.put(idNumPrefix + "-object", fr);
                        readNext();
                    }
                });
                refreshInformation0();
            } else
                RusselApi.uploadResource(file, file.getName(), new ESBCallback<ESBPacket>() {
                    @Override
                    public void onFailure(Throwable caught) {
                        status.setMessage(StatusHandler.getFileMessageError(filename));
                        status.setState(StatusRecord.ALERT_ERROR);
                        StatusHandler.alterMessage(status);
                    }

                    @Override
                    public void onSuccess(ESBPacket result) {
                        RUSSELFileRecord fr = new RUSSELFileRecord();
                        fr.setFilename(filename);
                        fr.setGuid(result.getPayloadString());
                        status.setMessage(StatusHandler.getFileMessageDone(filename));
                        status.setState(StatusRecord.ALERT_SUCCESS);
                        StatusHandler.alterMessage(status);
                        String filename = fr.getFilename();
                        //                                             if (filename.substring(filename.lastIndexOf(".")+1).equalsIgnoreCase("rpf")) {
                        //                                                ProjectRecord.updatePfmNodeId(fr);
                        //                                             }
                        readNext();
                    }
                });
        }
    });
}