com.google.gwt.event.logical.shared.SelectionEvent Java Examples

The following examples show how to use com.google.gwt.event.logical.shared.SelectionEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BaseTree.java    From EasyML with Apache License 2.0 6 votes vote down vote up
public BaseTree() {
	super(new TreeImageResources(), true);

	this.addStyleName("bda-treedir");

	this.addSelectionHandler(new SelectionHandler<TreeItem>() {
		@Override
		public void onSelection(SelectionEvent<TreeItem> event) {
			TreeItem item = event.getSelectedItem();
			Boolean state = item.getState();
			// [GWT Issue 3660] to avoid pass invoke onSection two times
			TreeItem parent = item.getParentItem();
			item.getTree().setSelectedItem(parent, false);
			if (parent != null)
				parent.setSelected(false);
			item.setState(!state);
		}
	});
}
 
Example #2
Source File: DefaultTabLayoutPanel.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void selectTab(final int index) {
    if (index < PAGE_LIMIT) {
        // visible pages
        flagSelected(prevSelectedIndex, false);
        super.selectTab(index);
        flagSelected(index, true);
        prevSelectedIndex = index;

        if (index == PAGE_LIMIT - 1 && offPageContainer.getSelectedDeck() == -1) {
            offPageContainer.selectDeck(0);
        }

    } else {
        // off page
        offPageContainer.selectDeck(offPageIndex(index));
        if (getSelectedIndex() == PAGE_LIMIT - 1) {
            SelectionEvent.fire(this, PAGE_LIMIT - 1);
        }
        tabs.lastTab().setText(offPageContainer.getTexts().get(offPageIndex(index)).getText());
        selectTab(PAGE_LIMIT - 1);
    }
}
 
Example #3
Source File: EditorHarness.java    From incubator-retired-wave with Apache License 2.0 6 votes vote down vote up
void initContentOracle() {
  contentOracle = new MultiWordSuggestOracle();

  contentSuggestBox = new SuggestBox(contentOracle);
  contentSuggestBox.getElement().setId("content-box");

  // Some initial content xml strings
  contentOracle.add("");
  contentOracle.add("abcd");

  contentSuggestBox.addSelectionHandler(new SelectionHandler<SuggestOracle.Suggestion>() {
    @Override public void onSelection(SelectionEvent<SuggestOracle.Suggestion> event) {
      setFromContentBox();
    }
  });

  String[] extra = extendSampleContent();
  if (extra != null) {
    for (String content : extra) {
      contentOracle.add(content);
    }
  }
}
 
Example #4
Source File: CopyElementDialog.java    From geowe-core with GNU General Public License v3.0 6 votes vote down vote up
private ComboBox<VectorLayerInfo> initLayerCombo1() {
					
	VectorLayerProperties properties = GWT
			.create(VectorLayerProperties.class);

	layerStore1 = new ListStore<VectorLayerInfo>(properties.key());

	layerCombo1 = new ComboBox<VectorLayerInfo>(layerStore1,
			properties.name());
	layerCombo1.setEmptyText((UIMessages.INSTANCE.sbLayerComboEmptyText()));
	layerCombo1.setTypeAhead(true);
	layerCombo1.setTriggerAction(TriggerAction.ALL);
	layerCombo1.setForceSelection(true);
	layerCombo1.setEditable(false);
	layerCombo1.enableEvents();
	layerCombo1.setWidth(width);

	layerCombo1.addSelectionHandler(new SelectionHandler<VectorLayerInfo>() {
		@Override
		public void onSelection(SelectionEvent<VectorLayerInfo> event) {
			layerCombo1.setValue(event.getSelectedItem(), true);
		}
	});

	return layerCombo1;
}
 
Example #5
Source File: EditorHarness.java    From swellrt with Apache License 2.0 6 votes vote down vote up
void initContentOracle() {
  contentOracle = new MultiWordSuggestOracle();

  contentSuggestBox = new SuggestBox(contentOracle);
  contentSuggestBox.getElement().setId("content-box");

  // Some initial content xml strings
  contentOracle.add("");
  contentOracle.add("abcd");

  contentSuggestBox.addSelectionHandler(new SelectionHandler<SuggestOracle.Suggestion>() {
    @Override public void onSelection(SelectionEvent<SuggestOracle.Suggestion> event) {
      setFromContentBox();
    }
  });

  String[] extra = extendSampleContent();
  if (extra != null) {
    for (String content : extra) {
      contentOracle.add(content);
    }
  }
}
 
Example #6
Source File: MaterialPopupMenuTest.java    From gwt-material-addins with Apache License 2.0 6 votes vote down vote up
protected void checkSelectionHandler(MaterialPopupMenu popupMenu) {
    final boolean[] isSelectionFired = {false};
    popupMenu.setEnabled(true);
    popupMenu.addSelectionHandler(selectionEvent -> isSelectionFired[0] = true);
    popupMenu.fireEvent(new GwtEvent<SelectionHandler<?>>() {
        @Override
        public Type<SelectionHandler<?>> getAssociatedType() {
            return SelectionEvent.getType();
        }

        @Override
        protected void dispatch(SelectionHandler<?> eventHandler) {
            eventHandler.onSelection(null);
        }
    });
    assertTrue(isSelectionFired[0]);
}
 
Example #7
Source File: MaterialNavSectionTest.java    From gwt-material with Apache License 2.0 6 votes vote down vote up
public void testSelectionEvent() {
    MaterialNavSection widget = new MaterialNavSection();

    final boolean[] isSelectionEventFired = {false};
    widget.addSelectionHandler(selectionEvent -> isSelectionEventFired[0] = true);
    widget.fireEvent(new GwtEvent<SelectionHandler<?>>() {
        @Override
        public Type<SelectionHandler<?>> getAssociatedType() {
            return SelectionEvent.getType();
        }

        @Override
        protected void dispatch(SelectionHandler eventHandler) {
            eventHandler.onSelection(null);
        }
    });

    assertTrue(isSelectionEventFired[0]);
}
 
Example #8
Source File: GeoDataImportDialog.java    From geowe-core with GNU General Public License v3.0 6 votes vote down vote up
private SelectionHandler<Widget> getTabPanelSelectionHandler() {
	return new SelectionHandler<Widget>() {

		@Override
		public void onSelection(SelectionEvent<Widget> event) {
			if (UIMessages.INSTANCE.empty().equals(getActiveTab())) {
				dataFormatField.setVisible(false);
			} else {
				dataFormatField.setVisible(true);
			}
			if (UIMessages.INSTANCE.wfs().equals(getActiveTab())) {
				vectorFormatCombo.setValue(VectorFormat.GML_FORMAT);
			} else {
				vectorFormatCombo.setValue(null);
			}
			
			if (UIMessages.INSTANCE.gitHubResponseTitle().equals(getActiveTab())) {					
				layerName.setEnabled(false);
			} else {
				layerName.setEnabled(true);
			}
		}
	};
}
 
Example #9
Source File: MaterialCollection.java    From gwt-material with Apache License 2.0 6 votes vote down vote up
@Override
protected void onLoad() {
    super.onLoad();

    if (selectable) {
        selectHandler = registerHandler(addSelectionHandler(selectionEvent -> {
            clearActive();
            selectionEvent.getSelectedItem().setActive(true);
        }));

        for (Widget child : getChildren()) {
            if (child instanceof MaterialCollectionItem) {
                child.getElement().getStyle().setCursor(Style.Cursor.POINTER);
                ((MaterialCollectionItem) child).addClickHandler(clickEvent -> SelectionEvent.fire(MaterialCollection.this, (MaterialCollectionItem) child));
            }
        }
    } else {
        removeHandler(selectHandler);
    }
}
 
Example #10
Source File: MaterialTreeItem.java    From gwt-material-addins with Apache License 2.0 6 votes vote down vote up
public void select() {
    // Fire selection event
    SelectionEvent.fire(getTree(), this);

    List<MaterialTreeItem> treeItems = getTreeItems();
    if (!treeItems.isEmpty()) {
        for (MaterialTreeItem treeItem : treeItems) {
            if (hide) {
                treeItem.setVisible(false);
            } else {
                treeItem.setVisible(true);
            }
        }
        // Firing of events based on the status of the tree item
        if (hide) {
            CloseEvent.fire(getTree(), this);
            hide = false;
        } else {
            OpenEvent.fire(getTree(), this);
            hide = true;
        }
    }
}
 
Example #11
Source File: GeoprocessComboBox.java    From geowe-core with GNU General Public License v3.0 5 votes vote down vote up
private void createSelectionHandler() {
	addSelectionHandler(new SelectionHandler<Geoprocess>() {
		@Override
		public void onSelection(SelectionEvent<Geoprocess> event) {
			setValue(event.getSelectedItem(), true);
		}
	});
}
 
Example #12
Source File: DefaultTabLayoutPanel.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Selects the tab with the specified text. If there's no tab with the specified text, the selected tab remains
 * unchanged. If there's more than one tab with the specified text, the first one will be selected.
 *
 * @param text
 */
@Override
public void selectTab(final String text) {
    for (int i = 0; i < tabs.size(); i++) {
        if (text.equals(tabs.get(i).getText())) {
            selectTab(i);
            return;
        }
    }

    // not found in visible tabs, should be in off-page
    for (OffPageText opt : offPageContainer.getTexts()) {
        if (text.equals(opt.getText())) {
            if (opt.getIndex() == 0) {
                // the first off-page needs special treatment
                offPageContainer.selectDeck(opt.getIndex());
                if (getSelectedIndex() == PAGE_LIMIT - 1) {
                    SelectionEvent.fire(this, PAGE_LIMIT - 1);
                }
                tabs.lastTab().setText(opt.getText());
                selectTab(PAGE_LIMIT - 1);
            } else {
                selectTab(PAGE_LIMIT - 1 + opt.getIndex());
            }
        }
    }
}
 
Example #13
Source File: VectorFormatComboBox.java    From geowe-core with GNU General Public License v3.0 5 votes vote down vote up
private void createSelectionHandler() {
	addSelectionHandler(new SelectionHandler<VectorFormat>() {
		@Override
		public void onSelection(SelectionEvent<VectorFormat> event) {
			setValue(event.getSelectedItem(), true);
		}
	});
}
 
Example #14
Source File: ExportDataDialog.java    From geowe-core with GNU General Public License v3.0 5 votes vote down vote up
private SelectionHandler<VectorFormat> getVectorComboSelectionHandler() {
	return new SelectionHandler<VectorFormat>() {
		@Override
		public void onSelection(SelectionEvent<VectorFormat> event) {
				epsgCombo.enable();
		}
	};
}
 
Example #15
Source File: MenuBarView.java    From gwt-material-demo with Apache License 2.0 5 votes vote down vote up
@UiHandler({"dpFile", "dpNew", "dpView", "dpEdit", "dpFormat"})
void onSelectionFileDropdown(SelectionEvent<Widget> selection) {
    if(selection.getSelectedItem() instanceof MaterialLink){
        MaterialToast.fireToast("Triggered : " + ((MaterialLink)selection.getSelectedItem()).getText());
    }else if(selection.getSelectedItem() instanceof MaterialCheckBox){
        MaterialToast.fireToast("Checked : " + ((MaterialCheckBox)selection.getSelectedItem()).getText());
    }
}
 
Example #16
Source File: MenuBarView.java    From gwt-material-demo with Apache License 2.0 5 votes vote down vote up
@UiHandler("dpMode")
void onSelectionMode(SelectionEvent<Widget> selection) {
    for(Widget w : dpMode.getItems()){
        if(w instanceof MaterialCheckBox){
            ((MaterialCheckBox) w).setValue(false);
        }
    }
    if(selection.getSelectedItem() instanceof MaterialCheckBox){
        ((MaterialCheckBox) selection.getSelectedItem()).setValue(true);
        MaterialToast.fireToast("Checked : " + ((MaterialCheckBox) selection.getSelectedItem()).getText());
    }
}
 
Example #17
Source File: JsonTable.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
@Override
public void load() {
    if (value != null) {
        setId(DOM.createUniqueId());
        options.id = "#" + getId();

        JsTable.jsontotable(value, options);

        $("tr").mousedown((e, handler) -> {
            SelectionEvent.fire(JsonTable.this, $(e.target).parent().asElement());
            return true;
        });
    }
}
 
Example #18
Source File: MaterialStepper.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
/**
 * Called when a step title is clicked.
 */
@Override
public void onSelection(SelectionEvent<MaterialStep> event) {
    if (stepSkippingAllowed) {
        if (event.getSelectedItem().getState() == State.SUCCESS) {
            goToStep(event.getSelectedItem());
        }
    }
}
 
Example #19
Source File: MaterialStep.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
@Override
protected void onLoad() {
    super.onLoad();

    ClickHandler handler = event -> {
        if (isEnabled() && isVisible()) {
            SelectionEvent.fire(MaterialStep.this, MaterialStep.this);
        }
    };
    registerHandler(header.addClickHandler(handler));
    registerHandler(divTitle.addClickHandler(handler));
    registerHandler(divDescription.addClickHandler(handler));
}
 
Example #20
Source File: MaterialStep.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
@Override
public HandlerRegistration addSelectionHandler(final SelectionHandler<MaterialStep> handler) {
    return this.addHandler(new SelectionHandler<MaterialStep>() {
        @Override
        public void onSelection(SelectionEvent<MaterialStep> event) {
            if (isEnabled()) {
                handler.onSelection(event);
            }
        }
    }, SelectionEvent.getType());
}
 
Example #21
Source File: GroupToggleButtonTest.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
public void testSelectionHandler() {
    Integer SELECTED_ITEM = 1;
    GroupToggleButton<Integer> button = getWidget();

    final boolean[] selectionFired = {false};
    button.addSelectionHandler((SelectionEvent<Integer> selectionEvent) -> {
        assertEquals(SELECTED_ITEM, selectionEvent.getSelectedItem());
        selectionFired[0] = true;
    });

    SelectionEvent.fire(button, SELECTED_ITEM);
    assertTrue(selectionFired[0]);
}
 
Example #22
Source File: GalleryTreeViewImpl.java    From dashbuilder with Apache License 2.0 5 votes vote down vote up
private Tree initNavigationTree() {
    Tree navTree = new Tree();

    List<GalleryTreeNode> mainNodes = galleryTree.getMainNodes();
    populateNavigationTree(mainNodes, navTree);

    navTree.addSelectionHandler(new SelectionHandler<TreeItem>() {
        public void onSelection(SelectionEvent<TreeItem> event) {
            TreeItem ti = event.getSelectedItem();
            GalleryTreeNode node = (GalleryTreeNode) ti.getUserObject();
            treeItemClicked(ti, node);
        }
    });
    return navTree;
}
 
Example #23
Source File: DebugPanelFilterWidget.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected void selectItem(Item item, int idx) {
  if (item != selected) {
    if (selected != null) {
      selected.setSelected(false);
    }
    selected = item;
    if (selected != null) {
      selected.setSelected(true);
    }
    SelectionEvent.fire(this, idx);
  }
}
 
Example #24
Source File: GeoprocessDialog.java    From geowe-core with GNU General Public License v3.0 5 votes vote down vote up
private void createComboLayer(final ComboBox<VectorLayerInfo> combo,
		final String numCombo, final TextButton validateButton) {
	clearLayerComboBox(combo);
	combo.setTypeAhead(true);
	combo.setTriggerAction(TriggerAction.ALL);
	combo.setForceSelection(true);
	combo.setEditable(false);
	combo.enableEvents();
	combo.setWidth(WIDTH_COMBO_LAYER);
	combo.setId(numCombo);

	combo.addSelectionHandler(new SelectionHandler<VectorLayerInfo>() {
		@Override
		public void onSelection(SelectionEvent<VectorLayerInfo> event) {
			combo.setValue(event.getSelectedItem(), true);
			List<VectorLayerInfo> updatedLayers = removeLayer(event
					.getSelectedItem());
			if (COMBO1_ID.equals(combo.getId())) {
				updateCombo(LAYER_COMBO_2, LAYER_STORE_2, updatedLayers);
			} else {
				updateCombo(LAYER_COMBO_1, LAYER_STORE_1, updatedLayers);
			}
		}
	});
	
	validateButton.setToolTip(UIMessages.INSTANCE
			.descriptionValidationToolText());

	final HorizontalPanel horizontalGroup = getHorizontalPanel();
	horizontalGroup.add(combo);
	horizontalGroup.add(validateButton);

	panel.add(new Label(UIMessages.INSTANCE.layerLabelText(numCombo)));
	panel.add(horizontalGroup);
}
 
Example #25
Source File: Menu.java    From sc2gears with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new Menu.
 */
public Menu( final MenuItem[] menuItems, final Panel pageContainer ) {
	this.menuItems     = menuItems;
	this.pageContainer = pageContainer;
	
	for ( final MenuItem mi : menuItems )
		addTab( mi.getLabel() );
	
	addSelectionHandler( new SelectionHandler< Integer >() {
		@Override
		public void onSelection( final SelectionEvent< Integer > event ) {
			menuItems[ event.getSelectedItem() ].onActivate( Menu.this );
		}
	} );
}
 
Example #26
Source File: GeoprocessDialog.java    From geowe-core with GNU General Public License v3.0 5 votes vote down vote up
private void createGeoprocessAndDistanceField(final Geoprocesses spatialOperation) {
	spatialOperationComboBox = new GeoprocessComboBox(
			spatialOperation.getAll());
	spatialOperationComboBox.setWidth(WIDTH_SPATIAL_OPERATION_COMBO);
	clearSpatialOperationComboBox();				
	spatialOperationComboBox
			.addSelectionHandler(new SelectionHandler<Geoprocess>() {
				@Override
				public void onSelection(SelectionEvent<Geoprocess> event) {
					spatialOperationComboBox.setValue(
							event.getSelectedItem(), true);

					if (event.getSelectedItem() instanceof BufferGeoprocess) {
						LAYER_COMBO_2.setValue(null);
						LAYER_COMBO_2.setEnabled(false);
						distanceTextField.setText("0");
						distanceTextField.setEnabled(true);
						distanceTextField.setVisible(true);
					} else {							
						LAYER_COMBO_2.setEnabled(true);
						distanceTextField.setText("");
						distanceTextField.setEnabled(false);
						distanceTextField.setVisible(false);
					}
				}
			});

	initDistanceTextField();
	final HorizontalPanel horizontalGroup = getHorizontalPanel();
	horizontalGroup.add(spatialOperationComboBox);
	horizontalGroup.add(distanceTextField);
	panel.add(horizontalGroup);
}
 
Example #27
Source File: FolderSelectTree.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Folder Tree
 */
public FolderSelectTree() {
	tree = new Tree();
	rootItem.setHTML(Util.imageItemHTML("img/menuitem_childs.gif", "root_schema", "top"));
	rootItem.setStyleName("okm-TreeItem");
	rootItem.setUserObject(new GWTFolder());
	rootItem.setSelected(true);
	rootItem.setState(true);
	tree.setStyleName("okm-Tree");
	tree.addItem(rootItem);
	tree.addSelectionHandler(new SelectionHandler<TreeItem>() {
		@Override
		public void onSelection(SelectionEvent<TreeItem> event) {
			boolean refresh = true;
			TreeItem item = event.getSelectedItem();

			// Case that not refreshing tree and file browser ( right click )
			if (actualItem.equals(item)) {
				refresh = false;
			} else {
				// Disables actual item because on changing active node by
				// application this it's not changed automatically
				if (!actualItem.equals(item)) {
					actualItem.setSelected(false);
					actualItem = item;
				} else {
					refresh = false;
				}
			}

			if (refresh) {
				refresh(true);
			}
		}
	});
	actualItem = tree.getItem(0);
	initWidget(tree);
}
 
Example #28
Source File: MaterialTab.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
protected void registerChildHandler(Widget child) {
    if (child instanceof MaterialTabItem) {
        MaterialTabItem item = (MaterialTabItem) child;
        item.getHandlerRegistry().clearHandlers();
        item.registerHandler(item.addMouseDownHandler(e -> SelectionEvent.fire(MaterialTab.this, getChildren().indexOf(child))));
    }
}
 
Example #29
Source File: FolderSelectTree.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Folder Tree
 */
public FolderSelectTree() {
	tree = new Tree();
	rootItem.setHTML(Util.imageItemHTML("img/menuitem_childs.gif", "root_schema", "top"));
	rootItem.setStyleName("okm-TreeItem");
	rootItem.setUserObject(new GWTFolder());
	rootItem.setSelected(true);
	rootItem.setState(true);
	tree.setStyleName("okm-Tree");
	tree.addItem(rootItem);
	tree.addSelectionHandler(new SelectionHandler<TreeItem>() {
		@Override
		public void onSelection(SelectionEvent<TreeItem> event) {
			boolean refresh = true;
			TreeItem item = event.getSelectedItem();

			// Case that not refreshing tree and file browser ( right click )
			if (actualItem.equals(item)) {
				refresh = false;
			} else {
				// Disables actual item because on changing active node by
				// application this it's not changed automatically
				if (!actualItem.equals(item)) {
					actualItem.setSelected(false);
					actualItem = item;
				} else {
					refresh = false;
				}
			}

			if (refresh) {
				refresh(true);
			}
		}
	});
	actualItem = tree.getItem(0);
	initWidget(tree);
}
 
Example #30
Source File: CourseFinderFreeTime.java    From unitime with Apache License 2.0 4 votes vote down vote up
@Override
public HandlerRegistration addSelectionHandler(SelectionHandler<RequestedCourse> handler) {
	return addHandler(handler, SelectionEvent.getType());
}