Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: bbe8b68e2d5a8bef97805a52dcf3553c2d9e41dc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*******************************************************************************
 * Copyright (c) 2007, 2009 Wind River Systems and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     Wind River Systems - initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.dsf.ui.viewmodel.update;

import java.util.Map;

import org.eclipse.jface.viewers.TreePath;

/**
 * An "automatic" update policy which causes the view model provider cache to 
 * be flushed whenever an event causes a delta to be generated in the given 
 * model.
 * 
 * @since 1.0
 */
public class AutomaticUpdatePolicy implements IVMUpdatePolicy {

    public static String AUTOMATIC_UPDATE_POLICY_ID = "org.eclipse.cdt.dsf.ui.viewmodel.update.defaultUpdatePolicy";  //$NON-NLS-1$
    
    public static IElementUpdateTester fgUpdateTester = new IElementUpdateTester() {
        @Override
		public int getUpdateFlags(Object viewerInput, TreePath path) {
            return FLUSH | ARCHIVE; 
        }  
        
        @Override
		public boolean includes(IElementUpdateTester tester) {
            return tester.equals(this);
        }

        @Override
        public String toString() {
            return "Automatic update tester"; //$NON-NLS-1$
        }
    };
    
    @Override
	public String getID() {
        return AUTOMATIC_UPDATE_POLICY_ID;
    }

    @Override
	public String getName() {
        return ViewModelUpdateMessages.AutomaticUpdatePolicy_name;
    }

    @Override
	public IElementUpdateTester getElementUpdateTester(Object event) {
        return fgUpdateTester;
    }

    @Override
	public Object[] getInitialRootElementChildren(Object rootElement) {
        return null;
    }
    
    @Override
	public Map<String, Object> getInitialRootElementProperties(Object rootElement) {
        return null;
    }
}

Back to the top