001: /* ====================================================================
002: * The JRefactory License, Version 1.0
003: *
004: * Copyright (c) 2001 JRefactory. All rights reserved.
005: *
006: * Redistribution and use in source and binary forms, with or without
007: * modification, are permitted provided that the following conditions
008: * are met:
009: *
010: * 1. Redistributions of source code must retain the above copyright
011: * notice, this list of conditions and the following disclaimer.
012: *
013: * 2. Redistributions in binary form must reproduce the above copyright
014: * notice, this list of conditions and the following disclaimer in
015: * the documentation and/or other materials provided with the
016: * distribution.
017: *
018: * 3. The end-user documentation included with the redistribution,
019: * if any, must include the following acknowledgment:
020: * "This product includes software developed by the
021: * JRefactory (http://www.sourceforge.org/projects/jrefactory)."
022: * Alternately, this acknowledgment may appear in the software itself,
023: * if and wherever such third-party acknowledgments normally appear.
024: *
025: * 4. The names "JRefactory" must not be used to endorse or promote
026: * products derived from this software without prior written
027: * permission. For written permission, please contact seguin@acm.org.
028: *
029: * 5. Products derived from this software may not be called "JRefactory",
030: * nor may "JRefactory" appear in their name, without prior written
031: * permission of Chris Seguin.
032: *
033: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
034: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
035: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
036: * DISCLAIMED. IN NO EVENT SHALL THE CHRIS SEGUIN OR
037: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
038: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
039: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
040: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
041: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
042: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
043: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
044: * SUCH DAMAGE.
045: * ====================================================================
046: *
047: * This software consists of voluntary contributions made by many
048: * individuals on behalf of JRefactory. For more information on
049: * JRefactory, please see
050: * <http://www.sourceforge.org/projects/jrefactory>.
051: */
052: package org.acm.seguin.ide.netbeans;
053:
054: import java.io.StringReader;
055: import java.io.IOException;
056:
057: import java.awt.Frame;
058:
059: import net.sourceforge.jrefactory.action.SelectedFileSet;
060: import org.acm.seguin.summary.FileSummary;
061: import org.acm.seguin.summary.TypeSummary;
062: import org.netbeans.modules.java.JavaDataObject;
063:
064: import org.acm.seguin.ide.common.IDEPlugin;
065: import org.acm.seguin.ide.common.options.SelectedRules;
066:
067: /**
068: * The concrete implementation of this class for Netbeans
069: *
070: *@author <a href="JRefactory@ladyshot.demon.co.uk">Mike Atkinson</a>
071: *@version $Id: NetbeansSelectedFileSet.java,v 1.1 2004/05/05 17:28:52 mikeatkinson Exp $
072: *@created May 05, 2004
073: */
074: public class NetbeansSelectedFileSet extends SelectedFileSet {
075: private Frame view;
076: private JavaDataObject[] buffers;
077:
078: /**
079: * Constructor for the JBuilderSelectedFileSet object
080: *
081: *@param init Description of Parameter
082: */
083: public NetbeansSelectedFileSet(Frame view, JavaDataObject buffer) {
084: this .view = view;
085: this .buffers = new JavaDataObject[] { buffer };
086: }
087:
088: /**
089: * Constructor for the JBuilderSelectedFileSet object
090: *
091: *@param init Description of Parameter
092: */
093: public NetbeansSelectedFileSet(Frame view, JavaDataObject[] buffers) {
094: this .view = view;
095: this .buffers = buffers;
096: }
097:
098: /**
099: * Gets the TypeSummaryArray attribute of the SelectedFileSet object
100: *
101: *@return The TypeSummaryArray value
102: */
103: public TypeSummary[] getTypeSummaryArray() {
104: TypeSummary[] typeSummaryArray = new TypeSummary[buffers.length];
105:
106: for (int ndx = 0; ndx < buffers.length; ndx++) {
107: TypeSummary typeSummary = getTypeSummaryFromBuffer(buffers[ndx]);
108: if (typeSummary == null) {
109: return null;
110: }
111: typeSummaryArray[ndx] = typeSummary;
112: }
113:
114: return typeSummaryArray;
115: }
116:
117: /**
118: * Gets the AllJava attribute of the SelectedFileSet object
119: *
120: *@return The AllJava value
121: */
122: public boolean isAllJava() {
123: System.out.println("JEditSelectedFileSet.isAllJava()");
124: for (int i = 0; i < buffers.length; i++) {
125: if (!javaBuffer(buffers[i])) {
126: return false;
127: }
128: }
129: return true;
130: }
131:
132: private boolean javaBuffer(JavaDataObject buffer) {
133: //return buffer.getPrimaryEntry().getFile().getExt().toLowerCase().equals("java");
134: return true;
135: }
136:
137: /**
138: * Gets the SingleJavaFile attribute of the SelectedFileSet object
139: *
140: *@return The SingleJavaFile value
141: */
142: public boolean isSingleJavaFile() {
143: System.out.println("JEditSelectedFileSet.isSingleJavaFile()");
144: return (buffers.length == 1 && javaBuffer(buffers[0]));
145: }
146:
147: /**
148: * Gets the TypeSummaryFromNode attribute of the AddParentClassAction
149: * object
150: *
151: *@param node Description of Parameter
152: *@return The TypeSummaryFromNode value
153: */
154: private TypeSummary getTypeSummaryFromBuffer(JavaDataObject buffer) {
155: System.out
156: .println("JEditSelectedFileSet.getTypeSummaryFromBuffer("
157: + buffer + ")");
158: FileSummary fileSummary = reloadBuffer(buffer);
159: if (fileSummary == null) {
160: return null;
161: }
162:
163: return getTypeSummary(fileSummary);
164: }
165:
166: /**
167: * Description of the Method
168: *
169: *@param node Description of Parameter
170: *@return Description of the Returned Value
171: */
172: private FileSummary reloadBuffer(JavaDataObject buffer) {
173: System.out.println("JEditSelectedFileSet.reloadBuffer("
174: + buffer + ")");
175: StringReader reader = new StringReader(IDEPlugin.getText(view,
176: buffer));
177: return reloadFile(new java.io.File(IDEPlugin
178: .getFilePathForBuffer(buffer)), reader);
179: }
180:
181: }
|