Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 9d35794bb392eecd3de4011c55531f12ae372269 (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
/*******************************************************************************
 * Copyright (c) 2007, 2009 THALES GLOBAL SERVICES.
 * 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:
 *    Obeo - initial API and implementation
 *******************************************************************************/
package org.eclipse.sirius.diagram.ui.tools.internal.properties.filter;

import java.util.Iterator;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.sirius.diagram.ui.tools.api.properties.filter.AbstractPropertyFilter;
import org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor;
import org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessorsRegistry;
import org.eclipse.sirius.viewpoint.SiriusPlugin;

/**
 * Filters the extension property section.
 * 
 * @author ymortier
 */
public class ExtendedPropertyFilter extends AbstractPropertyFilter {

    /**
     * {@inheritDoc}
     * 
     * @see org.eclipse.sirius.diagram.ui.tools.api.properties.filter.AbstractPropertyFilter#select(java.lang.Object)
     */
    @Override
    public boolean select(final Object toTest) {
        final boolean select = super.select(toTest);
        boolean areAnnotation = false;
        ModelAccessorsRegistry modelAccessorRegistry = SiriusPlugin.getDefault().getModelAccessorRegistry();
        final Iterator<EObject> iterSemantics = this.semanticElements.iterator();
        while (iterSemantics.hasNext() && !areAnnotation) {
            final EObject next = iterSemantics.next();
            ModelAccessor modelAccessor = modelAccessorRegistry.getModelAccessor(next);
            if (modelAccessor.hasExtension(next)) {
                areAnnotation = true;
            } else if (modelAccessor.isExtension(next)) {
                areAnnotation = true;
            }

        }
        return select && areAnnotation;
    }
}

Back to the top