use of java.awt.event.MouseAdapter in project adempiere by adempiere.
the class PDFViewerBean method createActionButton.
protected JButton createActionButton(Action action, String text, String image, String tooltip) {
final ImageIcon icon = new ImageIcon(getClass().getResource(image));
final double colorFactor = 0.9;
final RGBImageFilter filter = new RGBImageFilter() {
public int filterRGB(int x, int y, int rgb) {
final int alpha = (rgb >> 24) & 0xff;
final int red = (rgb >> 16) & 0xff;
final int green = (rgb >> 8) & 0xff;
final int blue = (rgb) & 0xff;
return ((int) (alpha * colorFactor) << 24) | ((int) (red * colorFactor) << 16) | ((int) (green * colorFactor) << 8) | ((int) (blue * colorFactor));
}
};
final ImageIcon darkerIcon = new ImageIcon(Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(icon.getImage().getSource(), filter)));
final JButton result = new JButton();
result.setAction(action);
result.setText(text);
result.setIcon(darkerIcon);
result.setBorderPainted(false);
result.setHorizontalTextPosition(SwingConstants.CENTER);
result.setVerticalTextPosition(SwingConstants.BOTTOM);
result.setMnemonic(0);
result.setToolTipText(tooltip);
final Dimension dim = result.getPreferredSize();
result.setMaximumSize(new Dimension(32, dim.height));
result.addMouseListener(new MouseAdapter() {
public void mouseEntered(MouseEvent me) {
result.setBorderPainted(true);
result.setIcon(icon);
}
public void mouseExited(MouseEvent me) {
result.setBorderPainted(false);
result.setIcon(darkerIcon);
}
});
result.setBorderPainted(false);
result.setFocusPainted(false);
return result;
}
use of java.awt.event.MouseAdapter in project adempiere by adempiere.
the class VSortTab method jbInit.
/**
* Static Layout
* @throws Exception
*/
private void jbInit() throws Exception {
this.setLayout(mainLayout);
//
noLabel.setText("No");
yesLabel.setText("Yes");
for (MouseMotionListener mml : noList.getMouseMotionListeners()) noList.removeMouseMotionListener(mml);
for (MouseMotionListener mml : yesList.getMouseMotionListeners()) yesList.removeMouseMotionListener(mml);
MouseListener mouseListener = new MouseAdapter() {
public void mouseClicked(MouseEvent me) {
if (me.getClickCount() > 1) {
JList list = (JList) me.getComponent();
Point p = me.getPoint();
int index = list.locationToIndex(p);
if (index > -1 && list.getCellBounds(index, index).contains(p))
migrateValueAcrossLists(me);
}
}
};
yesList.addMouseListener(mouseListener);
noList.addMouseListener(mouseListener);
//
yesList.setCellRenderer(listRenderer);
noList.setCellRenderer(listRenderer);
ActionListener actionListener = new ActionListener() {
public void actionPerformed(ActionEvent ae) {
migrateValueAcrossLists(ae);
}
};
bAdd.setIcon(Env.getImageIcon("Detail24.gif"));
bAdd.setMargin(new Insets(2, 2, 2, 2));
bAdd.addActionListener(actionListener);
bRemove.setIcon(Env.getImageIcon("Parent24.gif"));
bRemove.setMargin(new Insets(2, 2, 2, 2));
bRemove.addActionListener(actionListener);
MouseInputListener crossListMouseListener = new DragListener();
yesList.addMouseListener(crossListMouseListener);
yesList.addMouseMotionListener(crossListMouseListener);
noList.addMouseListener(crossListMouseListener);
noList.addMouseMotionListener(crossListMouseListener);
actionListener = new ActionListener() {
public void actionPerformed(ActionEvent ae) {
migrateValueWithinYesList(ae);
}
};
bUp.setIcon(Env.getImageIcon("Previous24.gif"));
bUp.setMargin(new Insets(2, 2, 2, 2));
bUp.addActionListener(actionListener);
bDown.setIcon(Env.getImageIcon("Next24.gif"));
bDown.setMargin(new Insets(2, 2, 2, 2));
bDown.addActionListener(actionListener);
MouseMotionListener yesListMouseMotionListener = new MouseMotionAdapter() {
public void mouseDragged(MouseEvent me) {
JList list = (JList) me.getComponent();
Point p = me.getPoint();
int index = list.locationToIndex(p);
if (index > -1 && list.getCellBounds(index, index).contains(p))
migrateValueWithinYesList(me);
}
};
yesList.addMouseMotionListener(yesListMouseMotionListener);
// Yamel Senih, 2015-11-13
// Maximize Panel when the window is resized
yesList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
noList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
this.add(noLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
this.add(yesLabel, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
this.add(bDown, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
this.add(noPane, new GridBagConstraints(0, 1, 1, 3, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(4, 4, 4, 4), 0, 0));
this.add(yesPane, new GridBagConstraints(2, 1, 1, 3, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(4, 4, 4, 4), 0, 0));
this.add(bUp, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
this.add(bAdd, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
this.add(bRemove, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
// End Yamel Senih
}
use of java.awt.event.MouseAdapter in project adempiere by adempiere.
the class Viewer method dynInit.
// jbInit
/**
* Dynamic Init
*/
private void dynInit() {
createMenu();
comboZoom.setSelectedIndex(m_viewPanel.getZoomLevel());
comboZoom.addActionListener(this);
// Change Listener to set Page no
//pb comment this out so that scrolling works normally
//centerScrollPane.getViewport().addChangeListener(this);
// end pb
// Default summary from print format
summary.setSelected(m_reportEngine.getPrintFormat().isSummary());
//FR 201156
summary.addActionListener(this);
// Max Page
m_pageMax = m_viewPanel.getPageCount();
spinnerModel.setMaximum(new Integer(m_pageMax));
spinner.addChangeListener(this);
fillComboReport(m_reportEngine.getPrintFormat().get_ID());
// View Panel Mouse Listener
m_viewPanel.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (SwingUtilities.isRightMouseButton(e))
mouse_clicked(e, true);
else if (e.getClickCount() > 1)
mouse_clicked(e, false);
}
});
// fill Drill Options (Name, TableName)
comboDrill.addItem(new ValueNamePair(null, ""));
String sql = "SELECT t.AD_Table_ID, t.TableName, e.PrintName, NULLIF(e.PO_PrintName,e.PrintName) " + "FROM AD_Column c " + " INNER JOIN AD_Column used ON (c.ColumnName=used.ColumnName)" + " INNER JOIN AD_Table t ON (used.AD_Table_ID=t.AD_Table_ID AND t.IsView='N' AND t.AD_Table_ID <> c.AD_Table_ID)" + " INNER JOIN AD_Column cKey ON (t.AD_Table_ID=cKey.AD_Table_ID AND cKey.IsKey='Y')" + " INNER JOIN AD_Element e ON (cKey.ColumnName=e.ColumnName) " + "WHERE c.AD_Table_ID=? AND c.IsKey='Y' " + "ORDER BY 3";
boolean trl = !Env.isBaseLanguage(Env.getCtx(), "AD_Element");
if (trl)
sql = "SELECT t.AD_Table_ID, t.TableName, et.PrintName, NULLIF(et.PO_PrintName,et.PrintName) " + "FROM AD_Column c" + " INNER JOIN AD_Column used ON (c.ColumnName=used.ColumnName)" + " INNER JOIN AD_Table t ON (used.AD_Table_ID=t.AD_Table_ID AND t.IsView='N' AND t.AD_Table_ID <> c.AD_Table_ID)" + " INNER JOIN AD_Column cKey ON (t.AD_Table_ID=cKey.AD_Table_ID AND cKey.IsKey='Y')" + " INNER JOIN AD_Element e ON (cKey.ColumnName=e.ColumnName)" + " INNER JOIN AD_Element_Trl et ON (e.AD_Element_ID=et.AD_Element_ID) " + "WHERE c.AD_Table_ID=? AND c.IsKey='Y'" + " AND et.AD_Language=? " + "ORDER BY 3";
try {
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_reportEngine.getPrintFormat().getAD_Table_ID());
if (trl)
pstmt.setString(2, Env.getAD_Language(Env.getCtx()));
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
String tableName = rs.getString(2);
String name = rs.getString(3);
String poName = rs.getString(4);
if (poName != null)
name += "/" + poName;
comboDrill.addItem(new ValueNamePair(tableName, name));
}
rs.close();
pstmt.close();
} catch (SQLException e) {
log.log(Level.SEVERE, sql, e);
}
if (comboDrill.getItemCount() == 1) {
labelDrill.setVisible(false);
comboDrill.setVisible(false);
} else
comboDrill.addActionListener(this);
revalidate();
}
use of java.awt.event.MouseAdapter in project adempiere by adempiere.
the class WFActivity method jbInit.
// dynInit
/**
* Static Init.
* Called after Dynamic Init
* @throws Exception
*/
private void jbInit() throws Exception {
int width = 150;
centerPanel.setLayout(centerLayout);
fNode.setReadWrite(false);
fDescription.setReadWrite(false);
fDescription.setPreferredSize(new Dimension(width, 40));
fHelp.setReadWrite(false);
fHelp.setPreferredSize(new Dimension(width, 40));
fHistory.setReadWrite(false);
fHistory.setPreferredSize(new Dimension(width, 80));
fTextMsg.setPreferredSize(new Dimension(width, 40));
//
// bPrevious.addActionListener(this);
// bNext.addActionListener(this);
selTable.setModel(selTableModel);
// 0-ID
selTable.setColumnClass(0, IDColumn.class, false, " ");
// 1-Priority
selTable.setColumnClass(1, Integer.class, true);
// 2-AD_WF_Node_ID
selTable.setColumnClass(2, String.class, true);
// 3-Summary
selTable.setColumnClass(3, String.class, true);
selTable.getSelectionModel().addListSelectionListener(this);
// Listen the Column Move Event
selTable.getColumnModel().addColumnModelListener(new TableColumnModelListener() {
public void columnMoved(TableColumnModelEvent e) {
if (columnValue == -1)
columnValue = e.getFromIndex();
columnNewValue = e.getToIndex();
}
@Override
public void columnAdded(TableColumnModelEvent e) {
}
@Override
public void columnMarginChanged(ChangeEvent e) {
}
@Override
public void columnRemoved(TableColumnModelEvent e) {
}
@Override
public void columnSelectionChanged(ListSelectionEvent e) {
}
});
//Listen the mouse released Moved
selTable.getTableHeader().addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
if (columnValue != -1 && (columnValue == 0 || columnNewValue == 0))
selTable.moveColumn(columnNewValue, columnValue);
columnValue = -1;
columnNewValue = -1;
}
});
bZoom.addActionListener(this);
bOK.addActionListener(this);
//
this.setLayout(new BorderLayout());
this.add(centerPanel, BorderLayout.CENTER);
this.add(statusBar, BorderLayout.SOUTH);
//
// answers.setOpaque(false);
answers.add(fAnswerText);
answers.add(fAnswerList);
answers.add(fAnswerButton);
fAnswerButton.addActionListener(this);
//
int row = 0;
selPane.setPreferredSize(new Dimension(width, 60));
selPane.setMinimumSize(new Dimension(100, 60));
centerPanel.add(selPane, new GridBagConstraints(0, row, 4, 1, 0.3, 0.3, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(5, 10, 5, 10), 0, 0));
centerPanel.add(lNode, new GridBagConstraints(0, ++row, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(5, 10, 5, 5), 0, 0));
centerPanel.add(fNode, new GridBagConstraints(1, row, 3, 2, 0.5, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 10), 0, 0));
centerPanel.add(lDesctiption, new GridBagConstraints(0, ++row, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(5, 10, 5, 5), 0, 0));
centerPanel.add(fDescription, new GridBagConstraints(1, row, 3, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 10), 0, 0));
centerPanel.add(lHelp, new GridBagConstraints(0, ++row, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(2, 10, 5, 5), 0, 0));
centerPanel.add(fHelp, new GridBagConstraints(1, row, 3, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(2, 0, 5, 10), 0, 0));
centerPanel.add(lHistory, new GridBagConstraints(0, ++row, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(5, 10, 5, 5), 0, 0));
centerPanel.add(fHistory, new GridBagConstraints(1, row, 3, 1, 0.5, 0.5, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(5, 0, 5, 10), 0, 0));
centerPanel.add(lAnswer, new GridBagConstraints(0, ++row, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(10, 10, 5, 5), 0, 0));
centerPanel.add(answers, new GridBagConstraints(1, row, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 5, 5), 0, 0));
centerPanel.add(bZoom, new GridBagConstraints(3, row, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(10, 0, 10, 10), 0, 0));
centerPanel.add(lTextMsg, new GridBagConstraints(0, ++row, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(5, 10, 5, 5), 0, 0));
centerPanel.add(fTextMsg, new GridBagConstraints(1, row, 3, 1, 0.5, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 10), 0, 0));
centerPanel.add(lForward, new GridBagConstraints(0, ++row, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(10, 10, 5, 5), 0, 0));
centerPanel.add(fForward, new GridBagConstraints(1, row, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 0, 5, 0), 0, 0));
centerPanel.add(lOptional, new GridBagConstraints(2, row, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 5, 5, 5), 0, 0));
centerPanel.add(bOK, new GridBagConstraints(3, row, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(10, 5, 5, 10), 0, 0));
}
use of java.awt.event.MouseAdapter in project intellij-community by JetBrains.
the class ShowUsagesAction method prepareTable.
@NotNull
private Runnable prepareTable(final MyTable table, final Editor editor, final RelativePoint popupPosition, final FindUsagesHandler handler, final int maxUsages, @NotNull final FindUsagesOptions options, final boolean previewMode) {
SpeedSearchBase<JTable> speedSearch = new MySpeedSearch(table);
speedSearch.setComparator(new SpeedSearchComparator(false));
table.setRowHeight(PlatformIcons.CLASS_ICON.getIconHeight() + 2);
table.setShowGrid(false);
table.setShowVerticalLines(false);
table.setShowHorizontalLines(false);
table.setTableHeader(null);
table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
table.setIntercellSpacing(new Dimension(0, 0));
final AtomicReference<List<Object>> selectedUsages = new AtomicReference<>();
final AtomicBoolean moreUsagesSelected = new AtomicBoolean();
final AtomicBoolean outsideScopeUsagesSelected = new AtomicBoolean();
table.getSelectionModel().addListSelectionListener(e -> {
selectedUsages.set(null);
outsideScopeUsagesSelected.set(false);
moreUsagesSelected.set(false);
List<Object> usages = null;
for (int i : table.getSelectedRows()) {
Object value = table.getValueAt(i, 0);
if (value instanceof UsageNode) {
Usage usage = ((UsageNode) value).getUsage();
if (usage == USAGES_OUTSIDE_SCOPE_SEPARATOR) {
outsideScopeUsagesSelected.set(true);
usages = null;
break;
} else if (usage == MORE_USAGES_SEPARATOR) {
moreUsagesSelected.set(true);
usages = null;
break;
} else {
if (usages == null)
usages = new ArrayList<>();
usages.add(usage instanceof UsageInfo2UsageAdapter ? ((UsageInfo2UsageAdapter) usage).getUsageInfo().copy() : usage);
}
}
}
selectedUsages.set(usages);
});
final Runnable itemChosenCallback = () -> {
if (moreUsagesSelected.get()) {
appendMoreUsages(editor, popupPosition, handler, maxUsages, options);
return;
}
if (outsideScopeUsagesSelected.get()) {
options.searchScope = GlobalSearchScope.projectScope(handler.getProject());
showElementUsages(editor, popupPosition, handler, maxUsages, options);
return;
}
List<Object> usages = selectedUsages.get();
if (usages != null) {
for (Object usage : usages) {
if (usage instanceof UsageInfo) {
UsageViewUtil.navigateTo((UsageInfo) usage, true);
} else if (usage instanceof Navigatable) {
((Navigatable) usage).navigate(true);
}
}
}
};
if (previewMode) {
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
if (UIUtil.isActionClick(e, MouseEvent.MOUSE_RELEASED) && !UIUtil.isSelectionButtonDown(e) && !e.isConsumed()) {
itemChosenCallback.run();
}
}
});
table.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
itemChosenCallback.run();
}
}
});
}
return itemChosenCallback;
}
Aggregations