OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Compare Revisions

Ignore whitespace Rev 152 → Rev 153

/trunk/jOpenCalendar/src/org/jopencalendar/ui/left_2x.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/jOpenCalendar/src/org/jopencalendar/ui/left_2x.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/jOpenCalendar/src/org/jopencalendar/ui/DatePicker.java
81,99 → 81,16
this.add(spacer);
}
 
final ImageIcon icon = new ImageIcon(this.getClass().getResource("calendar.png"));
String iconFileName = "calendar.png";
if (getFont().getSize() > 16) {
iconFileName = "calendar_2x.png";
}
final ImageIcon icon = new ImageIcon(this.getClass().getResource(iconFileName));
button = new JButton(new AbstractAction(null, icon) {
 
@Override
public void actionPerformed(ActionEvent e) {
final JComponent source = (JComponent) e.getSource();
 
if (text != null) {
// if the button isn't focusable, no FOCUS_LOST will occur and the text won't
// get
// committed (or reverted). So act as if the user requested a commit, so that
// invalidEdit() can be called (usually causing a beep).
if (!source.isFocusable()) {
for (final Action a : text.getActions()) {
final String name = (String) a.getValue(Action.NAME);
if (JTextField.notifyAction.equals(name))
a.actionPerformed(new ActionEvent(text, e.getID(), null));
}
}
 
// if after trying to commit, the value is invalid then don't show the popup
if (!text.isEditValid())
return;
}
if (dialog == null) {
final JDialog d = new JDialog(SwingUtilities.getWindowAncestor(DatePicker.this));
pickerPanel = new DatePickerPanel();
 
d.setContentPane(pickerPanel);
d.setUndecorated(true);
pickerPanel.setBorder(BorderFactory.createLineBorder(Color.GRAY));
d.setSize(330, 270);
 
pickerPanel.addPropertyChangeListener(DatePickerPanel.TIME_IN_MILLIS, new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (!DatePicker.this.isEditable())
return;
final Long millis = (Long) evt.getNewValue();
final Calendar c = Calendar.getInstance();
c.setTimeInMillis(millis);
setDate(c.getTime());
if (dialog != null) {
dialog.dispose();
dialog = null;
}
fireActionPerformed();
}
 
});
d.addWindowFocusListener(new WindowFocusListener() {
 
public void windowGainedFocus(WindowEvent e) {
// do nothing
}
 
public void windowLostFocus(WindowEvent e) {
if (dialog != null) {
final Window oppositeWindow = e.getOppositeWindow();
if (oppositeWindow != null && SwingUtilities.isDescendingFrom(oppositeWindow, dialog)) {
return;
}
dialog.dispose();
dialog = null;
}
dialogLostFocusTime = System.currentTimeMillis();
}
 
});
dialog = d;
}
// Set picker panel date
final Calendar calendar = Calendar.getInstance();
if (date != null) {
calendar.setTime(date);
pickerPanel.setSelectedDate(calendar);
} else {
pickerPanel.setSelectedDate(null);
}
// Show dialog
final int x = source.getLocation().x;
final int y = source.getLocation().y + source.getHeight();
Point p = new Point(x, y);
SwingUtilities.convertPointToScreen(p, DatePicker.this);
p = adjustPopupLocationToFitScreen(p.x, p.y, dialog.getSize(), source.getSize());
dialog.setLocation(p.x, p.y);
final long time = System.currentTimeMillis() - dialogLostFocusTime;
if (time > RELEASE_TIME_MS) {
dialog.setVisible(true);
} else {
dialogLostFocusTime = System.currentTimeMillis() - RELEASE_TIME_MS;
}
calendarButtonPressed(e);
}
 
});
345,7 → 262,98
}
}
 
static public final boolean equals(Object o1, Object o2) {
private void calendarButtonPressed(ActionEvent e) {
final JComponent source = (JComponent) e.getSource();
 
if (text != null) {
// if the button isn't focusable, no FOCUS_LOST will occur and the text won't
// get
// committed (or reverted). So act as if the user requested a commit, so that
// invalidEdit() can be called (usually causing a beep).
if (!source.isFocusable()) {
for (final Action a : text.getActions()) {
final String name = (String) a.getValue(Action.NAME);
if (JTextField.notifyAction.equals(name))
a.actionPerformed(new ActionEvent(text, e.getID(), null));
}
}
 
// if after trying to commit, the value is invalid then don't show the popup
if (!text.isEditValid())
return;
}
if (dialog == null) {
final JDialog d = new JDialog(SwingUtilities.getWindowAncestor(DatePicker.this));
pickerPanel = new DatePickerPanel();
 
d.setContentPane(pickerPanel);
d.setUndecorated(true);
pickerPanel.setBorder(BorderFactory.createLineBorder(Color.GRAY));
d.pack();
 
pickerPanel.addPropertyChangeListener(DatePickerPanel.TIME_IN_MILLIS, new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (!DatePicker.this.isEditable())
return;
final Long millis = (Long) evt.getNewValue();
final Calendar c = Calendar.getInstance();
c.setTimeInMillis(millis);
setDate(c.getTime());
if (dialog != null) {
dialog.dispose();
dialog = null;
}
fireActionPerformed();
}
 
});
d.addWindowFocusListener(new WindowFocusListener() {
 
public void windowGainedFocus(WindowEvent e) {
// do nothing
}
 
public void windowLostFocus(WindowEvent e) {
if (dialog != null) {
final Window oppositeWindow = e.getOppositeWindow();
if (oppositeWindow != null && SwingUtilities.isDescendingFrom(oppositeWindow, dialog)) {
return;
}
dialog.dispose();
dialog = null;
}
dialogLostFocusTime = System.currentTimeMillis();
}
 
});
dialog = d;
}
// Set picker panel date
final Calendar calendar = Calendar.getInstance();
if (date != null) {
calendar.setTime(date);
pickerPanel.setSelectedDate(calendar);
} else {
pickerPanel.setSelectedDate(null);
}
// Show dialog
final int x = source.getLocation().x;
final int y = source.getLocation().y + source.getHeight();
Point p = new Point(x, y);
SwingUtilities.convertPointToScreen(p, DatePicker.this);
p = adjustPopupLocationToFitScreen(p.x, p.y, dialog.getSize(), source.getSize());
dialog.setLocation(p.x, p.y);
final long time = System.currentTimeMillis() - dialogLostFocusTime;
if (time > RELEASE_TIME_MS) {
dialog.setVisible(true);
} else {
dialogLostFocusTime = System.currentTimeMillis() - RELEASE_TIME_MS;
}
}
 
public static final boolean equals(Object o1, Object o2) {
if (o1 == null && o2 == null)
return true;
if (o1 == null || o2 == null)
/trunk/jOpenCalendar/src/org/jopencalendar/ui/calendar.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/jOpenCalendar/src/org/jopencalendar/ui/calendar_2x.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/jOpenCalendar/src/org/jopencalendar/ui/calendar_2x.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/jOpenCalendar/src/org/jopencalendar/ui/right_2x.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/jOpenCalendar/src/org/jopencalendar/ui/right_2x.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/jOpenCalendar/src/org/jopencalendar/ui/DatePickerPanel.java
57,7 → 57,13
this.setLayout(new BorderLayout(2, 2));
JPanel navigator = new JPanel();
navigator.setLayout(new BorderLayout());
bLeft = new JButton(new ImageIcon(this.getClass().getResource("left.png")));
String leftFileName = "left.png";
String rightFileName = "right.png";
if (this.getFont().getSize() > 16) {
leftFileName = "left_2x.png";
rightFileName = "right_2x.png";
}
bLeft = new JButton(new ImageIcon(this.getClass().getResource(leftFileName)));
configureButton(bLeft);
 
navigator.add(bLeft, BorderLayout.WEST);
64,7 → 70,8
title = new JLabel("...", SwingConstants.CENTER);
title.setFont(title.getFont().deriveFont(Font.BOLD));
navigator.add(title, BorderLayout.CENTER);
bRight = new JButton(new ImageIcon(this.getClass().getResource("right.png")));
 
bRight = new JButton(new ImageIcon(this.getClass().getResource(rightFileName)));
configureButton(bRight);
navigator.add(bRight, BorderLayout.EAST);
this.add(navigator, BorderLayout.NORTH);
93,7 → 100,9
j = 1;
}
String d = dateFormatSymbols[j];
dayPanel.add(new JLabel(d, SwingConstants.RIGHT));
final JLabel lDay = new JLabel(d, SwingConstants.RIGHT);
lDay.setMinimumSize(new Dimension(lDay.getPreferredSize().width, lDay.getPreferredSize().width));
dayPanel.add(lDay);
}
 
//
180,7 → 189,7
}
 
private void configureButton(final JButton button) {
int buttonSize = 28;
int buttonSize = button.getIcon().getIconWidth() + 8;
button.setMinimumSize(new Dimension(buttonSize, buttonSize));
button.setPreferredSize(new Dimension(buttonSize, buttonSize));
button.setFocusPainted(false);
345,14 → 354,17
 
@Override
public void mouseReleased(MouseEvent e) {
// Nothing
}
 
@Override
public void mouseEntered(MouseEvent e) {
// Nothing
}
 
@Override
public void mouseExited(MouseEvent e) {
// Nothing
}
 
}