OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Compare Revisions

Regard whitespace Rev 177 → Rev 178

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