use of blue.score.layers.LayerGroupProvider in project blue by kunstmusik.
the class ScoreManagerDialog method getAddLayerGroupMenu.
private JPopupMenu getAddLayerGroupMenu() {
if (addLayerGroupMenu == null) {
addLayerGroupMenu = new JPopupMenu();
ActionListener listener = (ActionEvent e) -> {
JMenuItem menuItem = (JMenuItem) e.getSource();
LayerGroupProvider provider = (LayerGroupProvider) menuItem.getClientProperty("provider");
LayerGroup layerGroup = provider.createLayerGroup();
LayerGroupTableModel model = getLayerGroupListModel();
int index = (layerGroupsTable.getSelectionModel().getMaxSelectionIndex());
if (index < 0 || index > model.getRowCount()) {
index = model.getRowCount();
model.addLayerGroup(index, layerGroup);
} else {
model.addLayerGroup(index, layerGroup);
}
ListSelectionModel selection = layerGroupsTable.getSelectionModel();
selection.setSelectionInterval(index, index);
};
LayerGroupProviderManager manager = LayerGroupProviderManager.getInstance();
for (LayerGroupProvider provider : manager) {
JMenuItem item = new JMenuItem("Add " + provider.getLayerGroupName() + " Layer Group");
item.putClientProperty("provider", provider);
item.addActionListener(listener);
addLayerGroupMenu.add(item);
}
}
return addLayerGroupMenu;
}
Aggregations