use of java.awt.event.MouseListener in project buck by facebook.
the class BuckToolWindowFactory method createBuildInfoPanel.
private JComponent createBuildInfoPanel(Project project) {
Tree result = new Tree(BuckUIManager.getInstance(project).getTreeModel());
result.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
Tree tree = (Tree) e.getComponent();
int selRow = tree.getRowForLocation(e.getX(), e.getY());
TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
if (selRow != -1 && e.getClickCount() == 2) {
TreeNode node = (TreeNode) selPath.getLastPathComponent();
if (node.isLeaf()) {
BuckTreeNodeDetail buckNode = (BuckTreeNodeDetail) node;
if (buckNode instanceof BuckTreeNodeDetailError) {
BuckToolWindowFactory.this.handleClickOnError((BuckTreeNodeDetailError) buckNode);
}
}
}
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
});
result.setCellRenderer(new BuckTreeCellRenderer());
result.setShowsRootHandles(false);
result.setRowHeight(0);
JBScrollPane treeView = new JBScrollPane(result);
return treeView;
}
use of java.awt.event.MouseListener in project silk by jbee.
the class TestMockingBinds method moreSpecificUpperBoundTypesAreMorePrecise.
@Test
public void moreSpecificUpperBoundTypesAreMorePrecise() {
Injector injector = Bootstrap.injector(TestMockingBindsModule.class);
MouseListener mock = injector.resolve(dependency(MouseListener.class));
assertTrue(isProxyClass(mock.getClass()));
assertEquals(EventListener.class.getCanonicalName(), mock.toString());
}
use of java.awt.event.MouseListener in project languagetool by languagetool-org.
the class LanguageToolSupport method init.
private void init() {
try {
config = new Configuration(new File(System.getProperty("user.home")), CONFIG_FILE, null);
} catch (IOException ex) {
throw new RuntimeException("Could not load configuration", ex);
}
Language defaultLanguage = config.getLanguage();
if (defaultLanguage == null) {
defaultLanguage = Languages.getLanguageForLocale(Locale.getDefault());
}
/**
* Warm-up: we have a lot of lazy init in LT, which causes the first check to
* be very slow (several seconds) for languages with a lot of data and a lot of
* rules. We just assume that the default language is the language that the user
* often uses and init the LT object for that now, not just when it's first used.
* This makes the first check feel much faster:
*/
reloadLanguageTool(defaultLanguage);
checkExecutor = new ScheduledThreadPoolExecutor(1, new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
Thread t = new Thread(r);
t.setDaemon(true);
t.setPriority(Thread.MIN_PRIORITY);
t.setName(t.getName() + "-lt-background");
return t;
}
});
check = new AtomicInteger(0);
this.textComponent.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
mustDetectLanguage = config.getAutoDetect();
recalculateSpans(e.getOffset(), e.getLength(), false);
if (backgroundCheckEnabled) {
checkDelayed(null);
}
}
@Override
public void removeUpdate(DocumentEvent e) {
mustDetectLanguage = config.getAutoDetect();
recalculateSpans(e.getOffset(), e.getLength(), true);
if (backgroundCheckEnabled) {
checkDelayed(null);
}
}
@Override
public void changedUpdate(DocumentEvent e) {
mustDetectLanguage = config.getAutoDetect();
if (backgroundCheckEnabled) {
checkDelayed(null);
}
}
});
mouseListener = new MouseListener() {
@Override
public void mouseClicked(MouseEvent me) {
}
@Override
public void mousePressed(MouseEvent me) {
if (me.isPopupTrigger()) {
showPopup(me);
}
}
@Override
public void mouseReleased(MouseEvent me) {
if (me.isPopupTrigger()) {
showPopup(me);
}
}
@Override
public void mouseEntered(MouseEvent me) {
}
@Override
public void mouseExited(MouseEvent me) {
}
};
this.textComponent.addMouseListener(mouseListener);
actionListener = e -> _actionPerformed(e);
mustDetectLanguage = config.getAutoDetect();
if (!this.textComponent.getText().isEmpty() && backgroundCheckEnabled) {
checkImmediately(null);
}
}
use of java.awt.event.MouseListener in project jna by java-native-access.
the class BalloonManagerDemo method main.
public static void main(String[] args) {
try {
System.setProperty("sun.java2d.noddraw", "true");
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
}
JFrame f = new JFrame("Balloon Test");
final String BALLOON_TEXT = "<html><center>" + "This is some sample balloon text<br>" + "which has been formatted with html.<br>" + "Click to dismiss.</center></html>";
final JLabel content = new JLabel(BALLOON_TEXT);
content.setIconTextGap(10);
content.setBorder(new EmptyBorder(0, 8, 0, 8));
content.setSize(content.getPreferredSize());
content.setIcon(new InfoIcon());
JLabel label = new JLabel("Click anywhere for more information");
label.setHorizontalAlignment(SwingConstants.CENTER);
label.addMouseListener(new MouseAdapter() {
private MouseListener listener = new MouseAdapter() {
public void mousePressed(MouseEvent e) {
hidePopup(e);
}
};
private Popup popup;
private void hidePopup(MouseEvent e) {
e.getComponent().removeMouseListener(listener);
if (popup != null)
popup.hide();
}
public void mousePressed(MouseEvent e) {
hidePopup(e);
popup = BalloonManager.getBalloon(e.getComponent(), content, e.getX(), e.getY());
popup.show();
content.getParent().addMouseListener(listener);
}
});
f.getContentPane().add(label);
f.pack();
f.setSize(new Dimension(300, 300));
f.setLocation(100, 100);
try {
// Force a load of JNA
WindowUtils.setWindowMask(f, WindowUtils.MASK_NONE);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
} catch (UnsatisfiedLinkError e) {
e.printStackTrace();
String msg = e.getMessage() + "\nError loading the JNA library";
JTextArea area = new JTextArea(msg);
area.setOpaque(false);
area.setFont(UIManager.getFont("Label.font"));
area.setEditable(false);
area.setColumns(80);
area.setRows(8);
area.setWrapStyleWord(true);
area.setLineWrap(true);
JOptionPane.showMessageDialog(null, new JScrollPane(area), "Library Load Error: " + System.getProperty("os.name") + "/" + System.getProperty("os.arch"), JOptionPane.ERROR_MESSAGE);
System.exit(1);
}
}
use of java.awt.event.MouseListener in project intellij-community by JetBrains.
the class PaletteItemsComponent method updateUI.
@Override
public void updateUI() {
setUI(new BasicListUI() {
MouseListener myListener;
@Override
protected void updateLayoutState() {
super.updateLayoutState();
Insets insets = list.getInsets();
int listWidth = list.getWidth() - (insets.left + insets.right);
if (listWidth >= cellWidth) {
int columnCount = listWidth / cellWidth;
cellWidth = (columnCount == 0) ? 1 : listWidth / columnCount;
}
}
@Override
protected void installListeners() {
addMouseListener(myListener = new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
myBeforeClickSelectedRow = list.getSelectedIndex();
}
});
super.installListeners();
}
@Override
protected void uninstallListeners() {
if (myListener != null) {
removeMouseListener(myListener);
}
super.uninstallListeners();
}
});
invalidate();
}
Aggregations