001 /*
002 * Copyright (c) 2005 Einar Pehrson <einar@pehrson.nu>.
003 *
004 * This file is part of
005 * CleanSheets - a spreadsheet application for the Java platform.
006 *
007 * CleanSheets is free software; you can redistribute it and/or modify
008 * it under the terms of the GNU General Public License as published by
009 * the Free Software Foundation; either version 2 of the License, or
010 * (at your option) any later version.
011 *
012 * CleanSheets is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
015 * GNU General Public License for more details.
016 *
017 * You should have received a copy of the GNU General Public License
018 * along with CleanSheets; if not, write to the Free Software
019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020 */
021 package csheets.ext;
022
023 import csheets.core.Cell;
024 import csheets.core.Spreadsheet;
025 import csheets.ui.ctrl.UIController;
026 import csheets.ui.ext.UIExtension;
027
028 /**
029 * An interface for extensions to the CleanSheets application.
030 * @author Einar Pehrson
031 */
032 public abstract class Extension implements Comparable<Extension> {
033
034 /** The name of the extension */
035 private final String name;
036
037 /** The base key to use for properties of the extension */
038 private final String basePropKey;
039
040 /**
041 * Creates a new extension.
042 * @param name the name of the extension
043 */
044 public Extension(String name) {
045 this.name = name;
046
047 // Builds UI extension base property key
048 String basePropKey = "";
049 for (String token : name.toLowerCase().split(" "))
050 basePropKey += token;
051 this.basePropKey = basePropKey + ".ui.";
052 }
053
054 /**
055 * Returns the name of the extension.
056 * @return the name of the extension
057 */
058 public final String getName() {
059 return name;
060 }
061
062 /**
063 * Returns the base key to use for properties of the UI extension.
064 * @return the base key to use for properties of the UI extension
065 */
066 public final String getPropertyKey() {
067 return basePropKey;
068 }
069
070 /**
071 * Compares this extension with the given extension for order.
072 * Ordering is done by the extensions' names.
073 * @param extension the extension to compared to
074 * @return a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
075 */
076 public final int compareTo(Extension extension) {
077 return name.compareTo(extension.name);
078 }
079
080 /**
081 * Returns an extension of the given spreadsheet.
082 * @param spreadsheet the spreadsheet to extend
083 * @return a spreadsheet extension, or null if none is provided
084 */
085 public SpreadsheetExtension extend(Spreadsheet spreadsheet) {
086 return null;
087 }
088
089 /**
090 * Returns an extension of the given cell.
091 * @param cell the cell to extend
092 * @return a cell extension, or null if none is provided
093 */
094 public CellExtension extend(Cell cell) {
095 return null;
096 }
097
098 /**
099 * Returns the user interface extension of this extension.
100 * @param uiController the user interface controller
101 * @return a user interface extension, or null if none is provided
102 */
103 public UIExtension getUIExtension(UIController uiController) {
104 return null;
105 }
106 }