Search in sources :

Example 1 with Bookmarks

use of org.cytoscape.property.bookmark.Bookmarks in project cytoscape-impl by cytoscape.

the class Cy2SessionReaderImpl method extractBookmarks.

private void extractBookmarks(InputStream is, String entryName) throws Exception {
    CyPropertyReader reader = propertyReaderMgr.getReader(is, entryName);
    reader.run(taskMonitor);
    final Bookmarks bookmarks = (Bookmarks) reader.getProperty();
    final CyProperty<Bookmarks> cyProps = new SimpleCyProperty<Bookmarks>("bookmarks", bookmarks, Bookmarks.class, CyProperty.SavePolicy.SESSION_FILE);
    properties.add(cyProps);
}
Also used : Bookmarks(org.cytoscape.property.bookmark.Bookmarks) CyPropertyReader(org.cytoscape.io.read.CyPropertyReader) SimpleCyProperty(org.cytoscape.property.SimpleCyProperty)

Example 2 with Bookmarks

use of org.cytoscape.property.bookmark.Bookmarks in project cytoscape-impl by cytoscape.

the class Cy3SessionReaderImpl method extractProperties.

private void extractProperties(InputStream is, String entryName) throws Exception {
    CyPropertyReader reader = propertyReaderMgr.getReader(is, entryName);
    if (reader == null)
        return;
    reader.run(taskMonitor);
    CyProperty<?> cyProps = null;
    Object obj = reader.getProperty();
    if (obj instanceof Properties) {
        Properties props = (Properties) obj;
        Matcher matcher = PROPERTIES_PATTERN.matcher(entryName);
        if (matcher.matches()) {
            String propsName = matcher.group(2);
            if (propsName != null) {
                cyProps = new SimpleCyProperty<>(propsName, props, Properties.class, CyProperty.SavePolicy.SESSION_FILE);
            }
        }
    } else if (obj instanceof Bookmarks) {
        cyProps = new SimpleCyProperty<>("bookmarks", (Bookmarks) obj, Bookmarks.class, CyProperty.SavePolicy.SESSION_FILE);
    } else {
        // TODO: get name and create the CyProperty for unknown types
        logger.error("Cannot extract CyProperty name from: " + entryName);
    }
    if (cyProps != null)
        properties.add(cyProps);
}
Also used : Bookmarks(org.cytoscape.property.bookmark.Bookmarks) Matcher(java.util.regex.Matcher) CyPropertyReader(org.cytoscape.io.read.CyPropertyReader) Properties(java.util.Properties) SimpleCyProperty(org.cytoscape.property.SimpleCyProperty)

Example 3 with Bookmarks

use of org.cytoscape.property.bookmark.Bookmarks in project cytoscape-impl by cytoscape.

the class OntologyPanelBuilder method setAnnotationComboBox.

@SuppressWarnings("unchecked")
protected void setAnnotationComboBox() throws JAXBException, IOException {
    final CyProperty<Bookmarks> bookmarksProp = serviceRegistrar.getService(CyProperty.class, "(cyPropertyName=bookmarks)");
    final BookmarksUtil bkUtil = serviceRegistrar.getService(BookmarksUtil.class);
    final Bookmarks bookmarks = bookmarksProp.getProperties();
    final List<DataSource> annotations = bkUtil.getDataSourceList("annotation", bookmarks.getCategory());
    String key = null;
    panel.annotationComboBox.addItem(DEF_ANNOTATION_ITEM);
    for (DataSource source : annotations) {
        key = source.getName();
        panel.annotationComboBox.addItem(key);
        annotationUrlMap.put(key, source.getHref());
        annotationFormatMap.put(key, source.getFormat());
        final Map<String, String> attrMap = new HashMap<String, String>();
        for (Attribute attr : source.getAttribute()) attrMap.put(attr.getName(), attr.getContent());
        annotationAttributesMap.put(key, attrMap);
    }
    panel.annotationComboBox.setToolTipText(getAnnotationTooltip());
}
Also used : Bookmarks(org.cytoscape.property.bookmark.Bookmarks) HashMap(java.util.HashMap) Attribute(org.cytoscape.property.bookmark.Attribute) BookmarksUtil(org.cytoscape.property.bookmark.BookmarksUtil) DataSource(org.cytoscape.property.bookmark.DataSource)

Example 4 with Bookmarks

use of org.cytoscape.property.bookmark.Bookmarks in project cytoscape-impl by cytoscape.

the class BookmarksCyProperty method setup.

@Before
public void setup() {
    Properties coreP = new Properties();
    coreP.setProperty("cyPropertyName", "cytoscape3.props");
    Properties p = new Properties();
    p.setProperty("cyPropertyName", "bookmarks");
    CyProperty<Properties> cyProp = new BasicCyProperty(new Properties(), CyProperty.SavePolicy.CONFIG_DIR);
    registerMockService(CyProperty.class, cyProp, coreP);
    BookmarksCyProperty cyBookProp = new BookmarksCyProperty(new Bookmarks(), CyProperty.SavePolicy.CONFIG_DIR);
    registerMockService(CyProperty.class, cyBookProp, p);
    registerMockService(BookmarksUtil.class);
    registerMockService(FileUtil.class);
}
Also used : Bookmarks(org.cytoscape.property.bookmark.Bookmarks) BasicCyProperty(org.cytoscape.property.BasicCyProperty) Properties(java.util.Properties) Before(org.junit.Before)

Example 5 with Bookmarks

use of org.cytoscape.property.bookmark.Bookmarks in project cytoscape-impl by cytoscape.

the class BookmarksUtilImpl method saveBookmark.

public void saveBookmark(Bookmarks pBookmarks, String pCategoryName, DataSource pDataSource, String pProvider) {
    if (pBookmarks == null) {
        pBookmarks = new Bookmarks();
    }
    List<Category> theCategoryList = pBookmarks.getCategory();
    // if the category does not exist, create it
    if (theCategoryList.size() == 0) {
        Category theCategory = new Category();
        theCategory.setName(pCategoryName);
        theCategoryList.add(theCategory);
    }
    Category theCategory = getCategory(pCategoryName, theCategoryList);
    if (theCategory == null) {
        Category newCategory = new Category();
        newCategory.setName(pCategoryName);
        theCategoryList.add(newCategory);
        theCategory = newCategory;
    }
    List<Object> theObjList = theCategory.getCategoryOrDataSource();
    if (!theObjList.contains(pDataSource))
        theObjList.add(pDataSource);
    org.cytoscape.io.datasource.DataSource data = convertToDataSource(pBookmarks, pCategoryName, pDataSource, pProvider);
    if (data != null && !dataSourceMap.containsKey(pDataSource)) {
        register.registerService(data, org.cytoscape.io.datasource.DataSource.class, new Properties());
        dataSourceMap.put(pDataSource, data);
    }
}
Also used : Bookmarks(org.cytoscape.property.bookmark.Bookmarks) DataCategory(org.cytoscape.io.DataCategory) Category(org.cytoscape.property.bookmark.Category) Properties(java.util.Properties)

Aggregations

Bookmarks (org.cytoscape.property.bookmark.Bookmarks)7 Properties (java.util.Properties)3 BookmarksUtil (org.cytoscape.property.bookmark.BookmarksUtil)3 DataSource (org.cytoscape.property.bookmark.DataSource)3 DataCategory (org.cytoscape.io.DataCategory)2 CyPropertyReader (org.cytoscape.io.read.CyPropertyReader)2 SimpleCyProperty (org.cytoscape.property.SimpleCyProperty)2 Category (org.cytoscape.property.bookmark.Category)2 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 HashMap (java.util.HashMap)1 Matcher (java.util.regex.Matcher)1 DefaultDataSource (org.cytoscape.io.datasource.DefaultDataSource)1 BasicCyProperty (org.cytoscape.property.BasicCyProperty)1 Attribute (org.cytoscape.property.bookmark.Attribute)1 Before (org.junit.Before)1