Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010 JBoss Inc
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package org.drools.workbench.screens.testscenario.client;
 
 import java.util.List;
 
 
 
     private final ScenarioParentWidget scenarioWidget;
     private final PackageDataModelOracle dmo;
 
     private final String[] availableRules;
 
     private boolean showResults;
     private Scenario scenario;
     private String packageName;
 
     protected ScenarioWidgetComponentCreator(String packageName,
                                              ScenarioParentWidget scenarioWidget,
                                              PackageDataModelOracle dmo,
                                              String[] availableRules) {
         this. = scenarioWidget;
         this. = packageName;
         this. = dmo;
         this. = availableRules;
     }
 
     protected GlobalPanel createGlobalPanel(ScenarioHelper scenarioHelperExecutionTrace previousExecutionTrace) {
         return new GlobalPanel(
                 scenarioHelper.lumpyMapGlobals(getScenario().getGlobals()),
                 getScenario(),
                 previousExecutionTrace,
                 this.,
                 this.);
     }
 
     protected HorizontalPanel createHorizontalPanel() {
         HorizontalPanel h = new HorizontalPanel();
         h.add(new GlobalButton(getScenario(), this.));
         h.add(new SmallLabel(..globals()));
         return h;
     }
 
     protected SmallLabel createSmallLabel() {
         return new SmallLabel(..configuration());
     }
 
     protected ConfigWidget createConfigWidget() {
         return new ConfigWidget(getScenario(), this);
     }
 
     protected AddExecuteButton createAddExecuteButton() {
         return new AddExecuteButton(getScenario(), this.);
     }
 
     protected VerifyRulesFiredWidget createVerifyRulesFiredWidget(FixtureList fixturesList) {
         return new VerifyRulesFiredWidget(fixturesListgetScenario(), isShowResults());
     }
 
     protected VerifyFactsPanel createVerifyFactsPanel(List<ExecutionTracelistExecutionTraceint executionTraceLineFixtureList fixturesList) {
         return new VerifyFactsPanel(fixturesListlistExecutionTrace.get(executionTraceLine), getScenario(), this.isShowResults(), );
    }
    protected CallMethodLabelButton createCallMethodLabelButton(List<ExecutionTracelistExecutionTraceint executionTraceLineExecutionTrace previousExecutionTrace) {
        return new CallMethodLabelButton(previousExecutionTracegetScenario(), listExecutionTrace.get(executionTraceLine), this.);
    }
    protected GivenLabelButton createGivenLabelButton(List<ExecutionTracelistExecutionTraceint executionTraceLineExecutionTrace previousExecutionTrace) {
        return new GivenLabelButton(previousExecutionTracegetScenario(), listExecutionTrace.get(executionTraceLine), this.);
    }
    protected ExecutionWidget createExecutionWidget(ExecutionTrace currentExecutionTrace) {
        return new ExecutionWidget(currentExecutionTraceisShowResults());
    }
    protected ExpectPanel createExpectPanel(ExecutionTrace currentExecutionTrace) {
        return new ExpectPanel(currentExecutionTracegetScenario(), this.this);
    }
        DirtyableFlexTable editorLayout = new DirtyableFlexTable();
        editorLayout.clear();
        editorLayout.setWidth("100%");
        editorLayout.setStyleName("model-builder-Background");
        return editorLayout;
    }
    protected Widget createGivenPanel(List<ExecutionTracelistExecutionTraceint executionTraceLineFixturesMap given) {
        if (given.size() > 0) {
            return new GivenPanel(
                    listExecutionTrace,
                    executionTraceLine,
                    given,
                    getScenario(),
                    this.,
                    this.);
        } else {
            return new HTML("<i><small>" + ..AddInputDataAndExpectationsHere() + "</small></i>");
        }
    }
    protected Widget createCallMethodOnGivenPanel(List<ExecutionTracelistExecutionTraceint executionTraceLineCallFixtureMap given) {
        if (given.size() > 0) {
            return new CallMethodOnGivenPanel(listExecutionTraceexecutionTraceLinegivengetScenario(), this.);
        } else {
            return new HTML("<i><small>" + ..AddInputDataAndExpectationsHere() + "</small></i>");
        }
    }
    protected TextBox createRuleNameTextBox() {
        final TextBox ruleNameTextBox = new TextBox();
        return ruleNameTextBox;
    }
    protected Button createOkButton(final RuleSelectionEvent selectedfinal TextBox ruleNameTextBox) {
        Button ok = new Button(..OK());
        ok.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                selected.ruleSelected(ruleNameTextBox.getText());
            }
        });
        return ok;
    }
    protected ChangeHandler createRuleChangeHandler(final TextBox ruleNameTextBoxfinal ListBox availableRulesBox) {
        final ChangeHandler ruleSelectionCL = new ChangeHandler() {
            public void onChange(ChangeEvent event) {
                ruleNameTextBox.setText(availableRulesBox.getItemText(availableRulesBox.getSelectedIndex()));
            }
        };
        return ruleSelectionCL;
    }
    protected ListBox createAvailableRulesBox(String[] list) {
        final ListBox availableRulesBox = new ListBox();
        availableRulesBox.addItem(..pleaseChoose1());
        for (int i = 0; i < list.lengthi++) {
            availableRulesBox.addItem(list[i]);
        }
        return availableRulesBox;
    }
    public void setShowResults(boolean showResults) {
        this. = showResults;
    }
    public boolean isShowResults() {
        return this.;
    }
    public Scenario getScenario() {
        return ;
    }
    public void setScenario(Scenario scenario) {
        this. = scenario;
    }
    public Widget getRuleSelectionWidget(final RuleSelectionEvent selected) {
        final HorizontalPanel horizontalPanel = new HorizontalPanel();
        final TextBox ruleNameTextBox = createRuleNameTextBox();
        horizontalPanel.add(ruleNameTextBox);
        if ( != null) {
            final ListBox availableRulesBox = createAvailableRulesBox();
            availableRulesBox.setSelectedIndex(0);
            if ( != null) {
                .removeHandler();
            }
            final ChangeHandler ruleSelectionCL = createRuleChangeHandler(ruleNameTextBox,
                    availableRulesBox);
             = availableRulesBox.addChangeHandler(ruleSelectionCL);
            horizontalPanel.add(availableRulesBox);
        } else {
            final Button showList = new Button(..showListButton());
            horizontalPanel.add(showList);
            showList.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    horizontalPanel.remove(showList);
                    final Image busy = new Image(..searching());
                    final Label loading = new SmallLabel(..loadingList1());
                    horizontalPanel.add(busy);
                    horizontalPanel.add(loading);
//                    Scheduler scheduler = Scheduler.get();
//                    scheduler.scheduleDeferred(new Command() {
//                        public void execute() {
//                            ModuleServiceAsync moduleService = GWT.create(ModuleService.class);
//                            moduleService.listRulesInPackage(packageName,
//                                    createGenericCallback(horizontalPanel,
//                                            ruleNameTextBox,
//                                            busy,
//                                            loading));
//                        }
//                        private GenericCallback<String[]> createGenericCallback(final HorizontalPanel horizontalPanel,
//                                                                                final TextBox ruleNameTextBox,
//                                                                                final Image busy,
//                                                                                final Label loading) {
//                            return new GenericCallback<String[]>() {
//
//                                public void onSuccess(String[] list) {
//                                    availableRules = (list);
//                                    final ListBox availableRulesBox = scenarioWidgetComponentCreator.createAvailableRulesBox(list);
//
//                                    final ChangeHandler ruleSelectionCL = new ChangeHandler() {
//                                        public void onChange(ChangeEvent event) {
//                                            ruleNameTextBox.setText(availableRulesBox.getItemText(availableRulesBox.getSelectedIndex()));
//                                        }
//                                    };
//                                    availableRulesHandlerRegistration = availableRulesBox.addChangeHandler(ruleSelectionCL);
//                                    availableRulesBox.setSelectedIndex(0);
//                                    horizontalPanel.add(availableRulesBox);
//                                    horizontalPanel.remove(busy);
//                                    horizontalPanel.remove(loading);
//                                }
//
//                            };
//                        }
//                    });
                }
            });
        }
        Button ok = createOkButton(selected,
                ruleNameTextBox);
        horizontalPanel.add(ok);
        return horizontalPanel;
    }
New to GrepCode? Check out our FAQ X