001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2008-2010 Sun Microsystems, Inc. 015 */ 016 017package org.opends.guitools.controlpanel.browser; 018 019import org.opends.guitools.controlpanel.ui.nodes.BasicNode; 020 021/** 022 * This is an abstract class that is extended to search for nodes or 023 * to refresh the contents of the nodes. 024 */ 025public abstract class AbstractNodeTask implements Runnable { 026 027 BasicNode node; 028 boolean cancelled; 029 030 /** 031 * The constructor of the node searcher. 032 * @param node the node to be searched/refreshed. 033 */ 034 protected AbstractNodeTask(BasicNode node) { 035 this.node = node; 036 cancelled = false; 037 } 038 039 040 /** 041 * Returns the node that is being searched/refreshed. 042 * @return the node that is being searched/refreshed. 043 */ 044 public BasicNode getNode() { 045 return node; 046 } 047 048 049 /** 050 * Cancels the searching/refreshing process. 051 * 052 */ 053 public void cancel() { 054 cancelled = true; 055 } 056 057 /** 058 * Tells whether the search/refresh operation is cancelled. 059 * @return <CODE>true</CODE> if the operation is cancelled and 060 * <CODE>false</CODE> otherwise. 061 */ 062 public boolean isCanceled() { 063 return cancelled; 064 } 065 066 /** 067 * The method that is called to refresh/search the node. 068 */ 069 public abstract void run(); 070}