Project

General

Profile

Download (1.65 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 *
3
 */
4
package eu.etaxonomy.taxeditor.view;
5

    
6
import org.eclipse.swt.widgets.Composite;
7
import org.eclipse.ui.IEditorPart;
8

    
9
import eu.etaxonomy.taxeditor.editor.ISecuredEditor;
10
import eu.etaxonomy.taxeditor.model.AbstractUtility;
11
import eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider;
12

    
13
/**
14
 * <p>
15
 * Abstract AbstractCdmEditorViewPart class.
16
 * </p>
17
 *
18
 * @author n.hoffmann
19
 * @created Sep 21, 2010
20
 * @version 1.0
21
 */
22
public abstract class AbstractCdmEditorViewPart extends AbstractCdmViewPart {
23

    
24
	/*
25
	 * (non-Javadoc)
26
	 *
27
	 * @see
28
	 * eu.etaxonomy.taxeditor.model.AbstractCdmViewPart#createPartControl(org
29
	 * .eclipse.swt.widgets.Composite)
30
	 */
31
	/** {@inheritDoc} */
32
	@Override
33
	public void createPartControl(Composite parent) {
34
		super.createPartControl(parent);
35
	}
36

    
37
	/**
38
	 * <p>
39
	 * getEditor
40
	 * </p>
41
	 *
42
	 * @return the currently active editor
43
	 */
44
	public IEditorPart getEditor() {
45
		return AbstractUtility.getActiveEditor();
46
	}
47

    
48
	/** {@inheritDoc} */
49
	@Override
50
	public void setFocus() {
51
		super.setFocus();
52

    
53
		if(getEditor() != null && ISecuredEditor.class.isAssignableFrom(getEditor().getClass())){
54
			boolean doEnable = ((ISecuredEditor)getEditor()).permissionsSatisfied();
55
			setEnabled(doEnable);
56
		}
57
    }
58

    
59
    /** {@inheritDoc} */
60
    @Override
61
    public void changed(Object object) {
62
        if (part instanceof AbstractCdmViewPart) {
63
            ((AbstractCdmViewPart) part).changed(object);
64
        } else {
65
            IEditorPart editor = getEditor();
66
            if (editor != null && editor instanceof IDirtyMarkableSelectionProvider) {
67
                ((IDirtyMarkableSelectionProvider) editor).changed(object);
68
            }
69
        }
70
    }
71

    
72
}
(3-3/5)