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 * Portions Copyright 2016 ForgeRock AS. 016 */ 017 018package org.opends.guitools.controlpanel.browser; 019 020import org.opends.guitools.controlpanel.ui.nodes.BasicNode; 021 022/** 023 * This is an abstract class that is extended to search for nodes or 024 * to refresh the contents of the nodes. 025 */ 026public abstract class AbstractNodeTask implements Runnable { 027 028 private final BasicNode node; 029 private boolean cancelled; 030 031 /** 032 * The constructor of the node searcher. 033 * @param node the node to be searched/refreshed. 034 */ 035 protected AbstractNodeTask(BasicNode node) { 036 this.node = node; 037 cancelled = false; 038 } 039 040 041 /** 042 * Returns the node that is being searched/refreshed. 043 * @return the node that is being searched/refreshed. 044 */ 045 public BasicNode getNode() { 046 return node; 047 } 048 049 050 /** Cancels the searching/refreshing process. */ 051 public void cancel() { 052 cancelled = true; 053 } 054 055 /** 056 * Tells whether the search/refresh operation is cancelled. 057 * @return <CODE>true</CODE> if the operation is cancelled and 058 * <CODE>false</CODE> otherwise. 059 */ 060 public boolean isCanceled() { 061 return cancelled; 062 } 063 064 /** The method that is called to refresh/search the node. */ 065 @Override 066 public abstract void run(); 067}