use of java.awt.event.ComponentEvent in project blue by kunstmusik.
the class TracksEditor method setupTable.
private void setupTable() {
table.setShowGrid(false);
table.getTableHeader().setReorderingAllowed(false);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.setDefaultRenderer(String.class, new TrackerCellRenderer());
table.setDefaultEditor(String.class, new TrackColumnEditor());
table.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
namePanel.updateSize();
}
});
table.getColumnModel().addColumnModelListener(new TableColumnModelListener() {
@Override
public void columnAdded(TableColumnModelEvent e) {
}
@Override
public void columnMarginChanged(ChangeEvent e) {
if (trackList != null) {
namePanel.updateLabelSizes();
}
}
@Override
public void columnMoved(TableColumnModelEvent e) {
}
@Override
public void columnRemoved(TableColumnModelEvent e) {
}
@Override
public void columnSelectionChanged(ListSelectionEvent e) {
}
});
table.getColumnModel().getSelectionModel().addListSelectionListener((ListSelectionEvent e) -> {
int h = table.getRowHeight();
int y1 = table.getSelectedRow() * h;
int selectionH = table.getSelectedRowCount() * h;
table.repaint(0, y1, table.getWidth(), selectionH);
});
SwingUtil.installActions(table, new Action[] { new IncrementAction(), new DecrementAction(), new TieAction(), new SpaceBarAction(), new NoteOffAction(), new CutAction(), new CopyAction(), new PasteAction(), new InsertAction(), new DeleteAction(), new BackSpaceAction() });
}
use of java.awt.event.ComponentEvent in project cytoscape-impl by cytoscape.
the class VisualPropertySheetItem method getMappingPnl.
protected JPanel getMappingPnl() {
if (mappingPnl == null) {
mappingPnl = new JPanel();
mappingPnl.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIManager.getColor("Separator.foreground")));
mappingPnl.setLayout(new BorderLayout());
mappingPnl.setVisible(false);
mappingPnl.add(getPropSheetPnl(), BorderLayout.CENTER);
final JPanel bottomPnl = new JPanel();
bottomPnl.setLayout(new BoxLayout(bottomPnl, BoxLayout.X_AXIS));
bottomPnl.add(Box.createHorizontalGlue());
bottomPnl.add(getRemoveMappingBtn());
bottomPnl.add(Box.createRigidArea(new Dimension(0, PROP_SHEET_ROW_HEIGHT)));
bottomPnl.setBorder(BorderFactory.createEmptyBorder(0, 4, 4, 4));
mappingPnl.add(bottomPnl, BorderLayout.SOUTH);
mappingPnl.addComponentListener(new ComponentAdapter() {
@Override
public void componentShown(final ComponentEvent e) {
updateMappingPanelSize();
}
});
}
return mappingPnl;
}
use of java.awt.event.ComponentEvent in project cytoscape-impl by cytoscape.
the class VisualPropertySheetItem method getPropSheetTbl.
protected PropertySheetTable getPropSheetTbl() {
if (propSheetTbl == null) {
propSheetTbl = new VizMapPropertySheetTable();
propSheetTbl.setRowHeight(PROP_SHEET_ROW_HEIGHT);
propSheetTbl.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
propSheetTbl.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(final ComponentEvent e) {
updateMappingPanelSize();
}
});
}
return propSheetTbl;
}
use of java.awt.event.ComponentEvent in project cytoscape-impl by cytoscape.
the class VisualPropertySheetItem method getMappingBtn.
protected JToggleButton getMappingBtn() {
if (mappingBtn == null) {
mappingBtn = new VizMapperToggleButton();
mappingBtn.setIcon(getIcon(null, VALUE_ICON_WIDTH, VALUE_ICON_HEIGHT));
mappingBtn.setUI(new VPButtonUI(VPButtonUI.SOUTH));
mappingBtn.setHorizontalAlignment(JLabel.CENTER);
mappingBtn.setDisabledIcon(disabledBtnIcon);
updateMappingIcon();
mappingBtn.addActionListener(evt -> {
if (getMappingPnl().isShowing())
collapse();
else
expand();
updateMappingIcon();
});
getMappingPnl().addComponentListener(new ComponentAdapter() {
@Override
public void componentShown(final ComponentEvent ce) {
if (mappingBtn != null)
mappingBtn.setSelected(true);
updateMappingIcon();
}
@Override
public void componentHidden(final ComponentEvent ce) {
if (mappingBtn != null)
mappingBtn.setSelected(false);
updateMappingIcon();
}
});
}
return mappingBtn;
}
use of java.awt.event.ComponentEvent in project cytoscape-impl by cytoscape.
the class VizMapperMediator method addViewListeners.
private void addViewListeners(final VisualPropertySheet vpSheet, final VisualPropertySheetItem<?> vpSheetItem) {
if (vpSheetItem.getModel().getVisualPropertyDependency() == null) {
// It's a regular VisualProperty Editor...
// Default value button clicked
vpSheetItem.getDefaultBtn().addActionListener(evt -> {
openDefaultValueEditor(evt, vpSheetItem);
});
// Default value button right-clicked
vpSheetItem.getDefaultBtn().addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
maybeShowContextMenu(e);
}
@Override
public void mouseReleased(final MouseEvent e) {
maybeShowContextMenu(e);
}
private void maybeShowContextMenu(final MouseEvent e) {
if (e.isPopupTrigger()) {
final JPopupMenu contextMenu = new JPopupMenu();
contextMenu.add(new JMenuItem(new AbstractAction("Reset Default Value") {
@Override
public void actionPerformed(final ActionEvent e) {
vpSheetItem.getModel().resetDefaultValue();
}
}));
showContextMenu(contextMenu, e);
}
}
});
// Bypass button clicked
if (vpSheetItem.getModel().isLockedValueAllowed()) {
// Create context menu
final JPopupMenu bypassMenu = new JPopupMenu();
final JMenuItem removeBypassMenuItem;
bypassMenu.add(new JMenuItem(new AbstractAction("Set Bypass...") {
@Override
public void actionPerformed(final ActionEvent e) {
openLockedValueEditor(e, vpSheetItem);
}
}));
bypassMenu.add(removeBypassMenuItem = new JMenuItem(new AbstractAction("Remove Bypass") {
@Override
public void actionPerformed(final ActionEvent e) {
removeLockedValue(e, vpSheetItem);
}
}));
// Right-clicked
vpSheetItem.getBypassBtn().addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
maybeShowContextMenu(e);
}
@Override
public void mouseReleased(final MouseEvent e) {
maybeShowContextMenu(e);
}
private void maybeShowContextMenu(final MouseEvent e) {
if (vpSheetItem.getBypassBtn().isEnabled() && e.isPopupTrigger()) {
final LockedValueState state = vpSheetItem.getModel().getLockedValueState();
removeBypassMenuItem.setEnabled(state != LockedValueState.ENABLED_NOT_SET);
showContextMenu(bypassMenu, e);
}
}
});
// Left-clicked
vpSheetItem.getBypassBtn().addActionListener(evt -> {
final LockedValueState state = vpSheetItem.getModel().getLockedValueState();
final JButton btn = vpSheetItem.getBypassBtn();
if (state == LockedValueState.ENABLED_NOT_SET) {
// There is only one option to execute, so do it now, rather than showing the popup menu
openLockedValueEditor(evt, vpSheetItem);
} else {
bypassMenu.show(btn, 0, btn.getHeight());
bypassMenu.requestFocusInWindow();
}
});
}
// Right-click
final ContextMenuMouseListener cmMouseListener = new ContextMenuMouseListener(vpSheet, vpSheetItem);
vpSheetItem.addMouseListener(cmMouseListener);
if (vpSheetItem.getModel().isVisualMappingAllowed()) {
vpSheetItem.getPropSheetPnl().getTable().addMouseListener(cmMouseListener);
vpSheetItem.getRemoveMappingBtn().addActionListener(evt -> {
removeVisualMapping(vpSheetItem);
});
vpSheetItem.getPropSheetTbl().addPropertyChangeListener("editingVizMapperProperty", evt -> {
// Save the current editor (the one the user is interacting with)
curVpSheetItem = vpSheetItem;
curVizMapperProperty = (VizMapperProperty<?, ?, ?>) evt.getNewValue();
final VizMapperProperty<String, VisualMappingFunctionFactory, VisualMappingFunction<?, ?>> mappingTypeProperty = vizMapPropertyBuilder.getMappingTypeProperty(vpSheetItem.getPropSheetPnl());
final VisualMappingFunctionFactory factory = (VisualMappingFunctionFactory) mappingTypeProperty.getValue();
attrProxy.setCurrentMappingType(factory != null ? factory.getMappingFunctionType() : null);
final VizMapperProperty<VisualProperty<?>, String, VisualMappingFunctionFactory> columnProp = vizMapPropertyBuilder.getColumnProperty(vpSheetItem.getPropSheetPnl());
final Object columnValue = columnProp.getValue();
mappingFactoryProxy.setCurrentColumnName(columnValue != null ? columnValue.toString() : null);
mappingFactoryProxy.setCurrentTargetDataType(vpSheet.getModel().getTargetDataType());
});
}
} else {
// It's a Dependency Editor...
vpSheetItem.getDependencyCkb().addItemListener(evt -> {
onDependencySelectionChanged(evt, vpSheetItem);
});
}
// Save sheet items that were explicitly shown/hidden by the user,
// so his preferences can be respected when the current style changes
vpSheetItem.addComponentListener(new ComponentAdapter() {
@Override
public void componentShown(final ComponentEvent e) {
userProps.put(vpSheetItem.getModel().getId(), Boolean.TRUE);
}
@Override
public void componentHidden(final ComponentEvent e) {
userProps.put(vpSheetItem.getModel().getId(), Boolean.FALSE);
}
});
}
Aggregations