/** * Returns an array containing the selected item. * * @return an array of Objects containing the selected item */ @Override public Object[] getSelectedObjects() { Object selectedObject = getSelectedItem(); if (selectedObject == null) return new Object[0]; else return new Object[]{selectedObject}; }
/** * Creates a combo box. * * @return the created combo box. */ protected SComboBox createSComboBox() { SComboBox comboBox = new SComboBox(); comboBox.setHorizontalAlignment(SConstants.LEFT_ALIGN); return comboBox; }
/** * Adds an ActionListener. The listener will receive an action event * when the user changed the selection. * * @param listener the ActionListener that is to be notified */ public void addActionListener(ActionListener listener) { addEventListener(ActionListener.class, listener); reload(); }
private IView<SComponent> createEnumerationPropertyView( IEnumerationPropertyDescriptor propertyDescriptor, IActionHandler actionHandler, Locale locale) { SComboBox viewComponent = createSComboBox(); if (!propertyDescriptor.isMandatory()) { viewComponent.addItem(null); } for (Object enumElement : propertyDescriptor.getEnumerationValues()) { viewComponent.addItem(enumElement); } viewComponent.setRenderer(new TranslatedEnumerationListCellRenderer( propertyDescriptor, locale)); adjustSizes(viewComponent, null, getEnumerationTemplateValue( propertyDescriptor, locale), 48); SComboBoxConnector connector = new SComboBoxConnector(propertyDescriptor .getName(), viewComponent); connector.setExceptionHandler(actionHandler); return constructView(viewComponent, null, connector); }
/** * Selects the item at index <code>index</code>. * * @param index the item to be selected */ public void setSelectedIndex(int index) { int size = dataModel.getSize(); if (index == -1) setSelectedItem(null); else if (index < -1 || index >= size) throw new IllegalArgumentException("setSelectedIndex: " + index + " out of bounds"); else{ int oldVal = this.getSelectedIndex(); setSelectedItem(dataModel.getElementAt(index)); } }
@Override public void installCG(final SComponent comp) { super.installCG(comp); final SComboBox component = (SComboBox) comp; final CGManager manager = component.getSession().getCGManager(); Object value = manager.getObject("SComboBox.renderer", SDefaultListCellRenderer.class); if (value != null) { component.setRenderer((SDefaultListCellRenderer) value); } }
/** * Sets the selected item in the combobox to be the connector value to set. * <p> * {@inheritDoc} */ @Override protected void setConnecteeValue(Object aValue) { getConnectedSComponent().setSelectedItem(aValue); } }
/** * {@inheritDoc} */ @Override public void updateState() { super.updateState(); getConnectedSComponent().setEnabled(isWritable()); }
/** * {@inheritDoc} */ @Override protected void bindSComponent() { getConnectedSComponent().addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) { fireConnectorValueChange(); } }); }
/** * Adds an ItemListener. The listener will receive an action event * when the user changed the selection. * * @param listener the ItemListener that is to be notified */ @Override public void addItemListener(ItemListener listener) { addEventListener(ItemListener.class, listener); }
viewComponent = createSComboBox(); if (!propertyDescriptor.isMandatory()) { ((SComboBox) viewComponent).addItem(null); ((SComboBox) viewComponent).addItem(enumElement); .setRenderer(new TranslatedEnumerationListCellRenderer( propertyDescriptor, actionHandler, locale)); adjustSizes(
/** * Sets the selected item in the combobox to be the connector value to set. * <p> * {@inheritDoc} */ @Override protected void setConnecteeValue(Object aValue) { getConnectedSComponent().setSelectedItem(aValue); } }
/** * {@inheritDoc} */ @Override public void writabilityChange() { super.writabilityChange(); getConnectedSComponent().setEnabled(isWritable()); }
/** * {@inheritDoc} */ @Override protected void bindSComponent() { getConnectedSComponent().addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) { fireConnectorValueChange(); } }); }
/** * Creates a combo box. * * @return the created combo box. */ protected SComboBox createSComboBox() { SComboBox comboBox = new SComboBox(); comboBox.setHorizontalAlignment(SConstants.LEFT_ALIGN); return comboBox; }
/** * Returns the selected object in the combobox. * <p> * {@inheritDoc} */ @Override protected Object getConnecteeValue() { return getConnectedSComponent().getSelectedItem(); }
/** * Returns the selected object in the combobox. * <p> * {@inheritDoc} */ @Override protected Object getConnecteeValue() { return getConnectedSComponent().getSelectedItem(); }