X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fuk%2Fac%2Fvamsas%2Fclient%2Fsimpleclient%2FSessionFileWatcherElement.java;h=1ef053f234886703b3d9343021b161c5c7750578;hb=844ccad5a3fcbedec17b2af66d460f31abc7cff1;hp=034aae6c31dad977f3f7f21e305d56afa0a3f9d6;hpb=6f33f705957d674dc2ab6c994a6ea87f7a91f40f;p=vamsas.git diff --git a/src/uk/ac/vamsas/client/simpleclient/SessionFileWatcherElement.java b/src/uk/ac/vamsas/client/simpleclient/SessionFileWatcherElement.java index 034aae6..1ef053f 100644 --- a/src/uk/ac/vamsas/client/simpleclient/SessionFileWatcherElement.java +++ b/src/uk/ac/vamsas/client/simpleclient/SessionFileWatcherElement.java @@ -1,42 +1,71 @@ +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ package uk.ac.vamsas.client.simpleclient; - /** - * Element of the VamsasFileWatcherThread event generator chain. - * Keep a reference to this element before adding it to the chain - * in order to control the generation of events with halt and enable. + * Element of the VamsasFileWatcherThread event generator chain. Keep a + * reference to this element before adding it to the chain in order to control + * the generation of events with halt and enable. * * doWatch will do nothing if the element is not enabled. * */ public class SessionFileWatcherElement extends WatcherElement { - SessionFile watched=null; + SessionFile watched = null; + /** * create a new, enabled watch element - * @param watcher file being watched - * @param handler handler to call on state change + * + * @param watcher + * file being watched + * @param handler + * handler to call on state change */ public SessionFileWatcherElement(SessionFile watcher, WatcherCallBack handler) { this(watcher, handler, true); } + protected void initWatch() { - if (watched==null) + if (watched == null) return; - if (watcher==null || !watcher.getSubject().equals(watched.sessionFile)) - watcher=new FileWatcher(watched.sessionFile); + if (watcher == null || !watcher.getSubject().equals(watched.sessionFile)) + watcher = new FileWatcher(watched.sessionFile); else watcher.setState(); } + protected void endWatch() { // leaves watcher in state its in. } + /** * new watcher with flag to initially skip watching this sessionfile + * * @param watcher * @param handler * @param enableWatching */ - public SessionFileWatcherElement(SessionFile watcher, WatcherCallBack handler, boolean enableWatching) { + public SessionFileWatcherElement(SessionFile watcher, + WatcherCallBack handler, boolean enableWatching) { super(handler); this.watched = watcher; if (enableWatching) @@ -44,12 +73,14 @@ public class SessionFileWatcherElement extends WatcherElement { else haltWatch(); } + /** * @return the watched */ public SessionFile getWatched() { return watched; } + protected String getSubject() { return watched.sessionFile.toString(); }