use of com.intellij.ui.ColorPickerListener in project android by JetBrains.
the class ColorPanel method initColorFrame.
private void initColorFrame(Color color) {
myColorFrame.setBackground(color);
myColorFrame.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
ColorPicker.showDialog(myContentPane, "Edit color", color, true, new ColorPickerListener[] { new ColorPickerListener() {
@Override
public void colorChanged(Color color) {
}
@Override
public void closed(@Nullable Color color) {
if (color != null) {
myColorName.setText(getColorHexString(color.getRGB()));
}
}
} }, true);
}
@Override
public void mouseEntered(MouseEvent e) {
System.out.println("ColorPanel.mouseEntered");
for (int i = 0; i < myListeners.size(); i++) {
myListeners.get(i).entered(myExtractedColor);
}
}
@Override
public void mouseExited(MouseEvent e) {
for (int i = 0; i < myListeners.size(); i++) {
myListeners.get(i).exited();
}
}
});
}
use of com.intellij.ui.ColorPickerListener in project intellij-community by JetBrains.
the class UserColorLookup method handleUserSelection.
private static void handleUserSelection(InsertionContext context, @NotNull Function<Color, String> colorToStringConverter) {
Project project = context.getProject();
Editor editor = context.getEditor();
int startOffset = context.getStartOffset();
context.getDocument().deleteString(startOffset, context.getTailOffset());
PsiElement element = context.getFile().findElementAt(editor.getCaretModel().getOffset());
Color myColorAtCaret = element instanceof XmlToken ? getColorFromElement(element) : null;
context.setLaterRunnable(() -> {
if (editor.isDisposed() || project.isDisposed())
return;
List<ColorPickerListener> listeners = ColorPickerListenerFactory.createListenersFor(element);
Color color = ColorChooser.chooseColor(WindowManager.getInstance().suggestParentWindow(project), XmlBundle.message("choose.color.dialog.title"), myColorAtCaret, true, listeners, true);
if (color != null) {
WriteCommandAction.runWriteCommandAction(project, () -> {
editor.getCaretModel().moveToOffset(startOffset);
EditorModificationUtil.insertStringAtCaret(editor, colorToStringConverter.fun(color));
});
}
});
}
Aggregations