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

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

Introduction

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

Prototype

public static int getClientWidth() 

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.//  w ww .  j ava  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  w  ww.ja v  a2 s . c om*/
    // 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 Widget warnings() {
    if (this.previousResponse != null && this.previousResponse.hasErrors) {
        Image img = new Image("images/warning.gif");
        HorizontalPanel h = new HorizontalPanel();
        h.add(img);//  w  w  w  . j av a  2 s . c om
        HTML msg = new HTML("<b>There were errors validating this package configuration.");
        h.add(msg);
        Button show = new Button("View errors");
        show.addClickListener(new ClickListener() {
            public void onClick(Widget w) {
                ValidationMessageWidget wid = new ValidationMessageWidget(previousResponse.errorHeader,
                        previousResponse.errorMessage);
                wid.setPopupPosition(Window.getClientWidth() / 4, w.getAbsoluteTop());
                wid.show();
            }
        });
        h.add(show);
        return h;
    } else {
        return new SimplePanel();
    }
}

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();/*w  w w  . j  a  va 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.
 *///from   ww w  .ja v  a  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

/**
 * Width of pop-up, 1/4 of the client width or MIN_WIDTH
 * // w w  w.j a va 2s  . com
 * @return
 */
protected int getChoicesWidth() {
    int w = Window.getClientWidth() / 4;
    if (w < MIN_WIDTH) {
        w = MIN_WIDTH;
    }
    return w;
}

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.jav  a2s .  c  om
                }
            });

            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

/**
 * Width of pop-up, 75% of the client width or MIN_WIDTH
 * //w w  w .j a v  a 2s . c o  m
 * @return
 */
private int getPopupWidth() {
    int w = (int) (Window.getClientWidth() * 0.75);
    if (w < MIN_WIDTH) {
        w = MIN_WIDTH;
    }
    return w;
}

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

License:Apache License

/**
 * Width of pop-up, 50% of the client width or MIN_WIDTH
 * //  w w  w . j a v  a 2  s  . c o m
 * @return
 */
private int getPopupWidth() {
    int w = (int) (Window.getClientWidth() * 0.50);
    if (w < MIN_WIDTH) {
        w = MIN_WIDTH;
    }
    return w;
}

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  va  2s .  c  om*/
                }
            });
            HorizontalPanel pnlClose = new HorizontalPanel();
            pnlClose.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
            pnlClose.add(close);
            popUp.addAttribute("", pnlClose);

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