use of org.exbin.deltahex.EditationMode in project deltahex-java by exbin.
the class DeltaHexEditorBasic method editationModeLabelMouseClicked.
// GEN-LAST:event_aboutMenuItemActionPerformed
private void editationModeLabelMouseClicked(java.awt.event.MouseEvent evt) {
// GEN-FIRST:event_editationModeLabelMouseClicked
if (evt.getButton() == MouseEvent.BUTTON1) {
EditationMode editationMode;
if (((EditationModeCapable) codeArea.getWorker()).getEditationMode() == EditationMode.INSERT) {
editationMode = EditationMode.OVERWRITE;
} else {
editationMode = EditationMode.INSERT;
}
((EditationModeCapable) codeArea.getWorker()).setEditationMode(editationMode);
}
}
use of org.exbin.deltahex.EditationMode in project deltahex-java by exbin.
the class DeltaHexEditorBasic method postInit.
private void postInit() {
codeArea.setComponentPopupMenu(mainPopupMenu);
setIconImage(new javax.swing.ImageIcon(getClass().getResource("/org/exbin/deltahex/editor/basic/resources/icons/icon.png")).getImage());
undoHandler.addUndoUpdateListener(new BinaryDataUndoUpdateListener() {
@Override
public void undoCommandPositionChanged() {
updateUndoState();
codeArea.repaint();
}
@Override
public void undoCommandAdded(@Nonnull BinaryDataCommand command) {
updateUndoState();
codeArea.repaint();
}
});
((EditationModeCapable) codeArea.getWorker()).addEditationModeChangedListener(new EditationModeChangedListener() {
@Override
public void editationModeChanged(EditationMode editationMode) {
switch(editationMode) {
case INSERT:
{
editationModeLabel.setText("INS");
break;
}
case OVERWRITE:
{
editationModeLabel.setText("OVR");
break;
}
default:
{
throw new IllegalStateException("Unexpected editation mode " + editationMode.name());
}
}
}
});
((CaretCapable) codeArea.getWorker()).addCaretMovedListener(new CaretMovedListener() {
@Override
public void caretMoved(CaretPosition caretPosition) {
positionLabel.setText(caretPosition.getDataPosition() + ":" + caretPosition.getCodeOffset());
}
});
((SelectionCapable) codeArea.getWorker()).addSelectionChangedListener(new SelectionChangedListener() {
@Override
public void selectionChanged(SelectionRange selection) {
updateClipboardState();
}
});
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.addFlavorListener(new FlavorListener() {
@Override
public void flavorsChanged(FlavorEvent e) {
updateClipboardState();
}
});
updateUndoState();
updateClipboardState();
openFileButton.setText("Open");
}
Aggregations