Search in sources :

Example 1 with AttributeDesignation

use of name.abuchen.portfolio.ui.wizards.security.EditSecurityModel.AttributeDesignation in project portfolio by buchen.

the class AttributesPage method createControl.

@Override
public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NULL);
    setControl(composite);
    GridLayoutFactory.fillDefaults().numColumns(1).applyTo(composite);
    attributeContainer = new Composite(composite, SWT.NULL);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(attributeContainer);
    GridLayoutFactory.fillDefaults().numColumns(3).margins(5, 5).applyTo(attributeContainer);
    for (AttributeDesignation attribute : model.getAttributes()) addAttributeBlock(attributeContainer, attribute);
    // add button
    final Button addButton = new Button(composite, SWT.PUSH);
    addButton.setImage(Images.ADD.image());
    addButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            showAdditionalAttributes();
        }
    });
    GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).applyTo(addButton);
    parent.addDisposeListener(e -> {
        if (menu != null && !menu.isDisposed())
            menu.dispose();
    });
}
Also used : Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) AttributeDesignation(name.abuchen.portfolio.ui.wizards.security.EditSecurityModel.AttributeDesignation)

Example 2 with AttributeDesignation

use of name.abuchen.portfolio.ui.wizards.security.EditSecurityModel.AttributeDesignation 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)

Aggregations

AttributeDesignation (name.abuchen.portfolio.ui.wizards.security.EditSecurityModel.AttributeDesignation)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 Button (org.eclipse.swt.widgets.Button)2 Composite (org.eclipse.swt.widgets.Composite)2 HashSet (java.util.HashSet)1 Set (java.util.Set)1 AttributeType (name.abuchen.portfolio.model.AttributeType)1 Security (name.abuchen.portfolio.model.Security)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 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 Action (org.eclipse.jface.action.Action)1 IMenuListener (org.eclipse.jface.action.IMenuListener)1