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

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

Introduction

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

Prototype

public static int getClientHeight() 

Source Link

Usage

From source file:org.daxplore.presenter.embed.EmbedEntryPoint.java

License:Open Source License

/**
 * This is the entry point method. It is automatically called by GWT to
 * create the embed web page.//ww w  . jav a  2  s . c om
 */
@Override
public void onModuleLoad() {
    QuestionMetadata questions = injector.getQuestions();
    String queryString = Window.Location.getParameter("q");
    QueryDefinition queryDefinition = new QueryDefinition(questions, queryString);
    ChartFactory chartFactory = injector.getChartFactory();

    String href = Window.Location.getHref();
    EmbedDefinition embedDefinition;
    if (href.contains("#")) {
        String base64 = href.substring(href.lastIndexOf("#") + 1);
        embedDefinition = new EmbedDefinition(base64);
    } else {
        LinkedList<EmbedFlag> emptyDefaultList = new LinkedList<EmbedFlag>();
        embedDefinition = new EmbedDefinition(emptyDefaultList);
    }

    try {
        ChartDataParserClient queryData = ChartDataParserClient.getEmbeddedData();
        GChartChart chart;
        boolean printMode = embedDefinition.hasFlag(EmbedFlag.PRINT);
        if (!queryDefinition.hasFlag(QueryFlag.SECONDARY)) {
            chart = chartFactory.createBarChart(queryDefinition, printMode);
            ((BarChart) chart)
                    .addData(new QueryResultCount(queryData.getDataItems(), queryData.getTotalDataItem()));
        } else {
            chart = chartFactory.createBarChartCompare(queryDefinition, printMode);
            ((BarChartCompare) chart).addData(
                    new QueryResultCountCompare(queryData.getDataItems(), queryData.getTotalDataItem()));
        }
        EmbedView embedView = new EmbedView(chart, Window.getClientWidth(), Window.getClientHeight(),
                embedDefinition);
        RootPanel.get().add(embedView);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.drools.brms.client.modeldriven.ui.RuleModeller.java

License:Apache License

protected void showActionSelector(Widget w) {
    final FormStylePopup popup = new FormStylePopup("images/new_fact.gif", "Add a new action...");

    popup.setStyleName("ks-popups-Popup");

    ///*from ww w  . j av  a  2 s  .  co  m*/
    // First load up the stuff to do with bound variables or globals
    //
    List vars = model.getBoundFacts();
    final ListBox varBox = new ListBox();
    final ListBox retractBox = new ListBox();
    final ListBox modifyBox = new ListBox();
    varBox.addItem("Choose ...");
    retractBox.addItem("Choose ...");
    modifyBox.addItem("Choose ...");
    for (Iterator iter = vars.iterator(); iter.hasNext();) {
        String v = (String) iter.next();
        varBox.addItem(v);
        retractBox.addItem(v);
        modifyBox.addItem(v);
    }
    String[] globals = this.completions.getGlobalVariables();
    for (int i = 0; i < globals.length; i++) {
        varBox.addItem(globals[i]);
    }

    varBox.setSelectedIndex(0);
    varBox.addChangeListener(new ChangeListener() {
        public void onChange(Widget w) {
            addActionSetField(varBox.getItemText(varBox.getSelectedIndex()));
            popup.hide();
        }
    });

    retractBox.addChangeListener(new ChangeListener() {
        public void onChange(Widget w) {
            addRetract(retractBox.getItemText(retractBox.getSelectedIndex()));
            popup.hide();
        }
    });

    modifyBox.addChangeListener(new ChangeListener() {
        public void onChange(Widget w) {
            addModify(modifyBox.getItemText(modifyBox.getSelectedIndex()));
            popup.hide();
        }
    });

    if (varBox.getItemCount() > 1) {
        popup.addAttribute("Set the values of a field on", varBox);
    }

    if (modifyBox.getItemCount() > 1) {
        HorizontalPanel horiz = new HorizontalPanel();
        horiz.add(modifyBox);
        Image img = new Image("images/information.gif");
        img.setTitle("Modify a field on a fact, and notify the engine to re-evaluate rules.");
        horiz.add(img);
        popup.addAttribute("Modify a fact", horiz);
    }

    //popup.addRow( new HTML("<hr/>") );

    if (retractBox.getItemCount() > 1) {
        popup.addAttribute("Retract the fact", retractBox);
    }

    //popup.addRow( new HTML("<hr/>") );

    final ListBox factsToAssert = new ListBox();
    final ListBox factsToLogicallyAssert = new ListBox();
    factsToAssert.addItem("Choose ...");
    factsToLogicallyAssert.addItem("Choose ...");
    for (int i = 0; i < completions.getFactTypes().length; i++) {
        String item = completions.getFactTypes()[i];
        factsToAssert.addItem(item);
        factsToLogicallyAssert.addItem(item);
    }

    factsToAssert.addChangeListener(new ChangeListener() {
        public void onChange(Widget w) {
            String fact = factsToAssert.getItemText(factsToAssert.getSelectedIndex());
            model.addRhsItem(new ActionInsertFact(fact));
            refreshWidget();
            popup.hide();

        }
    });

    factsToLogicallyAssert.addChangeListener(new ChangeListener() {
        public void onChange(Widget w) {
            String fact = factsToLogicallyAssert.getItemText(factsToLogicallyAssert.getSelectedIndex());
            model.addRhsItem(new ActionInsertLogicalFact(fact));
            refreshWidget();
            popup.hide();

        }
    });

    if (factsToAssert.getItemCount() > 1) {
        popup.addAttribute("Insert a new fact", factsToAssert);
        HorizontalPanel horiz = new HorizontalPanel();
        horiz.add(factsToLogicallyAssert);
        Image img = new Image("images/information.gif");
        img.setTitle(
                "Logically assert a fact - the fact will be retracted when the supporting evidence is removed.");
        horiz.add(img);
        popup.addAttribute("Logically insert a new fact", horiz);
    }

    //
    // The list of DSL sentences
    //
    if (completions.getDSLActions().length > 0) {
        final ListBox dsls = new ListBox();
        dsls.addItem("Choose...");
        for (int i = 0; i < completions.getDSLActions().length; i++) {
            DSLSentence sen = (DSLSentence) completions.getDSLActions()[i];
            dsls.addItem(sen.toString(), Integer.toString(i));
        }

        dsls.addChangeListener(new ChangeListener() {
            public void onChange(Widget w) {
                int idx = Integer.parseInt(dsls.getValue(dsls.getSelectedIndex()));
                addNewDSLRhs((DSLSentence) completions.getDSLActions()[idx]);
                popup.hide();
            }
        });
        popup.addAttribute("DSL sentence", dsls);
    }

    popup.setPopupPosition(Window.getClientWidth() / 3, Window.getClientHeight() / 3);
    popup.show();
}

From source file:org.drools.brms.client.packages.PackageEditor.java

License:Apache License

private void showRenameDialog() {
    final FormStylePopup pop = new FormStylePopup("images/new_wiz.gif", "Rename the package");
    pop.addRow(new HTML("<i>Rename the package. A new unique name is required.</i>"));
    final TextBox name = new TextBox();
    pop.addAttribute("New package name:", name);
    Button ok = new Button("OK");
    pop.addAttribute("", ok);

    ok.addClickListener(new ClickListener() {
        public void onClick(Widget w) {
            RepositoryServiceFactory.getService().renamePackage(conf.uuid, name.getText(),
                    new GenericCallback() {
                        public void onSuccess(Object data) {
                            refreshCommand.execute();
                            Window.alert("Package renamed successfully.");
                            pop.hide();//from   w  ww. j a  v a 2 s  .  c o  m
                        }
                    });
        }
    });

    pop.setWidth("40%");
    pop.setPopupPosition(Window.getClientWidth() / 3, Window.getClientHeight() / 3);
    pop.show();
}

From source file:org.drools.brms.client.packages.PackageEditor.java

License:Apache License

/**
 * Will show a copy dialog for copying the whole package.
 *//*  w w w.j a va 2s.  c o  m*/
private void showCopyDialog() {
    final FormStylePopup pop = new FormStylePopup("images/new_wiz.gif", "Copy the package");
    pop.addRow(new HTML("<i>Copy the package and all its assets. A new unique name is required.</i>"));
    final TextBox name = new TextBox();
    pop.addAttribute("New package name:", name);
    Button ok = new Button("OK");
    pop.addAttribute("", ok);

    ok.addClickListener(new ClickListener() {
        public void onClick(Widget w) {
            RepositoryServiceFactory.getService().copyPackage(conf.name, name.getText(), new GenericCallback() {
                public void onSuccess(Object data) {
                    refreshCommand.execute();
                    Window.alert("Package copied successfully.");
                    pop.hide();
                }
            });
        }
    });

    pop.setWidth("40%");
    pop.setPopupPosition(Window.getClientWidth() / 3, Window.getClientHeight() / 3);
    pop.show();

}

From source file:org.drools.guvnor.client.asseteditor.drools.modeldriven.ui.AbstractRuleModellerSelectorPopup.java

License:Apache License

/**
 * Height of pop-up, 1/2 of the client height or MIN_HEIGHT
 * //w ww  . jav a 2s  .  c o m
 * @return
 */
protected int getChoicesHeight() {
    int h = Window.getClientHeight() / 2;
    if (h < MIN_HEIGHT) {
        h = MIN_HEIGHT;
    }
    return h;
}

From source file:org.drools.guvnor.client.asseteditor.drools.modeldriven.ui.templates.RuleTemplateEditor.java

License:Apache License

public RuleTemplateEditor(final Asset asset, final RuleViewer viewer, final ClientFactory clientFactory,
        final EventBus globalEventBus) {

    this.globalEventBus = globalEventBus;
    this.model = (TemplateModel) asset.getContent();
    this.ruleModeller = new RuleModeller(asset, null, clientFactory, eventBus,
            new TemplateModellerWidgetFactory());

    String packageName = asset.getMetaData().getModuleName();
    this.sce = SuggestionCompletionCache.getInstance().getEngineFromCache(packageName);

    final VerticalPanel tPanel = new VerticalPanel();
    tPanel.setWidth("100%");

    tPanel.add(new Button(Constants.INSTANCE.LoadTemplateData(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            int height = (int) (Window.getClientHeight() * 0.7);
            int width = (int) (Window.getClientWidth() * 0.7);

            final FormStylePopup popUp = new FormStylePopup(null, Constants.INSTANCE.TemplateData(), width);

            //Initialise table to edit data
            table = new TemplateDataTableWidget(model, sce, asset.isReadonly(), eventBus);
            table.setPixelSize(width, height);
            popUp.addAttribute("", table);

            Button btnOK = new Button(ConstantsCore.INSTANCE.OK(), new ClickHandler() {
                public void onClick(ClickEvent event) {
                    popUp.hide();/*from  ww  w  . j  ava2 s  . co  m*/
                }
            });

            Button btnAddRow = new Button(Constants.INSTANCE.AddRow(), new ClickHandler() {

                public void onClick(ClickEvent event) {
                    table.appendRow();
                }

            });

            HorizontalPanel pnlClose = new HorizontalPanel();
            pnlClose.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
            pnlClose.add(btnOK);
            pnlClose.add(btnAddRow);
            popUp.addAttribute("", pnlClose);

            popUp.show();
        }
    }));
    tPanel.add(ruleModeller);
    initWidget(tPanel);
}

From source file:org.drools.guvnor.client.decisiontable.AbstractBRLColumnViewImpl.java

License:Apache License

/**
 * Height of pop-up, 75% of the client height or MIN_HEIGHT
 * /*www  .j ava 2s  . c  o  m*/
 * @return
 */
protected int getPopupHeight() {
    int h = (int) (Window.getClientHeight() * 0.75);
    if (h < MIN_HEIGHT) {
        h = MIN_HEIGHT;
    }
    return h;
}

From source file:org.drools.guvnor.client.decisiontable.widget.auditlog.AuditLogViewImpl.java

License:Apache License

/**
 * Height of pop-up, 50% of the client height or MIN_HEIGHT
 * //from  w w  w.  ja va 2  s . com
 * @return
 */
protected int getPopupHeight() {
    int h = (int) (Window.getClientHeight() * 0.50);
    if (h < MIN_HEIGHT) {
        h = MIN_HEIGHT;
    }
    return h;
}

From source file:org.drools.guvnor.client.modeldriven.ui.RuleTemplateEditor.java

License:Apache License

public RuleTemplateEditor(RuleAsset asset) {
    model = (TemplateModel) asset.content;

    final VerticalPanel tPanel = new VerticalPanel();
    tPanel.setWidth("100%");
    ruleModeller = new RuleModeller(asset, new TemplateModellerWidgetFactory());

    tPanel.add(new Button(constants.LoadTemplateData(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            final FormStylePopup popUp = new FormStylePopup(null, constants.TemplateData(),
                    (int) (Window.getClientWidth() * 0.8));
            popUp.setHeight(((int) (Window.getClientHeight() * 0.8)) + "px");
            popUp.addAttribute("", buildTemplateTable());
            Button close = new Button(constants.Close(), new ClickHandler() {
                public void onClick(ClickEvent event) {
                    popUp.hide();/*w  ww  .  j  a v a  2  s .  c o  m*/
                }
            });
            HorizontalPanel pnlClose = new HorizontalPanel();
            pnlClose.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
            pnlClose.add(close);
            popUp.addAttribute("", pnlClose);

            popUp.show();
        }
    }));
    tPanel.add(ruleModeller);
    initWidget(tPanel);
}

From source file:org.drools.guvnor.client.moduleeditor.drools.PackageBuilderWidget.java

License:Apache License

/**
 * Popup the view source dialog, showing the given content.
 */// w  w  w . j  av  a2s  .  c  om
public static void showSource(final String content, String name) {
    int windowWidth = Window.getClientWidth() / 2;
    int windowHeight = Window.getClientHeight() / 2;
    Image image = new Image(DroolsGuvnorImageResources.INSTANCE.viewSource());
    image.setAltText(Constants.INSTANCE.ViewSource());
    final FormStylePopup pop = new FormStylePopup(image, Constants.INSTANCE.ViewingSourceFor0(name),
            windowWidth);

    String[] rows = content.split("\n");

    FlexTable table = new FlexTable();
    for (int i = 0; i < rows.length; i++) {

        table.setHTML(i, 0, "<span style='color:grey;'>" + (i + 1) + ".</span>");
        table.setHTML(i, 1, "<span style='color:green;' >|</span>");
        table.setHTML(i, 2, addSyntaxHilights(rows[i]));
    }

    ScrollPanel scrollPanel = new ScrollPanel(table);

    scrollPanel.setHeight(windowHeight + "px");
    scrollPanel.setWidth(windowWidth + "px");

    pop.addRow(scrollPanel);

    LoadingPopup.close();

    pop.show();

}