001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: package org.netbeans.modules.collab.channel.filesharing.filehandler;
042:
043: import com.sun.collablet.CollabException;
044:
045: import org.openide.filesystems.*;
046:
047: import javax.swing.text.StyledDocument;
048:
049: import org.netbeans.modules.collab.channel.filesharing.mdc.CollabContext;
050: import org.netbeans.modules.collab.channel.filesharing.mdc.eventlistener.CollabDocumentListener;
051: import org.netbeans.modules.collab.channel.filesharing.msgbean.FileChanged;
052: import org.netbeans.modules.collab.channel.filesharing.msgbean.FileChangedData;
053: import org.netbeans.modules.collab.channel.filesharing.msgbean.LockRegionData;
054: import org.netbeans.modules.collab.channel.filesharing.msgbean.SendFile;
055: import org.netbeans.modules.collab.channel.filesharing.msgbean.SendFileData;
056: import org.netbeans.modules.collab.channel.filesharing.msgbean.UnlockRegion;
057: import org.netbeans.modules.collab.channel.filesharing.msgbean.UnlockRegionData;
058:
059: /**
060: * Interface for Collab Filesharing FileHandlers
061: *
062: * @author Ayub Khan, ayub.khan@sun.com
063: * @version 1.0
064: */
065: public interface CollabFileHandler {
066: ////////////////////////////////////////////////////////////////////////////
067: // Constants
068: ////////////////////////////////////////////////////////////////////////////
069:
070: /* empty file content */
071: public static final String EMPTY_CONTENT = "\n\n\n"; //NoI18n
072:
073: /* empty file content */
074: public static final String DIGEST = "xxxx"; //NoI18n
075:
076: /* empty file content */
077: public static final String ENCODING = "base64"; //NoI18n
078:
079: /* COLLAB_LINEREGION_USER */
080: public static final String COLLAB_LINEREGION_USER = "COLLAB_LINEREGION_USER"; //NoI18n
081:
082: /* special text handling contenttype */
083: public static final String TEXT_UNKNOWN = "text/unknown"; //NoI18n
084:
085: ////////////////////////////////////////////////////////////////////////////
086: // Message handler methods
087: ////////////////////////////////////////////////////////////////////////////
088:
089: /**
090: * constructs send-file-data Node
091: *
092: * @param sendFile the send-file Node
093: * @param syncOperation is send-file for sync file during user join
094: * @return sendFileData the send-file-data Node
095: * @throws CollabException
096: */
097: public SendFileData constructSendFileData(SendFile sendFile)
098: throws CollabException;
099:
100: /**
101: * handles send-file message
102: *
103: * @param messageOriginator the sender of this message
104: * @param sendFileData the send-file-data Node inside the message
105: * @throws CollabException
106: */
107: public void handleSendFile(String messageOriginator,
108: SendFileData sendFileData) throws CollabException;
109:
110: /**
111: * constructs lock-region-data Node
112: *
113: * @param regionInfo the RegionInfo bean
114: * @param lockRegionData the intial lock-region-data Node
115: * @throws CollabException
116: * @see RegionInfo
117: */
118: public void constructLockRegionData(RegionInfo regionInfo,
119: LockRegionData lockRegionData) throws CollabException;
120:
121: /**
122: * handles lock message
123: *
124: * @param messageOriginator the sender of this message
125: * @param lockRegionData the lock-region-data Node inside the message
126: * @throws CollabException
127: */
128: public void handleLock(String messageOriginator,
129: LockRegionData lockRegionData) throws CollabException;
130:
131: /**
132: * constructs unlock-region-data Node
133: *
134: * @param regionName the regionName
135: * @param unlockRegionData the intial unlock-region-data Node
136: * @throws CollabException
137: */
138: public void constructUnlockRegionData(String regionName,
139: UnlockRegionData unlockRegionData) throws CollabException;
140:
141: /**
142: * constructs unlock-region-data Node
143: *
144: * @param unlockRegionData the intial unlock-region-data Node
145: * @throws CollabException
146: */
147: public boolean constructUnlockRegionData(UnlockRegion unlockRegion)
148: throws CollabException;
149:
150: /**
151: * handles unlock message
152: *
153: * @param messageOriginator the sender of this message
154: * @param unlockRegionData the unlock-region-data Node inside the message
155: * @throws CollabException
156: */
157: public void handleUnlock(String messageOriginator,
158: UnlockRegionData unlockRegionData) throws CollabException;
159:
160: /**
161: * constructs file-changed-data Node
162: *
163: * @param fileChanged the file-changed Node
164: * @return fileChangedData the file-changed-data Node
165: * @throws CollabException
166: */
167: public FileChangedData constructFileChangedData(
168: FileChanged fileChanged) throws CollabException;
169:
170: /**
171: * handles send-change message
172: *
173: * @param messageOriginator the sender of this message
174: * @param fileChangedData the fileChangedData Node inside the message
175: * @throws CollabException
176: */
177: public void handleSendChange(String messageOriginator,
178: FileChangedData fileChangedData) throws CollabException;
179:
180: /**
181: * handles pause message
182: *
183: * @throws CollabException
184: */
185: public void handlePause() throws CollabException;
186:
187: /**
188: * handles resume message
189: *
190: * @throws CollabException
191: */
192: public void handleResume() throws CollabException;
193:
194: /**
195: * creates a CollabRegion, a super-class for all regions
196: *
197: * @param regionName the regionName
198: * @param beginOffset the beginOffset
199: * @param endOffset the endOffset
200: * @return CollabRegion created user region
201: * @throws CollabException
202: */
203: public CollabRegion createRegion(String regionName,
204: int beginOffset, int endOffset) throws CollabException;
205:
206: /**
207: * creates a CollabRegion, a super-class for all regions
208: *
209: * @param regionName the regionName
210: * @param beginOffset the beginOffset
211: * @param endOffset the endOffset
212: * @param testOverlap testOverlap before create
213: * @return CollabRegion created user region
214: * @throws CollabException
215: */
216: public CollabRegion createRegion(String regionName,
217: int beginOffset, int endOffset, boolean testOverlap)
218: throws CollabException;
219:
220: /**
221: * doUpdateRegion
222: *
223: * @param messageOriginator the sender of this message
224: * @param JavaEditor#simpleSection
225: * @param text
226: * @throws CollabException
227: */
228: public boolean doUpdateRegion(String messageOriginator,
229: CollabRegion region, String text) throws CollabException;
230:
231: ////////////////////////////////////////////////////////////////////////////
232: // Document methods
233: ////////////////////////////////////////////////////////////////////////////
234:
235: /**
236: * add DocumentListener
237: *
238: * @return DocumentListener
239: * @throws CollabException
240: */
241: public CollabDocumentListener addDocumentListener()
242: throws CollabException;
243:
244: /**
245: * get the file document content of a region
246: *
247: * @param regionName the regionName
248: * @return document Content content
249: * @throws CollabException
250: */
251: public String getContent(String regionName) throws CollabException;
252:
253: /**
254: * getCurrentState
255: *
256: * @return state
257: */
258: public int getCurrentState();
259:
260: /**
261: * setCurrentState
262: *
263: * @param state
264: */
265: public void setCurrentState(int state);
266:
267: /**
268: * setCurrentState
269: *
270: * @param currentState
271: * @param delay
272: * @param saveUnconditionally
273: * @param changeSkipUpdate
274: */
275: public void setCurrentState(final int currentState, long delay,
276: final boolean saveUnconditionally,
277: final boolean changeSkipUpdate);
278:
279: ////////////////////////////////////////////////////////////////////////////
280: // Filehandler methods
281: ////////////////////////////////////////////////////////////////////////////
282:
283: /**
284: * getter for fileObject
285: *
286: * @return fileObject fileObject of file being handled
287: * @throws CollabException
288: */
289: public FileObject getFileObject() throws CollabException;
290:
291: /**
292: * return document object for this file
293: *
294: * @throws CollabException
295: * @return document
296: */
297: public StyledDocument getDocument() throws CollabException;
298:
299: /**
300: * getter for fileName
301: *
302: * @return fileName name of file being handled
303: */
304: public String getName();
305:
306: /**
307: * getter for fileSize
308: *
309: * @return fileSize size of file being handled
310: */
311: public long getFileSize() throws CollabException;
312:
313: /**
314: * setter for fileName
315: *
316: * @param fileName name of file being handled
317: */
318: public void setFileName(String fileName);
319:
320: /**
321: * getter for groupName where this file belongs
322: *
323: * @return fileGroupName name of fileGroup
324: */
325: public String getFileGroupName();
326:
327: /**
328: * setter for sharedFileGroup where this file belongs
329: *
330: * @param sharedFileGroup
331: */
332: public void setFileGroup(SharedFileGroup sharedFileGroup);
333:
334: /**
335: * getter for contentType
336: *
337: * @return contentType
338: */
339: public String getContentType();
340:
341: /**
342: * setter for contentType
343: *
344: * @param contentType
345: */
346: public void setContentType(String contentType);
347:
348: /**
349: * isSendFirstTime
350: *
351: * @return isSendFirstTime
352: */
353: public boolean isSendFirstTime();
354:
355: /**
356: * setter for fileObject
357: *
358: * @param fileObject fileObject of file being handled
359: */
360: public void setFileObject(FileObject fileObject);
361:
362: /**
363: * setter for CollabContext
364: *
365: * @param context
366: */
367: public void setContext(CollabContext context);
368:
369: /**
370: * test if the file changed
371: *
372: * @return true/false true if file changes
373: */
374: public boolean isChanged() throws CollabException;
375:
376: /**
377: * register DocumentListener
378: *
379: * @throws CollabException
380: */
381: public void registerDocumentListener() throws CollabException;
382:
383: /**
384: * skip Insert or Remove if set to true
385: *
386: * @param status if true skip insert/remove
387: * @throws CollabException
388: */
389: public void setSkipUpdate(boolean skipStatus);
390:
391: /**
392: * setSkipUpdateAlways
393: *
394: * @param skipUpdateAlways
395: */
396: public void setSkipUpdateAlways(boolean skipUpdateAlways);
397:
398: /**
399: * isRetrieveFileContentOnly
400: *
401: */
402: public boolean isRetrieveFileContentOnly();
403:
404: /**
405: * setRetrieveFileContentOnly
406: *
407: */
408: public void setRetrieveFileContentOnly(boolean flag);
409:
410: /**
411: * isDocumentModified
412: *
413: */
414: public boolean isDocumentModified() throws CollabException;
415:
416: /**
417: * saveDocument
418: *
419: */
420: public boolean saveDocument() throws CollabException;
421:
422: /**
423: * get region
424: *
425: * @param lockRegionData the intial lock-region-data Node
426: * @return region
427: */
428: public RegionInfo getLockRegion(LockRegionData lockRegionData);
429:
430: /**
431: * setValid
432: *
433: * @param status if false handler is invalid
434: * @throws CollabException
435: */
436: public void setValid(boolean valid) throws CollabException;
437:
438: /**
439: * test if the filehandler is valid
440: *
441: * @return true/false true if valid
442: */
443: public boolean isValid() throws CollabException;
444:
445: /**
446: * clear
447: *
448: * @throws CollabException
449: */
450: public void clear() throws CollabException;
451: }
|