blob: 75b00aac7020d7863ec2550e69b775b3f36237c2 [file] [log] [blame]
//------------------------------------------------------------------------------
// Copyright (c) 2005, 2006 IBM Corporation 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:
// IBM Corporation - initial implementation
//------------------------------------------------------------------------------
package org.eclipse.epf.publishing.services;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.epf.library.layout.ElementLayoutManager;
import org.eclipse.epf.library.layout.HtmlBuilder;
import org.eclipse.epf.library.services.LibraryProcessor;
import org.eclipse.epf.publishing.layout.Bookmark;
import com.ibm.uma.MethodElement;
import com.ibm.uma.MethodLibrary;
/**
* @author Jinhua Xi
* @since 1.0
*/
public class LibraryViewBuilder extends AbstractViewBuilder {
public LibraryViewBuilder(HtmlBuilder builder) {
super(builder, null);
}
public static LibraryViewBuilder getViewBuilder(String pubDir) {
ElementLayoutManager layoutMgr = new ElementLayoutManager(null, pubDir);
HtmlBuilder builder = new HtmlBuilder(layoutMgr);
return new LibraryViewBuilder(builder);
}
public List buildViews(IProgressMonitor monitor) {
MethodLibrary library = LibraryProcessor.getInstance().getLibrary();
Bookmark root = super.createBookmark(monitor, library);
ElementLayoutManager layoutMgr = LibraryProcessor.getInstance()
.getConfigurationFactory().getLayoutManager(null);
iterateElement(monitor, layoutMgr, root, library);
List views = new ArrayList();
views.add(root);
return views;
}
private void iterateElement(IProgressMonitor monitor,
ElementLayoutManager layoutMgr, Bookmark parent,
MethodElement element) {
Bookmark b = super.createBookmark(monitor, element);
parent.addChild(b);
List children = element.eContents();
if (children != null) {
for (Iterator it = children.iterator(); it.hasNext();) {
Object e = it.next();
if (e instanceof MethodElement) {
iterateElement(monitor, layoutMgr, b, (MethodElement) e);
}
}
}
}
}