summaryrefslogtreecommitdiff
path: root/propertysheet/src/org/eclipse/wb/internal/core/model/property/category
diff options
context:
space:
mode:
Diffstat (limited to 'propertysheet/src/org/eclipse/wb/internal/core/model/property/category')
-rw-r--r--propertysheet/src/org/eclipse/wb/internal/core/model/property/category/PropertyCategory.java159
-rw-r--r--propertysheet/src/org/eclipse/wb/internal/core/model/property/category/PropertyCategoryProvider.java26
-rw-r--r--propertysheet/src/org/eclipse/wb/internal/core/model/property/category/PropertyCategoryProviders.java85
3 files changed, 0 insertions, 270 deletions
diff --git a/propertysheet/src/org/eclipse/wb/internal/core/model/property/category/PropertyCategory.java b/propertysheet/src/org/eclipse/wb/internal/core/model/property/category/PropertyCategory.java
deleted file mode 100644
index a135b03..0000000
--- a/propertysheet/src/org/eclipse/wb/internal/core/model/property/category/PropertyCategory.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Google, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Google, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wb.internal.core.model.property.category;
-
-import org.eclipse.wb.internal.core.model.property.Property;
-import org.eclipse.wb.internal.core.utils.check.Assert;
-
-/**
- * Describes category of {@link Property}.
- *
- * @author scheglov_ke
- * @coverage core.model.property
- */
-public final class PropertyCategory {
- /**
- * "Normal" category, used for properties that should be displayed without any effect.
- */
- public static final PropertyCategory NORMAL = new PropertyCategory(0, "NORMAL");
- /**
- * "Preferred" category, for properties that are most useful for component.
- */
- public static final PropertyCategory PREFERRED = new PropertyCategory(-1, "PREFERRED");
- /**
- * "Advanced" category, for properties that are rarely used, visible if modified, even if not
- * enabled.
- */
- public static final PropertyCategory ADVANCED = new PropertyCategory(1, "ADVANCED");
- /**
- * "Advanced" category, for properties that are rarely used, visible only if enabled.
- */
- public static final PropertyCategory ADVANCED_REALLY = new PropertyCategory(2, "ADVANCED_REALLY");
- /**
- * "Hidden" category, for properties that should not be displayed.
- */
- public static final PropertyCategory HIDDEN = new PropertyCategory(3, "HIDDEN");
-
- ////////////////////////////////////////////////////////////////////////////
- //
- // System
- //
- ////////////////////////////////////////////////////////////////////////////
- /**
- * @return the system {@link PropertyCategory} with given priority.
- */
- public static final PropertyCategory system(int priority) {
- return new PropertyCategory(SYSTEM_BASE + priority, "SYSTEM:" + priority);
- }
-
- /**
- * @return the system {@link PropertyCategory} with priority
- * <code>system.getPriority() + additional</code>.
- */
- public static final PropertyCategory system(PropertyCategory system, int additional) {
- Assert.isTrue(system.isSystem());
- return system(system.getPriority() - SYSTEM_BASE + additional);
- }
-
- ////////////////////////////////////////////////////////////////////////////
- //
- // Instance fields
- //
- ////////////////////////////////////////////////////////////////////////////
- private static final int SYSTEM_BASE = 1000;
- private final int m_priority;
- private final String m_string;
-
- ////////////////////////////////////////////////////////////////////////////
- //
- // Constructor
- //
- ////////////////////////////////////////////////////////////////////////////
- private PropertyCategory(int priority, String string) {
- m_priority = priority;
- m_string = string;
- }
-
- ////////////////////////////////////////////////////////////////////////////
- //
- // Object
- //
- ////////////////////////////////////////////////////////////////////////////
- @Override
- public String toString() {
- return m_string;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
- if (obj instanceof PropertyCategory) {
- PropertyCategory category = (PropertyCategory) obj;
- return m_priority == category.m_priority;
- }
- // unknown class
- return false;
- }
-
- @Override
- public int hashCode() {
- return m_priority;
- }
-
- ////////////////////////////////////////////////////////////////////////////
- //
- // Access
- //
- ////////////////////////////////////////////////////////////////////////////
- /**
- * @return <code>true</code> if this property is preferred.
- */
- public boolean isPreferred() {
- return this == PREFERRED;
- }
-
- /**
- * @return <code>true</code> if this property is advanced.
- */
- public boolean isAdvanced() {
- return this == ADVANCED;
- }
-
- /**
- * @return <code>true</code> if this property is really advanced.
- */
- public boolean isAdvancedReally() {
- return this == ADVANCED_REALLY;
- }
-
- /**
- * @return <code>true</code> if this property is hidden.
- */
- public boolean isHidden() {
- return this == HIDDEN;
- }
-
- /**
- * @return <code>true</code> if this property is system.
- */
- public boolean isSystem() {
- return m_priority >= 900;
- }
-
- /**
- * @return the priority of this category.
- */
- public int getPriority() {
- return m_priority;
- }
-}
diff --git a/propertysheet/src/org/eclipse/wb/internal/core/model/property/category/PropertyCategoryProvider.java b/propertysheet/src/org/eclipse/wb/internal/core/model/property/category/PropertyCategoryProvider.java
deleted file mode 100644
index b435576..0000000
--- a/propertysheet/src/org/eclipse/wb/internal/core/model/property/category/PropertyCategoryProvider.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Google, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Google, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wb.internal.core.model.property.category;
-
-import org.eclipse.wb.internal.core.model.property.Property;
-
-/**
- * This interface is used to get {@link PropertyCategory} for {@link Property}.
- *
- * @author scheglov_ke
- * @coverage core.model.property
- */
-public interface PropertyCategoryProvider {
- /**
- * @return the {@link PropertyCategory} of given Property, not <code>null</code>.
- */
- PropertyCategory getCategory(Property property);
-}
diff --git a/propertysheet/src/org/eclipse/wb/internal/core/model/property/category/PropertyCategoryProviders.java b/propertysheet/src/org/eclipse/wb/internal/core/model/property/category/PropertyCategoryProviders.java
deleted file mode 100644
index 83aaebb..0000000
--- a/propertysheet/src/org/eclipse/wb/internal/core/model/property/category/PropertyCategoryProviders.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Google, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Google, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wb.internal.core.model.property.category;
-
-import org.eclipse.wb.internal.core.model.property.Property;
-import org.eclipse.wb.internal.core.model.property.PropertyManager;
-
-/**
- * Factory for {@link PropertyCategoryProvider} instances.
- *
- * @author scheglov_ke
- * @coverage core.model.property
- */
-public final class PropertyCategoryProviders {
- ////////////////////////////////////////////////////////////////////////////
- //
- // Simple providers
- //
- ////////////////////////////////////////////////////////////////////////////
- private static final PropertyCategoryProvider FROM_PROPERTY = new PropertyCategoryProvider() {
- public PropertyCategory getCategory(Property property) {
- return property.getCategory();
- }
- };
-
- /**
- * Returns result of {@link Property#getCategory()}, never <code>null</code>.
- */
- public static PropertyCategoryProvider fromProperty() {
- return FROM_PROPERTY;
- }
-
- private static final PropertyCategoryProvider FORCED_BY_USER = new PropertyCategoryProvider() {
- public PropertyCategory getCategory(Property property) {
- return PropertyManager.getCategoryForced(property);
- }
- };
-
- /**
- * Returns category forced by user, may be <code>null</code>.
- */
- public static PropertyCategoryProvider forcedByUser() {
- return FORCED_BY_USER;
- }
-
- ////////////////////////////////////////////////////////////////////////////
- //
- // Compound
- //
- ////////////////////////////////////////////////////////////////////////////
- /**
- * Returns first not <code>null</code> category returned by provider.
- */
- public static PropertyCategoryProvider combine(final PropertyCategoryProvider... providers) {
- return new PropertyCategoryProvider() {
- public PropertyCategory getCategory(Property property) {
- for (PropertyCategoryProvider provider : providers) {
- PropertyCategory category = provider.getCategory(property);
- if (category != null) {
- return category;
- }
- }
- throw new IllegalStateException("Can not provide category for " + property.getTitle());
- }
- };
- }
-
- private static final PropertyCategoryProvider DEF = combine(forcedByUser(), fromProperty());
-
- /**
- * Returns the default combination of {@link PropertyCategoryProvider}s - first
- * {@link #forcedByUser()}, then {@link #fromProperty()}.
- */
- public static PropertyCategoryProvider def() {
- return DEF;
- }
-}