コード例 #1
0
 private boolean categoryExists(String name) {
   ISiteCategoryDefinition[] defs = fModel.getSite().getCategoryDefinitions();
   for (int i = 0; i < defs.length; i++) {
     ISiteCategoryDefinition def = defs[i];
     String dname = def.getName();
     if (dname != null && dname.equals(name)) return true;
   }
   return false;
 }
コード例 #2
0
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#canPaste(java.lang.Object,
  *      java.lang.Object[])
  */
 protected boolean canPaste(Object target, Object[] objects) {
   if (target == null || target instanceof ISiteCategoryDefinition) {
     for (int i = 0; i < objects.length; i++) {
       if (objects[i] instanceof SiteFeatureAdapter) return true;
       if (objects[i] instanceof ISiteCategoryDefinition) {
         String name = ((ISiteCategoryDefinition) objects[i]).getName();
         ISiteCategoryDefinition[] defs = fModel.getSite().getCategoryDefinitions();
         for (int j = 0; j < defs.length; j++) {
           ISiteCategoryDefinition def = defs[j];
           String dname = def.getName();
           if (dname != null && dname.equals(name)) return false;
         }
         return true;
       }
     }
   }
   return false;
 }
コード例 #3
0
 private void handleAddCategoryDefinition() {
   String name =
       NLS.bind(
           PDEUIMessages.CategorySection_newCategoryName, Integer.toString(++newCategoryCounter));
   while (categoryExists(name)) {
     name =
         NLS.bind(
             PDEUIMessages.CategorySection_newCategoryName,
             Integer.toString(++newCategoryCounter));
   }
   String label =
       NLS.bind(
           PDEUIMessages.CategorySection_newCategoryLabel, Integer.toString(newCategoryCounter));
   ISiteCategoryDefinition categoryDef = fModel.getFactory().createCategoryDefinition();
   try {
     categoryDef.setName(name);
     categoryDef.setLabel(label);
     fModel.getSite().addCategoryDefinitions(new ISiteCategoryDefinition[] {categoryDef});
   } catch (CoreException e) {
     PDEPlugin.logException(e);
   }
   fCategoryViewer.setSelection(new StructuredSelection(categoryDef), true);
 }