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);
}
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);
}
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());
}
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);
}
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);
}
}
Aggregations