use of javax.swing.event.CaretEvent in project intellij-community by JetBrains.
the class HgInitDialog method init.
@Override
protected void init() {
super.init();
setTitle(HgVcsMessages.message("hg4idea.init.dialog.title"));
if (myProject != null && (!myProject.isDefault())) {
mySelectedDir = myProject.getBaseDir();
}
mySelectWhereToCreateRadioButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
myTextFieldBrowser.setEnabled(true);
updateEverything();
}
});
myCreateRepositoryForTheRadioButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
myTextFieldBrowser.setEnabled(false);
updateEverything();
}
});
myTextFieldBrowser.getTextField().addCaretListener(new CaretListener() {
public void caretUpdate(CaretEvent e) {
updateEverything();
}
});
myTextFieldBrowser.addBrowseFolderListener(HgVcsMessages.message("hg4idea.init.destination.directory.title"), HgVcsMessages.message("hg4idea.init.destination.directory.description"), myProject, myFileDescriptor);
}
use of javax.swing.event.CaretEvent in project intellij-community by JetBrains.
the class AbstractCreateVirtualEnvDialog method registerValidators.
protected void registerValidators(final FacetValidatorsManager validatorsManager) {
myDestination.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
validatorsManager.validate();
}
});
myDestination.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
validatorsManager.validate();
}
});
myName.addCaretListener(new CaretListener() {
@Override
public void caretUpdate(CaretEvent event) {
validatorsManager.validate();
}
});
myDestination.getTextField().addCaretListener(new CaretListener() {
@Override
public void caretUpdate(CaretEvent event) {
validatorsManager.validate();
}
});
}
use of javax.swing.event.CaretEvent in project knime-core by knime.
the class SubnodeLayoutJSONEditorPage method createJSONEditorComposite.
private Composite createJSONEditorComposite(final Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(1, true));
composite.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
if (isWindows()) {
Composite embedComposite = new Composite(composite, SWT.EMBEDDED | SWT.NO_BACKGROUND);
final GridLayout gridLayout = new GridLayout();
gridLayout.verticalSpacing = 0;
gridLayout.marginWidth = 0;
gridLayout.marginHeight = 0;
gridLayout.horizontalSpacing = 0;
embedComposite.setLayout(gridLayout);
embedComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
Frame frame = SWT_AWT.new_Frame(embedComposite);
Panel heavyWeightPanel = new Panel();
heavyWeightPanel.setLayout(new BoxLayout(heavyWeightPanel, BoxLayout.Y_AXIS));
frame.add(heavyWeightPanel);
frame.setFocusTraversalKeysEnabled(false);
// Use JApplet with JRootPane as layer in between heavyweightPanel and RTextScrollPane
// This reduces flicker on resize in RSyntaxTextArea
JApplet applet = new JApplet();
JRootPane root = applet.getRootPane();
Container contentPane = root.getContentPane();
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
heavyWeightPanel.add(applet);
m_textArea = new RSyntaxTextArea(10, 60);
m_textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JSON);
m_textArea.setCodeFoldingEnabled(true);
m_textArea.setAntiAliasingEnabled(true);
RTextScrollPane sp = new RTextScrollPane(m_textArea);
sp.setDoubleBuffered(true);
m_textArea.setText(m_jsonDocument);
m_textArea.setEditable(true);
m_textArea.setEnabled(true);
contentPane.add(sp);
Dimension size = sp.getPreferredSize();
embedComposite.setSize(size.width, size.height);
// forward focus to RSyntaxTextArea
embedComposite.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(final FocusEvent e) {
ViewUtils.runOrInvokeLaterInEDT(new Runnable() {
@Override
public void run() {
m_textArea.requestFocus();
m_textArea.setCaretPosition(m_caretPosition);
}
});
}
@Override
public void focusLost(final FocusEvent e) {
// do nothing
}
});
// delete content of status line, when something is inserted or deleted
m_textArea.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void changedUpdate(final DocumentEvent arg0) {
if (!composite.isDisposed()) {
composite.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
if (m_statusLine != null && !m_statusLine.isDisposed()) {
m_statusLine.setText("");
updateModelFromJson();
}
}
});
}
}
@Override
public void insertUpdate(final DocumentEvent arg0) {
/* do nothing */
}
@Override
public void removeUpdate(final DocumentEvent arg0) {
/* do nothing */
}
});
// remember caret position
m_textArea.addCaretListener(new CaretListener() {
@Override
public void caretUpdate(final CaretEvent arg0) {
m_caretPosition = arg0.getDot();
}
});
} else {
m_text = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
GridData layoutData = new GridData(GridData.FILL_BOTH);
layoutData.widthHint = 600;
layoutData.heightHint = 400;
m_text.setLayoutData(layoutData);
m_text.addModifyListener(new ModifyListener() {
@Override
public void modifyText(final ModifyEvent e) {
m_jsonDocument = m_text.getText();
if (m_statusLine != null && !m_statusLine.isDisposed()) {
m_statusLine.setText("");
updateModelFromJson();
}
}
});
m_text.setText(m_jsonDocument);
}
// add status line
m_statusLine = new Label(composite, SWT.SHADOW_NONE | SWT.WRAP);
GridData statusGridData = new GridData(SWT.LEFT | SWT.FILL, SWT.BOTTOM, true, false);
int maxHeight = new PixelConverter(m_statusLine).convertHeightInCharsToPixels(3);
statusGridData.heightHint = maxHeight + 5;
// seems to have no impact on the layout. The height will still be 3 rows (at least on Windows 8)
statusGridData.minimumHeight = new PixelConverter(m_statusLine).convertHeightInCharsToPixels(1);
m_statusLine.setLayoutData(statusGridData);
compareNodeIDs();
return composite;
}
use of javax.swing.event.CaretEvent in project boosters-lab by taedixon.
the class TscPane method initActions.
private void initActions(ResourceManager iMan) {
if (defPanel == null) {
defPanel = createDefinePanel();
}
if (commandPanel == null) {
commandPanel = createCommandPanel(iMan);
}
this.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
textBoxKeyReleased(evt);
}
});
lastFocus = this;
this.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent arg0) {
lastFocus = TscPane.this;
}
@Override
public void focusLost(FocusEvent arg0) {
// nothing
}
});
this.addCaretListener(new CaretListener() {
@Override
public void caretUpdate(CaretEvent eve) {
if (commandList.isVisible()) {
JTextPane area = (JTextPane) eve.getSource();
int cPos = eve.getDot();
// weed out carriage return characters
String txt = area.getText();
if (txt == null) {
return;
}
// $NON-NLS-1$ //$NON-NLS-2$
txt = txt.replace("\r", "");
String searchTxt = txt.substring(0, cPos);
int tagPos = searchTxt.lastIndexOf('<');
if (tagPos < 0) {
return;
}
if ((txt.length() - tagPos >= 4)) {
String tag = txt.substring(tagPos, tagPos + 4);
int index = commandList.getNextMatch(tag, 0, Position.Bias.Forward);
commandList.setSelectedIndex(index);
setCommandExtras(index, txt.substring(tagPos, txt.length()));
}
}
}
});
}
use of javax.swing.event.CaretEvent in project omegat by omegat-org.
the class SplittingPanelController method show.
/**
* Show the dialog. The dialog is modal, so this method will block until complete.
* <p>
* If the user cancels, the result array will contain as its sole member the original string provided to
* the constructor. Otherwise the array will contain the (trimmed) results of splitting the original
* string.
*
* @param parent
* The parent window of the dialog
* @return The result array
*/
public String[] show(Window parent) {
final JDialog dialog = new JDialog(parent, OStrings.getString("ALIGNER_DIALOG_SPLITTER"), ModalityType.DOCUMENT_MODAL);
dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
doCancel(dialog);
}
});
StaticUIUtils.setEscapeClosable(dialog);
final EditingPanel panel = new EditingPanel();
panel.editorPane.setEditable(false);
panel.editorPane.setText(text);
StaticUIUtils.makeCaretAlwaysVisible(panel.editorPane);
panel.okButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
splitOffset = panel.editorPane.getCaretPosition();
dialog.dispose();
}
});
panel.cancelButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
doCancel(dialog);
}
});
panel.okButton.setEnabled(false);
panel.editorPane.addCaretListener(new CaretListener() {
@Override
public void caretUpdate(CaretEvent e) {
panel.okButton.setEnabled(e.getDot() == e.getMark() && e.getDot() > 0 && e.getDot() < text.length());
}
});
panel.editorPane.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
panel.okButton.doClick();
}
}
});
if (reference != null) {
JPanel referencePanel = new JPanel(new BorderLayout());
JTextArea textArea = new JTextArea(reference);
textArea.setOpaque(false);
textArea.setWrapStyleWord(true);
textArea.setLineWrap(true);
textArea.setEditable(false);
textArea.setFocusable(false);
referencePanel.add(textArea);
referencePanel.setBorder(new EmptyBorder(10, 10, 10, 10));
panel.add(referencePanel, BorderLayout.NORTH);
}
panel.helpText.setText(OStrings.getString("ALIGNER_DIALOG_SPLITTER_HELP"));
dialog.add(panel);
dialog.getRootPane().setDefaultButton(panel.okButton);
dialog.setMinimumSize(new Dimension(450, 250));
dialog.pack();
dialog.setLocationRelativeTo(parent);
dialog.setVisible(true);
if (splitOffset == -1) {
return new String[] { text };
} else {
return new String[] { text.substring(0, splitOffset).trim(), text.substring(splitOffset, text.length()).trim() };
}
}
Aggregations