1 /******************************************************************************* 2 * Copyright (c) 2005, 2011 IBM Corporation and others. 3 * 4 * This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License 2.0 6 * which accompanies this distribution, and is available at 7 * https://www.eclipse.org/legal/epl-2.0/ 8 * 9 * SPDX-License-Identifier: EPL-2.0 10 * 11 * Contributors: 12 * IBM Corporation - initial API and implementation 13 *******************************************************************************/ 14 package org.eclipse.debug.internal.ui.viewers.model.provisional; 15 16 import org.eclipse.debug.internal.ui.viewers.provisional.AbstractModelProxy; 17 import org.eclipse.jface.viewers.Viewer; 18 19 /** 20 * A model proxy represents a model for a specific presentation context and 21 * fires deltas to notify listeners of changes in the model. A model proxy 22 * is created by a model proxy factory. 23 * <p> 24 * When an element is added to an asynchronous viewer, its associated model proxy 25 * factory is queried to create a model proxy for that element. The model proxy 26 * is then installed into the viewer and the viewer listens to model deltas 27 * in order to update that element. Generally, a model proxy factory creates 28 * model proxies for root elements in a model, and then represents all elements 29 * within that model for a specific presentation context. 30 * </p> 31 * <p> 32 * Note: provider methods are called in the Display thread of the viewer. 33 * To avoid blocking the UI, long running operations should be performed 34 * asynchronously. 35 * </p> 36 * 37 * @noimplement Clients are not intended to implement this interface directly. Instead, clients 38 * creating and firing model deltas should create instances of {@link AbstractModelProxy}. 39 * @see IModelDelta 40 * @see IModelProxyFactory 41 * @see IModelChangedListener 42 * @see ICheckboxModelProxy 43 * @see IModelProxy2 44 * @since 3.2 45 */ 46 public interface IModelProxy { 47 48 /** 49 * Notification this model proxy has been created and is about to be installed 50 * in the following context. This is the first method called after a model proxy 51 * is created and it's called in a job thread and not on a display thread. 52 * <p> 53 * This method is called by the asynchronous viewer framework and should not 54 * be called by clients. 55 * </p> 56 * @param context presentation context in which the proxy will be installed 57 * @see IModelProxy2#initialize(ITreeModelViewer) 58 */ init(IPresentationContext context)59 void init(IPresentationContext context); 60 61 /** 62 * Notification this model proxy has been installed in the specified 63 * viewer. This indicates that the model proxy has been created and registered 64 * model change listeners are ready to process deltas. This method is called 65 * by the {@link AbstractModelProxy} base class using a job and NOT in viewers 66 * display thread. It allows the client to initialize the proxy without 67 * blocking the UI. The default implementaiton is a no-op. 68 * <p> 69 * This method is called by the asynchronous viewer framework and should not 70 * be called by clients. 71 * </p> 72 * @param viewer viewer 73 * @see IModelProxy2#initialize(ITreeModelViewer) 74 * @since 3.3 75 */ installed(Viewer viewer)76 void installed(Viewer viewer); 77 78 /** 79 * Disposes this model proxy. 80 * <p> 81 * This method is called by the asynchronous viewer framework and should not 82 * be called by clients. 83 * </p> 84 */ dispose()85 void dispose(); 86 87 /** 88 * Registers the given listener for model delta notification. 89 * 90 * @param listener model delta listener 91 */ addModelChangedListener(IModelChangedListener listener)92 void addModelChangedListener(IModelChangedListener listener); 93 94 /** 95 * Unregisters the given listener from model delta notification. 96 * 97 * @param listener model delta listener 98 */ removeModelChangedListener(IModelChangedListener listener)99 void removeModelChangedListener(IModelChangedListener listener); 100 101 /** 102 * Returns whether this proxy has been disposed. 103 * 104 * @return whether this proxy has been disposed 105 * @since 3.3 106 */ isDisposed()107 boolean isDisposed(); 108 109 } 110