Search in sources :

Example 6 with SimpleAction

use of name.abuchen.portfolio.ui.util.SimpleAction in project portfolio by buchen.

the class BookmarksListTab method addTestMenu.

private void addTestMenu(IMenuManager manager, Bookmark bookmark) {
    MenuManager securities = new MenuManager(Messages.MenuOpenSecurityOnSite);
    for (Security security : client.getSecurities()) {
        securities.add(new SimpleAction(security.getName(), a -> DesktopAPI.browse(bookmark.constructURL(client, security))));
    }
    manager.add(securities);
    manager.add(new Separator());
}
Also used : ContextMenu(name.abuchen.portfolio.ui.util.ContextMenu) Arrays(java.util.Arrays) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Client(name.abuchen.portfolio.model.Client) TableViewer(org.eclipse.jface.viewers.TableViewer) Images(name.abuchen.portfolio.ui.Images) Image(org.eclipse.swt.graphics.Image) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) Inject(javax.inject.Inject) ModificationListener(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport.ModificationListener) Composite(org.eclipse.swt.widgets.Composite) Messages(name.abuchen.portfolio.ui.Messages) StringEditingSupport(name.abuchen.portfolio.ui.util.viewers.StringEditingSupport) Separator(org.eclipse.jface.action.Separator) Shell(org.eclipse.swt.widgets.Shell) CTabFolder(org.eclipse.swt.custom.CTabFolder) MenuManager(org.eclipse.jface.action.MenuManager) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Column(name.abuchen.portfolio.ui.util.viewers.Column) Action(org.eclipse.jface.action.Action) Security(name.abuchen.portfolio.model.Security) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) DesktopAPI(name.abuchen.portfolio.ui.util.DesktopAPI) ColumnEditingSupport(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport) ShowHideColumnHelper(name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper) CTabItem(org.eclipse.swt.custom.CTabItem) List(java.util.List) Bookmark(name.abuchen.portfolio.model.Bookmark) IMenuManager(org.eclipse.jface.action.IMenuManager) SWT(org.eclipse.swt.SWT) LabelOnly(name.abuchen.portfolio.ui.util.LabelOnly) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ClientSettings(name.abuchen.portfolio.model.ClientSettings) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Security(name.abuchen.portfolio.model.Security) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Separator(org.eclipse.jface.action.Separator)

Example 7 with SimpleAction

use of name.abuchen.portfolio.ui.util.SimpleAction in project portfolio by buchen.

the class AbstractNodeTreeViewer method fillContextMenu.

protected // NOSONAR
void fillContextMenu(// NOSONAR
IMenuManager manager) {
    // do not show context menu if multiple nodes are selected
    IStructuredSelection selection = (IStructuredSelection) nodeViewer.getSelection();
    if (selection.isEmpty() || selection.size() > 1)
        return;
    TaxonomyNode node = (TaxonomyNode) selection.getFirstElement();
    if (node.isUnassignedCategory())
        return;
    // allow inherited views to contribute to the context menu
    manager.add(new Separator(MENU_GROUP_CUSTOM_ACTIONS));
    manager.add(new Separator(MENU_GROUP_DEFAULT_ACTIONS));
    if (node.isClassification()) {
        manager.add(new SimpleAction(Messages.MenuTaxonomyClassificationCreate, a -> doAddClassification(node)));
        TaxonomyNode unassigned = getModel().getUnassignedNode();
        if (!unassigned.getChildren().isEmpty()) {
            MenuManager subMenu = new MenuManager(Messages.MenuTaxonomyMakeAssignment);
            addAvailableAssignments(subMenu, node);
            manager.add(subMenu);
        }
        manager.add(new Separator());
        MenuManager sorting = new MenuManager(Messages.MenuTaxonomySortTreeBy);
        sorting.add(new SimpleAction(Messages.MenuTaxonomySortByTypName, a -> doSort(node, true)));
        sorting.add(new SimpleAction(Messages.MenuTaxonomySortByName, a -> doSort(node, false)));
        manager.add(sorting);
        if (!node.isRoot()) {
            manager.add(new Separator(MENU_GROUP_DELETE_ACTIONS));
            manager.add(new SimpleAction(Messages.MenuTaxonomyClassificationDelete, a -> doDeleteClassification(node)));
        }
    } else {
        // node is assignment, but not in unassigned category
        if (!node.getParent().isUnassignedCategory()) {
            manager.add(new SimpleAction(Messages.MenuTaxonomyAssignmentRemove, a -> {
                int oldWeight = node.getWeight();
                node.setWeight(0);
                doChangeAssignmentWeight(node, oldWeight);
                onTaxnomyNodeEdited(getModel().getVirtualRootNode());
            }));
        }
        Security security = node.getBackingSecurity();
        if (security != null) {
            manager.add(new Separator());
            manager.add(new BookmarkMenu(part, security));
        }
    }
}
Also used : NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) Arrays(java.util.Arrays) DND(org.eclipse.swt.dnd.DND) Classification(name.abuchen.portfolio.model.Classification) ModificationListener(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport.ModificationListener) ESelectionService(org.eclipse.e4.ui.workbench.modeling.ESelectionService) Composite(org.eclipse.swt.widgets.Composite) ColumnViewerToolTipSupport(org.eclipse.jface.viewers.ColumnViewerToolTipSupport) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) UIConstants(name.abuchen.portfolio.ui.UIConstants) Separator(org.eclipse.jface.action.Separator) Predicate(java.util.function.Predicate) MenuManager(org.eclipse.jface.action.MenuManager) Set(java.util.Set) Security(name.abuchen.portfolio.model.Security) UUID(java.util.UUID) Display(org.eclipse.swt.widgets.Display) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) ExchangeRate(name.abuchen.portfolio.money.ExchangeRate) PortfolioPart(name.abuchen.portfolio.ui.PortfolioPart) ColumnEditingSupport(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport) Transfer(org.eclipse.swt.dnd.Transfer) ShowHideColumnHelper(name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper) List(java.util.List) Colors(name.abuchen.portfolio.ui.util.Colors) CurrencyConverter(name.abuchen.portfolio.money.CurrencyConverter) AttributeColumn(name.abuchen.portfolio.ui.views.columns.AttributeColumn) LocalDate(java.time.LocalDate) SWT(org.eclipse.swt.SWT) TreeViewer(org.eclipse.jface.viewers.TreeViewer) SecurityTransfer(name.abuchen.portfolio.ui.dnd.SecurityTransfer) SecuritySelection(name.abuchen.portfolio.ui.selection.SecuritySelection) DragSourceEvent(org.eclipse.swt.dnd.DragSourceEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TransferData(org.eclipse.swt.dnd.TransferData) DragSourceAdapter(org.eclipse.swt.dnd.DragSourceAdapter) ContextMenu(name.abuchen.portfolio.ui.util.ContextMenu) Values(name.abuchen.portfolio.money.Values) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) InvestmentVehicle(name.abuchen.portfolio.model.InvestmentVehicle) BookmarkMenu(name.abuchen.portfolio.ui.util.BookmarkMenu) NameColumnLabelProvider(name.abuchen.portfolio.ui.views.columns.NameColumn.NameColumnLabelProvider) Images(name.abuchen.portfolio.ui.Images) Image(org.eclipse.swt.graphics.Image) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) ViewerDropAdapter(org.eclipse.jface.viewers.ViewerDropAdapter) IsinColumn(name.abuchen.portfolio.ui.views.columns.IsinColumn) Messages(name.abuchen.portfolio.ui.Messages) TreeSelection(org.eclipse.jface.viewers.TreeSelection) StringEditingSupport(name.abuchen.portfolio.ui.util.viewers.StringEditingSupport) LinkedList(java.util.LinkedList) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) ValueEditingSupport(name.abuchen.portfolio.ui.util.viewers.ValueEditingSupport) Viewer(org.eclipse.jface.viewers.Viewer) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Column(name.abuchen.portfolio.ui.util.viewers.Column) Action(org.eclipse.jface.action.Action) TreeViewerCSVExporter(name.abuchen.portfolio.ui.util.TreeViewerCSVExporter) Preference(org.eclipse.e4.core.di.extensions.Preference) Color(org.eclipse.swt.graphics.Color) IMenuManager(org.eclipse.jface.action.IMenuManager) Named(name.abuchen.portfolio.model.Named) StringJoiner(java.util.StringJoiner) TreeColumnLayout(org.eclipse.jface.layout.TreeColumnLayout) ToolTip(org.eclipse.jface.window.ToolTip) Collections(java.util.Collections) Control(org.eclipse.swt.widgets.Control) Assignment(name.abuchen.portfolio.model.Classification.Assignment) BookmarkMenu(name.abuchen.portfolio.ui.util.BookmarkMenu) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Security(name.abuchen.portfolio.model.Security) Separator(org.eclipse.jface.action.Separator)

Example 8 with SimpleAction

use of name.abuchen.portfolio.ui.util.SimpleAction in project portfolio by buchen.

the class DefinitionViewer method fillContextMenu.

@Override
protected void fillContextMenu(IMenuManager manager) {
    super.fillContextMenu(manager);
    final IStructuredSelection selection = getNodeViewer().getStructuredSelection();
    if (selection.isEmpty() || selection.size() > 1)
        return;
    final TaxonomyNode node = (TaxonomyNode) selection.getFirstElement();
    if (node == null || node.isUnassignedCategory())
        return;
    if (!node.isClassification())
        return;
    MenuManager color = new MenuManager(Messages.ColumnColor);
    color.add(new SimpleAction(Messages.MenuTaxonomyColorEdit, a -> doEditColor(node)));
    color.add(new SimpleAction(Messages.MenuTaxonomyColorRandomPalette, a -> doAutoAssignColors(node)));
    color.add(new SimpleAction(Messages.MenuTaxonomyColorCascadeToChildren, a -> doCascadeColorsDown(node)));
    manager.appendToGroup(MENU_GROUP_DEFAULT_ACTIONS, color);
}
Also used : MenuManager(org.eclipse.jface.action.MenuManager) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Column(name.abuchen.portfolio.ui.util.viewers.Column) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) ShowHideColumnHelper(name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper) Inject(javax.inject.Inject) ColorDialog(org.eclipse.swt.widgets.ColorDialog) Colors(name.abuchen.portfolio.ui.util.Colors) Color(org.eclipse.swt.graphics.Color) IMenuManager(org.eclipse.jface.action.IMenuManager) Messages(name.abuchen.portfolio.ui.Messages) SWT(org.eclipse.swt.SWT) RGB(org.eclipse.swt.graphics.RGB) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction)

Example 9 with SimpleAction

use of name.abuchen.portfolio.ui.util.SimpleAction in project portfolio by buchen.

the class ReBalancingViewer method fillContextMenu.

@Override
protected void fillContextMenu(IMenuManager manager) {
    super.fillContextMenu(manager);
    final IStructuredSelection selection = getNodeViewer().getStructuredSelection();
    if (selection.isEmpty() || selection.size() > 1)
        return;
    final TaxonomyNode node = (TaxonomyNode) selection.getFirstElement();
    if (node == null || node.isUnassignedCategory())
        return;
    if (node.isClassification() && getModel().hasWeightError(node)) {
        manager.appendToGroup(MENU_GROUP_CUSTOM_ACTIONS, new SimpleAction(Messages.MenuTaxonomyWeightFix, a -> doFixClassificationWeights(node)));
    }
}
Also used : Money(name.abuchen.portfolio.money.Money) Values(name.abuchen.portfolio.money.Values) ValueEditingSupport(name.abuchen.portfolio.ui.util.viewers.ValueEditingSupport) Images(name.abuchen.portfolio.ui.Images) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Column(name.abuchen.portfolio.ui.util.viewers.Column) Image(org.eclipse.swt.graphics.Image) AssetPosition(name.abuchen.portfolio.snapshot.AssetPosition) Security(name.abuchen.portfolio.model.Security) Display(org.eclipse.swt.widgets.Display) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) Classification(name.abuchen.portfolio.model.Classification) ShowHideColumnHelper(name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper) Inject(javax.inject.Inject) SharesLabelProvider(name.abuchen.portfolio.ui.util.viewers.SharesLabelProvider) Colors(name.abuchen.portfolio.ui.util.Colors) Color(org.eclipse.swt.graphics.Color) IMenuManager(org.eclipse.jface.action.IMenuManager) Messages(name.abuchen.portfolio.ui.Messages) LocalDate(java.time.LocalDate) SWT(org.eclipse.swt.SWT) SecurityPrice(name.abuchen.portfolio.model.SecurityPrice) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction)

Example 10 with SimpleAction

use of name.abuchen.portfolio.ui.util.SimpleAction in project portfolio by buchen.

the class StackedChartViewer method configMenuAboutToShow.

@Override
public void configMenuAboutToShow(IMenuManager manager) {
    super.configMenuAboutToShow(manager);
    Action action = new SimpleAction(Messages.LabelOrderByTaxonomy, a -> {
        getModel().setOrderByTaxonomyInStackChart(!getModel().isOrderByTaxonomyInStackChart());
        onConfigChanged();
    });
    action.setChecked(getModel().isOrderByTaxonomyInStackChart());
    manager.add(action);
}
Also used : SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Action(org.eclipse.jface.action.Action) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction)

Aggregations

SimpleAction (name.abuchen.portfolio.ui.util.SimpleAction)26 Action (org.eclipse.jface.action.Action)20 IMenuManager (org.eclipse.jface.action.IMenuManager)20 Messages (name.abuchen.portfolio.ui.Messages)17 Separator (org.eclipse.jface.action.Separator)16 MenuManager (org.eclipse.jface.action.MenuManager)14 Display (org.eclipse.swt.widgets.Display)13 Inject (javax.inject.Inject)11 SWT (org.eclipse.swt.SWT)11 Images (name.abuchen.portfolio.ui.Images)10 AbstractDropDown (name.abuchen.portfolio.ui.util.AbstractDropDown)9 Composite (org.eclipse.swt.widgets.Composite)9 List (java.util.List)8 LocalDate (java.time.LocalDate)7 Control (org.eclipse.swt.widgets.Control)7 LabelOnly (name.abuchen.portfolio.ui.util.LabelOnly)6 ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)6 Image (org.eclipse.swt.graphics.Image)6 Client (name.abuchen.portfolio.model.Client)5 Values (name.abuchen.portfolio.money.Values)5