Example usage for com.google.gwt.event.logical.shared SelectionEvent getSelectedItem

List of usage examples for com.google.gwt.event.logical.shared SelectionEvent getSelectedItem

Introduction

In this page you can find the example usage for com.google.gwt.event.logical.shared SelectionEvent getSelectedItem.

Prototype

public T getSelectedItem() 

Source Link

Document

Gets the selected item.

Usage

From source file:org.openelis.modules.quickEntry.client.QuickEntryScreenUI.java

License:Open Source License

private void entryChanged() {
    int index;/*from   w w w. ja v a2s  . c om*/
    final Date recDate;
    Exception ex;
    Integer accessionNum;
    SampleManager1 sampleMan;
    SampleManagerRowCount smRowCount;
    String val;
    SystemVariableDO sysVarDO;

    val = entry.getValue();
    window.clearStatus();

    try {
        recDate = DateTimeFormat.getFormat(Messages.get().dateTimePattern()).parseStrict(val);
        if (todaysDate.after(recDate)) {
            ex = new Exception(Messages.get().receivedDateNotTodayExceptionBody(
                    DateTimeFormat.getFormat(Messages.get().dateTimePattern()).format(recDate)));
            receivedDateNotTodayConfirm = new Confirm(Confirm.Type.QUESTION,
                    Messages.get().receivedDateNotTodayExceptionTitle(), ex.getMessage(), "No", "Yes");
            receivedDateNotTodayConfirm.addSelectionHandler(new SelectionHandler<Integer>() {
                public void onSelection(SelectionEvent<Integer> event) {
                    switch (event.getSelectedItem().intValue()) {
                    case 0:
                        // do nothing
                        break;
                    case 1:
                        receivedDate.setValue(new Datetime(Datetime.YEAR, Datetime.MINUTE, recDate));
                        break;
                    }
                }
            });
            receivedDateNotTodayConfirm.show();
        } else {
            receivedDate.setValue(new Datetime(Datetime.YEAR, Datetime.MINUTE, recDate));
        }
    } catch (IllegalArgumentException iaE) {
        // ignore and fall through
        if (val.matches("[TP][0-9]*\\-[0-9]*")) { // test & panel
            try {
                testMethodSampleType.setValue(val, true);
            } catch (Exception e) {
                ex = new Exception(Messages.get().sample_invalidEntryException(val));
                window.setError(ex.getMessage());
            }
        } else if (val.matches("[a-zA-Z]{3}[0-9]{3}")) { // tube #
            tubeNumber.setValue(val);
        } else if (val.matches("NEW")) { // new accession #
            // TODO: Implement using the "NEW" keyword to get the next
            // accession
            // number for use when printing the labels on the fly
            Window.alert("Not yet implemented!");
            // if (validateFields()) {
            // if (accNumUtil == null)
            // accNumUtil = new AccessionNumberUtility();
            //
            // try {
            // accessionNum = accNumUtil.getNewAccessionNumber();
            // accessionNumber.setFieldValue(accessionNum);
            // addAnalysisRow();
            // } catch (ValidationErrorsList e) {
            // showErrors(e);
            // } catch (Exception e) {
            // Window.alert(e.getMessage());
            // }
            // }
        } else if (val.matches("[0-9]+") || val.matches("[0-9]+-[0-9]+")) { // accession
                                                                            // #
            if (validateFields()) {
                //
                // Trim the Sample Item ID from the end of the bar coded
                // accession number
                //
                index = val.indexOf("-");
                if (index != -1)
                    val = val.substring(0, index);

                try {
                    accessionNum = Integer.valueOf(val);
                    smRowCount = managers.get(accessionNum);
                    if (smRowCount == null) {
                        try {
                            sampleMan = SampleService1.get().fetchByAccession(accessionNum,
                                    (SampleManager1.Load[]) null);
                            if (Constants.dictionary().SAMPLE_RELEASED
                                    .equals(sampleMan.getSample().getStatusId()))
                                throw new InconsistencyException(Messages.get().sample_cantAddAnalysis());
                            sampleMan = SampleService1.get().fetchForUpdate(sampleMan.getSample().getId(),
                                    (SampleManager1.Load[]) null);
                        } catch (NotFoundException nfE) {
                            sysVarDO = SystemVariableService1Impl.INSTANCE
                                    .fetchByExactName("last_accession_number");
                            if (accessionNum.compareTo(Integer.valueOf(sysVarDO.getValue())) > 0)
                                throw new InconsistencyException(
                                        Messages.get().sample_accessionNumberNotInUse(accessionNum));
                            sampleMan = SampleService1.get().getInstance(Constants.domain().QUICKENTRY);
                            sampleMan.getSample().setAccessionNumber(accessionNum);
                            sampleMan.getSample().setReceivedDate(receivedDate.getValue());
                            sampleMan.getSample().setReceivedById(receivedBy.getValue().getId());
                        }
                        managers.put(sampleMan.getSample().getAccessionNumber(),
                                new SampleManagerRowCount(sampleMan, 0));
                    } else {
                        sampleMan = smRowCount.sampleManager;
                    }
                    accessionNumber.setValue(accessionNum);
                    addAnalysis();
                } catch (NumberFormatException e) {
                    ex = new Exception(Messages.get().invalidEntryException(val));
                    window.setError(ex.getMessage());
                } catch (InconsistencyException e) {
                    window.setError(e.getMessage());
                } catch (ValidationErrorsList e) {
                    int i;
                    FieldErrorException fe;
                    ValidationErrorsList newE;

                    newE = new ValidationErrorsList();

                    // convert all the field errors to form errors
                    for (i = 0; i < e.size(); i++) {
                        if (e.getErrorList().get(i) instanceof FieldErrorException) {
                            fe = (FieldErrorException) e.getErrorList().get(i);
                            newE.add(new FormErrorException(fe.getMessage()));
                        } else {
                            newE.add(e.getErrorList().get(i));
                        }
                    }
                    showErrors(newE);
                } catch (Exception e) {
                    Window.alert(e.getMessage());
                }
            }
        } else {
            ex = new Exception(Messages.get().invalidEntryException(val));
            window.setError(ex.getMessage());
        }
    }
    entry.setValue(null);
    /*
     * to set the focus back on the entry widget, a command must be
     * scheduled
     */
    Scheduler.get().scheduleDeferred(focusEntryCmd);
}

From source file:org.openelis.modules.sample1.client.AnalysisTabUI.java

License:Open Source License

private void setMethod(AutoCompleteValue value) {
    if (value == null) {
        /*//www  .  ja  v  a  2s.  co  m
         * if the user blanks the field, selecting nothing, the previous
         * method is put back in the autocomplete
         */
        method.setValue(getMethodId(), getMethodName());
        return;
    }

    /*
     * let the user know that changing the method may make them lose results
     * and change the method only if the user says yes
     */
    isBusy = true;
    if (changeMethodConfirm == null) {
        changeMethodConfirm = new Confirm(Confirm.Type.QUESTION, Messages.get().analysis_loseResultsCaption(),
                Messages.get().analysis_loseResultsWarning(), Messages.get().gen_no(),
                Messages.get().gen_yes());
        changeMethodConfirm.setWidth("300px");
        changeMethodConfirm.setHeight("150px");
        changeMethodConfirm.addSelectionHandler(new SelectionHandler<Integer>() {
            public void onSelection(com.google.gwt.event.logical.shared.SelectionEvent<Integer> event) {
                TestMethodVO data;

                switch (event.getSelectedItem().intValue()) {
                case 0:
                    method.setValue(getMethodId(), getMethodName());
                    break;
                case 1:
                    /*
                     * the argument passed to setMethod is not used here
                     * because it gets fixed for this confirm when the
                     * confirm is created, so if that value were to be
                     * used here, it will always be the same regardless
                     * of what gets passed to setMethod
                     */
                    data = (TestMethodVO) method.getValue().getData();
                    parentBus.fireEventFromSource(new AnalysisChangeEvent(displayedUid, data.getMethodId(),
                            AnalysisChangeEvent.Action.METHOD_CHANGED), screen);
                    break;
                }

                isBusy = false;
            }
        });
    }

    changeMethodConfirm.show();
}

From source file:org.opennms.features.poller.remote.gwt.client.FilterPanel.java

License:Open Source License

/**
 * <p>onApplicationSelect</p>
 *
 * @param event a {@link com.google.gwt.event.logical.shared.SelectionEvent} object.
 *//*w  w w  .  ja  v  a 2 s. co  m*/
@UiHandler("applicationNameSuggestBox")
public void onApplicationSelect(final SelectionEvent<Suggestion> event) {
    Suggestion item = event.getSelectedItem();
    m_eventBus.fireEvent(new ApplicationSelectedEvent(item.getReplacementString()));
}

From source file:org.opennms.features.topology.app.internal.gwt.client.VSearchBox.java

License:Open Source License

@Override
public void onLoad() {
    m_componentHolder.clear();//ww w . jav a 2 s  .c om
    this.setStyleName("topology-search");
    final TextBoxBase textField = new TextBox();
    textField.setWidth("245px");
    textField.setStyleName("topology-search-box");
    textField.getElement().setAttribute("placeholder", "Search...");
    textField.setFocus(true);
    RemoteSuggestOracle oracle = new RemoteSuggestOracle();

    m_suggestBox = new SuggestBox(oracle, textField);

    m_suggestBox.addSelectionHandler(new SelectionHandler<SuggestOracle.Suggestion>() {
        @Override
        public void onSelection(SelectionEvent<SuggestOracle.Suggestion> event) {
            SearchSuggestion selectedItem = (SearchSuggestion) event.getSelectedItem();
            textField.setText("");
            m_connector.addToFocus(selectedItem);
        }
    });

    if (m_isMultiValued) {
        m_suggestBox.setStyleName("multivalue");
    }

    m_suggestBox.addStyleName("wideTextField");
    m_suggestBox.addSelectionHandler(this);
    m_suggestBox.addKeyUpHandler(this);

    m_componentHolder.setWidth("245px");
    m_componentHolder.add(m_suggestBox);

    if (m_focusedContainer == null) {
        m_focusedContainer = new VerticalPanel();
        m_scrollContainer = new FlowPanel();
        m_scrollContainer.add(m_focusedContainer);

    }

    m_focusedContainer.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    m_focusedContainer.setTitle("Focused Vertices");
    m_componentHolder.add(m_scrollContainer);

    Timer timer = new Timer() {

        @Override
        public void run() {
            updateScrollPanelSize();
        }
    };

    timer.schedule(1000);

    m_windowResizeRegistration = Window.addResizeHandler(new ResizeHandler() {
        @Override
        public void onResize(ResizeEvent event) {
            updateScrollPanelSize();
        }
    });

}

From source file:org.opennms.features.topology.app.internal.gwt.client.VSearchBox.java

License:Open Source License

@Override
public void onSelection(SelectionEvent<SuggestOracle.Suggestion> event) {
    SuggestOracle.Suggestion suggestion = event.getSelectedItem();
}

From source file:org.opennms.gwt.web.ui.asset.client.tools.fieldsets.FieldSetSuggestBox.java

License:Open Source License

@Override
public void onSelection(SelectionEvent<Suggestion> event) {
    String selected = event.getSelectedItem().getReplacementString();
    ValueChangeEvent.fire(suggBox, selected);
    checkField();//  w  w  w . j av a  2  s . c  o m
}

From source file:org.openremote.modeler.client.widget.buildingmodeler.DiscoveredDevicesWizardWindow.java

License:Open Source License

@UiHandler(value = { "menuItemAll", "menuItemOnlyNew", "menuItemCreate", "menuItemExit", "menuEdit",
        "menuOptions" })
public void onMenuSelection(SelectionEvent<Item> event) {
    MenuItem item = (MenuItem) event.getSelectedItem();
    if (item.getText().equals("Exit wizard")) {
        this.hide();
    } else if (item.getText().equals("Create objects per device")) {
        oneDevicePerProtocol = false;//from  www.  jav a  2  s  .  com
    } else if (item.getText().equals("Create objects per protocol")) {
        oneDevicePerProtocol = true;
    } else if (item.getText().equals("Delete selected")) {
        deleteSelected();
    } else if (item.getText().equals("Show all")) {
        loadDiscoveredDevices(false);
    } else if (item.getText().equals("Show only new")) {
        loadDiscoveredDevices(true);
    } else if (item.getText().equals("Create selected devices")) {
        createDevices();
    }
}

From source file:org.openxdata.designer.client.CenterPanel.java

/**
 * @see com.google.gwt.event.logical.shared.SelectionHandler#onSelection(SelectionEvent)
 *///w ww .  ja  v a2 s .c  om
public void onSelection(SelectionEvent<Integer> event) {
    // register selection in history
    History.newItem(event.getSelectedItem().toString(), false);

    selectedTabIndex = event.getSelectedItem();

    if (selectedTabIndex == SELECTED_INDEX_DESIGN_SURFACE)
        Context.setCurrentMode(Context.MODE_DESIGN);
    else if (selectedTabIndex == SELECTED_INDEX_PREVIEW) {
        if (formDef != null && formDef.getQuestionCount() > 0 && !designSurfaceView.hasWidgets()) {
            tabs.selectTab(SELECTED_INDEX_DESIGN_SURFACE);

            Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                @Override
                public void execute() {
                    tabs.selectTab(SELECTED_INDEX_PREVIEW);

                }
            });
            return;
        }

        Context.setCurrentMode(Context.MODE_PREVIEW);
    } else if (selectedTabIndex == SELECTED_INDEX_PROPERTIES)
        Context.setCurrentMode(Context.MODE_QUESTION_PROPERTIES);
    else if (selectedTabIndex == SELECTED_INDEX_XFORMS_SOURCE)
        Context.setCurrentMode(Context.MODE_XFORMS_SOURCE);
    else
        Context.setCurrentMode(Context.MODE_NONE);

    if (selectedTabIndex == SELECTED_INDEX_PREVIEW) {
        if (formDef != null) {
            if (!previewView.isPreviewing())
                loadPreview();
            else
                previewView.moveToFirstWidget();
        }
    } else if (selectedTabIndex == SELECTED_INDEX_DESIGN_SURFACE) {
        if (!designSurfaceView.hasWidgets())
            designSurfaceView.refresh();
    }

    eventBus.fireEvent(new CenterPanelTabSelectedEvent(selectedTabIndex));
}

From source file:org.openxdata.designer.client.view.DesignSurfaceView.java

/**
 * @see com.google.gwt.event.logical.shared.SelectionHandler#onSelection(SelectionEvent)
 *///from  ww  w  .j a  v a2  s  . co  m
public void onSelection(SelectionEvent<Integer> event) {
    selectedTabIndex = event.getSelectedItem();

    selectedDragController = dragControllers.elementAt(selectedTabIndex);
    selectedPanel = selectedDragController.getBoundaryPanel();

    widgetSelectionListener.onWidgetSelected(getSelPageDesignWidget(), false);
}

From source file:org.openxdata.designer.client.view.FormsTreeView.java

/**
 * @see com.google.gwt.event.logical.shared.SelectionHandler#onSelection(SelectionEvent)
 *//*w ww. j a  v a2  s . co  m*/
public void onSelection(SelectionEvent<TreeItem> event) {

    scrollToLeft();

    TreeItem item = event.getSelectedItem();

    //Should not call this more than once for the same selected item.
    if (item != this.item) {
        Context.setFormDef(FormDef.getFormDef(item.getUserObject()));
        formDef = Context.getFormDef();

        fireFormItemSelected(item.getUserObject());
        this.item = item;

        //Expand if has kids such that users do not have to click the plus
        //sign to expand. Besides, some are not even aware of that.
        //if(item.getChildCount() > 0)
        //   item.setState(true);
    }
}