Example usage for com.google.gwt.user.client Window open

List of usage examples for com.google.gwt.user.client Window open

Introduction

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

Prototype

public static void open(String url, String name, String features) 

Source Link

Usage

From source file:org.ol3cesium.demo.client.ExamplePanel.java

License:Apache License

/**
 * Constructs the ExamplePanel using an Example
 *
 * @param example/* www .  ja v a2s  .  c o  m*/
 */
public ExamplePanel(final ExampleBean example) {
    final VerticalPanel vp = new VerticalPanel();
    vp.setSpacing(5);

    final ScrollPanel sp = new ScrollPanel();
    sp.getElement().getStyle().setOverflowX(Overflow.HIDDEN);
    sp.setSize("350px", "100px");
    sp.setWidget(vp);

    final Label lblName = new Label(example.getName());
    final Label lblDescription = new Label(example.getDescription());
    final StringBuffer sb = new StringBuffer();
    final String[] tags = example.getTags();
    for (String tag : tags) {
        sb.append(tag).append(", ");
    }
    final Label lblTags = new Label(I18N.tags(sb.toString().substring(0, sb.toString().length() - 2)));
    lblTags.setStyleName("exampletags");

    lblName.setStyleName("examplename");
    vp.add(lblName);
    vp.add(lblDescription);
    vp.add(lblTags);

    final FocusPanel fp = new FocusPanel(sp);
    this.initWidget(fp);
    this.setStyleName("examplepanel");

    fp.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (Window.Location.getHref().contains("?")) {
                Window.open(Window.Location.getHref() + "&example=" + example.getName(), "_BLANK", null);
            } else {
                Window.open(Window.Location.getHref() + "?example=" + example.getName(), "_BLANK", null);
            }
        }
    });
}

From source file:org.olanto.mySelfQD.client.ParseWidget.java

License:Open Source License

private void setHeader() {
    initWidget(mainWidget);/*from  www .  ja v a  2  s.c o  m*/
    mainWidget.setStyleName("mainContent");
    mainWidget.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);

    mainWidget.add(headerContainer);
    mainWidget.add(mainContainer);
    mainWidget.add(statusContainer);

    headerContainer.setBodyBorder(true);
    headerContainer.setHeaderVisible(false);
    headerContainer.add(headPanel);
    headerContainer.setStylePrimaryName("searchHeader");
    headPanel.setStylePrimaryName("searchHeader");
    headPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);

    headerPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
    headerPanel.add(fileUpload);
    headerPanel.add(GoSrch);
    headerPanel.add(minLn);
    headerPanel.add(minLength);
    headerPanel.add(minFr);
    headerPanel.add(minFreq);
    headerPanel.add(help);
    headerPanel.add(save);
    if (GuiConstant.CHOOSE_GUI_LANG) {
        headerPanel.add(chooseLang);
        headerPanel.add(langInterface);
    }

    headerPanel.setStylePrimaryName("searchHeader");

    headPanel.add(leftheadPanel);
    headPanel.add(SQDText);
    headPanel.setCellHorizontalAlignment(SQDText, HorizontalPanel.ALIGN_RIGHT);
    if ((!GuiConstant.LOGO_PATH.isEmpty()) && (!GuiConstant.LOGO_PATH.isEmpty())) {
        if ((!GuiConstant.LOGO_PATH.equalsIgnoreCase(" ")) && (!GuiConstant.LOGO_PATH.equalsIgnoreCase(" "))) {
            headPanel.add(im);
            headPanel.setCellHorizontalAlignment(im, HorizontalPanel.ALIGN_RIGHT);
        }
    }

    topJobsSet.setTabBarPosition(Side.TOP);
    topJobsSet.setDefaultHeight(H_Unit);
    topJobsSet.setPaneContainerClassName("searchHeader");
    leftheadPanel.add(topJobsSet);
    leftheadPanel.add(headerPanel);

    mainContainer.setBodyBorder(true);
    mainContainer.setHeaderVisible(false);
    mainContainer.setStylePrimaryName("mainContent");

    statusContainer.setBodyBorder(true);
    statusContainer.setHeaderVisible(false);
    statusContainer.add(statusPanel);
    statusPanel.setHeight(H_Unit + "px");
    statusPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
    statusPanel.add(msg);
    statusPanel.setCellHorizontalAlignment(msg, HorizontalPanel.ALIGN_LEFT);
    statusPanel.add(contact);
    statusPanel.setCellHorizontalAlignment(contact, HorizontalPanel.ALIGN_RIGHT);

    contact.setPixelSize(300, 25);
    contact.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
    Anchor poweredBy = new Anchor(GuiConstant.OLANTO_URL.substring(0, GuiConstant.OLANTO_URL.indexOf("|")),
            true,
            GuiConstant.OLANTO_URL.substring(GuiConstant.OLANTO_URL.indexOf("|") + 1,
                    GuiConstant.OLANTO_URL.lastIndexOf("|")),
            GuiConstant.OLANTO_URL.substring(GuiConstant.OLANTO_URL.lastIndexOf("|") + 1));
    contact.add(poweredBy);
    poweredBy.setStylePrimaryName("contactInfo");
    contact.setCellHorizontalAlignment(poweredBy, HorizontalPanel.ALIGN_LEFT);
    contact.add(new HTML(" || "));
    Anchor feedback = new Anchor(
            GuiConstant.FEEDBACK_MAIL.substring(0, GuiConstant.FEEDBACK_MAIL.indexOf("|")));
    contact.add(new HTML(" "));
    contact.setCellHorizontalAlignment(feedback, HorizontalPanel.ALIGN_RIGHT);
    contact.add(feedback);
    feedback.setStylePrimaryName("contactInfo");

    statusContainer.setStylePrimaryName("statusPanel");
    statusPanel.setStylePrimaryName("statusPanel");

    mainContainer.add(htmlWrapper);

    refArea.setVisible(true);
    refArea.setStyleName("TextBlock");
    fileUpload.addOnStartUploadHandler(onStartUploaderHandler);
    fileUpload.addOnFinishUploadHandler(onFinishUploaderHandler);
    help.addListener(Events.OnClick, new Listener<BaseEvent>() {
        @Override
        public void handleEvent(BaseEvent be) {
            Window.open(GuiConstant.SQD_HELP_URL, "", GuiConstant.W_OPEN_FEATURES);
        }
    });
    fileUpload.setAutoSubmit(true);
    setMessage("warning", GuiConstant.MSG_5);
    for (int i = GuiConstant.MIN_FREQ; i < GuiConstant.MAX_FREQ; i++) {
        minFreq.addItem("" + i);
    }
    for (int i = GuiConstant.MIN_OCCU; i < GuiConstant.MAX_OCCU; i++) {
        minLength.addItem("" + i);
    }
    minLength.setSelectedIndex(Integer.parseInt(Cookies.getCookie(CookiesNamespace.ParseMinLength)));
    minFreq.setSelectedIndex(Integer.parseInt(Cookies.getCookie(CookiesNamespace.ParseMinFreq)));

    minFreq.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            MyParseCookies.updateCookie(CookiesNamespace.ParseMinFreq, "" + minFreq.getSelectedIndex());
        }
    });
    minLength.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            MyParseCookies.updateCookie(CookiesNamespace.ParseMinLength, "" + minLength.getSelectedIndex());
        }
    });
    if (GuiConstant.CHOOSE_GUI_LANG) {
        langInterface.addChangeHandler(new ChangeHandler() {
            @Override
            public void onChange(ChangeEvent event) {
                MyParseCookies.updateCookie(CookiesNamespace.InterfaceLanguage,
                        INT_LANG[langInterface.getSelectedIndex()]);
                Window.Location.reload();
            }
        });
    }
    if ((!GuiConstant.LOGO_PATH.isEmpty()) && (!GuiConstant.LOGO_PATH.isEmpty())) {
        im.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                Window.open(GuiConstant.LOGO_URL, "", GuiConstant.W_OPEN_FEATURES);
            }
        });
    }
    feedback.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            mailto(GuiConstant.FEEDBACK_MAIL.substring(GuiConstant.FEEDBACK_MAIL.lastIndexOf("|") + 1),
                    GuiConstant.MSG_6 + GuiConstant.SELF_QD);
        }
    });
}

From source file:org.olanto.mySelfQD.client.ParseWidget.java

License:Open Source License

public void mailto(String address, String subject) {
    Window.open("mailto:" + address + "?subject=" + URL.encode(subject), "_blank", "");
}

From source file:org.olanto.mySelfQD.client.ParseWidget.java

License:Open Source License

public void draWidget() {
    setbuttonstyle(GoSrch, GoSrch.getText().length() * 2 * CHAR_W, H_Unit);
    setbuttonstyle(help, help.getText().length() * (CHAR_W + 2), H_Unit);
    setbuttonstyle(save, save.getText().length() * (CHAR_W + 2), H_Unit);
    minFr.setStyleName("gwt-w-label");
    minLn.setStyleName("gwt-w-label");
    SQDText.setText(GuiConstant.SELF_QD);
    SQDText.setStyleName("gwt-im-text");
    chooseLang.setStyleName("gwt-w-label");

    for (int i = 0; i < INT_LANG.length; i++) {
        langInterface.addItem(INT_LANG[i]);
    }/*from   w ww.java2s.  co m*/
    langInterface.setWidth(2 * W_Unit + "px");
    langInterface.setSelectedIndex(getIndex(INT_LANG, Cookies.getCookie(CookiesNamespace.InterfaceLanguage)));

    htmlWrapper.setPixelSize((Window.getClientWidth() - 2 * W_Unit), (Window.getClientHeight() - 4 * H_Unit));
    refArea.setWidth((Window.getClientWidth() - 3 * W_Unit) + "px");
    if ((GuiConstant.JOBS_ITEMS != null) && (GuiConstant.JOBS_ITEMS.length() > 1)) {
        String jobs = GuiConstant.JOBS_ITEMS;
        String[] tablist = jobs.split("\\;");
        Tab tinv = new Tab();
        topJobsSet.addTab(tinv);
        tinv.setTitle("Select Tab : ");
        tinv.setID("Empty");
        tinv.setDisabled(true);
        if (tablist.length > 0) {
            for (int i = 0; i < tablist.length; i++) {
                Tab tTab = new Tab();
                tTab.setIcon("./icons/16/folder_document.png");
                tTab.setTitle(tablist[i].substring(0, tablist[i].indexOf("|")));
                tTab.setAttribute("URL",
                        tablist[i].substring(tablist[i].indexOf("|") + 1, tablist[i].lastIndexOf("|")));
                tTab.setAttribute("MODE", tablist[i].substring(tablist[i].lastIndexOf("|") + 1));
                topJobsSet.addTab(tTab);
            }
        }
        topJobsSet.setSelectedTab(0);
        topJobsSet.addTabSelectedHandler(new TabSelectedHandler() {
            @Override
            public void onTabSelected(TabSelectedEvent event) {
                if (!(event.getTab().getID().contains("Empty"))) {
                    Window.open(event.getTab().getAttribute("URL"), event.getTab().getAttribute("MODE"), "");
                }
            }
        });
        topJobsSet.setWidth(headerPanel.getOffsetWidth());
        topJobsSet.draw();
        topJobsSet.setCursor(Cursor.HAND);
    } else {
        leftheadPanel.remove(topJobsSet);
    }
    adaptSize();
}

From source file:org.olanto.TranslationText.client.BitextWidget.java

License:Open Source License

public void AddOtherEvents() {

    // Handler of the going to align the line in the source text
    AlignS.addListener(Events.OnClick, new Listener<BaseEvent>() {
        @Override/*from  www  .  j a v a  2  s . c om*/
        public void handleEvent(BaseEvent be) {
            pp.hide();
            int posi = sourceTextArea.getCursorPos();
            int len = sourceTextArea.getSelectedText().length();
            indexS = Utility.getInd(posi, resultS);
            //                Window.alert("Got index source: " + indexS);
            indexT = Map.from[indexS];
            //                Window.alert("Got index target: " + indexT);

            showpanel(false, resultT[indexT][0] + 1, indexT);

            if ((Window.Navigator.getUserAgent().contains("MSIE 7.0"))
                    || (Window.Navigator.getUserAgent().contains("MSIE 8.0"))) {
                int idx = resultS[indexS][2];
                int idxt = resultT[indexT][2];
                sourceTextArea.setCursorPos(0);
                targetTextArea.setCursorPos(0);
                sourceTextArea.setCursorPos(idx);
                targetTextArea.setCursorPos(idxt);
            } else {
                setNetScapePos(indexS, indexT, (sourceTextArea.getVisibleLines() / 2));
            }
            if (len > 1) {
                sourceTextArea.setSelectionRange(posi, len);
            } else {
                sourceTextArea.setSelectionRange(posi, 1);
            }
            sourceTextArea.setFocus(true);
        }
    });

    // Handler of the going to align the line in the target text
    AlignT.addListener(Events.OnClick, new Listener<BaseEvent>() {
        @Override
        public void handleEvent(BaseEvent be) {
            pp.hide();
            int posi = targetTextArea.getCursorPos();
            int len = targetTextArea.getSelectedText().length();
            indexT = Utility.getInd(posi, resultT);
            indexS = Map.to[indexT];
            showpanel(true, resultS[indexS][0] + 1, indexS);

            if ((Window.Navigator.getUserAgent().contains("MSIE 7.0"))
                    || (Window.Navigator.getUserAgent().contains("MSIE 8.0"))) {
                int idx = resultS[indexS][2];
                int idxt = resultT[indexT][2];
                sourceTextArea.setCursorPos(0);
                targetTextArea.setCursorPos(0);
                sourceTextArea.setCursorPos(idx);
                targetTextArea.setCursorPos(idxt);
            } else {
                setNetScapePosT(indexS, indexT, (targetTextArea.getVisibleLines() / 2));
            }
            if (len > 1) {
                targetTextArea.setSelectionRange(posi, len);
            } else {
                targetTextArea.setSelectionRange(posi, 1);
            }
            targetTextArea.setFocus(true);
        }
    });

    schS.addListener(Events.OnClick, new Listener<BaseEvent>() {
        @Override
        public void handleEvent(BaseEvent be) {
            setMessage("info", GuiMessageConst.MSG_7);
            SchS = true;
            SchArea.setText("");
            pSch.setPopupPosition(sourceTextArea.getAbsoluteLeft() + sourceTextArea.getOffsetWidth() / 8,
                    sourceTextArea.getAbsoluteTop());
            pSch.show();
            SchArea.setFocus(true);
            SchBtn.removeAllListeners();
            SchBtn.addListener(Events.OnClick, new Listener<BaseEvent>() {
                @Override
                public void handleEvent(BaseEvent be) {
                    ClearHitsEvents();
                    words = null;

                    search = Utility.replaceAll2(SchArea.getText().trim());
                    queryLength = search.length();
                    if ((search.contains(" AND ")) || (search.contains(" OR "))) {
                        words = Utility.getQueryWords(search, MainEntryPoint.stopWords);
                        getPositionsSAO(resultS, contentS, words, queryLength);
                    } else if (search.contains(" NEAR ")) {
                        words = Utility.getQueryWords(search, MainEntryPoint.stopWords);
                        if (GuiConstant.TA_HILITE_OVER_CR) {
                            getPositionsNearSCR(contentS, words, queryLength);
                        } else {
                            getPositionsNearS(resultS, contentS, words, queryLength);
                        }
                    } else if ((search.contains("*"))) {
                        rpcS.getExpandTerms(Utility.processWildCard(search), new AsyncCallback<String[]>() {
                            @Override
                            public void onFailure(Throwable caught) {
                                setMessage("error", GuiMessageConst.MSG_3);
                            }

                            @Override
                            public void onSuccess(String[] result) {
                                words = Utility.getWildCardQueryWords(result, MainEntryPoint.stopWords);
                                getPositionsSAO(resultS, contentS, words, queryLength);
                            }
                        });
                    } else {
                        if (search.startsWith("\"")) {
                            words = Utility.getexactWords(search);
                        } else {
                            words = Utility.getQueryWords(search, MainEntryPoint.stopWords);
                        }
                        if (GuiConstant.TA_HILITE_OVER_CR) {
                            getPositionsSCR(contentS, words, queryLength);
                        } else {
                            getPositionsS(resultS, contentS, words, queryLength);
                        }
                    }
                }
            });
        }
    });
    save.addListener(Events.OnClick, new Listener<BaseEvent>() {
        @Override
        public void handleEvent(BaseEvent be) {
            setMessage("info", GuiMessageConst.MSG_35);
            MyCatDownload.downloadZipFromServlet(Align.source.uri, msg);
        }
    });

    orgnS.addListener(Events.OnClick, new Listener<BaseEvent>() {
        @Override
        public void handleEvent(BaseEvent be) {
            rpcS.getOriginalUrl(Align.source.uri, new AsyncCallback<String>() {
                @Override
                public void onFailure(Throwable caught) {
                    setMessage("error", GuiMessageConst.MSG_4);
                }

                @Override
                public void onSuccess(String result) {
                    //                        Window.alert("request : " + result);
                    Window.open(result, "Original", features);
                }
            });
        }
    });

    orgnT.addListener(Events.OnClick, new Listener<BaseEvent>() {
        @Override
        public void handleEvent(BaseEvent be) {
            rpcS.getOriginalUrl(Align.target.uri, new AsyncCallback<String>() {
                @Override
                public void onFailure(Throwable caught) {
                    setMessage("error", GuiMessageConst.MSG_5);
                }

                @Override
                public void onSuccess(String result) {
                    //                        Window.alert("request : " + result);
                    Window.open(result, "Original", features);
                }
            });
        }
    });

    CclBtn.addListener(Events.OnClick, new Listener<BaseEvent>() {
        @Override
        public void handleEvent(BaseEvent be) {
            pSch.hide();
        }
    });

    schT.addListener(Events.OnClick, new Listener<BaseEvent>() {
        @Override
        public void handleEvent(BaseEvent be) {
            setMessage("info", GuiMessageConst.MSG_6);
            SchS = false;
            SchArea.setText("");
            pSch.setPopupPosition(targetTextArea.getAbsoluteLeft() + targetTextArea.getOffsetWidth() / 8,
                    targetTextArea.getAbsoluteTop());
            pSch.show();
            SchArea.setFocus(true);
            SchBtn.removeAllListeners();
            SchBtn.addListener(Events.OnClick, new Listener<BaseEvent>() {
                @Override
                public void handleEvent(BaseEvent be) {
                    ClearHitsEvents();
                    words = null;

                    search = Utility.replaceAll2(SchArea.getText().trim());
                    queryLength = search.length();
                    if ((search.contains(" AND ")) || (search.contains(" OR "))) {
                        words = Utility.getQueryWords(search, MainEntryPoint.stopWords);
                        getPositionsTAO(resultT, contentT, words, queryLength);
                    } else if (search.contains(" NEAR ")) {
                        words = Utility.getQueryWords(search, MainEntryPoint.stopWords);
                        if (GuiConstant.TA_HILITE_OVER_CR) {
                            getPositionsNearTCR(contentT, words, queryLength);
                        } else {
                            getPositionsNearT(resultT, contentT, words, queryLength);
                        }
                    } else if ((search.contains("*"))) {
                        rpcS.getExpandTerms(Utility.processWildCard(search), new AsyncCallback<String[]>() {
                            @Override
                            public void onFailure(Throwable caught) {
                                setMessage("error", GuiMessageConst.MSG_3);
                            }

                            @Override
                            public void onSuccess(String[] result) {
                                words = Utility.getWildCardQueryWords(result, MainEntryPoint.stopWords);
                                getPositionsTAO(resultT, contentT, words, queryLength);
                            }
                        });
                    } else {
                        if (search.startsWith("\"")) {
                            words = Utility.getexactWords(search);
                        } else {
                            words = Utility.getQueryWords(search, MainEntryPoint.stopWords);
                        }
                        if (GuiConstant.TA_HILITE_OVER_CR) {
                            getPositionsTCR(contentT, words, queryLength);
                        } else {
                            getPositionsT(resultT, contentT, words, queryLength);
                        }
                    }
                }
            });
        }
    });

    SchArea.addKeyPressHandler(new KeyPressHandler() {
        @Override
        public void onKeyPress(KeyPressEvent event) {

            if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
                if (SchS) {
                    ClearHitsEvents();
                    words = null;
                    search = Utility.replaceAll2(SchArea.getText().trim());
                    queryLength = search.length();
                    if ((search.contains(" AND ")) || (search.contains(" OR "))) {
                        words = Utility.getQueryWords(search, MainEntryPoint.stopWords);
                        getPositionsSAO(resultS, contentS, words, queryLength);
                    } else if (search.contains(" NEAR ")) {
                        words = Utility.getQueryWords(search, MainEntryPoint.stopWords);
                        if (GuiConstant.TA_HILITE_OVER_CR) {
                            getPositionsNearSCR(contentS, words, queryLength);
                        } else {
                            getPositionsNearS(resultS, contentS, words, queryLength);
                        }
                    } else if ((search.contains("*"))) {
                        rpcS.getExpandTerms(Utility.processWildCard(search), new AsyncCallback<String[]>() {
                            @Override
                            public void onFailure(Throwable caught) {
                                setMessage("error", GuiMessageConst.MSG_3);
                            }

                            @Override
                            public void onSuccess(String[] result) {
                                words = Utility.getWildCardQueryWords(result, MainEntryPoint.stopWords);
                                getPositionsSAO(resultS, contentS, words, queryLength);
                            }
                        });
                    } else {
                        if (search.startsWith("\"")) {
                            words = Utility.getexactWords(search);
                        } else {
                            words = Utility.getQueryWords(search, MainEntryPoint.stopWords);
                        }
                        if (GuiConstant.TA_HILITE_OVER_CR) {
                            getPositionsSCR(contentS, words, queryLength);
                        } else {
                            getPositionsS(resultS, contentS, words, queryLength);
                        }
                    }
                } else {
                    ClearHitsEvents();
                    words = null;
                    search = Utility.replaceAll2(SchArea.getText().trim());
                    queryLength = search.length();
                    if ((search.contains(" AND ")) || (search.contains(" OR "))) {
                        words = Utility.getQueryWords(search, MainEntryPoint.stopWords);
                        getPositionsTAO(resultT, contentT, words, queryLength);
                    } else if (search.contains(" NEAR ")) {
                        words = Utility.getQueryWords(search, MainEntryPoint.stopWords);
                        if (GuiConstant.TA_HILITE_OVER_CR) {
                            getPositionsNearTCR(contentT, words, queryLength);
                        } else {
                            getPositionsNearT(resultT, contentT, words, queryLength);
                        }
                    } else if ((search.contains("*"))) {
                        rpcS.getExpandTerms(Utility.processWildCard(search), new AsyncCallback<String[]>() {
                            @Override
                            public void onFailure(Throwable caught) {
                                setMessage("error", GuiMessageConst.MSG_3);
                            }

                            @Override
                            public void onSuccess(String[] result) {
                                words = Utility.getWildCardQueryWords(result, MainEntryPoint.stopWords);
                                getPositionsTAO(resultT, contentT, words, queryLength);
                            }
                        });
                    } else {
                        if (search.startsWith("\"")) {
                            words = Utility.getexactWords(search);
                        } else {
                            words = Utility.getQueryWords(search, MainEntryPoint.stopWords);
                        }
                        if (GuiConstant.TA_HILITE_OVER_CR) {
                            getPositionsTCR(contentT, words, queryLength);
                        } else {
                            getPositionsT(resultT, contentT, words, queryLength);
                        }
                    }
                }
            }
        }
    });
}

From source file:org.olanto.TranslationText.client.BitextWidget.java

License:Open Source License

public void AddOtherEventsMono() {

    // Handler of the going to align the line in the source text
    schS.addListener(Events.OnClick, new Listener<BaseEvent>() {
        @Override/*from w ww.  ja  v  a 2s . c om*/
        public void handleEvent(BaseEvent be) {
            setMessage("info", GuiMessageConst.MSG_7);
            pSch.setPopupPosition(sourceTextArea.getAbsoluteLeft() + sourceTextArea.getOffsetWidth() / 8,
                    sourceTextArea.getAbsoluteTop());
            pSch.show();
            SchArea.setFocus(true);
            SchBtn.removeAllListeners();
            SchBtn.addListener(Events.OnClick, new Listener<BaseEvent>() {
                @Override
                public void handleEvent(BaseEvent be) {
                    ClearHitsEvents();
                    words = null;

                    search = Utility.replaceAll2(SchArea.getText().trim());
                    queryLength = search.length();
                    if ((search.contains(" AND ")) || (search.contains(" OR "))) {
                        words = Utility.getQueryWords(search, MainEntryPoint.stopWords);
                        getPositionsMonoAO(resultS, contentS, words, queryLength);
                    } else if (search.contains(" NEAR ")) {
                        words = Utility.getQueryWords(search, MainEntryPoint.stopWords);
                        if (GuiConstant.TA_HILITE_OVER_CR) {
                            getPositionsNearMonoCR(contentS, words, queryLength);
                        } else {
                            getPositionsNearMono(resultS, contentS, words, queryLength);
                        }
                    } else if ((search.contains("*"))) {
                        rpcS.getExpandTerms(Utility.processWildCard(search), new AsyncCallback<String[]>() {
                            @Override
                            public void onFailure(Throwable caught) {
                                setMessage("error", GuiMessageConst.MSG_3);
                            }

                            @Override
                            public void onSuccess(String[] result) {
                                words = Utility.getWildCardQueryWords(result, MainEntryPoint.stopWords);
                                getPositionsMonoAO(resultS, contentS, words, queryLength);
                            }
                        });
                    } else {
                        if (search.startsWith("\"")) {
                            words = Utility.getexactWords(search);
                        } else {
                            words = Utility.getQueryWords(search, MainEntryPoint.stopWords);
                        }
                        if (GuiConstant.TA_HILITE_OVER_CR) {
                            getPositionsMonoCR(contentS, words, queryLength);
                        } else {
                            getPositionsMono(resultS, contentS, words, queryLength);
                        }
                    }
                }
            });
        }
    });
    save.addListener(Events.OnClick, new Listener<BaseEvent>() {
        @Override
        public void handleEvent(BaseEvent be) {
            setMessage("info", GuiMessageConst.MSG_35);
            MyCatDownload.downloadZipFromServlet(Align.source.uri, msg);
        }
    });

    orgnS.addListener(Events.OnClick, new Listener<BaseEvent>() {
        @Override
        public void handleEvent(BaseEvent be) {
            rpcS.getOriginalUrl(Align.source.uri, new AsyncCallback<String>() {
                @Override
                public void onFailure(Throwable caught) {
                    setMessage("error", GuiMessageConst.MSG_4);
                }

                @Override
                public void onSuccess(String result) {
                    //                        Window.alert("request : " + result);
                    Window.open(result, "Original", features);
                }
            });
        }
    });

    CclBtn.addListener(Events.OnClick, new Listener<BaseEvent>() {
        @Override
        public void handleEvent(BaseEvent be) {
            pSch.hide();
        }
    });

    SchArea.addKeyPressHandler(new KeyPressHandler() {
        @Override
        public void onKeyPress(KeyPressEvent event) {

            if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
                ClearHitsEvents();
                words = null;
                search = Utility.replaceAll2(SchArea.getText().trim());
                queryLength = search.length();
                if ((search.contains(" AND ")) || (search.contains(" OR "))) {
                    words = Utility.getQueryWords(search, MainEntryPoint.stopWords);
                    getPositionsMonoAO(resultS, contentS, words, queryLength);
                } else if (search.contains(" NEAR ")) {
                    words = Utility.getQueryWords(search, MainEntryPoint.stopWords);
                    if (GuiConstant.TA_HILITE_OVER_CR) {
                        getPositionsNearMonoCR(contentS, words, queryLength);
                    } else {
                        getPositionsNearMono(resultS, contentS, words, queryLength);
                    }
                } else if ((search.contains("*"))) {
                    rpcS.getExpandTerms(Utility.processWildCard(search), new AsyncCallback<String[]>() {
                        @Override
                        public void onFailure(Throwable caught) {
                            setMessage("error", GuiMessageConst.MSG_3);
                        }

                        @Override
                        public void onSuccess(String[] result) {
                            words = Utility.getWildCardQueryWords(result, MainEntryPoint.stopWords);
                            getPositionsMonoAO(resultS, contentS, words, queryLength);
                        }
                    });
                } else {
                    if (search.startsWith("\"")) {
                        words = Utility.getexactWords(search);
                    } else {
                        words = Utility.getQueryWords(search, MainEntryPoint.stopWords);
                    }
                    if (GuiConstant.TA_HILITE_OVER_CR) {
                        getPositionsMonoCR(contentS, words, queryLength);
                    } else {
                        getPositionsMono(resultS, contentS, words, queryLength);
                    }
                }

            }
        }
    });
}

From source file:org.olanto.TranslationText.client.QuoteBitextWidget.java

License:Open Source License

public void AddOtherEvents() {

    // Handler of the going to align the line in the source text
    AlignS.addListener(Events.OnClick, new Listener<BaseEvent>() {
        @Override//  w w  w.  j a  v  a  2  s  .c om
        public void handleEvent(BaseEvent be) {
            pp.hide();
            int posi = sourceTextArea.getCursorPos();
            int len = sourceTextArea.getSelectedText().length();
            indexS = Utility.getInd(posi, resultS);
            indexT = Map.from[indexS];
            showpanel(false, resultT[indexT][0] + 1, indexT);

            if ((Window.Navigator.getUserAgent().contains("MSIE 7.0"))
                    || (Window.Navigator.getUserAgent().contains("MSIE 8.0"))) {
                int idx = resultS[indexS][2];
                int idxt = resultT[indexT][2];
                sourceTextArea.setCursorPos(0);
                targetTextArea.setCursorPos(0);
                sourceTextArea.setCursorPos(idx);
                targetTextArea.setCursorPos(idxt);
            } else {
                setNetScapePos(indexS, indexT, (sourceTextArea.getVisibleLines() / 2));
            }
            if (len > 1) {
                sourceTextArea.setSelectionRange(posi, len);
            } else {
                sourceTextArea.setSelectionRange(posi, 1);
            }
            sourceTextArea.setFocus(true);
        }
    });

    // Handler of the going to align the line in the target text
    AlignT.addListener(Events.OnClick, new Listener<BaseEvent>() {
        @Override
        public void handleEvent(BaseEvent be) {
            pp.hide();
            int posi = targetTextArea.getCursorPos();
            int len = targetTextArea.getSelectedText().length();
            indexT = Utility.getInd(posi, resultT);
            indexS = Map.to[indexT];
            showpanel(true, resultS[indexS][0] + 1, indexS);

            if ((Window.Navigator.getUserAgent().contains("MSIE 7.0"))
                    || (Window.Navigator.getUserAgent().contains("MSIE 8.0"))) {
                int idx = resultS[indexS][2];
                int idxt = resultT[indexT][2];
                sourceTextArea.setCursorPos(0);
                targetTextArea.setCursorPos(0);
                sourceTextArea.setCursorPos(idx);
                targetTextArea.setCursorPos(idxt);
            } else {
                setNetScapePosT(indexS, indexT, (targetTextArea.getVisibleLines() / 2));
            }
            if (len > 1) {
                targetTextArea.setSelectionRange(posi, len);
            } else {
                targetTextArea.setSelectionRange(posi, 1);
            }
            targetTextArea.setFocus(true);
        }
    });

    schS.addListener(Events.OnClick, new Listener<BaseEvent>() {
        @Override
        public void handleEvent(BaseEvent be) {
            setMessage("info", GuiMessageConst.MSG_7);
            SchS = true;
            SchArea.setText("");
            pSch.setPopupPosition(sourceTextArea.getAbsoluteLeft() + sourceTextArea.getOffsetWidth() / 8,
                    sourceTextArea.getAbsoluteTop());
            pSch.show();
            SchArea.setFocus(true);
            SchBtn.removeAllListeners();
            SchBtn.addListener(Events.OnClick, new Listener<BaseEvent>() {
                @Override
                public void handleEvent(BaseEvent be) {
                    ClearHitsEvents();
                    words = null;

                    search = Utility.replaceAll2(SchArea.getText().trim());
                    queryLength = search.length();
                    if ((search.contains(" AND ")) || (search.contains(" OR "))) {
                        words = Utility.getQueryWords(search, MainEntryPoint.stopWords);
                        getPositionsSAO(resultS, contentS, words, queryLength);
                    } else if (search.contains(" NEAR ")) {
                        words = Utility.getQueryWords(search, MainEntryPoint.stopWords);
                        if (GuiConstant.TA_HILITE_OVER_CR) {
                            getPositionsNearSCR(contentS, words, queryLength);
                        } else {
                            getPositionsNearS(resultS, contentS, words, queryLength);
                        }
                    } else if ((search.contains("*"))) {
                        rpcS.getExpandTerms(Utility.processWildCard(search), new AsyncCallback<String[]>() {
                            @Override
                            public void onFailure(Throwable caught) {
                                setMessage("error", GuiMessageConst.MSG_3);
                            }

                            @Override
                            public void onSuccess(String[] result) {
                                words = Utility.getWildCardQueryWords(result, MainEntryPoint.stopWords);
                                getPositionsSAO(resultS, contentS, words, queryLength);
                            }
                        });
                    } else {
                        if (search.startsWith("\"")) {
                            words = Utility.getexactWords(search);
                        } else {
                            words = Utility.getQueryWords(search, MainEntryPoint.stopWords);
                        }
                        if (GuiConstant.TA_HILITE_OVER_CR) {
                            getPositionsSCR(contentS, words, queryLength);
                        } else {
                            getPositionsS(resultS, contentS, words, queryLength);
                        }
                    }
                }
            });
        }
    });
    save.addListener(Events.OnClick, new Listener<BaseEvent>() {
        @Override
        public void handleEvent(BaseEvent be) {
            setMessage("info", GuiMessageConst.MSG_35);
            MyCatDownload.downloadZipFromServlet(Align.source.uri, msg);
        }
    });

    orgnS.addListener(Events.OnClick, new Listener<BaseEvent>() {
        @Override
        public void handleEvent(BaseEvent be) {
            rpcS.getOriginalUrl(Align.source.uri, new AsyncCallback<String>() {
                @Override
                public void onFailure(Throwable caught) {
                    setMessage("error", GuiMessageConst.MSG_4);
                }

                @Override
                public void onSuccess(String result) {
                    //                        Window.alert("request : " + result);
                    Window.open(result, "Original", features);
                }
            });
        }
    });

    orgnT.addListener(Events.OnClick, new Listener<BaseEvent>() {
        @Override
        public void handleEvent(BaseEvent be) {
            rpcS.getOriginalUrl(Align.target.uri, new AsyncCallback<String>() {
                @Override
                public void onFailure(Throwable caught) {
                    setMessage("error", GuiMessageConst.MSG_5);
                }

                @Override
                public void onSuccess(String result) {
                    //                        Window.alert("request : " + result);
                    Window.open(result, "Original", features);
                }
            });
        }
    });

    CclBtn.addListener(Events.OnClick, new Listener<BaseEvent>() {
        @Override
        public void handleEvent(BaseEvent be) {
            pSch.hide();
        }
    });

    schT.addListener(Events.OnClick, new Listener<BaseEvent>() {
        @Override
        public void handleEvent(BaseEvent be) {
            setMessage("info", GuiMessageConst.MSG_6);
            SchS = false;
            SchArea.setText("");
            pSch.setPopupPosition(targetTextArea.getAbsoluteLeft() + targetTextArea.getOffsetWidth() / 8,
                    targetTextArea.getAbsoluteTop());
            pSch.show();
            SchArea.setFocus(true);
            SchBtn.removeAllListeners();
            SchBtn.addListener(Events.OnClick, new Listener<BaseEvent>() {
                @Override
                public void handleEvent(BaseEvent be) {
                    ClearHitsEvents();
                    words = null;

                    search = Utility.replaceAll2(SchArea.getText().trim());
                    queryLength = search.length();
                    if ((search.contains(" AND ")) || (search.contains(" OR "))) {
                        words = Utility.getQueryWords(search, MainEntryPoint.stopWords);
                        getPositionsTAO(resultT, contentT, words, queryLength);
                    } else if (search.contains(" NEAR ")) {
                        words = Utility.getQueryWords(search, MainEntryPoint.stopWords);
                        if (GuiConstant.TA_HILITE_OVER_CR) {
                            getPositionsNearTCR(contentT, words, queryLength);
                        } else {
                            getPositionsNearT(resultT, contentT, words, queryLength);
                        }
                    } else if ((search.contains("*"))) {
                        rpcS.getExpandTerms(Utility.processWildCard(search), new AsyncCallback<String[]>() {
                            @Override
                            public void onFailure(Throwable caught) {
                                setMessage("error", GuiMessageConst.MSG_3);
                            }

                            @Override
                            public void onSuccess(String[] result) {
                                words = Utility.getWildCardQueryWords(result, MainEntryPoint.stopWords);
                                getPositionsTAO(resultT, contentT, words, queryLength);
                            }
                        });
                    } else {
                        if (search.startsWith("\"")) {
                            words = Utility.getexactWords(search);
                        } else {
                            words = Utility.getQueryWords(search, MainEntryPoint.stopWords);
                        }
                        if (GuiConstant.TA_HILITE_OVER_CR) {
                            getPositionsTCR(contentT, words, queryLength);
                        } else {
                            getPositionsT(resultT, contentT, words, queryLength);
                        }
                    }
                }
            });
        }
    });

    SchArea.addKeyPressHandler(new KeyPressHandler() {
        @Override
        public void onKeyPress(KeyPressEvent event) {

            if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
                if (SchS) {
                    ClearHitsEvents();
                    words = null;

                    search = Utility.replaceAll2(SchArea.getText().trim());
                    queryLength = search.length();
                    if ((search.contains(" AND ")) || (search.contains(" OR "))) {
                        words = Utility.getQueryWords(search, MainEntryPoint.stopWords);
                        getPositionsSAO(resultS, contentS, words, queryLength);
                    } else if (search.contains(" NEAR ")) {
                        words = Utility.getQueryWords(search, MainEntryPoint.stopWords);
                        if (GuiConstant.TA_HILITE_OVER_CR) {
                            getPositionsNearSCR(contentS, words, queryLength);
                        } else {
                            getPositionsNearS(resultS, contentS, words, queryLength);
                        }
                    } else if ((search.contains("*"))) {
                        rpcS.getExpandTerms(Utility.processWildCard(search), new AsyncCallback<String[]>() {
                            @Override
                            public void onFailure(Throwable caught) {
                                setMessage("error", GuiMessageConst.MSG_3);
                            }

                            @Override
                            public void onSuccess(String[] result) {
                                words = Utility.getWildCardQueryWords(result, MainEntryPoint.stopWords);
                                getPositionsSAO(resultS, contentS, words, queryLength);
                            }
                        });
                    } else {
                        if (search.startsWith("\"")) {
                            words = Utility.getexactWords(search);
                        } else {
                            words = Utility.getQueryWords(search, MainEntryPoint.stopWords);
                        }
                        if (GuiConstant.TA_HILITE_OVER_CR) {
                            getPositionsSCR(contentS, words, queryLength);
                        } else {
                            getPositionsS(resultS, contentS, words, queryLength);
                        }
                    }
                } else {
                    ClearHitsEvents();
                    words = null;

                    search = Utility.replaceAll2(SchArea.getText().trim());
                    queryLength = search.length();
                    if ((search.contains(" AND ")) || (search.contains(" OR "))) {
                        words = Utility.getQueryWords(search, MainEntryPoint.stopWords);
                        getPositionsTAO(resultT, contentT, words, queryLength);
                    } else if (search.contains(" NEAR ")) {
                        words = Utility.getQueryWords(search, MainEntryPoint.stopWords);
                        if (GuiConstant.TA_HILITE_OVER_CR) {
                            getPositionsNearTCR(contentT, words, queryLength);
                        } else {
                            getPositionsNearT(resultT, contentT, words, queryLength);
                        }
                    } else if ((search.contains("*"))) {
                        rpcS.getExpandTerms(Utility.processWildCard(search), new AsyncCallback<String[]>() {
                            @Override
                            public void onFailure(Throwable caught) {
                                setMessage("error", GuiMessageConst.MSG_3);
                            }

                            @Override
                            public void onSuccess(String[] result) {
                                words = Utility.getWildCardQueryWords(result, MainEntryPoint.stopWords);
                                getPositionsTAO(resultT, contentT, words, queryLength);
                            }
                        });
                    } else {
                        if (search.startsWith("\"")) {
                            words = Utility.getexactWords(search);
                        } else {
                            words = Utility.getQueryWords(search, MainEntryPoint.stopWords);
                        }
                        if (GuiConstant.TA_HILITE_OVER_CR) {
                            getPositionsTCR(contentT, words, queryLength);
                        } else {
                            getPositionsT(resultT, contentT, words, queryLength);
                        }
                    }
                }
            }
        }
    });
}

From source file:org.olanto.TranslationText.client.QuoteWidget.java

License:Open Source License

private void setHeader() {
    initWidget(mainWidget);//from w ww  . j av  a2 s  . c o m
    mainWidget.setStyleName("mainContent");
    mainWidget.add(headerContainer);
    mainWidget.setCellHorizontalAlignment(headerContainer, VerticalPanel.ALIGN_CENTER);
    mainWidget.add(refpanel);
    mainWidget.setCellHorizontalAlignment(refpanel, VerticalPanel.ALIGN_CENTER);
    mainWidget.add(mainContainer);
    mainWidget.setCellHorizontalAlignment(mainContainer, VerticalPanel.ALIGN_LEFT);
    mainWidget.add(statusContainer);
    mainWidget.setCellHorizontalAlignment(statusContainer, VerticalPanel.ALIGN_CENTER);

    headerContainer.setBodyBorder(true);
    headerContainer.setHeaderVisible(false);
    headerContainer.add(headPanel);
    headerContainer.setStylePrimaryName("searchHeader");
    headPanel.setStylePrimaryName("searchHeader");
    headPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);

    headerPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
    headerPanel.add(fileUpload);
    headerPanel.add(GoSrch);
    headerPanel.add(langS);
    headerPanel.add(langT);
    headerPanel.add(coll);
    headerPanel.add(minLn);
    headerPanel.add(minLength);
    headerPanel.add(prev);
    headerPanel.add(next);
    headerPanel.add(refIndic);
    headerPanel.add(TextAligner);
    headerPanel.add(help);
    if (GuiConstant.SAVE_ON) {
        headerPanel.add(save);
    }
    if (GuiConstant.AUTO_ON) {
        headerPanel.add(resize);
    }
    headerPanel.setStylePrimaryName("searchHeader");

    headPanel.add(leftheadPanel);
    headPanel.add(QDText);
    headPanel.setCellHorizontalAlignment(QDText, HorizontalPanel.ALIGN_RIGHT);
    headPanel.add(new HTML("&nbsp;"));
    if ((!GuiConstant.LOGO_PATH.isEmpty()) && (!GuiConstant.LOGO_PATH.isEmpty())) {
        if ((!GuiConstant.LOGO_PATH.equalsIgnoreCase(" ")) && (!GuiConstant.LOGO_PATH.equalsIgnoreCase(" "))) {
            headPanel.add(im);
            headPanel.setCellHorizontalAlignment(im, HorizontalPanel.ALIGN_RIGHT);
        }
    }
    topJobsSet.setTabBarPosition(Side.TOP);
    topJobsSet.setDefaultHeight(H_Unit);
    topJobsSet.setPaneContainerClassName("searchHeader");
    leftheadPanel.add(topJobsSet);
    leftheadPanel.add(headerPanel);

    mainContainer.setBodyBorder(true);
    mainContainer.setHeaderVisible(false);
    mainContainer.add(resultsPanel);
    mainContainer.setStylePrimaryName("mainContent");

    statusContainer.setBodyBorder(true);
    statusContainer.setHeaderVisible(false);
    statusContainer.add(statusPanel);
    statusPanel.setHeight(H_Unit + "px");
    statusPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
    statusPanel.add(msg);
    statusPanel.setCellHorizontalAlignment(msg, HorizontalPanel.ALIGN_LEFT);
    statusPanel.add(contact);
    statusPanel.setCellHorizontalAlignment(contact, HorizontalPanel.ALIGN_RIGHT);
    contact.setPixelSize(GuiConstant.DOC_LIST_WIDTH, 25);
    contact.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
    Anchor poweredBy = new Anchor(GuiConstant.OLANTO_URL.substring(0, GuiConstant.OLANTO_URL.indexOf("|")),
            true,
            GuiConstant.OLANTO_URL.substring(GuiConstant.OLANTO_URL.indexOf("|") + 1,
                    GuiConstant.OLANTO_URL.lastIndexOf("|")),
            GuiConstant.OLANTO_URL.substring(GuiConstant.OLANTO_URL.lastIndexOf("|") + 1));
    contact.add(poweredBy);
    poweredBy.setStylePrimaryName("contactInfo");
    contact.setCellHorizontalAlignment(poweredBy, HorizontalPanel.ALIGN_LEFT);
    contact.add(new HTML("||"));
    Anchor feedback = new Anchor(
            GuiConstant.FEEDBACK_MAIL.substring(0, GuiConstant.FEEDBACK_MAIL.indexOf("|")));
    contact.add(feedback);
    feedback.setStylePrimaryName("contactInfo");
    contact.setCellHorizontalAlignment(feedback, HorizontalPanel.ALIGN_RIGHT);
    contact.add(new HTML("&nbsp;"));

    statusContainer.setStylePrimaryName("statusPanel");
    statusPanel.setStylePrimaryName("statusPanel");

    refpanel.setBodyBorder(true);
    refpanel.setHeaderVisible(false);
    refpanel.add(htmlWrapper);
    htmlWrapper.add(refArea);

    docListContainer.setBodyBorder(true);
    resultsPanel.add(docListContainer);
    resultsPanel.setCellHorizontalAlignment(docListContainer, HorizontalPanel.ALIGN_LEFT);
    docListContainer.add(staticDecorator);
    tS = new QuoteBitextWidget(msg);
    resultsPanel.add(tS);

    refArea.setVisible(true);
    refArea.setStyleName("TextBlock");
    fileUpload.addOnStartUploadHandler(onStartUploaderHandler);
    fileUpload.addOnFinishUploadHandler(onFinishUploaderHandler);
    help.addListener(Events.OnClick, new Listener<BaseEvent>() {
        @Override
        public void handleEvent(BaseEvent be) {
            Window.open(GuiConstant.QD_HELP_URL, "", GuiConstant.W_OPEN_FEATURES);
        }
    });
    resize.addListener(Events.OnClick, new Listener<BaseEvent>() {
        @Override
        public void handleEvent(BaseEvent be) {
            resizeAll();
            resizeAll();
            reselectDocument();
        }
    });
    staticDecorator.setStyleName("doclist");
    staticDecorator.setWidget(staticTreeWrapper);
    fileUpload.setAutoSubmit(true);
    setMessage("info", "");
    for (int i = GuiConstant.MIN_OCCU; i < GuiConstant.MAX_OCCU; i++) {
        minLength.addItem("" + i);
    }
    minLength.setSelectedIndex(Integer.parseInt(Cookies.getCookie(CookiesNamespace.MyQuoteMinLength)));
    minLength.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            GoSrch.enable();
            MyCatCookies.updateCookie(CookiesNamespace.MyQuoteMinLength, "" + minLength.getSelectedIndex());
        }
    });
    langS.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            GoSrch.enable();
            MyCatCookies.updateCookie(CookiesNamespace.MyQuotelangS,
                    langS.getItemText(langS.getSelectedIndex()));
        }
    });
    langT.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            GoSrch.enable();
            MyCatCookies.updateCookie(CookiesNamespace.MyQuotelangT,
                    langT.getItemText(langT.getSelectedIndex()));
        }
    });
    if ((!GuiConstant.LOGO_PATH.isEmpty()) && (!GuiConstant.LOGO_PATH.isEmpty())) {
        im.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                Window.open(GuiConstant.LOGO_URL, "", GuiConstant.W_OPEN_FEATURES);
            }
        });
    }
    feedback.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            mailto(GuiConstant.FEEDBACK_MAIL.substring(GuiConstant.FEEDBACK_MAIL.lastIndexOf("|") + 1),
                    GuiMessageConst.MSG_39 + GuiConstant.QUOTE_DETECTOR_LBL);
        }
    });
}

From source file:org.olanto.TranslationText.client.QuoteWidget.java

License:Open Source License

public void draWidget() {
    setbuttonstyle(GoSrch, GoSrch.getText().length() * 2 * CHAR_W, H_Unit);
    setbuttonstyle(TextAligner, TextAligner.getText().length() * CHAR_W, H_Unit);
    setbuttonstyle(coll, coll.getText().length() * CHAR_W, H_Unit);
    setbuttonstyle(help, help.getText().length() * CHAR_W, H_Unit);
    setbuttonstyle(resize, resize.getText().length() * CHAR_W, H_Unit);
    setbuttonstyle(save, save.getText().length() * CHAR_W, H_Unit);
    setbuttonstyle(prev, prev.getText().length() * CHAR_W, H_Unit);
    setbuttonstyle(next, next.getText().length() * CHAR_W, H_Unit);

    GoSrch.setAutoWidth(true);//  w ww .  java  2s . c  o  m
    TextAligner.setAutoWidth(true);
    coll.setAutoWidth(true);
    help.setAutoWidth(true);
    save.setAutoWidth(true);
    prev.setAutoWidth(true);
    next.setAutoWidth(true);
    resize.setAutoWidth(true);

    langS.setWidth((int) (2.5 * W_Unit) + "px");
    langT.setWidth((int) (2.5 * W_Unit) + "px");
    minLn.setStyleName("gwt-w-label");
    minLn.setWidth("70px");
    refIndic.setStyleName("gwt-w-label");
    refIndic.setWidth("40px");
    QDText.setStyleName("gwt-im-text");
    htmlWrapper.setAlwaysShowScrollBars(true);
    htmlWrapper.setPixelSize(Window.getClientWidth() - W_Unit, MainEntryPoint.IMeasures.QD_HTMLAREA_HEIGHT);
    refArea.setWidth(Window.getClientWidth() - 2 * W_Unit);
    setMessage("warning", GuiMessageConst.MSG_60);
    docListContainer.setHeading(GuiMessageConst.MSG_60);
    staticTreeWrapper.setAlwaysShowScrollBars(true);
    staticTreeWrapper.setPixelSize(MainEntryPoint.IMeasures.DOC_LIST_WIDTH,
            MainEntryPoint.IMeasures.QD_DOC_LIST_HEIGHT - H_Unit);
    docListContainer.setSize(MainEntryPoint.IMeasures.DOC_LIST_WIDTH,
            MainEntryPoint.IMeasures.QD_DOC_LIST_HEIGHT);
    if ((GuiConstant.JOBS_ITEMS != null) && (GuiConstant.JOBS_ITEMS.length() > 1)) {
        String jobs = GuiConstant.JOBS_ITEMS;
        String[] tablist = jobs.split("\\;");
        Tab tinv = new Tab();
        topJobsSet.addTab(tinv);
        tinv.setTitle("Select Tab : ");
        tinv.setID("Empty");
        tinv.setDisabled(true);
        if (tablist.length > 0) {
            for (int i = 0; i < tablist.length; i++) {
                Tab tTab = new Tab();
                tTab.setIcon("./icons/16/folder_document.png");
                tTab.setTitle(tablist[i].substring(0, tablist[i].indexOf("|")));
                tTab.setAttribute("URL",
                        tablist[i].substring(tablist[i].indexOf("|") + 1, tablist[i].lastIndexOf("|")));
                tTab.setAttribute("MODE", tablist[i].substring(tablist[i].lastIndexOf("|") + 1));
                topJobsSet.addTab(tTab);
            }
        }
        topJobsSet.setSelectedTab(0);
        topJobsSet.addTabSelectedHandler(new TabSelectedHandler() {
            @Override
            public void onTabSelected(TabSelectedEvent event) {
                if (!(event.getTab().getID().contains("Empty"))) {
                    //                        Window.alert("URL: " + event.getTab().getAttribute("URL") + "mode: " + event.getTab().getAttribute("MODE"));
                    Window.open(event.getTab().getAttribute("URL"), event.getTab().getAttribute("MODE"), "");
                }
            }
        });
        topJobsSet.setWidth(headerPanel.getOffsetWidth());
        topJobsSet.draw();
        topJobsSet.setCursor(Cursor.HAND);
    } else {
        leftheadPanel.remove(topJobsSet);
    }
    GoSrch.disable();
    qualibrateSize();
}

From source file:org.olanto.TranslationText.client.ResearchWidget.java

License:Open Source License

private void setHeader() {
    initWidget(mainWidget);/*w w w.ja va  2  s .com*/
    mainWidget.setStyleName("mainContent");
    mainWidget.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    mainWidget.add(mainContentWidget);

    mainContentWidget.add(headerContainer);
    mainContentWidget.add(mainContainer);
    mainContentWidget.add(statusContainer);

    headerContainer.setBodyBorder(true);
    headerContainer.setHeaderVisible(false);
    headerContainer.add(headPanel);
    headerContainer.setStylePrimaryName("searchHeader");
    headPanel.setStylePrimaryName("searchHeader");
    headPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);

    headerPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
    headerPanel.add(search);
    headerPanel.add(GoSrch);
    headerPanel.add(langS);
    headerPanel.add(langT);
    headerPanel.add(coll);
    headerPanel.add(sortBy);
    headerPanel.add(myQuote);
    headerPanel.add(help);
    if (GuiConstant.CHOOSE_GUI_LANG) {
        headerPanel.add(chooseLang);
        headerPanel.add(langInterface);
    }
    if (GuiConstant.AUTO_ON) {
        headerPanel.add(resize);
    }
    headerPanel.setStylePrimaryName("searchHeader");

    headPanel.add(leftheadPanel);
    headPanel.add(TAText);
    headPanel.setCellHorizontalAlignment(TAText, HorizontalPanel.ALIGN_RIGHT);
    if ((!GuiConstant.LOGO_PATH.isEmpty()) && (!GuiConstant.LOGO_PATH.isEmpty())) {
        if ((!GuiConstant.LOGO_PATH.equalsIgnoreCase(" ")) && (!GuiConstant.LOGO_PATH.equalsIgnoreCase(" "))) {
            headPanel.add(new HTML("&nbsp;"));
            headPanel.add(im);
            headPanel.setCellHorizontalAlignment(im, HorizontalPanel.ALIGN_RIGHT);
        }
    }

    topJobsSet.setTabBarPosition(Side.TOP);
    topJobsSet.setDefaultHeight(H_Unit);
    topJobsSet.setPaneContainerClassName("searchHeader");
    leftheadPanel.add(topJobsSet);
    leftheadPanel.add(headerPanel);

    mainContainer.setBodyBorder(true);
    mainContainer.setHeaderVisible(false);
    mainContainer.add(resultsPanel);
    mainContainer.setStylePrimaryName("mainContent");

    statusContainer.setBodyBorder(true);
    statusContainer.setHeaderVisible(false);
    statusContainer.add(statusPanel);
    statusPanel.setHeight(H_Unit + "px");
    statusPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
    statusPanel.add(msg);
    statusPanel.setCellHorizontalAlignment(msg, HorizontalPanel.ALIGN_LEFT);
    statusPanel.add(contact);
    statusPanel.setCellHorizontalAlignment(contact, HorizontalPanel.ALIGN_RIGHT);
    contact.setPixelSize(300, 25);
    contact.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
    Anchor poweredBy = new Anchor(GuiConstant.OLANTO_URL.substring(0, GuiConstant.OLANTO_URL.indexOf("|")),
            true,
            GuiConstant.OLANTO_URL.substring(GuiConstant.OLANTO_URL.indexOf("|") + 1,
                    GuiConstant.OLANTO_URL.lastIndexOf("|")),
            GuiConstant.OLANTO_URL.substring(GuiConstant.OLANTO_URL.lastIndexOf("|") + 1));
    contact.add(poweredBy);
    poweredBy.setStylePrimaryName("contactInfo");
    contact.setCellHorizontalAlignment(poweredBy, HorizontalPanel.ALIGN_LEFT);
    contact.add(new HTML("||"));
    Anchor feedback = new Anchor(
            GuiConstant.FEEDBACK_MAIL.substring(0, GuiConstant.FEEDBACK_MAIL.indexOf("|")));
    contact.add(feedback);
    feedback.setStylePrimaryName("contactInfo");
    contact.setCellHorizontalAlignment(feedback, HorizontalPanel.ALIGN_RIGHT);
    contact.add(new HTML("&nbsp;"));

    statusContainer.setStylePrimaryName("statusPanel");
    statusPanel.setStylePrimaryName("statusPanel");

    docListContainer.setBodyBorder(true);
    docListContainer.setHeading(GuiMessageConst.MSG_41);
    resultsPanel.add(docListContainer);

    docListContainer.add(staticDecorator);

    langS.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            MyCatCookies.updateCookie(CookiesNamespace.MyCatlangS, langS.getItemText(langS.getSelectedIndex()));
        }
    });
    langT.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            MyCatCookies.updateCookie(CookiesNamespace.MyCatlangT, langT.getItemText(langT.getSelectedIndex()));
        }
    });
    sortBy.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            MyCatCookies.updateCookie(CookiesNamespace.SortBy, SORT_BY_Eff[sortBy.getSelectedIndex()]);
        }
    });
    help.addListener(Events.OnClick, new Listener<BaseEvent>() {
        @Override
        public void handleEvent(BaseEvent be) {
            Window.open(GuiConstant.TA_HELP_URL, "", GuiConstant.W_OPEN_FEATURES);
        }
    });
    if (GuiConstant.CHOOSE_GUI_LANG) {
        langInterface.addChangeHandler(new ChangeHandler() {
            @Override
            public void onChange(ChangeEvent event) {
                MyCatCookies.updateCookie(CookiesNamespace.InterfaceLanguage,
                        INT_LANG[langInterface.getSelectedIndex()]);
                Window.Location.reload();
            }
        });
    }
    if ((!GuiConstant.LOGO_PATH.isEmpty()) && (!GuiConstant.LOGO_PATH.isEmpty())) {
        im.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                Window.open(GuiConstant.LOGO_URL, "", GuiConstant.W_OPEN_FEATURES);
            }
        });
    }
    feedback.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            mailto(GuiConstant.FEEDBACK_MAIL.substring(GuiConstant.FEEDBACK_MAIL.lastIndexOf("|") + 1),
                    "Feedback about " + GuiConstant.TEXT_ALIGNER_LBL);
        }
    });
}