Example usage for com.google.gwt.user.client.ui Widget getAbsoluteTop

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

Introduction

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

Prototype

public int getAbsoluteTop() 

Source Link

Document

Gets the object's absolute top position in pixels, as measured from the browser window's client area.

Usage

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

License:Apache License

/**
 * Pops up the fact selector.//from w ww.j  a v  a 2 s. com
 */
protected void showConditionSelector(final Widget w) {
    final FormStylePopup popup = new FormStylePopup("images/new_fact.gif", "Add a condition to the rule...");

    //
    // The list of facts
    //
    String[] facts = completions.getFactTypes();
    final ListBox factTypeBox = new ListBox();
    factTypeBox.addItem("Choose fact type...", "IGNORE");
    for (int i = 0; i < facts.length; i++) {
        factTypeBox.addItem(facts[i]);
    }
    factTypeBox.setSelectedIndex(0);
    if (facts.length > 0)
        popup.addAttribute("Fact", factTypeBox);
    factTypeBox.addChangeListener(new ChangeListener() {
        public void onChange(Widget w) {
            String s = factTypeBox.getItemText(factTypeBox.getSelectedIndex());
            if (!s.equals("IGNORE")) {
                addNewFact(s);
                popup.hide();
            }
        }
    });
    popup.setStyleName("ks-popups-Popup");

    //
    // The list of top level CEs
    //
    String ces[] = HumanReadable.CONDITIONAL_ELEMENTS;
    final ListBox ceBox = new ListBox();
    ceBox.addItem("Choose condition type...", "IGNORE");
    for (int i = 0; i < ces.length; i++) {
        String ce = ces[i];
        ceBox.addItem(HumanReadable.getCEDisplayName(ce), ce);
    }
    ceBox.setSelectedIndex(0);

    if (facts.length > 0)
        popup.addAttribute("Condition type", ceBox);
    ceBox.addChangeListener(new ChangeListener() {
        public void onChange(Widget w) {
            String s = ceBox.getValue(ceBox.getSelectedIndex());
            if (!s.equals("IGNORE")) {
                addNewCE(s);
                popup.hide();
            }
        }
    });

    //
    // The list of DSL sentences
    //
    if (completions.getDSLConditions().length > 0) {
        final ListBox dsls = new ListBox();
        dsls.addItem("Choose...");
        for (int i = 0; i < completions.getDSLConditions().length; i++) {
            DSLSentence sen = completions.getDSLConditions()[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()));
                addNewDSLLhs((DSLSentence) completions.getDSLConditions()[idx]);
                popup.hide();
            }
        });
        popup.addAttribute("DSL sentence", dsls);
    }

    popup.setPopupPosition(w.getAbsoluteLeft() - 400, w.getAbsoluteTop());
    popup.show();

}

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

License:Apache License

/**
 * This adds the widget to the UI, also adding the remove icon.
 *//*from www .  ja  v a 2s  .c o m*/
private Widget wrapLHSWidget(final RuleModel model, int i, Widget w) {
    DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();

    Image remove = new ImageButton("images/delete_item_small.gif");
    remove.setTitle("Remove this ENTIRE condition, and all the field constraints that belong to it.");
    final int idx = i;
    remove.addClickListener(new ClickListener() {
        public void onClick(Widget w) {
            YesNoDialog diag = new YesNoDialog("Remove this entire condition?", new Command() {
                public void execute() {
                    if (model.removeLhsItem(idx)) {
                        refreshWidget();
                    } else {
                        ErrorPopup.showMessage(
                                "Can't remove that item as it is used in the action part of the rule.");
                    }
                }
            });
            diag.setPopupPosition(w.getAbsoluteLeft(), w.getAbsoluteTop());
            diag.show();
        }
    });

    horiz.setWidth("100%");
    w.setWidth("100%");

    horiz.add(w);
    horiz.add(remove);

    return horiz;
}

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);//from ww w  .  j  a va 2s  .  c  o m
        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

protected void showStatusChanger(Widget w) {
    final StatusChangePopup pop = new StatusChangePopup(conf.uuid, true);
    pop.setChangeStatusEvent(new Command() {
        public void execute() {
            setState(pop.getState());// ww  w .j a v  a2s .co  m
        }
    });
    pop.setPopupPosition(w.getAbsoluteLeft(), w.getAbsoluteTop());
    pop.show();

}

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

License:Apache License

private Widget header() {

    final TextArea area = new TextArea();
    area.setWidth("100%");
    area.setVisibleLines(8);//from  w ww. j a v  a2  s  . co m

    area.setCharacterWidth(100);

    area.setText(this.conf.header);
    area.addChangeListener(new ChangeListener() {
        public void onChange(Widget w) {
            conf.header = area.getText();
            dirtyCommand.execute();
        }
    });

    HorizontalPanel panel = new HorizontalPanel();
    panel.add(area);

    VerticalPanel vert = new VerticalPanel();

    Image max = new Image("images/max_min.gif");
    max.addClickListener(new ClickListener() {
        public void onClick(Widget w) {
            if (area.getVisibleLines() != 32) {
                area.setVisibleLines(32);
            } else {
                area.setVisibleLines(8);
            }
        }
    });
    max.setTitle("Increase view area.");
    vert.add(max);

    Image newImport = new Image("images/new_import.gif");
    newImport.addClickListener(new ClickListener() {
        public void onClick(Widget w) {
            area.setText(area.getText() + "\n" + "import <your class here>");
            conf.header = area.getText();
        }
    });
    vert.add(newImport);
    newImport.setTitle("Add a new Type/Class import to the package.");

    Image newGlobal = new Image("images/new_global.gif");
    newGlobal.addClickListener(new ClickListener() {
        public void onClick(Widget w) {
            area.setText(area.getText() + "\n" + "global <your class here> <variable name>");
            conf.header = area.getText();
        }
    });
    newGlobal.setTitle("Add a new global variable declaration.");
    vert.add(newGlobal);

    Image newFactTemplate = new Image("images/fact_template.gif");
    newFactTemplate.addClickListener(new ClickListener() {
        public void onClick(Widget w) {
            final FactTemplateWizard wiz = new FactTemplateWizard();
            wiz.setPopupPosition(w.getAbsoluteLeft() - 400, w.getAbsoluteTop() - 250);
            wiz.setOKClick(new Command() {
                public void execute() {
                    area.setText(area.getText() + "\n" + wiz.getTemplateText());
                    conf.header = area.getText();

                }
            });
            wiz.show();
        }
    });
    newFactTemplate.setTitle("Add a new fact template.");
    //vert.add( newFactTemplate );

    panel.setWidth("100%");

    panel.add(vert);
    return panel;
}

From source file:org.drools.brms.client.ruleeditor.ActionToolbar.java

License:Apache License

/**
 * Called when user wants to checkin./*from  www .j a  v a2 s  . co m*/
 */
protected void doCheckinConfirm(Widget w) {

    final CheckinPopup pop = new CheckinPopup(w.getAbsoluteLeft(), w.getAbsoluteTop(), "Check in changes.");
    pop.setCommand(new Command() {

        public void execute() {
            metaData.checkinComment = pop.getCheckinComment();
            checkinAction.execute();
        }
    });
    pop.show();
}

From source file:org.drools.brms.client.ruleeditor.ActionToolbar.java

License:Apache License

/**
 * Show the stats change popup./*from   ww w . j  av a 2s . co  m*/
 */
private void showStatusChanger(Widget w) {
    final StatusChangePopup pop = new StatusChangePopup(uuid, false);
    pop.setChangeStatusEvent(new Command() {
        public void execute() {
            setState(pop.getState());
        }
    });
    pop.setPopupPosition(w.getAbsoluteLeft(), w.getAbsoluteTop());
    pop.show();
}

From source file:org.drools.brms.client.ruleeditor.VersionViewer.java

License:Apache License

private void restore(Widget w) {

    final CheckinPopup pop = new CheckinPopup(w.getAbsoluteLeft() + 10, w.getAbsoluteTop() + 10,
            "Restore this version?");
    pop.setCommand(new Command() {
        public void execute() {
            RepositoryServiceFactory.getService().restoreVersion(versionUUID, headUUID, pop.getCheckinComment(),
                    new GenericCallback() {
                        public void onSuccess(Object data) {
                            hide();/*ww w  . j av  a2s . com*/
                            refresh.execute();
                        }
                    });
        }
    });
    pop.show();
}

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

License:Apache License

protected void showAddFieldPopup(Widget w) {

    final SuggestionCompletionEngine completions = this.getModeller().getSuggestionCompletions();

    final FormStylePopup popup = new FormStylePopup(DroolsGuvnorImages.INSTANCE.Wizard(),
            Constants.INSTANCE.ChooseAMethodToInvoke());
    final ListBox box = new ListBox();
    box.addItem("...");

    for (int i = 0; i < fieldCompletionTexts.length; i++) {
        box.addItem(fieldCompletionTexts[i], fieldCompletionValues[i]);
    }/*from   www .j  a va2s .c  om*/

    box.setSelectedIndex(0);

    popup.addAttribute(Constants.INSTANCE.ChooseAMethodToInvoke(), box);
    box.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            model.state = ActionCallMethod.TYPE_DEFINED;

            String methodName = box.getItemText(box.getSelectedIndex());
            String methodNameWithParams = box.getValue(box.getSelectedIndex());

            model.methodName = methodName;
            List<String> fieldList = new ArrayList<String>();

            fieldList.addAll(completions.getMethodParams(variableClass, methodNameWithParams));

            int i = 0;
            for (String fieldParameter : fieldList) {
                model.addFieldValue(new ActionFieldFunction(methodName, String.valueOf(i), fieldParameter));
                i++;
            }

            getModeller().refreshWidget();
            popup.hide();
        }
    });
    popup.setPopupPosition(w.getAbsoluteLeft(), w.getAbsoluteTop());
    popup.show();

}

From source file:org.drools.guvnor.client.ruleeditor.ActionToolbar.java

License:Apache License

/**
 * Called when user wants to checkin.// w  w  w.  ja  v  a  2  s.  c om
 */
protected void doCheckinConfirm(Widget w) {
    final CheckinPopup pop = new CheckinPopup(w.getAbsoluteLeft(), w.getAbsoluteTop(), "Check in changes.");
    pop.setCommand(new Command() {
        public void execute() {
            checkinAction.doCheckin(pop.getCheckinComment());
            if (afterCheckinEvent != null)
                afterCheckinEvent.execute();
        }
    });
    pop.show();
}