コード例 #1
0
  private void getComboAttribute(Composite composite) {
    comboAttribute = new Combo(composite, SWT.READ_ONLY);
    comboAttribute.setText(Messages.getString("UpdateAttributeDialog.3")); // $NON-NLS-1$
    comboAttribute.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));

    Object firstElement = selection.get(0);
    if (firstElement instanceof EObject) {
      AttributeConfiguration configuration =
          RequirementUtils.getAttributeConfiguration(((EObject) firstElement).eResource());

      List<String> labelList = new ArrayList<String>();
      for (ConfiguratedAttribute anAttribute : configuration.getListAttributes()) {
        labelList.add(anAttribute.getName());
        comboAttribute.setData(anAttribute.getName(), anAttribute.getListValue());
      }

      comboAttribute.setItems(labelList.toArray(new String[0]));
      comboAttribute.addSelectionListener(new AttributeSelectionListener());
      comboAttribute.addModifyListener(
          new ModifyListener() {
            public void modifyText(ModifyEvent event) {
              attributeNameModified();
            }
          });
    }
  }
コード例 #2
0
 /** @see org.eclipse.jface.viewers.IFilter#select(java.lang.Object) */
 public boolean select(Object toTest) {
   if (toTest instanceof TextAttribute) {
     TextAttribute attribute = (TextAttribute) toTest;
     AttributeConfiguration configuration =
         RequirementUtils.getAttributeConfiguration(attribute.eResource());
     if (configuration != null) {
       for (ConfiguratedAttribute att : configuration.getListAttributes()) {
         if (AttributesType.TEXT.equals(att.getType())
             && attribute.getName().equals(att.getName())) {
           return att.getListValue().isEmpty();
         }
       }
     } else {
       return true;
     }
   }
   return false;
 }