Package de.FeatureModellingTool.Connector.View_IDMap

Source Code of de.FeatureModellingTool.Connector.View_IDMap.View_IDMapImplementation

package de.FeatureModellingTool.Connector.View_IDMap;

import de.FeatureModellingTool.Connector.Import;
import de.FeatureModellingTool.GraphicalEditor.DrawingViewContainer;
import de.reuse.ContextImplementation;
import de.reuse.GroupMap;
import de.reuse.GroupTreeMap;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent;

import research.DrawingView;
import research.FigureEnumeration;
import research.Figure;

/**
* Created by IntelliJ IDEA.
* User: saturn
* Date: 2004-5-6
* Time: 16:42:57
* To change this template use File | Settings | File Templates.
*/
class View_IDMapImplementation implements View_IDMap {

    protected DrawingViewContainer drawingViewContainer = null;

    protected final Import imp = new Import() {
        protected de.reuse.Context context = new ContextImplementation();

        public de.reuse.Context getContext() {
            return context;
        }
    };

    protected de.reuse.Context context = new ContextImplementation();

    public de.reuse.Context getContext() {
        return context;
    }

    public View_IDMapImplementation(){
        imp.getContext().addContextChangeListener(new ContextChangeListener());
    }

    protected class ContextChangeListener implements PropertyChangeListener {
        public void propertyChange(PropertyChangeEvent e) {
            contextChange(e);
        }
    }

    protected void contextChange(PropertyChangeEvent e) {
        String propertyName = e.getPropertyName();

        if (ConstantDefinition.DRAWING_VIEW_CONTAINER.equals(propertyName)) {
            drawingViewContainer = (DrawingViewContainer) e.getNewValue();
        }
    }

    public Import getImport() {
        return imp;
    }

    public GroupMap getView_IDMap(){
        if (drawingViewContainer == null) return null;

        DrawingView[] views = drawingViewContainer.getAllDrawingViews();

        GroupMap rst = new GroupTreeMap();

        for (int i = 0; i < views.length; i++){
            DrawingView view = views[i];

            FigureEnumeration fe = view.getDrawing().getFigures();

            while (fe.hasMoreElements()){
                Figure fig = fe.nextFigure();
                String id = (String) fig.getAttribute("id");

                if ((id != null) && (!id.equals(""))){
                    rst.add(view.getDrawing().getTitle(), id);
                }
            }
        }

        return rst;
    }

   
}
TOP

Related Classes of de.FeatureModellingTool.Connector.View_IDMap.View_IDMapImplementation

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.