Search in sources :

Example 1 with AttributeType

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));
}
Also used : UpdateValueStrategy(org.eclipse.core.databinding.UpdateValueStrategy) Images(name.abuchen.portfolio.ui.Images) HashSet(java.util.HashSet) WidgetProperties(org.eclipse.jface.databinding.swt.WidgetProperties) IConverter(org.eclipse.core.databinding.conversion.IConverter) Composite(org.eclipse.swt.widgets.Composite) Messages(name.abuchen.portfolio.ui.Messages) BindingHelper(name.abuchen.portfolio.ui.util.BindingHelper) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) Button(org.eclipse.swt.widgets.Button) MenuManager(org.eclipse.jface.action.MenuManager) GridDataFactory(org.eclipse.jface.layout.GridDataFactory) Set(java.util.Set) Action(org.eclipse.jface.action.Action) Security(name.abuchen.portfolio.model.Security) GridLayoutFactory(org.eclipse.jface.layout.GridLayoutFactory) IValidatingConverter(name.abuchen.portfolio.ui.util.IValidatingConverter) Binding(org.eclipse.core.databinding.Binding) BeanProperties(org.eclipse.core.databinding.beans.BeanProperties) IMenuManager(org.eclipse.jface.action.IMenuManager) SWT(org.eclipse.swt.SWT) AttributeDesignation(name.abuchen.portfolio.ui.wizards.security.EditSecurityModel.AttributeDesignation) AttributeType(name.abuchen.portfolio.model.AttributeType) LabelOnly(name.abuchen.portfolio.ui.util.LabelOnly) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) Label(org.eclipse.swt.widgets.Label) IMenuListener(org.eclipse.jface.action.IMenuListener) LabelOnly(name.abuchen.portfolio.ui.util.LabelOnly) AttributeType(name.abuchen.portfolio.model.AttributeType) AttributeDesignation(name.abuchen.portfolio.ui.wizards.security.EditSecurityModel.AttributeDesignation) HashSet(java.util.HashSet)

Example 2 with AttributeType

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"));
}
Also used : Bookmark(name.abuchen.portfolio.model.Bookmark) AttributeType(name.abuchen.portfolio.model.AttributeType) Client(name.abuchen.portfolio.model.Client) Security(name.abuchen.portfolio.model.Security) Test(org.junit.Test)

Example 3 with AttributeType

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);
}
Also used : AttributeType(name.abuchen.portfolio.model.AttributeType) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Separator(org.eclipse.jface.action.Separator)

Example 4 with AttributeType

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());
        }
    });
}
Also used : Action(org.eclipse.jface.action.Action) AttributeType(name.abuchen.portfolio.model.AttributeType) ClientSettings(name.abuchen.portfolio.model.ClientSettings) Security(name.abuchen.portfolio.model.Security) Separator(org.eclipse.jface.action.Separator)

Aggregations

AttributeType (name.abuchen.portfolio.model.AttributeType)4 Security (name.abuchen.portfolio.model.Security)3 Action (org.eclipse.jface.action.Action)2 Separator (org.eclipse.jface.action.Separator)2 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Bookmark (name.abuchen.portfolio.model.Bookmark)1 Client (name.abuchen.portfolio.model.Client)1 ClientSettings (name.abuchen.portfolio.model.ClientSettings)1 Images (name.abuchen.portfolio.ui.Images)1 Messages (name.abuchen.portfolio.ui.Messages)1 BindingHelper (name.abuchen.portfolio.ui.util.BindingHelper)1 IValidatingConverter (name.abuchen.portfolio.ui.util.IValidatingConverter)1 LabelOnly (name.abuchen.portfolio.ui.util.LabelOnly)1 AttributeDesignation (name.abuchen.portfolio.ui.wizards.security.EditSecurityModel.AttributeDesignation)1 Binding (org.eclipse.core.databinding.Binding)1 UpdateValueStrategy (org.eclipse.core.databinding.UpdateValueStrategy)1 BeanProperties (org.eclipse.core.databinding.beans.BeanProperties)1 IConverter (org.eclipse.core.databinding.conversion.IConverter)1 IMenuListener (org.eclipse.jface.action.IMenuListener)1