Java Code Examples for com.google.gwt.view.client.SingleSelectionModel#getSelectedObject()

The following examples show how to use com.google.gwt.view.client.SingleSelectionModel#getSelectedObject() . 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: DriverStep.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
protected boolean onNext(final Context<T> context) {
    JDBCDriver driver = null;
    if (selectedTab == 0) {
        FormValidation formValidation = form.validate();
        if (!formValidation.hasErrors()) {
            driver = form.getUpdatedEntity();
        }
    } else {
        form.clearValues();
        SingleSelectionModel<JDBCDriver> selection =
                (SingleSelectionModel<JDBCDriver>) table.getSelectionModel();
        driver = selection.getSelectedObject();
    }

    if (driver != null) {
        wizard.applyDriver(driver);
        return true;
    } else {
        Console.warning(Console.CONSTANTS.noDriverSpecified());
        return false;
    }
}
 
Example 2
Source File: DataProviderFilter.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void clearSelection() {
    for (HasData<T> table : delegate.getDataDisplays()) {
        SelectionModel<? super T> selectionModel = table.getSelectionModel();
        if (selectionModel instanceof SingleSelectionModel) {
            SingleSelectionModel<T> sm = (SingleSelectionModel<T>) selectionModel;
            T selectedObject = sm.getSelectedObject();
            if (selectedObject != null) {
                ((SingleSelectionModel<T>) selectionModel).setSelected(selectedObject, false);
            }
        }
    }
}
 
Example 3
Source File: DivertList.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@SuppressWarnings("unchecked")
public ActivemqDivert getSelectedEntity() {
    SingleSelectionModel<ActivemqDivert> selectionModel = (SingleSelectionModel<ActivemqDivert>) table
            .getSelectionModel();
    return selectionModel.getSelectedObject();
}
 
Example 4
Source File: ConnectionFactoryList.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public ConnectionFactory getSelectedFactory() {
    SingleSelectionModel<ConnectionFactory> selectionModel = (SingleSelectionModel<ConnectionFactory>)factoryTable.getSelectionModel();
    return selectionModel.getSelectedObject();
}
 
Example 5
Source File: ClusterConnectionList.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public ClusterConnection getSelectedEntity() {
    SingleSelectionModel<ClusterConnection> selectionModel = (SingleSelectionModel<ClusterConnection>)factoryTable.getSelectionModel();
    return selectionModel.getSelectedObject();
}
 
Example 6
Source File: BroadcastGroupList.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public BroadcastGroup getSelectedEntity() {
    SingleSelectionModel<BroadcastGroup> selectionModel = (SingleSelectionModel<BroadcastGroup>)factoryTable.getSelectionModel();
    return selectionModel.getSelectedObject();
}
 
Example 7
Source File: DiscoveryGroupList.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public DiscoveryGroup getSelectedEntity() {
    SingleSelectionModel<DiscoveryGroup> selectionModel = (SingleSelectionModel<DiscoveryGroup>)factoryTable.getSelectionModel();
    return selectionModel.getSelectedObject();
}
 
Example 8
Source File: DivertList.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Divert getSelectedEntity() {
    SingleSelectionModel<Divert> selectionModel = (SingleSelectionModel<Divert>) table.getSelectionModel();
    return selectionModel.getSelectedObject();
}
 
Example 9
Source File: AcceptorList.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Acceptor getSelectedEntity() {
    SingleSelectionModel<Acceptor> selectionModel = (SingleSelectionModel<Acceptor>) table.getSelectionModel();
    return selectionModel.getSelectedObject();
}
 
Example 10
Source File: ConnectorList.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Connector getSelectedEntity() {
    SingleSelectionModel<Connector> selectionModel = (SingleSelectionModel<Connector>) table.getSelectionModel();
    return selectionModel.getSelectedObject();
}
 
Example 11
Source File: ConnectorServiceList.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public ConnectorService getSelectedEntity() {
    SingleSelectionModel<ConnectorService> selectionModel = (SingleSelectionModel<ConnectorService>) table.getSelectionModel();
    return selectionModel.getSelectedObject();
}
 
Example 12
Source File: BridgesList.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Bridge getSelectedEntity() {
    SingleSelectionModel<Bridge> selectionModel = (SingleSelectionModel<Bridge>)factoryTable.getSelectionModel();
    return selectionModel.getSelectedObject();
}
 
Example 13
Source File: PropertyEditor.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@SuppressWarnings("unchecked")
public Widget asWidget() {
    VerticalPanel panel = new VerticalPanel();
    panel.addStyleName("fill-layout-width");

    // table
    table = new DefaultCellTable<>(numRows, keyProvider);
    dataProvider = new ListDataProvider<>(keyProvider);
    dataProvider.addDataDisplay(table);
    final SingleSelectionModel<Property> selectionModel = new SingleSelectionModel<>(keyProvider);
    table.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(event -> {
        Property selection = selectionModel.getSelectedObject();
        if (selection == null) {
            propertyManager.onDeselect();
        } else {
            propertyManager.onSelect(selection);
        }
    });

    // columns
    Column<Property, String> keyColumn = new TextColumn<Property>() {
        @Override
        public String getValue(Property property) {
            return property.getName();
        }
    };
    keyColumn.setSortable(true);
    Column<Property, String> valueColumn;
    if (inlineEditing) {
        valueColumn = new Column<Property, String>(new DefaultEditTextCell()) { {
                setFieldUpdater((index, property, value) -> getPropertyValue(property).set(value));
            }

            @Override
            public String getValue(Property property) {
                return property.getValue().get(VALUE).asString();
            }
        };
    } else {
        valueColumn = new TextColumn<Property>() {
            @Override
            public String getValue(Property property) {
                return getPropertyValue(property).asString();
            }
        };
    }
    ColumnSortEvent.ListHandler<Property> sortHandler = new ColumnSortEvent.ListHandler<>(dataProvider.getList());
    sortHandler.setComparator(keyColumn, new Comparator<Property>() {
        @Override
        public int compare(Property o1, Property o2) {
            return o1.getName().toLowerCase().compareTo(o2.getName().toLowerCase());
        }
    });
    table.addColumn(keyColumn, Console.CONSTANTS.common_label_key());
    table.addColumn(valueColumn, Console.CONSTANTS.common_label_value());
    table.setColumnWidth(keyColumn, 40, Style.Unit.PCT);
    table.setColumnWidth(valueColumn, 60, Style.Unit.PCT);
    table.addColumnSortHandler(sortHandler);
    table.getColumnSortList().push(keyColumn);

    // tools
    if (!hideTools) {
        ToolStrip tools = new ToolStrip();
        addButton = new ToolButton(addLabel, event -> {
            addDialog.clearValues();
            propertyManager.openAddDialog(addDialog);
        });
        removeButton = new ToolButton(removeLabel, event -> {
            final Property selection = selectionModel.getSelectedObject();
            if (selection != null) {
                Feedback.confirm(Console.MESSAGES.removeProperty(),
                        Console.MESSAGES.removePropertyConfirm(selection.getName()),
                        new Feedback.ConfirmationHandler() {
                            @Override
                            public void onConfirmation(boolean isConfirmed) {
                                if (isConfirmed) {
                                    propertyManager.onRemove(selection);
                                }
                            }
                        });
            }
        });
        AddressTemplate effectiveAddress = operationAddress != null ? operationAddress : propertyManager
                .getAddress();
        if (effectiveAddress != null) {
            addButton.setOperationAddress(effectiveAddress.getTemplate(), propertyManager.getAddOperationName());
            removeButton
                    .setOperationAddress(effectiveAddress.getTemplate(), propertyManager.getRemoveOperationName());
        }
        tools.addToolButtonRight(addButton);
        tools.addToolButtonRight(removeButton);
        panel.add(tools);
    }

    panel.add(table);
    DefaultPager pager = new DefaultPager();
    pager.setDisplay(table);
    panel.add(pager);
    return panel;
}
 
Example 14
Source File: AcceptorList.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@SuppressWarnings("unchecked")
public ActivemqAcceptor getSelectedEntity() {
    SingleSelectionModel<ActivemqAcceptor> selectionModel = (SingleSelectionModel<ActivemqAcceptor>) table.getSelectionModel();
    return selectionModel.getSelectedObject();
}
 
Example 15
Source File: ConnectorList.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@SuppressWarnings("unchecked")
public ActivemqConnector getSelectedEntity() {
    SingleSelectionModel<ActivemqConnector> selectionModel = (SingleSelectionModel<ActivemqConnector>) table.getSelectionModel();
    return selectionModel.getSelectedObject();
}
 
Example 16
Source File: ParticipantsPanel.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private TXParticipant getSelectedRecord() {
    SingleSelectionModel<TXParticipant> selectionModel = (SingleSelectionModel<TXParticipant>)table.getSelectionModel();
    return selectionModel.getSelectedObject();
}
 
Example 17
Source File: StackEditor.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@SuppressWarnings("unchecked")
private JGroupsProtocol getCurrentSelection() {
    SingleSelectionModel<JGroupsProtocol> selectionModel = (SingleSelectionModel<JGroupsProtocol>) table.getSelectionModel();
    return selectionModel.getSelectedObject();

}
 
Example 18
Source File: LocalSocketList.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public LocalSocketBinding getSelectedEntity() {
    SingleSelectionModel<LocalSocketBinding> selectionModel = (SingleSelectionModel<LocalSocketBinding>)factoryTable.getSelectionModel();
    return selectionModel.getSelectedObject();
}
 
Example 19
Source File: RemoteSocketList.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public RemoteSocketBinding getSelectedEntity() {
    SingleSelectionModel<RemoteSocketBinding> selectionModel = (SingleSelectionModel<RemoteSocketBinding>)factoryTable.getSelectionModel();
    return selectionModel.getSelectedObject();
}
 
Example 20
Source File: MemberDialog.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public Widget asWidget() {
    ProvidesKey<Principal> keyProvider = Principal::getId;

    AbstractCell<Principal> roleCell = new AbstractCell<Principal>() {
        @Override
        public void render(final Context context, final Principal value, final SafeHtmlBuilder sb) {
            sb.append(Templates.memberItem("navigation-column-item", value));
        }
    };
    DefaultCellList<Principal> list = new DefaultCellList<>(roleCell, keyProvider);
    list.setPageSize(30);
    list.setKeyboardPagingPolicy(INCREASE_RANGE);
    list.setKeyboardSelectionPolicy(BOUND_TO_SELECTION);

    ListDataProvider<Principal> dataProvider = new ListDataProvider<>(keyProvider);
    dataProvider.setList(Principals.orderedByType()
            .compound(Principals.orderedByName())
            .immutableSortedCopy(unassignedPrincipals));
    dataProvider.addDataDisplay(list);

    SingleSelectionModel<Principal> selectionModel = new SingleSelectionModel<>(keyProvider);
    list.setSelectionModel(selectionModel);
    selectionModel.setSelected(dataProvider.getList().get(0), true);
    Scheduler.get().scheduleDeferred(() -> list.setFocus(true));

    Label errorMessage = new Label();
    errorMessage.setVisible(false);
    errorMessage.getElement().getStyle().setColor("#c82e2e");
    errorMessage.getElement().getStyle().setPadding(7, PX);

    VerticalPanel layout = new VerticalPanel();
    layout.setStyleName("window-content");
    layout.add(errorMessage);
    layout.add(list);

    DialogueOptions options = new DialogueOptions(
            event -> {
                if (selectionModel.getSelectedObject() == null) {
                    errorMessage.setText(Console.CONSTANTS.pleaseSelectPrincipal());
                    errorMessage.setVisible(true);
                } else {
                    Assignment assignment = new Assignment(selectionModel.getSelectedObject(), role,
                            include);
                    circuit.dispatch(new AddAssignment(assignment, ROLE_TO_PRINCIPAL));
                    presenter.closeWindow();
                }
            },
            event -> presenter.closeWindow()
    );

    return new WindowContentBuilder(layout, options).build();
}