コード例 #1
0
 private void applyValue(String property, String value) throws CoreException {
   if (fCurrentCategoryDefinition == null) return;
   if (property.equals(PROPERTY_NAME)) {
     String oldName = fCurrentCategoryDefinition.getName();
     fCurrentCategoryDefinition.setName(value);
     bringFeatures(oldName);
   } else if (property.equals(PROPERTY_TYPE)) fCurrentCategoryDefinition.setLabel(value);
   else if (property.equals(PROPERTY_DESC)) {
     if (value == null || value.length() == 0) {
       fCurrentCategoryDefinition.setDescription(null);
     } else {
       ISiteDescription siteDesc = fCurrentCategoryDefinition.getDescription();
       if (siteDesc == null) {
         siteDesc =
             fCurrentCategoryDefinition
                 .getModel()
                 .getFactory()
                 .createDescription(fCurrentCategoryDefinition);
         siteDesc.setText(value);
         fCurrentCategoryDefinition.setDescription(siteDesc);
       } else {
         siteDesc.setText(value);
       }
     }
   }
 }
コード例 #2
0
 private boolean alreadyExists(String name) {
   ISiteCategoryDefinition[] defs =
       fCurrentCategoryDefinition.getModel().getSite().getCategoryDefinitions();
   for (int i = 0; i < defs.length; i++) {
     ISiteCategoryDefinition def = defs[i];
     if (def == fCurrentCategoryDefinition) continue;
     String dname = def.getName();
     if (dname != null && dname.equals(name)) return true;
   }
   return false;
 }
コード例 #3
0
 private void bringFeatures(String oldCategory) {
   ISiteFeature[] siteFeatures = fCurrentCategoryDefinition.getModel().getSite().getFeatures();
   for (int i = 0; i < siteFeatures.length; i++) {
     ISiteCategory[] categories = siteFeatures[i].getCategories();
     for (int c = 0; c < categories.length; c++) {
       if (oldCategory.equals(categories[c].getName())) {
         try {
           categories[c].setName(fCurrentCategoryDefinition.getName());
         } catch (CoreException ce) {
         }
       }
     }
   }
 }