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