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:cz.incad.kramerius.editor.client.view.LoadViewImpl.java

License:Open Source License

@UiHandler("oracleTextBox")
void onSuggestionCommit(SelectionEvent<SuggestOracle.Suggestion> event) {
    waiting(true);//w w  w. j a  v  a 2 s .c om
    callback.onLoadViewSuggestionCommit(event.getSelectedItem());
}

From source file:de.fhrt.codenvy.bpmn.editor.widget.diagram.BpmnEditorDiagramWidget.java

License:Open Source License

private TabLayoutPanel initRootLayout() {
    TabLayoutPanel root = new TabLayoutPanel(0, Unit.PX);
    root.setSize("100%", "100%");
    root.add(diagramHtmlPanel, "Design");
    root.add(cmWidget, "Source");
    root.addStyleName("bpmnDigramWidget-tabLayoutPanel");
    root.addSelectionHandler(new SelectionHandler<Integer>() {

        @Override//from  w w  w.  jav  a  2  s.  co m
        public void onSelection(SelectionEvent<Integer> event) {
            if (event.getSelectedItem() == 1) {
                Timer t = new Timer() {
                    @Override
                    public void run() {
                        cmWidget.refresh();
                    }
                };
                t.schedule(10);
            }
        }
    });
    return root;
}

From source file:de.knightsoftnet.navigation.client.ui.navigation.TreeNavigationView.java

License:Apache License

/**
 * menu item is selected in the menu tree.
 *
 * @param pselectionEvent selection event.
 *//*from  w  w w. j a v  a 2  s . co m*/
@UiHandler("navTree")
final void menuItemSelected(final SelectionEvent<TreeItem> pselectionEvent) {
    if (this.selectedItem != null && !this.selectedItem.equals(pselectionEvent.getSelectedItem())) {
        // workaround, revert selection, it's triggered by the selected page
        pselectionEvent.getSelectedItem().setSelected(false);
        this.selectedItem.setSelected(true);
    }
}

From source file:de.novanic.gwteventservice.demo.conversationapp.client.conversation.ui.GWTConversationChannelPanel.java

License:Open Source License

public HandlerRegistration addChannelSelectListener(final ChannelSelectListener aChannelSelectListener) {
    final SelectionHandler<TreeItem> theTreeSelectionHandler = new SelectionHandler<TreeItem>() {
        public void onSelection(SelectionEvent<TreeItem> aSelectionEvent) {
            final TreeItem theSelectedItem = aSelectionEvent.getSelectedItem();
            if (isChannelItem(theSelectedItem)) {
                final String theChannelName = theSelectedItem.getText();
                aChannelSelectListener.onSelect(theChannelName);
            }//from w  w w . java2s . c o  m
        }
    };

    final HandlerRegistration theSelectionHandlerRegistration = myChannelTree
            .addSelectionHandler(theTreeSelectionHandler);
    myHandlerRegistrations.add(theSelectionHandlerRegistration);
    return theSelectionHandlerRegistration;
}

From source file:edu.caltech.ipac.firefly.ui.MOSPanel.java

private void init() {
    naifTargetPanel = new NaifTargetPanel();
    InputField objectType2 = FormBuilder.createField(OBJ_TYPE_2_KEY);
    InputField mpcData = FormBuilder.createField(MPC_DATA_KEY);
    Widget mpcInputPanel = FormBuilder.createPanel(90, objectType2, mpcData);

    final SimpleInputField objectType3 = SimpleInputField.createByProp(OBJ_TYPE_3_KEY);

    InputField bodyDesignation = FormBuilder.createField(BODY_DESIGNATION_KEY);
    InputField epoch = FormBuilder.createField(EPOCH_KEY);
    InputField eccentricity = FormBuilder.createField(ECCENTRICITY_KEY);
    semimajorAxis = FormBuilder.createField(SEMIMAJOR_AXIS_KEY);
    perihDist = FormBuilder.createField(PERIH_DIST_KEY);

    manualInputLeft = new InputFieldPanel(140);
    manualInputLeft.addUserField(bodyDesignation, HorizontalPanel.ALIGN_LEFT);
    manualInputLeft.addUserField(epoch, HorizontalPanel.ALIGN_LEFT);
    manualInputLeft.addUserField(eccentricity, HorizontalPanel.ALIGN_LEFT);
    manualInputLeft.addUserField(semimajorAxis, HorizontalPanel.ALIGN_LEFT);
    manualInputLeft.addUserField(perihDist, HorizontalPanel.ALIGN_LEFT);

    InputField inclination = FormBuilder.createField(INCLINATION_KEY);
    InputField argPerihelion = FormBuilder.createField(ARH_PERIHELION_KEY);
    InputField ascendNode = FormBuilder.createField(ASCEND_NODE_KEY);
    meanAnomaly = FormBuilder.createField(MEAN_ANOMALY_KEY);
    perihTime = FormBuilder.createField(PERIH_TIME_KEY);

    manualInputRight = new InputFieldPanel(140);
    manualInputRight.addUserField(inclination, HorizontalPanel.ALIGN_LEFT);
    manualInputRight.addUserField(argPerihelion, HorizontalPanel.ALIGN_LEFT);
    manualInputRight.addUserField(ascendNode, HorizontalPanel.ALIGN_LEFT);
    manualInputRight.addUserField(meanAnomaly, HorizontalPanel.ALIGN_LEFT);
    manualInputRight.addUserField(perihTime, HorizontalPanel.ALIGN_LEFT);

    HorizontalPanel vp = new HorizontalPanel();
    vp.add(manualInputLeft);//  ww  w.j  av a 2  s .  c  o m
    vp.add(manualInputRight);

    FlowPanel manualInputPanel = new FlowPanel();
    manualInputPanel.add(objectType3);
    manualInputPanel.add(vp);

    tabPane.addTab(naifTargetPanel, "Object Name");
    tabPane.addTab(mpcInputPanel, "MPC Input");
    tabPane.addTab(manualInputPanel, "Manual Input");
    tabPane.addSelectionHandler(new SelectionHandler<Integer>() {
        public void onSelection(SelectionEvent<Integer> integerSelectionEvent) {
            int selected = integerSelectionEvent.getSelectedItem();
            if (selected == 0)
                tabPane.setSize("640px", "110px");
            else if (selected == 1)
                tabPane.setSize("640px", "130px");
            else if (selected == 2)
                tabPane.setSize("640px", "220px");
        }
    });
    tabPane.selectTab(0);
    tabPane.setSize("640px", "110px"); // tabPane is not rendered if size is not set
    tabPane.setTabPaneName("MOST TabPane");

    FormBuilder.Config config = new FormBuilder.Config(FormBuilder.Config.Direction.HORIZONTAL, 120, 5,
            HorizontalPanel.ALIGN_LEFT);
    datePanel = new DatePanel((10 * 365 + 3) * 24 * 60 * 60, START_DATE_KEY, END_DATE_KEY, config);
    datePanel.setIntervalViolationError("Position searches can only cover 10-year period.");

    mainPanel = new VerticalPanel();
    mainPanel.add(new HTML("&nbsp;"));
    mainPanel.add(tabPane);
    mainPanel.add(new HTML("&nbsp;"));
    mainPanel.add(datePanel);
    mainPanel.add(new HTML(
            "<i>&nbsp;&nbsp;&nbsp;&nbsp;Enter date range to search, format example: </i>2010-01-14 15:30:00<i>, or </i>2010-01-14<i>.</i><br><br>"));

    fields = Arrays.asList(objectType2, mpcData, objectType3.getField(), bodyDesignation, epoch, eccentricity,
            semimajorAxis, perihDist, inclination, argPerihelion, ascendNode, meanAnomaly, perihTime);

    fieldsTab1 = Arrays.asList(objectType2, mpcData);

    fieldsTab2Asteroid = Arrays.asList(objectType3.getField(), bodyDesignation, epoch, eccentricity,
            semimajorAxis, inclination, argPerihelion, ascendNode, meanAnomaly);
    fieldsTab2Comet = Arrays.asList(objectType3.getField(), bodyDesignation, epoch, eccentricity, perihDist,
            inclination, argPerihelion, ascendNode, perihTime);

    fieldsTab2 = objectType3.getValue().equalsIgnoreCase("asteroid") ? fieldsTab2Asteroid : fieldsTab2Comet;

    // perihDist and perihTime are only valid for comets
    // semimajorAxis and meanAnomaly are only valid for asteroids
    syncManualInputFieldVis(objectType3.getValue());

    objectType3.getField().addValueChangeHandler(new ValueChangeHandler<String>() {
        public void onValueChange(ValueChangeEvent valueChangeEvent) {
            syncManualInputFieldVis(objectType3.getValue());
        }
    });

}

From source file:edu.udes.bio.genus.client.ui.menu.Prop_Strands.java

License:Open Source License

private void setTextBoxStructure() {
    final MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
    for (final Structure s : GenUS.mainMenu.structMenu.structList) {
        oracle.add(s.structure);/*  ww  w  .j a  v a 2 s .co  m*/
    }

    this.txtStructure = new SuggestBox(oracle);
    this.txtStructure.setSize("400px", "20px");
    this.txtStructure.setAnimationEnabled(true);
    this.txtStructure.setAutoSelectEnabled(true);

    // Check validity and update RNAss when selection in suggestBox
    final SelectionHandler<Suggestion> sh = new SelectionHandler<Suggestion>() {
        @Override
        public void onSelection(SelectionEvent<Suggestion> event) {
            try {
                Prop_Strands.this.rnass.setRNAssDotParentheses(event.getSelectedItem().getReplacementString());
            } catch (final RNAException e) {
                Prop_Strands.this.txtStructure.setText(Prop_Strands.this.rnass.getDotParentesis());
            }
        }
    };
    this.txtStructure.addSelectionHandler(sh);

    // ADD FILTER TO THE Structure TEXTBOX
    final ChangeHandler dpChangeHandler = new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            try {
                Prop_Strands.this.rnass.setRNAssDotParentheses(Prop_Strands.this.txtStructure.getText());
            } catch (final RNAException e) {
                Prop_Strands.this.txtStructure.setText(Prop_Strands.this.rnass.getDotParentesis());
            }
        }
    };
    this.txtStructure.getTextBox().addChangeHandler(dpChangeHandler);

    final Set<Character> strucAllowedChars = new TreeSet<Character>();
    strucAllowedChars.add('.');
    strucAllowedChars.add('(');
    strucAllowedChars.add(')');

    final KeyUpHandler structUpHandler = new KeyUpHandler() {
        @Override
        public void onKeyUp(KeyUpEvent event) {
            if (Prop_Strands.this.updateStruct || KeyCodes.KEY_DELETE == event.getNativeKeyCode()
                    || KeyCodes.KEY_BACKSPACE == event.getNativeKeyCode()) {
                Prop_Strands.this.updateStruct = false;
                try {
                    Prop_Strands.this.rnass.setRNAssDotParentheses(Prop_Strands.this.txtStructure.getText());
                } catch (final RNAIncompleteException e) {

                } catch (final RNAException e) {
                    Prop_Strands.this.txtStructure.getTextBox().cancelKey();
                }
            }
        }
    };
    this.txtStructure.addKeyUpHandler(structUpHandler);

    final KeyPressHandler structPressHandler = new KeyPressHandler() {
        @Override
        public void onKeyPress(KeyPressEvent event) {
            final Character c = event.getCharCode();

            if (strucAllowedChars.contains(c)) {
                Prop_Strands.this.updateStruct = true;
            } else {
                Prop_Strands.this.txtStructure.getTextBox().cancelKey();
            }
        }
    };
    this.txtStructure.addKeyPressHandler(structPressHandler);
}

From source file:edu.udes.bio.genus.client.ui.menu.Prop_Strands.java

License:Open Source License

private void setTextBoxSequence() {
    final MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
    for (final Sequence s : GenUS.mainMenu.seqMenu.seqList) {
        oracle.add(s.sequence);//from ww w.  java2  s. com
    }

    this.txtSequence = new SuggestBox(oracle);
    this.txtSequence.setSize("400px", "20px");
    this.txtSequence.setAnimationEnabled(true);
    this.txtSequence.setAutoSelectEnabled(true);

    // Check validity and update RNAss when selection in suggestBox
    final SelectionHandler<Suggestion> sh = new SelectionHandler<Suggestion>() {
        @Override
        public void onSelection(SelectionEvent<Suggestion> event) {
            try {
                Prop_Strands.this.rnass.setRNAssSequence(event.getSelectedItem().getReplacementString());
            } catch (final RNAException e) {
                Prop_Strands.this.txtStructure.setText(Prop_Strands.this.rnass.getSequence());
            }
        }
    };
    this.txtSequence.addSelectionHandler(sh);

    // ADD FILTER TO THE SEQUENCE TEXTBOX
    final ChangeHandler seqChangeHandler = new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            try {
                Prop_Strands.this.rnass.setRNAssSequence(Prop_Strands.this.txtSequence.getText());
            } catch (final RNAException e) {
                Prop_Strands.this.txtSequence.setText(Prop_Strands.this.rnass.getSequence());
            }
        }
    };
    this.txtSequence.getTextBox().addChangeHandler(seqChangeHandler);

    final Set<Character> seqAllowedChars = new TreeSet<Character>();
    seqAllowedChars.add('G');
    seqAllowedChars.add('A');
    seqAllowedChars.add('C');
    seqAllowedChars.add('U');
    seqAllowedChars.add(' ');

    final KeyUpHandler seqUpHandler = new KeyUpHandler() {
        @Override
        public void onKeyUp(KeyUpEvent event) {
            if (Prop_Strands.this.updateSeq || KeyCodes.KEY_DELETE == event.getNativeKeyCode()
                    || KeyCodes.KEY_BACKSPACE == event.getNativeKeyCode()) {
                Prop_Strands.this.updateSeq = false;
                Prop_Strands.this.txtSequence.setText(Prop_Strands.this.txtSequence.getText().toUpperCase());
                try {
                    Prop_Strands.this.rnass.setRNAssSequence(Prop_Strands.this.txtSequence.getText());
                } catch (final RNAException e) {
                    Prop_Strands.this.txtSequence.getTextBox().cancelKey();
                }
            } //
        }
    };
    this.txtSequence.addKeyUpHandler(seqUpHandler);

    final KeyPressHandler seqPressHandler = new KeyPressHandler() {
        @Override
        public void onKeyPress(KeyPressEvent event) {
            final Character c = Character.toUpperCase(event.getCharCode());

            if (seqAllowedChars.contains(c)) {
                Prop_Strands.this.updateSeq = true;
            } else {
                Prop_Strands.this.txtSequence.getTextBox().cancelKey();
            }
        }
    };
    this.txtSequence.addKeyPressHandler(seqPressHandler);
}

From source file:edu.ycp.cs.netcoder.client.CourseAndProblemView.java

License:Open Source License

@Override
public void eventOccurred(Object key, Publisher publisher, Object hint) {
    if (key == Session.Event.ADDED_OBJECT && hint instanceof Course[]) {
        Course[] courseList = (Course[]) hint;

        // Build the course tree
        courseTree = new Tree();
        TreeItem curTermAndYearTreeItem = null;
        TermAndYear curTermAndYear = null;
        for (Course course : courseList) {
            TermAndYear courseTermAndYear = new TermAndYear(course.getTerm(), course.getYear());
            if (curTermAndYear == null || !curTermAndYear.equals(courseTermAndYear)) {
                curTermAndYearTreeItem = new TreeItem(new TermAndYearNode(courseTermAndYear));
                courseTree.addItem(curTermAndYearTreeItem);
                curTermAndYear = courseTermAndYear;
            }//from ww w. j a va  2 s  . c o m
            curTermAndYearTreeItem.addItem(new CourseNode(course));
        }

        // Handle selection events
        courseTree.addSelectionHandler(new SelectionHandler<TreeItem>() {
            @Override
            public void onSelection(SelectionEvent<TreeItem> event) {
                TreeItem treeItem = event.getSelectedItem();
                Widget w = treeItem.getWidget();
                if (w instanceof CourseNode) {
                    getSession().get(CourseSelection.class).courseSelected(((CourseNode) w).getCourse());
                }
            }
        });

        getLayoutPanel().add(courseTree);

        doResize();
    } else if (key == WindowResizeNotifier.WINDOW_RESIZED) {
        doResize();
    } else if (key == CourseSelection.Event.COURSE_SELECTED) {
        final Course selectedCourse = (Course) hint;
        AsyncCallback<Problem[]> callback = new AsyncCallback<Problem[]>() {
            @Override
            public void onFailure(Throwable caught) {
                GWT.log("Could not load problems for course", caught);
            }

            @Override
            public void onSuccess(Problem[] result) {
                getSession().get(CourseSelection.class).courseLoaded(selectedCourse, result);
            }
        };

        getCoursesAndProblemsService.getProblems(selectedCourse, callback);
    } else if (key == CourseSelection.Event.COURSE_LOADED) {
        showProblems(getSession().get(CourseSelection.class).getProblemList());
    }
}

From source file:eml.studio.client.graph.DiagramBuilder.java

License:Open Source License

public void bind() {
    presenter.getView().getProgramTree().addSelectionHandler(new SelectionHandler<TreeItem>() {

        @Override/*  ww w . j ava  2 s.c om*/
        public void onSelection(SelectionEvent<TreeItem> event) {

            TreeItem item = event.getSelectedItem();
            if (item instanceof ProgramLeaf) {
                Program program = ((ProgramLeaf) item).getModule();
                String uid = program.getName().replaceAll("[\\s,?]+", "") + "-" + UUID.randomID();

                ProgramWidget pw = null;
                if (!program.getProgramable()) {
                    pw = new CommonProgramWidget(program, uid);
                } else if (!program.isDistributed())
                    pw = new ScriptProgramWidget(program, uid);
                else
                    pw = new SqlProgramWidget(program, uid);
                //give pw a NEW_STATUS OozieAction
                pw.flushOozieAction();
                pw.genParamPanel(true);

                placeProgramWidget(pw);
            }
        }
    });

    presenter.getView().getDatasetTree().addSelectionHandler(new SelectionHandler<TreeItem>() {

        @Override
        public void onSelection(SelectionEvent<TreeItem> event) {
            TreeItem item = event.getSelectedItem();
            if (item instanceof DatasetLeaf) {
                Dataset dataset = ((DatasetLeaf) item).getModule();
                String uid = dataset.getName().replaceAll("[\\s,?]+", "") + "-" + UUID.randomID();
                final DatasetWidget dw = new DatasetWidget(dataset, uid);
                placeDatasetWidget(dw);
            }
        }
    });

    presenter.getView().getResultTree().addSelectionHandler(new SelectionHandler<TreeItem>() {

        @Override
        public void onSelection(SelectionEvent<TreeItem> event) {

            TreeItem item = event.getSelectedItem();
            if (item instanceof ProgramLeaf) {
                Program program = ((ProgramLeaf) item).getModule();
                String uid = program.getName().replaceAll("[\\s,?]+", "") + "-" + UUID.randomID();

                ProgramWidget pw = null;
                if (!program.getProgramable()) {
                    pw = new CommonProgramWidget(program, uid);
                } else if (!program.isDistributed())
                    pw = new ScriptProgramWidget(program, uid);
                else
                    pw = new SqlProgramWidget(program, uid);

                //give pw a NEW_STATUS OozieAction
                pw.flushOozieAction();
                pw.genParamPanel(true);

                placeProgramWidget(pw);
            }

            if (item instanceof DatasetLeaf) {
                Dataset dataset = ((DatasetLeaf) item).getModule();
                String uid = dataset.getName().replaceAll("[\\s,?]+", "") + "-" + UUID.randomID();
                final DatasetWidget dw = new DatasetWidget(dataset, uid);
                placeDatasetWidget(dw);
            }
        }
    });
}

From source file:eml.studio.client.ui.panel.PreviewPopupPanel.java

License:Open Source License

/**
 * Control event binding/* w w w .j ava  2s  .c o  m*/
 * 
 * @param path  Result root address path
 */
public void bind(final String path) {
    uploadSubmitButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent clickEvent) {
            Window.alert("Start calculating the file size");
            datasetSrv.getFileSize(path, new AsyncCallback<Double>() {

                @Override
                public void onFailure(Throwable caught) {
                    // TODO Auto-generated method stub
                    logger.warning("Failed to get download file size!");
                }

                @Override
                public void onSuccess(Double size) {
                    // TODO Auto-generated method stub
                    if (size < MAX_DOWNLOAD_SIZE) {
                        Window.alert("Start downloading the file");
                        String url = GWT.getModuleBaseURL().split("EMLStudio")[0]
                                + "EMLStudioMonitor/filedownload?filename=" + sourceUrl;
                        Window.open(url, "_blank", "status=0,toolbar=0,menubar=0,location=0");
                    } else
                        Window.alert("Download file over limit size (1g), can not download the file!");
                }

            });

        }
    });
    savebtn.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent clickEvent) {
            final SaveDatasetPanel saveDatasetPanel = new SaveDatasetPanel(PreviewPopupPanel.this);
            saveDatasetPanel.setDataset(dataset);
            saveDatasetPanel.init();
            saveDatasetPanel.show();
            PreviewPopupPanel.this.hide();
            saveDatasetPanel.center();
        }
    });

    resultDirTree.addSelectionHandler(new SelectionHandler<TreeItem>() {
        @Override
        public void onSelection(SelectionEvent<TreeItem> event) {
            // TODO Auto-generated method stub
            TreeItem item = event.getSelectedItem();
            if (item instanceof PopupRetDirLeaf) {
                PopupRetDirLeaf leaf = (PopupRetDirLeaf) item;
                fileLabel.setText(leaf.getText());
                PopupRetDirTreeLoad.wrapTreeNode(leaf);
                String filePath = leaf.getPath();
                //Only the root directory for data loading tips
                if (leaf.getName().equals(resultDirTree.getRoot().getName())
                        && leaf.getChildCount() == resultDirTree.getRoot().getChildCount())
                    fileTextArea.setText("The data is loading, please be patient ...");
                datasetSrv.previewFile(filePath, 100, new AsyncCallback<String>() {
                    @Override
                    public void onFailure(Throwable caught) {
                        // TODO Auto-generated method stub
                        logger.warning("File preview failed, the directory did not produce results!");
                    }

                    @Override
                    public void onSuccess(String result) {
                        // TODO Auto-generated method stub
                        fileTextArea.setText(result);
                    }
                });

                //The root directory does not file size statistics,
                // because of its slow statistics
                if (!(leaf.getName().equals(resultDirTree.getRoot().getName())
                        && leaf.getChildCount() == resultDirTree.getRoot().getChildCount())) {
                    datasetSrv.getFileSize(filePath, new AsyncCallback<Double>() {
                        @Override
                        public void onFailure(Throwable caught) {
                            // TODO Auto-generated method stub
                            logger.warning("Failed to get file size!");
                        }

                        @Override
                        public void onSuccess(Double result) {
                            // TODO Auto-generated method stub
                            fileSizeLabel.setVisible(true);
                            fileSizeLabel.setText("TotalSize:" + result + "kb");
                        }
                    });
                } else {
                    fileSizeLabel.setVisible(false);
                }
            }
        }
    });

    refreshBtn.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent clickEvent) {
            fileLabel.setText("");
            fileSizeLabel.setText("");
            fileTextArea.setText("");
            resultDirTree.clear();
            PopupRetDirTreeLoad.reBuild(resultDirTree, path);
        }
    });

}