1 /******************************************************************************* 2 * Copyright (c) 2000, 2016 IBM Corporation and others. 3 * 4 * This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License 2.0 6 * which accompanies this distribution, and is available at 7 * https://www.eclipse.org/legal/epl-2.0/ 8 * 9 * SPDX-License-Identifier: EPL-2.0 10 * 11 * Contributors: 12 * IBM Corporation - initial API and implementation 13 *******************************************************************************/ 14 package org.eclipse.ui.views.properties; 15 16 import java.util.ArrayList; 17 import java.util.List; 18 19 /** 20 * A category in a PropertySheet used to group <code>IPropertySheetEntry</code> 21 * entries so they are displayed together. 22 */ 23 /*package*/class PropertySheetCategory { 24 private String categoryName; 25 26 private List<IPropertySheetEntry> entries = new ArrayList<>(); 27 28 private boolean shouldAutoExpand = true; 29 30 /** 31 * Create a PropertySheet category with name. 32 * @param name 33 */ PropertySheetCategory(String name)34 public PropertySheetCategory(String name) { 35 categoryName = name; 36 } 37 38 /** 39 * Add an <code>IPropertySheetEntry</code> to the list 40 * of entries in this category. 41 * @param entry 42 */ addEntry(IPropertySheetEntry entry)43 public void addEntry(IPropertySheetEntry entry) { 44 entries.add(entry); 45 } 46 47 /** 48 * Return the category name. 49 * @return the category name 50 */ getCategoryName()51 public String getCategoryName() { 52 return categoryName; 53 } 54 55 /** 56 * Returns <code>true</code> if this category should be automatically 57 * expanded. The default value is <code>true</code>. 58 * 59 * @return <code>true</code> if this category should be automatically 60 * expanded, <code>false</code> otherwise 61 */ getAutoExpand()62 public boolean getAutoExpand() { 63 return shouldAutoExpand; 64 } 65 66 /** 67 * Sets if this category should be automatically 68 * expanded. 69 * @param autoExpand 70 */ setAutoExpand(boolean autoExpand)71 public void setAutoExpand(boolean autoExpand) { 72 shouldAutoExpand = autoExpand; 73 } 74 75 /** 76 * Returns the entries in this category. 77 * 78 * @return the entries in this category 79 */ getChildEntries()80 public IPropertySheetEntry[] getChildEntries() { 81 return entries.toArray(new IPropertySheetEntry[entries.size()]); 82 } 83 84 /** 85 * Removes all of the entries in this category. 86 * Doing so allows us to reuse this category entry. 87 */ removeAllEntries()88 public void removeAllEntries() { 89 entries = new ArrayList<>(); 90 } 91 } 92