OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Compare Revisions

Regard whitespace Rev 178 → Rev 177

/trunk/jOpenCalendar/src/org/jopencalendar/ui/MonthActivityStatesCellRenderer.java
25,6 → 25,7
JComponent c = new JPanel() {
@Override
public void paint(Graphics g) {
 
MonthActivityStates m = (MonthActivityStates) value;
if (!isSelected) {
g.setColor(Color.WHITE);
33,9 → 34,6
}
final int h = getHeight();
g.fillRect(0, 0, getWidth(), h);
// handle JTable$AccessibleJTable.getAccessibleChild()
if (m == null)
return;
// Week delimiters
List<Integer> lIndexes = m.getMondayIndex();
 
/trunk/jOpenCalendar/src/org/jopencalendar/ui/WeekView.java
43,11 → 43,13
* Load week
*
* @param week the week number (1 - 52)
*/
* */
public void loadWeek(final int week, final int year, boolean forceReload) {
if (!forceReload && week == this.week && year == this.year) {
if (!forceReload) {
if (week == this.week && year == this.year) {
return;
}
}
this.week = week;
this.year = year;
Calendar c = getFirstDayCalendar();
62,18 → 64,17
 
@Override
protected List<JCalendarItem> doInBackground() throws Exception {
return WeekView.this.manager.getItemInWeek(week, year);
return manager.getItemInWeek(week, year);
}
 
@Override
protected void done() {
try {
List<JCalendarItem> l = get();
List<List<JCalendarItem>> items = new ArrayList<>();
List<List<JCalendarItem>> items = new ArrayList<List<JCalendarItem>>();
for (int i = 0; i < columnCount; i++) {
List<JCalendarItem> list = new ArrayList<>();
int d = WeekView.this.daysOfYear[i];
int y = WeekView.this.years[i];
List<JCalendarItem> list = new ArrayList<JCalendarItem>();
int d = daysOfYear[i];
int y = years[i];
for (JCalendarItem jCalendarItem : l) {
if (jCalendarItem.getDtStart().get(Calendar.DAY_OF_YEAR) == d && jCalendarItem.getDtStart().get(Calendar.YEAR) == y) {
list.add(jCalendarItem);
86,18 → 87,18
throw new IllegalStateException("error while getting items", e);
}
 
}
};
};
w.execute();
}
 
public void setWeekEndMinimised(boolean b) {
this.weekEndMinimised = b;
weekEndMinimised = b;
repaint();
}
 
@Override
public void paintHeader(Graphics g) {
 
g.setColor(Color.WHITE);
g.fillRect(0, 0, this.getWidth() + 100, getHeaderHeight());
g.setColor(Color.GRAY);
169,7 → 170,7
 
Calendar c = getFirstDayCalendar();
final DateFormat df;
if (!this.weekEndMinimised) {
if (!weekEndMinimised) {
df = new SimpleDateFormat("EEEE d");
} else {
df = new SimpleDateFormat("E d");
206,7 → 207,7
c.set(year, 1, 0, 0, 0, 0);
c.set(Calendar.MILLISECOND, 0);
c.set(Calendar.DAY_OF_YEAR, day);
return this.monthAndYearFormat.format(c.getTime()).toUpperCase();
return monthAndYearFormat.format(c.getTime()).toUpperCase();
}
 
private Calendar getFirstDayCalendar() {
221,7 → 222,7
@Override
public String getColumnTitle(int index) {
final DateFormat df;
if (!this.weekEndMinimised) {
if (!weekEndMinimised) {
df = new SimpleDateFormat("EEEE d");
} else {
df = new SimpleDateFormat("E d");
247,7 → 248,7
@Override
public int getColumnWidth(int column) {
final int c;
if (this.weekEndMinimised) {
if (weekEndMinimised) {
int minSize = 50;
if (column == 5 || column == 6) {
return minSize;
/trunk/jOpenCalendar/src/org/jopencalendar/ui/CalendarWithToolBar.java
35,8 → 35,6
private final DatePicker picker;
private String title;
final JScrollPane contentPane = new JScrollPane();
private int week;
private int year;
 
public CalendarWithToolBar(JCalendarItemProvider manager) {
this(manager, false);
44,13 → 42,13
 
public CalendarWithToolBar(JCalendarItemProvider manager, boolean showPrintButton) {
this.weekView = new WeekView(manager);
Calendar currentDate = Calendar.getInstance();
this.year = currentDate.get(Calendar.YEAR);
this.week = currentDate.get(Calendar.WEEK_OF_YEAR);
 
JPanel toolbar = new JPanel();
toolbar.setLayout(new FlowLayout(FlowLayout.LEFT));
 
Calendar cal = Calendar.getInstance();
int week = cal.get(Calendar.WEEK_OF_YEAR);
int year = cal.get(Calendar.YEAR);
JButton bPrevious = new JButton(new ImageIcon(this.getClass().getResource("left.png")));
JButton bNext = new JButton(new ImageIcon(this.getClass().getResource("right.png")));
configureButton(bPrevious);
61,7 → 59,8
 
@Override
public void actionPerformed(ActionEvent e) {
nextWeek();
addWeek(1);
 
}
});
bPrevious.addActionListener(new ActionListener() {
68,19 → 67,20
 
@Override
public void actionPerformed(ActionEvent e) {
previousWeek();
addWeek(-1);
 
}
});
 
toolbar.add(new JLabel("Semaine"));
this.spinWeek = new JSpinner(new SpinnerNumberModel(this.week, 1, 53, 1));
toolbar.add(this.spinWeek);
spinWeek = new JSpinner(new SpinnerNumberModel(week, 1, 53, 1));
toolbar.add(spinWeek);
toolbar.add(new JLabel(" de "));
this.spinYear = new JSpinner(new SpinnerNumberModel(this.year, 1000, this.year + 20, 1));
toolbar.add(this.spinYear);
spinYear = new JSpinner(new SpinnerNumberModel(year, 1000, year + 20, 1));
toolbar.add(spinYear);
//
this.picker = new DatePicker(false);
toolbar.add(this.picker);
toolbar.add(picker);
//
 
final JSlider zoomSlider = createZoomSlider(this.weekView);
124,59 → 124,59
c.fill = GridBagConstraints.BOTH;
c.weighty = 1;
 
this.contentPane.setBorder(BorderFactory.createEmptyBorder());
this.contentPane.setOpaque(false);
this.contentPane.setColumnHeaderView(new WeekViewHeader(this.weekView));
this.contentPane.setViewportView(this.weekView);
this.contentPane.getViewport().setBackground(Color.WHITE);
final MouseWheelListener[] l = this.contentPane.getMouseWheelListeners();
contentPane.setBorder(BorderFactory.createEmptyBorder());
contentPane.setOpaque(false);
contentPane.setColumnHeaderView(new WeekViewHeader(weekView));
contentPane.setViewportView(weekView);
contentPane.getViewport().setBackground(Color.WHITE);
final MouseWheelListener[] l = contentPane.getMouseWheelListeners();
for (int i = 0; i < l.length; i++) {
MouseWheelListener string = l[i];
this.contentPane.removeMouseWheelListener(string);
contentPane.removeMouseWheelListener(string);
}
this.contentPane.addMouseWheelListener(new MouseWheelListener() {
contentPane.addMouseWheelListener(new MouseWheelListener() {
 
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
CalendarWithToolBar.this.weekView.mouseWheelMoved(e, l);
weekView.mouseWheelMoved(e, l);
}
});
 
this.add(this.contentPane, c);
this.add(contentPane, c);
final int value = 300;
this.contentPane.getVerticalScrollBar().setValue(value);
this.weekView.loadWeek(this.week, this.year, false);
contentPane.getVerticalScrollBar().setValue(value);
weekView.loadWeek(week, year, false);
final ChangeListener listener = new ChangeListener() {
 
@Override
public void stateChanged(ChangeEvent e) {
setDate(((Number) CalendarWithToolBar.this.spinWeek.getValue()).intValue(), CalendarWithToolBar.this.year);
 
Calendar c = getCurrentDate();
picker.setDate(c.getTime());
weekView.loadWeek(getWeek(), getYear(), false);
}
};
this.spinWeek.addChangeListener(listener);
spinWeek.addChangeListener(listener);
spinYear.addChangeListener(listener);
picker.addPropertyChangeListener("value", new PropertyChangeListener() {
 
final ChangeListener listenerYear = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
setDate(CalendarWithToolBar.this.week, ((Number) CalendarWithToolBar.this.spinYear.getValue()).intValue());
}
};
 
this.spinYear.addChangeListener(listenerYear);
 
this.picker.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
 
final Date d = CalendarWithToolBar.this.picker.getDate();
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getNewValue() != null) {
final Date d = (Date) evt.getNewValue();
final Calendar c = Calendar.getInstance();
c.setTime(d);
final int y = c.get(Calendar.YEAR);
final int w = c.get(Calendar.WEEK_OF_YEAR);
setDate(w, y);
spinWeek.removeChangeListener(listener);
spinYear.removeChangeListener(listener);
spinYear.setValue(y);
spinWeek.setValue(w);
spinWeek.addChangeListener(listener);
spinYear.addChangeListener(listener);
weekView.loadWeek(getWeek(), getYear(), false);
}
 
}
});
 
}
201,27 → 201,21
return zoomSlider;
}
 
protected void nextWeek() {
if (getWeek() >= 52) {
setDate(1, this.year + 1);
} else {
setDate(this.week + 1, this.year);
}
}
protected void addWeek(int i) {
Calendar c = getCurrentDate();
c.add(Calendar.DAY_OF_YEAR, i * 7);
final int year = c.get(Calendar.YEAR);
final int week = c.get(Calendar.WEEK_OF_YEAR);
spinYear.setValue(year);
spinWeek.setValue(week);
 
protected void previousWeek() {
if (getWeek() == 1) {
setDate(52, this.year - 1);
} else {
setDate(this.week - 1, this.year);
}
}
 
public Calendar getCurrentDate() {
Calendar c = Calendar.getInstance();
c.clear();
c.set(Calendar.YEAR, this.year);
c.set(Calendar.WEEK_OF_YEAR, this.week);
c.set(Calendar.YEAR, getYear());
c.set(Calendar.WEEK_OF_YEAR, getWeek());
return c;
}
 
230,37 → 224,9
}
 
public final void setCurrentDate(final Date d) {
Calendar c = Calendar.getInstance();
c.clear();
c.setTime(d);
this.setDate(c.get(Calendar.WEEK_OF_YEAR), c.get(Calendar.YEAR));
 
this.picker.setDate(d);
}
 
private void setDate(int week, int year) {
if (this.week != week || this.year != year) {
int oldWeek = this.week;
int oldYear = this.year;
this.week = week;
this.year = year;
if (this.week != oldWeek) {
this.spinWeek.setValue(week);
}
if (this.year != oldYear) {
this.spinYear.setValue(year);
}
 
Calendar c = Calendar.getInstance();
c.clear();
c.set(Calendar.YEAR, this.year);
c.set(Calendar.WEEK_OF_YEAR, this.week);
this.picker.setDate(c.getTime());
 
CalendarWithToolBar.this.weekView.loadWeek(getWeek(), getYear(), false);
 
}
}
 
private void configureButton(JButton b) {
b.setOpaque(false);
b.setBorderPainted(false);
270,19 → 236,19
}
 
public void reload() {
this.weekView.reload();
weekView.reload();
}
 
public int getWeek() {
return this.week;
return ((Number) spinWeek.getValue()).intValue();
}
 
public int getYear() {
return this.year;
return ((Number) spinYear.getValue()).intValue();
}
 
public WeekView getWeekView() {
return this.weekView;
return weekView;
}
 
public void setTitle(String title) {
290,10 → 256,10
}
 
public void scrollTo(int hour) {
this.contentPane.getVerticalScrollBar().setValue(hour * this.weekView.getRowHeight());
contentPane.getVerticalScrollBar().setValue(hour * weekView.getRowHeight());
}
 
public JScrollPane getContentPane() {
return this.contentPane;
return contentPane;
}
}