use of javax.swing.text.JTextComponent in project freeplane by freeplane.
the class TimeManagement method insertTime.
void insertTime(final Dialog dialog, final JButton appendButton) {
FormattedDate date = getCalendarDate();
final String dateAsString = dateFormat.formatObject(date).toString();
final Window parentWindow;
if (dialog != null) {
parentWindow = (Window) dialog.getParent();
} else {
parentWindow = SwingUtilities.getWindowAncestor(appendButton);
}
final Component mostRecentFocusOwner = parentWindow.getMostRecentFocusOwner();
if (mostRecentFocusOwner instanceof JTextComponent && !(mostRecentFocusOwner.getClass().getName().contains("JSpinField"))) {
final JTextComponent textComponent = (JTextComponent) mostRecentFocusOwner;
textComponent.replaceSelection(dateAsString);
return;
}
if (mostRecentFocusOwner instanceof JTable) {
JTable table = (JTable) mostRecentFocusOwner;
final int[] selectedRows = table.getSelectedRows();
final int[] selectedColumns = table.getSelectedColumns();
for (int r : selectedRows) for (int c : selectedColumns) table.setValueAt(date, r, c);
} else {
ModeController mController = Controller.getCurrentModeController();
for (final NodeModel node : mController.getMapController().getSelectedNodes()) {
final MTextController textController = (MTextController) TextController.getController();
textController.setNodeObject(node, date);
}
}
}
use of javax.swing.text.JTextComponent in project freeplane by freeplane.
the class UITools method isEditingText.
public static boolean isEditingText() {
final Component focusOwner = FocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
final boolean isTextComponentFocused = focusOwner instanceof JEditorPane;
return isTextComponentFocused && focusOwner.isShowing() && ((JTextComponent) focusOwner).isEditable();
}
use of javax.swing.text.JTextComponent in project freeplane by freeplane.
the class FilterConditionEditor method focusInputField.
public void focusInputField(final boolean selectAll) {
if (values.isEnabled()) {
values.requestFocus();
final Component editorComponent = values.getEditor().getEditorComponent();
if (selectAll && editorComponent instanceof JTextComponent) {
((JTextComponent) editorComponent).selectAll();
}
return;
}
}
use of javax.swing.text.JTextComponent in project freeplane by freeplane.
the class NodeSelector method createTimer.
public void createTimer(final MouseEvent e) {
if (controlRegionForDelayedSelection != null && controlRegionForDelayedSelection.contains(e.getPoint())) {
return;
}
if (!isInside(e))
return;
stopTimerForDelayedSelection();
Window focusedWindow = FocusManager.getCurrentManager().getFocusedWindow();
if (focusedWindow == null) {
return;
}
if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() instanceof JTextComponent) {
return;
}
/* Region to check for in the sequel. */
controlRegionForDelayedSelection = getControlRegion(e.getPoint());
final String selectionMethod = ResourceController.getResourceController().getProperty(SELECTION_METHOD);
if (selectionMethod.equals(SELECTION_METHOD_BY_CLICK)) {
return;
}
if (selectionMethod.equals(SELECTION_METHOD_DIRECT)) {
new TimeDelayedSelection(e).run();
return;
}
final int timeForDelayedSelection = ResourceController.getResourceController().getIntProperty(TIME_FOR_DELAYED_SELECTION, 0);
timerForDelayedSelection = SysUtils.createTimer(getClass().getSimpleName());
timerForDelayedSelection.schedule(new TimeDelayedSelection(e), timeForDelayedSelection);
}
use of javax.swing.text.JTextComponent in project basicv2 by EgonOlsen71.
the class BlockCaret method paint.
public void paint(Graphics g) {
if (isVisible()) {
try {
JTextComponent component = getComponent();
Rectangle r = component.getUI().modelToView(component, getDot());
Color c = g.getColor();
g.setColor(component.getBackground());
g.setXORMode(component.getCaretColor());
r.setBounds(r.x, r.y, g.getFontMetrics().charWidth('w'), g.getFontMetrics().getHeight());
g.fillRect(r.x, r.y, r.width, r.height);
g.setPaintMode();
g.setColor(c);
} catch (BadLocationException e) {
e.printStackTrace();
}
}
}
Aggregations