X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.debug.browser%2Fsrc%2Forg%2Fsimantics%2Fdebug%2Fbrowser%2Fcontent%2FResourceBrowserContent.java;h=945bfd077a825371e39395e877643bcfbc87f982;hp=ccb04411e6d7f90c41e48572dc7a7745c907a9ac;hb=refs%2Fchanges%2F38%2F238%2F2;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.debug.browser/src/org/simantics/debug/browser/content/ResourceBrowserContent.java b/bundles/org.simantics.debug.browser/src/org/simantics/debug/browser/content/ResourceBrowserContent.java index ccb04411e..945bfd077 100644 --- a/bundles/org.simantics.debug.browser/src/org/simantics/debug/browser/content/ResourceBrowserContent.java +++ b/bundles/org.simantics.debug.browser/src/org/simantics/debug/browser/content/ResourceBrowserContent.java @@ -1,69 +1,69 @@ -/******************************************************************************* - * Copyright (c) 2016 Association for Decentralized Information Management - * in Industry THTH ry. - * 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: - * THTH ry - initial API and implementation - *******************************************************************************/ -package org.simantics.debug.browser.content; - -import gnu.trove.map.hash.THashMap; - -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; -import org.simantics.debug.browser.sections.ResourceBrowserSection; - -public class ResourceBrowserContent { - public final Resource resource; - private final THashMap, ResourceBrowserSection> sectionMap = - new THashMap, ResourceBrowserSection>(); - - private ResourceBrowserContent(Resource resource) { - this.resource = resource; - } - - @SuppressWarnings("unchecked") - public T getSection(Class clazz) { - return (T)sectionMap.get(clazz); - } - - public void putSection(Class clazz, T section) { - sectionMap.put(clazz, section); - } - - @SuppressWarnings("unchecked") - public T removeSection(Class clazz) { - return (T)sectionMap.remove(clazz); - } - - private static final Comparator SECTION_COMPARATOR = new Comparator() { - @Override - public int compare(ResourceBrowserSection o1, ResourceBrowserSection o2) { - return Double.compare(o1.getPriority(), o2.getPriority()); - } - }; - - public void toHtml(ReadGraph graph, PrintWriter stream) throws DatabaseException { - ArrayList sections = new ArrayList(sectionMap.values()); - Collections.sort(sections, SECTION_COMPARATOR); - for(ResourceBrowserSection section : sections) - section.toHtml(graph, stream); - } - - public static ResourceBrowserContent createContentFor(ReadGraph graph, Resource resource) throws DatabaseException { - ResourceBrowserContent content = new ResourceBrowserContent(resource); - for(ResourceBrowserRewriter rewriter : ResourceBrowserRewriterRepository.getRewriters()) - rewriter.rewrite(graph, content); - return content; - } +/******************************************************************************* + * Copyright (c) 2016 Association for Decentralized Information Management + * in Industry THTH ry. + * 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: + * THTH ry - initial API and implementation + *******************************************************************************/ +package org.simantics.debug.browser.content; + +import gnu.trove.map.hash.THashMap; + +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; + +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.exception.DatabaseException; +import org.simantics.debug.browser.sections.ResourceBrowserSection; + +public class ResourceBrowserContent { + public final Resource resource; + private final THashMap, ResourceBrowserSection> sectionMap = + new THashMap, ResourceBrowserSection>(); + + private ResourceBrowserContent(Resource resource) { + this.resource = resource; + } + + @SuppressWarnings("unchecked") + public T getSection(Class clazz) { + return (T)sectionMap.get(clazz); + } + + public void putSection(Class clazz, T section) { + sectionMap.put(clazz, section); + } + + @SuppressWarnings("unchecked") + public T removeSection(Class clazz) { + return (T)sectionMap.remove(clazz); + } + + private static final Comparator SECTION_COMPARATOR = new Comparator() { + @Override + public int compare(ResourceBrowserSection o1, ResourceBrowserSection o2) { + return Double.compare(o1.getPriority(), o2.getPriority()); + } + }; + + public void toHtml(ReadGraph graph, PrintWriter stream) throws DatabaseException { + ArrayList sections = new ArrayList(sectionMap.values()); + Collections.sort(sections, SECTION_COMPARATOR); + for(ResourceBrowserSection section : sections) + section.toHtml(graph, stream); + } + + public static ResourceBrowserContent createContentFor(ReadGraph graph, Resource resource) throws DatabaseException { + ResourceBrowserContent content = new ResourceBrowserContent(resource); + for(ResourceBrowserRewriter rewriter : ResourceBrowserRewriterRepository.getRewriters()) + rewriter.rewrite(graph, content); + return content; + } } \ No newline at end of file