use of java.beans.PropertyChangeListener in project intellij-community by JetBrains.
the class TemplateState method initListeners.
private void initListeners() {
if (isDisposed())
return;
myEditorDocumentListener = new DocumentAdapter() {
@Override
public void beforeDocumentChange(DocumentEvent e) {
myDocumentChanged = true;
}
};
myLookupListener = new LookupAdapter() {
@Override
public void itemSelected(LookupEvent event) {
if (isCaretOutsideCurrentSegment(null)) {
if (isCaretInsideNextVariable()) {
nextTab();
} else {
gotoEnd(true);
}
}
}
};
LookupManager.getInstance(myProject).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (LookupManager.PROP_ACTIVE_LOOKUP.equals(evt.getPropertyName())) {
Lookup lookup = (Lookup) evt.getNewValue();
if (lookup != null) {
lookup.addLookupListener(myLookupListener);
}
}
}
}, this);
myCommandListener = new CommandAdapter() {
boolean started = false;
@Override
public void commandStarted(CommandEvent event) {
myDocumentChangesTerminateTemplate = isCaretOutsideCurrentSegment(event.getCommandName());
started = true;
}
@Override
public void beforeCommandFinished(CommandEvent event) {
if (started && !isDisposed()) {
Runnable runnable = () -> afterChangedUpdate();
final LookupImpl lookup = myEditor != null ? (LookupImpl) LookupManager.getActiveLookup(myEditor) : null;
if (lookup != null) {
lookup.performGuardedChange(runnable);
} else {
runnable.run();
}
}
}
};
myCaretListener = new CaretAdapter() {
@Override
public void caretAdded(CaretEvent e) {
if (isMultiCaretMode()) {
finishTemplateEditing();
}
}
@Override
public void caretRemoved(CaretEvent e) {
if (isMultiCaretMode()) {
finishTemplateEditing();
}
}
};
if (myEditor != null) {
myEditor.getCaretModel().addCaretListener(myCaretListener);
}
myDocument.addDocumentListener(myEditorDocumentListener, this);
CommandProcessor.getInstance().addCommandListener(myCommandListener, this);
}
use of java.beans.PropertyChangeListener in project intellij-community by JetBrains.
the class PushLog method createStrategyPanel.
private JComponent createStrategyPanel() {
final JPanel labelPanel = new JPanel(new BorderLayout());
labelPanel.setBackground(myTree.getBackground());
final LinkLabel<String> linkLabel = new LinkLabel<>("Edit all targets", null);
linkLabel.setBorder(new EmptyBorder(2, 2, 2, 2));
linkLabel.setListener(new LinkListener<String>() {
@Override
public void linkSelected(LinkLabel aSource, String aLinkData) {
if (linkLabel.isEnabled()) {
startSyncEditing();
}
}
}, null);
myTree.addPropertyChangeListener(PushLogTreeUtil.EDIT_MODE_PROP, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
Boolean editMode = (Boolean) evt.getNewValue();
linkLabel.setEnabled(!editMode);
linkLabel.setPaintUnderline(!editMode);
linkLabel.repaint();
}
});
labelPanel.add(linkLabel, BorderLayout.EAST);
return labelPanel;
}
use of java.beans.PropertyChangeListener in project intellij-community by JetBrains.
the class SpeedSearchSupply method installSupplyTo.
protected void installSupplyTo(final JComponent component) {
component.putClientProperty(SPEED_SEARCH_COMPONENT_MARKER, this);
addChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
component.repaint();
}
});
}
use of java.beans.PropertyChangeListener in project intellij-community by JetBrains.
the class NotificationsManagerImpl method createButtons.
@Nullable
private static JPanel createButtons(@NotNull Notification notification, @NotNull final JPanel content, @Nullable HyperlinkListener listener) {
if (notification instanceof NotificationActionProvider) {
JPanel buttons = new JPanel(new HorizontalLayout(5));
buttons.setOpaque(false);
content.add(BorderLayout.SOUTH, buttons);
final Ref<JButton> defaultButton = new Ref<>();
NotificationActionProvider provider = (NotificationActionProvider) notification;
for (NotificationActionProvider.Action action : provider.getActions(listener)) {
JButton button = new JButton(action) {
@Override
public void setUI(ButtonUI ui) {
boolean isDarcula = ui instanceof DarculaButtonUI && UIUtil.isUnderDarcula();
if (isDarcula) {
ui = new DarculaButtonUI() {
@Override
protected Color getButtonColor1() {
return new ColorUIResource(0x464b4c);
}
@Override
protected Color getButtonColor2() {
return new ColorUIResource(0x383c3d);
}
};
}
super.setUI(ui);
if (isDarcula) {
setBorder(new DarculaButtonPainter() {
@Override
protected Color getBorderColor() {
return new ColorUIResource(0x616263);
}
});
}
}
};
button.setOpaque(false);
if (action.isDefaultAction()) {
defaultButton.setIfNull(button);
}
buttons.add(HorizontalLayout.RIGHT, button);
}
if (!defaultButton.isNull()) {
UIUtil.addParentChangeListener(content, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (event.getOldValue() == null && event.getNewValue() != null) {
UIUtil.removeParentChangeListener(content, this);
JRootPane rootPane = UIUtil.getRootPane(content);
if (rootPane != null) {
rootPane.setDefaultButton(defaultButton.get());
}
}
}
});
}
return buttons;
}
return null;
}
use of java.beans.PropertyChangeListener in project intellij-community by JetBrains.
the class ShortcutDialog method createNorthPanel.
@Nullable
@Override
protected JComponent createNorthPanel() {
myAction.setIpad(JBUI.insets(10, 10, 5, 10));
myShortcutPanel.addPropertyChangeListener("shortcut", new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
setShortcut(toShortcut(event.getNewValue()));
}
});
JBPanel result = new JBPanel(new BorderLayout()).withPreferredWidth(300).withMinimumWidth(200);
result.add(BorderLayout.NORTH, myAction);
result.add(BorderLayout.SOUTH, myShortcutPanel);
return result;
}
Aggregations