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