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); } } } }
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); }