use of name.abuchen.portfolio.model.AttributeType in project portfolio by buchen.
the class AttributesPage method menuAboutToShow.
@Override
public void menuAboutToShow(IMenuManager manager) {
manager.add(new LabelOnly(Messages.LabelAvailableAttributes));
Set<AttributeType> existing = new HashSet<AttributeType>();
for (AttributeDesignation d : model.getAttributes()) existing.add(d.getType());
//
model.getClient().getSettings().getAttributeTypes().filter(//
a -> !existing.contains(a)).filter(//
a -> a.supports(Security.class)).forEach(attribute -> addMenu(manager, attribute));
}
use of name.abuchen.portfolio.model.AttributeType in project portfolio by buchen.
the class BookmarkTest method testCustomAttributes.
@Test
public void testCustomAttributes() {
AttributeType attribute = new AttributeType(UUID.randomUUID().toString());
attribute.setType(String.class);
attribute.setName("CUSIP Number");
attribute.setColumnLabel("CUSIP");
attribute.setConverter(AttributeType.StringConverter.class);
attribute.setTarget(Security.class);
Client client = new Client();
client.getSettings().addAttributeType(attribute);
Bookmark page = new Bookmark("", "https://www.flatex.de/suche/{CUSIP}");
Security security = new Security("Daimler", "DE0007100000", "DAI.DE", YahooFinanceQuoteFeed.ID);
security.getAttributes().put(attribute, "D1668R123");
assertThat(page.constructURL(client, security), equalTo("https://www.flatex.de/suche/D1668R123"));
}
use of name.abuchen.portfolio.model.AttributeType in project portfolio by buchen.
the class AttributeListTab method fillContextMenu.
private void fillContextMenu(IMenuManager manager) {
IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
AttributeType attributeType = (AttributeType) selection.getFirstElement();
if (selection.size() == 1)
addMoveUpAndDownActions(manager, attributeType);
manager.add(new Separator());
addDeleteActions(manager, selection);
}
use of name.abuchen.portfolio.model.AttributeType in project portfolio by buchen.
the class AttributeListTab method addDeleteActions.
private void addDeleteActions(IMenuManager manager, IStructuredSelection selection) {
manager.add(new Separator());
manager.add(new Action(Messages.BookmarksListView_delete) {
@Override
public void run() {
ClientSettings settings = client.getSettings();
for (Object element : selection.toArray()) {
AttributeType attribute = (AttributeType) element;
// remove any existing attribute values from securities
for (Security security : client.getSecurities()) security.getAttributes().remove(attribute);
settings.removeAttributeType(attribute);
}
client.markDirty();
tableViewer.setInput(settings.getAttributeTypes().toArray());
}
});
}
Aggregations