libmicroba-java-0.4.4.3.orig/ 0000775 0001750 0001750 00000000000 11057263622 015141 5 ustar gregoa gregoa libmicroba-java-0.4.4.3.orig/change.log.txt 0000644 0001750 0001750 00000007536 11050604100 017677 0 ustar gregoa gregoa v.0.4.4.3
* Added: CalendarPane.observeMonth(int, int);
* Added: Slovak and Czech translation (thanks to Lubomir Grajciar)
* Added: Hebrew translation (thanks to Moshe Elisha)
* Added: Turkish translation (thanks to Emre Yazici)
* Added: Hungarian translation (thanks to Zoltan Kuroli)
v.0.4.4.2
* changed misspelled package name 'jgrpah' to 'jgraph'
* fixed build script to correctly package resources (thanks to Velimir Gasparovic)
v.0.4.4.1
* Change: changed project directory structure according to Maven guidelines.
* Fixed: DatePicker popup did not close when clicked on already selecteed date.
* CalendarPane.fireCommitEvent(boolean) made public
* CalendarPane.fireActionEvent() made public
v.0.4.4
* Added: DatePicker.dropdownFocusable property
* Added: MicrobaComponent.colorOverrideMap property
* Added: Microba.setColorOverrideMap method
These two improvements allow to override colors on per-instance and per-L&F basis.
Currenty CalendarPane and DatePicker support some color overriding.
* Fixed: CalendarPane ignores enabled property
v.0.4.3.4 (21 nov 2006)
* Fixed: Microba works with NetBeans Matisse GUI editor.
Thanks to Witold Szczerba for testing the fix.
* Fixed: manifest now specifies javabeans
* Refactored: common superclass extracted: MicrobaComponent
v.0.4.3.3
* Fixed: DatePicker ignores locale passed in constructor
v.0.4.3.2
* Fixed: DatePicker ignores showWeekNumber
* Fixed: DatePicker may return wrong date via getDate() in some cases
* Fixed: Portuguese translation corrected by Roger Araújo
v.0.4.3.1
* Fixed: DatePicker displays no tooltip string
* Fixed: DatePicker goes to infinite loop if keepTime is true, and date format has no time fields.
Thanks to Wolfgang Fietzke for his excellent bug report!
v0.4.3
* Added: Birdview component for JGraph library
* Added: Swedish translation for DatePicker
* Added: CalendarPane.stripDate ( and DatePicker.stripDate ) property (optional time stripping)
* Added: DatePicker.keepTime property (improved time field handling)
* Added: DatePicker.pickerStyle property (controls visual style of the picker itself)
* Added: DatePicker.showButtonOnly() shortcut method
* Added: static CalendarPane.stripDate(...) utility method
* Fixed: DatePicker.setDateFormat(...) never fired a PropertyChangeEvent
* Changed: picker-16.png ico for DatePicker changed
v.0.4.2 (31 jul 2006)
* Refactored: dateStyle property of DatePicker was dropped in favour of dateFormat property. However,
old constructors preserved.
* Fixed: OutOfMemory exception bug fixed. The bug prevented components to be garbage collected because
references were held by Timer tasks. Regression: CalendarPane will update 'today' date only
on creation.
v.0.4.1 (18 jun 2006)
* Added: ability to show number of weeks for DatePicker and CalendarPane.
* Fixed: Applet refresh problem: see readme.txt, see Microba.init()
* Fixed: Polish translation (thanks to Gregory Kaczmarczyk)
v.0.4 (29 mar 2006)
* Refactored: com.michaelbaranov.microba.common package introduced
* Refactored: class HollidayPolicy renamed to HolidayPolicy
* Refactored: properties named 'hollidayPolicy' renamed to 'holidayPolicy' in all classes
* Refactored: renamed recources in com.michaelbaranov.microba.calendar.resource:
16.png -> picker-16.png
l.png -> back-16.png
ll.png -> back-fast-16.png
r.png -> forward-16.png
rr.png -> forward-fast-16.png
* Added: MarkerBar, GradientBar, GradientEditor controls
* Added: multiple translations for CalendarPane UI
* Added: enabled/disabled state for DatePicker and CalendarPane
* Fixed: DatePickerCellEditor not respected focus lost behavior of the DatePicker.
Now it is possible to commit cell edit when cell edit stops (e.g. tab out).
v.0.3 (15 dec 2005)
* First public release
libmicroba-java-0.4.4.3.orig/META-INF/ 0000755 0001750 0001750 00000000000 11050604324 016266 5 ustar gregoa gregoa libmicroba-java-0.4.4.3.orig/META-INF/MANIFEST.MF 0000644 0001750 0001750 00000000146 11050604322 017717 0 ustar gregoa gregoa Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.0
Created-By: 10.0-b22 (Sun Microsystems Inc.)
libmicroba-java-0.4.4.3.orig/src/ 0000755 0001750 0001750 00000000000 10634142534 015724 5 ustar gregoa gregoa libmicroba-java-0.4.4.3.orig/src/main/ 0000755 0001750 0001750 00000000000 10634142130 016640 5 ustar gregoa gregoa libmicroba-java-0.4.4.3.orig/src/main/java/ 0000755 0001750 0001750 00000000000 10706253360 017571 5 ustar gregoa gregoa libmicroba-java-0.4.4.3.orig/src/main/java/Snippet.java 0000644 0001750 0001750 00000002071 11013067372 022054 0 ustar gregoa gregoa import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyVetoException;
import javax.swing.JButton;
import javax.swing.JFrame;
import com.michaelbaranov.microba.calendar.DatePicker;
public class Snippet {
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setLayout(new FlowLayout());
final DatePicker picker = new DatePicker();
picker.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println(picker.getDate());
}
});
JButton btn = new JButton("NULL");
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
picker.setDate(null);
} catch (PropertyVetoException e1) {
System.out.println("Could not set null date.");
e1.printStackTrace();
}
picker.setEnabled(false);
}
});
frame.add(picker);
frame.add(btn);
frame.setSize(640, 480);
frame.setVisible(true);
}
}
libmicroba-java-0.4.4.3.orig/src/main/java/com/ 0000755 0001750 0001750 00000000000 10634142130 020337 5 ustar gregoa gregoa libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/ 0000755 0001750 0001750 00000000000 10634142130 023312 5 ustar gregoa gregoa libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/ 0000755 0001750 0001750 00000000000 10724465710 024742 5 ustar gregoa gregoa libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/jgraph/ 0000755 0001750 0001750 00000000000 10724465710 026215 5 ustar gregoa gregoa libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/jgraph/birdview/ 0000755 0001750 0001750 00000000000 10724465710 030030 5 ustar gregoa gregoa libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/jgraph/birdview/Birdview.java 0000644 0001750 0001750 00000022634 10724465712 032457 0 ustar gregoa gregoa package com.michaelbaranov.microba.jgraph.birdview;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.UIManager;
import org.jgraph.JGraph;
import org.jgraph.event.GraphModelEvent;
import org.jgraph.event.GraphModelListener;
import org.jgraph.graph.GraphLayoutCache;
/**
* A JFC/Swing component that displays a bird-eyes (thumbnail) view of a
* {@link JGraph} in combination with {@link JScrollPane}. Also allows to pan
* view with the mouse.
*
*
* @author Michael Baranov
*
*/
public class Birdview extends JPanel {
/**
* Color constant
*/
public static final Color PAN_RECT_COLOR = Color.black;
/**
* Color constant
*/
public static final Color BACKGROUND_COLOR = UIManager.getColor("Panel.background");
/**
* a {@link JGraph} component used as main display
*/
private JGraph displayGraph;
/**
* a {@link JScrollPane} to track
*/
private JScrollPane peerScroller;
/**
* a {@link JGraph} to tracl
*/
private JGraph peerGraph;
/**
* a rect, subrect of the component area, that matches the tracked view
*/
private Rectangle2D paintRect;
/**
* a rect, a subrect of the component area, that matches the tracked
* viewport
*/
private Rectangle2D panRect;
/**
* the scale applied to {@link #displayGraph} to fit into {@link #paintRect}
*/
private double scale = 1.0;
/**
* A listener
*/
private ScrollerListener scrollerListener = new ScrollerListener();
/**
* A listener
*/
private SelfMouseListener selfMouseListener = new SelfMouseListener();
/**
* A listener
*/
private GraphPropertyChangeListener graphPropertyChangeListener = new GraphPropertyChangeListener();
/**
* Constructor.
*
* @param doc
* document to track. May be null
*/
public Birdview() {
displayGraph = new JGraph();
displayGraph.setEnabled(false);
displayGraph.setAntiAliased(true);
displayGraph.addMouseListener(selfMouseListener);
displayGraph.addMouseMotionListener(selfMouseListener);
this.setLayout(null);
this.addComponentListener(new SelfResizeListener());
this.add(displayGraph);
}
/**
* Makes this component track the provided graph and scroller. Set
* parameters to null
to unbind thie component.
*
* @param graph
* the graph component. May be null
* @param scroller
* the croller, usually the one that holds the graph. May be
* null
*/
public void setTrackingFor(JGraph graph, JScrollPane scroller) {
if (this.peerGraph != null) {
this.peerGraph.getModel().removeGraphModelListener(scrollerListener);
this.peerGraph.removePropertyChangeListener(graphPropertyChangeListener);
}
this.peerGraph = graph;
if (this.peerGraph != null) {
this.peerGraph.getModel().addGraphModelListener(scrollerListener);
this.peerGraph.addPropertyChangeListener(graphPropertyChangeListener);
this.displayGraph.setGraphLayoutCache(peerGraph.getGraphLayoutCache());
} else {
this.displayGraph.setGraphLayoutCache(new GraphLayoutCache());
}
//
if (this.peerScroller != null) {
this.peerScroller.getHorizontalScrollBar().removeAdjustmentListener(
scrollerListener);
this.peerScroller.getVerticalScrollBar().removeAdjustmentListener(
scrollerListener);
}
this.peerScroller = scroller;
if (this.peerScroller != null) {
this.peerScroller.getHorizontalScrollBar().addAdjustmentListener(
scrollerListener);
this.peerScroller.getVerticalScrollBar().addAdjustmentListener(
scrollerListener);
}
update();
repaint();
}
/**
* Calculates {@link #paintRect}, {@link #panRect}, {@link #scale} based
* on observations of peerScroller.
*
*/
private void update() {
if (peerScroller != null) {
Dimension viewSize = peerScroller.getViewport().getViewSize();
double viewAspect = viewSize.getHeight() / viewSize.getWidth();
Dimension panelSize = this.getSize();
double panelAspect = panelSize.getHeight() / panelSize.getWidth();
if (panelAspect < viewAspect) {
// panel is wider, height is primary
double desiredPanelWidth = panelSize.getHeight() / viewAspect;
double blankWidth = panelSize.getWidth() - desiredPanelWidth;
double gap = blankWidth / 2;
paintRect = new Rectangle2D.Double(gap, 0, desiredPanelWidth,
panelSize.height);
scale = panelSize.getHeight() / viewSize.getHeight();
scale *= peerGraph.getScale();
} else {
// panel is heigher, width is primary
double desiredPanelHeight = panelSize.getWidth() * viewAspect;
double blankHeight = panelSize.getHeight() - desiredPanelHeight;
double gap = blankHeight / 2;
paintRect = new Rectangle2D.Double(0, gap, panelSize.getWidth(),
desiredPanelHeight);
scale = panelSize.getWidth() / viewSize.getWidth();
scale *= peerGraph.getScale();
}
Rectangle viewRect = peerScroller.getViewport().getViewRect();
double shiftX = viewRect.getX() / viewSize.getWidth();
double shiftY = viewRect.getY() / viewSize.getHeight();
double sizeX = viewRect.getWidth() / viewSize.getWidth();
double sizeY = viewRect.getHeight() / viewSize.getHeight();
panRect = new Rectangle2D.Double(paintRect.getX() + paintRect.getWidth()
* shiftX, paintRect.getY() + paintRect.getHeight() * shiftY,
paintRect.getWidth() * sizeX, paintRect.getHeight() * sizeY);
} else {
panRect = null;
paintRect = null;
scale = 1;
}
}
/**
* Addjusts {@link #panRect} to be postitionsed with the centter at a given
* point if possible. This methods ensures that {@link #panRect} fits
* entirely in {@link #paintRect}.
*
* @param point
* the desired panRect center
*/
private void panRectTo(Point point) {
Dimension viewSize = peerScroller.getViewport().getViewSize();
Rectangle viewRect = peerScroller.getViewport().getViewRect();
double panHalfWidth = panRect.getWidth() / 2;
double panHalfHeight = panRect.getHeight() / 2;
Point2D panOrigin = new Point2D.Double(point.x - panHalfWidth, point.y
- panHalfHeight);
double xk = panOrigin.getX() / paintRect.getWidth();
double yk = panOrigin.getY() / paintRect.getHeight();
Point viewPos = new Point((int) (viewSize.getWidth() * xk), (int) (viewSize
.getHeight() * yk));
// make sure we do not pan past the bounds:
if (viewPos.x < 0)
viewPos.x = 0;
if (viewPos.y < 0)
viewPos.y = 0;
int wd = (viewPos.x + viewRect.width) - viewSize.width;
int hd = (viewPos.y + viewRect.height) - viewSize.height;
if (wd > 0)
viewPos.x -= wd;
if (hd > 0)
viewPos.y -= hd;
// pan it
peerScroller.getViewport().setViewPosition(viewPos);
update();
repaint();
}
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
// fill background
g2.setColor(BACKGROUND_COLOR);
g2.fillRect(0, 0, this.getWidth(), this.getHeight());
if (peerGraph != null) {
// paint the graph display
displayGraph.setBounds(paintRect.getBounds());
displayGraph.setScale(scale);
displayGraph.setBackground(peerGraph.getBackground());
paintChildren(g);
}
if (panRect != null) {
// draw pan rect
g2.setColor(PAN_RECT_COLOR);
g2.draw(panRect.getBounds());
}
}
/**
* A listener to watch for scrollbar movement.
*
* @author Michael Baranov
*
*/
private class ScrollerListener implements AdjustmentListener, GraphModelListener {
public void adjustmentValueChanged(AdjustmentEvent e) {
update();
repaint();
}
public void graphChanged(GraphModelEvent e) {
update();
repaint();
}
}
/**
* A listener to watch for sizing of the component itself.
*
* @author Michael Baranov
*
*/
private class SelfResizeListener implements ComponentListener {
public void componentHidden(ComponentEvent e) {
}
public void componentMoved(ComponentEvent e) {
}
public void componentResized(ComponentEvent e) {
update();
repaint();
}
public void componentShown(ComponentEvent e) {
update();
repaint();
}
}
/**
* A listener to watch for mouse for the component itself.
*
* @author Michael Baranov
*
*/
private class SelfMouseListener implements MouseListener, MouseMotionListener {
public void mouseClicked(MouseEvent e) {
}
public void mouseEntered(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
}
public void mousePressed(MouseEvent e) {
}
public void mouseReleased(MouseEvent e) {
if (paintRect != null)
panRectTo(e.getPoint());
}
public void mouseDragged(MouseEvent e) {
if (paintRect != null)
panRectTo(e.getPoint());
}
public void mouseMoved(MouseEvent e) {
}
}
/**
* A listener to watch for graph property change, most important "scale".
*
* @author Michael Baranov
*
*/
private class GraphPropertyChangeListener implements PropertyChangeListener {
public void propertyChange(PropertyChangeEvent evt) {
if ("scale".equals(evt.getPropertyName())) {
update();
repaint();
}
}
}
}
libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/common/ 0000755 0001750 0001750 00000000000 10634142130 026216 5 ustar gregoa gregoa libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/common/Policy.java 0000644 0001750 0001750 00000000711 10412660742 030327 0 ustar gregoa gregoa package com.michaelbaranov.microba.common;
public interface Policy {
/**
* Adds a {@link PolicyListener}.
*
* @param listener
* a {@link PolicyListener} to add
*/
public void addVetoPolicyListener(PolicyListener listener);
/**
* Removes a {@link PolicyListener}.
*
* @param listener
* a {@link PolicyListener} to remove
*/
public void removeVetoPolicyListener(PolicyListener listener);
}
libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/common/MicrobaComponent.java 0000644 0001750 0001750 00000004322 10537216170 032331 0 ustar gregoa gregoa package com.michaelbaranov.microba.common;
import java.awt.Color;
import java.util.Collections;
import java.util.Map;
import javax.swing.JComponent;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import com.michaelbaranov.microba.Microba;
/**
* Superclass for all Microba GUI components.
*
* @author Michael Baranov
*
*/
public class MicrobaComponent extends JComponent {
public static final String PROPERTY_NAME_COLOR_OVERRIDE_MAP = "colorOverrideMap";
static {
Microba.init();
}
protected Map colorOverrideMap;
public ComponentUI getUI() {
return ui;
}
/**
* Sets the UI delegate of this component to the corresponding UI delegate
* taken from UIManager.
*
* This implementation has a workarount to fix the problem with non-standard
* class-loaders.
*/
public void updateUI() {
UIManager.getDefaults().put(UIManager.get(this.getUIClassID()), null);
ComponentUI delegate = UIManager.getUI(this);
setUI(delegate);
invalidate();
}
/**
* Returns per-instance (only for this instance) map of color overrides. May
* be null
.
*
* NOTE: returned map is unmodifiable. Use {@link #setColorOverrideMap(Map)}
* to change the map.
*
* @return keys in the map are {@link String} constants, valuse are of type
* {@link Color} or of type {@link String} (in this case,
* {@link Color} values are obtained via
* {@link UIManager#getColor(Object)})
*/
public Map getColorOverrideMap() {
if (colorOverrideMap == null)
return null;
return Collections.unmodifiableMap(colorOverrideMap);
}
/**
* Sets per-instance (only for this instance) map of color overrides.
*
* @param colorOverrideMap
* keys in the map are {@link String} constants, valuse are of
* type {@link Color} or of type {@link String} (in this case,
* {@link Color} values are obtained via
* {@link UIManager#getColor(Object)}). May be null
.
*/
public void setColorOverrideMap(Map colorOverrideMap) {
Object old = this.colorOverrideMap;
this.colorOverrideMap = colorOverrideMap;
firePropertyChange(PROPERTY_NAME_COLOR_OVERRIDE_MAP, old,
colorOverrideMap);
updateUI();
}
}
libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/common/AbstractPolicy.java 0000644 0001750 0001750 00000001762 10412660742 032022 0 ustar gregoa gregoa package com.michaelbaranov.microba.common;
import javax.swing.event.EventListenerList;
/**
* This is a convenience implementation of {@link Policy}.
*
* @author Michael Baranov
*
*/
public abstract class AbstractPolicy implements Policy {
private EventListenerList vetoPolicyListenerList = new EventListenerList();
public void addVetoPolicyListener(PolicyListener listener) {
vetoPolicyListenerList.add(PolicyListener.class, listener);
}
public void removeVetoPolicyListener(PolicyListener listener) {
vetoPolicyListenerList.remove(PolicyListener.class, listener);
}
/**
* Fires a {@link PolicyEvent} to all related {@link PolicyListener}s.
*/
protected void fireVetoPolicyChangeAction() {
Object[] listeners = vetoPolicyListenerList.getListenerList();
for (int i = listeners.length - 2; i >= 0; i -= 2)
if (listeners[i] == PolicyListener.class)
((PolicyListener) listeners[i + 1])
.policyChanged(new PolicyEvent(this));
}
}
libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/common/CommitEvent.java 0000644 0001750 0001750 00000001556 10412660742 031332 0 ustar gregoa gregoa package com.michaelbaranov.microba.common;
import java.util.EventObject;
/**
* An event used to indicate a change to a control has been commited or reverted
* (rolled back).
*
* @author Michael Baranov
*
*/
public class CommitEvent extends EventObject {
private boolean commit;
/**
* Constructor.
*
* @param source
* a control that fired the event
* @param commit
* true
to indicate commit, false
* to indicate revert (rollback)
*/
public CommitEvent(Object source, boolean commit) {
super(source);
this.commit = commit;
}
/**
* Returns the type of the event.
*
* @return true
if a change has been commited to a control,
* false
otherwise.
*/
public boolean isCommit() {
return commit;
}
}
././@LongLink 0000000 0000000 0000000 00000000154 00000000000 011565 L ustar root root libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/common/AbstractBoundedTableModel.java libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/common/AbstractBoundedTableMod0000644 0001750 0001750 00000004232 10412660742 032626 0 ustar gregoa gregoa package com.michaelbaranov.microba.common;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import javax.swing.table.AbstractTableModel;
/**
* A simple abstract implementation of BoundedTableModel
. A
* convenience class.
*
* @author Michael Baranov
*/
public abstract class AbstractBoundedTableModel extends AbstractTableModel
implements BoundedTableModel {
private PropertyChangeSupport propertySupport=new PropertyChangeSupport(this);
public void addPropertyChangeListener(PropertyChangeListener listener) {
propertySupport.addPropertyChangeListener(listener);
}
public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
propertySupport.addPropertyChangeListener(propertyName, listener);
}
public void firePropertyChange(PropertyChangeEvent evt) {
propertySupport.firePropertyChange(evt);
}
public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) {
propertySupport.firePropertyChange(propertyName, oldValue, newValue);
}
public void firePropertyChange(String propertyName, int oldValue, int newValue) {
propertySupport.firePropertyChange(propertyName, oldValue, newValue);
}
public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
propertySupport.firePropertyChange(propertyName, oldValue, newValue);
}
public PropertyChangeListener[] getPropertyChangeListeners() {
return propertySupport.getPropertyChangeListeners();
}
public PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
return propertySupport.getPropertyChangeListeners(propertyName);
}
public boolean hasListeners(String propertyName) {
return propertySupport.hasListeners(propertyName);
}
public void removePropertyChangeListener(PropertyChangeListener listener) {
propertySupport.removePropertyChangeListener(listener);
}
public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
propertySupport.removePropertyChangeListener(propertyName, listener);
}
}
libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/common/PolicyListener.java 0000644 0001750 0001750 00000000603 10412660742 032035 0 ustar gregoa gregoa package com.michaelbaranov.microba.common;
import java.util.EventListener;
/**
* A listener that is notified of {@link PolicyEvent} events.
*
* @author Michael Baranov
*
*/
public interface PolicyListener extends EventListener {
/**
* Called when a {@link PolicyEvent} is fired.
*
* @param event
*/
public void policyChanged(PolicyEvent event);
}
libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/common/PolicyEvent.java 0000644 0001750 0001750 00000000634 10412660742 031335 0 ustar gregoa gregoa package com.michaelbaranov.microba.common;
import java.util.EventObject;
/**
* An event used to indicate a policy (algorithm) has changed.
*
* @author Michael Baranov
*
*/
public class PolicyEvent extends EventObject {
/**
* Constructor.
*
* @param source
* an object whose policy has changed
*/
public PolicyEvent(Object source) {
super(source);
}
}
././@LongLink 0000000 0000000 0000000 00000000171 00000000000 011564 L ustar root root libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/common/AbstractBoundedTableModelWithSelection.java libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/common/AbstractBoundedTableMod0000644 0001750 0001750 00000006553 10412660742 032636 0 ustar gregoa gregoa package com.michaelbaranov.microba.common;
import java.util.EventListener;
import javax.swing.DefaultListSelectionModel;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionListener;
/**
* A simple abstract implementation of BoundedTableModel
with
* implemented ListSelectionModel
functionality. A convenience
* class.
*
* @author Michael Baranov
*
*/
public abstract class AbstractBoundedTableModelWithSelection extends
AbstractBoundedTableModel implements ListSelectionModel {
private DefaultListSelectionModel selection = new DefaultListSelectionModel();
public AbstractBoundedTableModelWithSelection() {
super();
}
public void addListSelectionListener(ListSelectionListener l) {
selection.addListSelectionListener(l);
}
public void addSelectionInterval(int index0, int index1) {
selection.addSelectionInterval(index0, index1);
}
public void clearSelection() {
selection.clearSelection();
}
public int getAnchorSelectionIndex() {
return selection.getAnchorSelectionIndex();
}
public int getLeadSelectionIndex() {
return selection.getLeadSelectionIndex();
}
public EventListener[] getListeners(Class listenerType) {
return selection.getListeners(listenerType);
}
public ListSelectionListener[] getListSelectionListeners() {
return selection.getListSelectionListeners();
}
public int getMaxSelectionIndex() {
return selection.getMaxSelectionIndex();
}
public int getMinSelectionIndex() {
return selection.getMinSelectionIndex();
}
public int getSelectionMode() {
return selection.getSelectionMode();
}
public boolean getValueIsAdjusting() {
return selection.getValueIsAdjusting();
}
public void insertIndexInterval(int index, int length, boolean before) {
selection.insertIndexInterval(index, length, before);
}
public boolean isLeadAnchorNotificationEnabled() {
return selection.isLeadAnchorNotificationEnabled();
}
public boolean isSelectedIndex(int index) {
return selection.isSelectedIndex(index);
}
public boolean isSelectionEmpty() {
return selection.isSelectionEmpty();
}
// J2SE5
// ////////////////////////////////////////////////////
// public void moveLeadSelectionIndex(int leadIndex) {
// selection.moveLeadSelectionIndex(leadIndex);
// }
public void removeIndexInterval(int index0, int index1) {
selection.removeIndexInterval(index0, index1);
}
public void removeListSelectionListener(ListSelectionListener l) {
selection.removeListSelectionListener(l);
}
public void removeSelectionInterval(int index0, int index1) {
selection.removeSelectionInterval(index0, index1);
}
public void setAnchorSelectionIndex(int anchorIndex) {
selection.setAnchorSelectionIndex(anchorIndex);
}
public void setLeadAnchorNotificationEnabled(boolean flag) {
selection.setLeadAnchorNotificationEnabled(flag);
}
public void setLeadSelectionIndex(int leadIndex) {
selection.setLeadSelectionIndex(leadIndex);
}
public void setSelectionInterval(int index0, int index1) {
selection.setSelectionInterval(index0, index1);
}
public void setSelectionMode(int selectionMode) {
selection.setSelectionMode(selectionMode);
}
public void setValueIsAdjusting(boolean isAdjusting) {
selection.setValueIsAdjusting(isAdjusting);
}
}
libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/common/CommitListener.java 0000644 0001750 0001750 00000000574 10412660742 032035 0 ustar gregoa gregoa package com.michaelbaranov.microba.common;
import java.util.EventListener;
/**
* A listener that is notified of {@link CommitEvent} events.
*
* @author Michael Baranov
*
*/
public interface CommitListener extends EventListener {
/**
* Called when a {@link CommitEvent} is fired.
*
* @param event
*/
public void commit(CommitEvent event);
}
libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/common/BoundedTableModel.java 0000644 0001750 0001750 00000003245 10412660742 032406 0 ustar gregoa gregoa package com.michaelbaranov.microba.common;
import java.beans.PropertyChangeListener;
import javax.swing.table.TableModel;
/**
* An extended TableModel
.
*
* The upper and lower bound values are introduced to further describe table
* data. For example, BoundedTableModel
is used as a data model
* for {@link com.michaelbaranov.microba.marker.MarkerBar}
,
* {@link com.michaelbaranov.microba.gradient.GradientBar}
,
* {@link com.michaelbaranov.microba.gradienteditor.GradientEditor}
*
* @version 0.1 (rev. 13 Aug 2005)
* @author Michael Baranov www.michaelbaranov.com
*
*/
public interface BoundedTableModel extends TableModel {
/**
* The name of the bound property, that holds lower bound value.
*/
public static final String PROPERTY_LOWER_BOUND = "lowerBound";
/**
* The name of the bound property, that holds upper bound value.
*/
public static final String PROPERTY_UPPER_BOUND = "upperBound";
/**
* Returns some lower bound, further describing the data.
*
* @return lower bound.
*/
int getLowerBound();
/**
* Returns some upper bound, further describing the data.
*
* @return upper bound.
*/
int getUpperBound();
public void addPropertyChangeListener(PropertyChangeListener listener);
public void addPropertyChangeListener(String propertyName,
PropertyChangeListener listener);
public void removePropertyChangeListener(PropertyChangeListener listener);
public void removePropertyChangeListener(String propertyName,
PropertyChangeListener listener);
}
libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/Microba.java 0000644 0001750 0001750 00000013137 10537216170 027162 0 ustar gregoa gregoa package com.michaelbaranov.microba;
import java.applet.Applet;
import java.awt.Color;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.HashMap;
import java.util.Map;
import javax.swing.LookAndFeel;
import javax.swing.UIManager;
import com.michaelbaranov.microba.common.MicrobaComponent;
/**
* This class is used to initialize Microba library.
*
* @author Michael Baranov
*
*/
public class Microba {
private static UIChangeListener changeListener = new UIChangeListener();
/**
* Initializes the library: installs L&F properties, sets up a L&F change
* listener.
*
* No need to call this method explicitly for desktop applications. You
* should only call it in {@link Applet#init()}. This will handle browser
* refresh button correctly.
*
*/
public static synchronized void init() {
setLookAndFeelProperties(UIManager.getLookAndFeel());
UIManager.removePropertyChangeListener(changeListener);
UIManager.addPropertyChangeListener(changeListener);
}
private static synchronized void setLookAndFeelProperties(
LookAndFeel lookAndFeel) {
if (lookAndFeel == null)
return;
String packagePrefix = "com.michaelbaranov.microba.";
// all L&F
UIManager.put("microba.CalendarPaneUI", packagePrefix
+ "calendar.ui.basic.BasicCalendarPaneUI");
UIManager.put("microba.DatePickerUI", packagePrefix
+ "calendar.ui.basic.BasicDatePickerUI");
UIManager.put("microba.GradientUI", packagePrefix
+ "gradient.ui.basic.BasicGradientUI");
UIManager.put("microba.GradientEditorUI", packagePrefix
+ "gradienteditor.ui.basic.BasicGradientEditorUI");
UIManager.put("microba.MarkerBarUI", packagePrefix
+ "marker.ui.basic.BasicMarkerBarUI");
// particular L&F
if (lookAndFeel.getID().equals("Windows")) {
UIManager.put("microba.MarkerBarUI", packagePrefix
+ "marker.ui.windows.WindowsMarkerBarUI");
} else if (lookAndFeel.getID().equals("Metal")) {
UIManager.put("microba.MarkerBarUI", packagePrefix
+ "marker.ui.metal.MetalMarkerBarUI");
} else if (lookAndFeel.getID().equals("Motif")) {
UIManager.put("microba.MarkerBarUI", packagePrefix
+ "marker.ui.motif.MotifMarkerBarUI");
}
}
private static final class UIChangeListener implements
PropertyChangeListener {
public void propertyChange(PropertyChangeEvent event) {
if ("lookAndFeel".equals(event.getPropertyName())) {
setLookAndFeelProperties((LookAndFeel) event.getNewValue());
}
}
}
private static Map lookAndFeelToOverride = new HashMap();
/**
* Sets per-Lokk&Feel map of color overrides.
*
*
* @param lookAndFeel
* look&feel ID
* @param overrides
* keys in the map are {@link String} constants, valuse are of
* type {@link Color} or of type {@link String} (in this case,
* {@link Color} values are obtained via
* {@link UIManager#getColor(Object)}). May be null
.
*/
public static void setColorOverrideMap(String lookAndFeel, Map overrides) {
lookAndFeelToOverride.put(lookAndFeel, overrides);
// TODO: refresh ui delegates
}
/**
* Returns overriden color for given component in current Look&Feel. The
* algorithms is:
*
null
is returned.
* null
if not overriden
*/
public static synchronized Color getOverridenColor(String colorConstant,
MicrobaComponent component) {
Map componentOverrideMap = component.getColorOverrideMap();
if (componentOverrideMap != null) {
if (componentOverrideMap.containsKey(colorConstant)) {
Object val = componentOverrideMap.get(colorConstant);
if (val instanceof Color)
return (Color) val;
else
return UIManager.getColor(val);
}
}
String currentLookAndFeel = UIManager.getLookAndFeel().getID();
Map overrides = (Map) lookAndFeelToOverride.get(currentLookAndFeel);
if (overrides != null) {
if (overrides.containsKey(colorConstant)) {
Object val = overrides.get(colorConstant);
if (val instanceof Color)
return (Color) val;
else
return UIManager.getColor(val);
}
}
return null;
}
/**
* Returns overriden color for given component in current Look&Feel or a
* default value. The algorithms is:
* * This implementatin allows for specifying time component along with the date. * Make sure that: 1) keepTime property is true; 2) stripTime is false; 3) * dateFormat has time fields; * * @author Michael Baranov */ public class DatePicker extends CalendarPane { /** * The name of a "dateFormat" property. */ public static final String PROPERTY_NAME_DATE_FORMAT = "dateFormat"; /** * The name of a "fieldEditable" property. */ public static final String PROPERTY_NAME_FIELD_EDITABLE = "fieldEditable"; /** * The name of a "keepTime" property. */ public static final String PROPERTY_NAME_KEEP_TIME = "keepTime"; /** * The name of a "pickerStyle" property. */ public static final String PROPERTY_NAME_PICKER_STYLE = "pickerStyle"; /** * The name of a "popupFocusable" property. */ public static final String PROPERTY_NAME_DROPDOWN_FOCUSABLE = "dropdownFocusable"; /** * A constant for the "pickerStyle" property. */ public static final int PICKER_STYLE_FIELD_AND_BUTTON = 0x110; /** * A constant for the "pickerStyle" property. */ public static final int PICKER_STYLE_BUTTON = 0x120; private static final String uiClassID = "microba.DatePickerUI"; private DateFormat dateFormat; private boolean fieldEditable; private boolean keepTime; private int pickerStyle; private boolean dropdownFocusable; /** * Constructor. */ public DatePicker() { this(new Date(), DateFormat.MEDIUM, Locale.getDefault(), TimeZone .getDefault()); } /** * Constructor. */ public DatePicker(Date initialDate) { this(initialDate, DateFormat.MEDIUM, Locale.getDefault(), TimeZone .getDefault()); } /** * Constructor. */ public DatePicker(Date initialDate, int dateStyle) { this(initialDate, dateStyle, Locale.getDefault(), TimeZone.getDefault()); } /** * Constructor. */ public DatePicker(Date initialDate, DateFormat dateFormat) { this(initialDate, dateFormat, Locale.getDefault(), TimeZone .getDefault()); } /** * Constructor. */ public DatePicker(Date initialDate, int dateStyle, Locale locale) { this(initialDate, dateStyle, locale, TimeZone.getDefault()); } /** * Constructor. */ public DatePicker(Date initialDate, DateFormat dateFormat, Locale locale) { this(initialDate, dateFormat, locale, TimeZone.getDefault()); } /** * Constructor. */ public DatePicker(Date initialDate, int dateStyle, Locale locale, TimeZone zone) { super(initialDate, CalendarPane.STYLE_CLASSIC, locale, zone); checkDateStyle(dateStyle); this.dateFormat = dateFormatFromStyle(dateStyle); this.fieldEditable = true; this.keepTime = true; this.pickerStyle = PICKER_STYLE_FIELD_AND_BUTTON; this.setStripTime(false); this.dropdownFocusable = true; updateUI(); } /** * Constructor. */ public DatePicker(Date initialDate, DateFormat dateFormat, Locale locale, TimeZone zone) { super(initialDate, CalendarPane.STYLE_CLASSIC, locale, zone); checkDateFormat(dateFormat); this.dateFormat = dateFormat; this.fieldEditable = true; this.keepTime = true; this.pickerStyle = PICKER_STYLE_FIELD_AND_BUTTON; this.setStripTime(false); this.dropdownFocusable = true; updateUI(); } public String getUIClassID() { return uiClassID; } /** * Returns the date format. *
* * @return current date format * @see #setDateFormat(DateFormat) */ public DateFormat getDateFormat() { return dateFormat; } /** * Sets the date format constant defined by {@link DateFormat} and updates * the control to reflect new date style. *
* * @param dateFormat * the date format constant to set * @see #getDateFormat() * @see DateFormat */ public void setDateFormat(DateFormat dateFormat) { checkDateFormat(dateFormat); Object oldValue = this.dateFormat; this.dateFormat = dateFormat; firePropertyChange(PROPERTY_NAME_DATE_FORMAT, oldValue, dateFormat); } /** * Is the edit field of the control editable by the user? *
* If not editable, the user can not type in the date and can only use
* calendar drop-down to select dates.
*
* @return true
if the edit field is editable,
* false
otherwise
*
* @see #setFieldEditable(boolean)
*/
public boolean isFieldEditable() {
return fieldEditable;
}
/**
* Enables or disables editing of the edit field by the user.
*
* If not editable, the user can not type in the date and can only use * calendar drop-down to select dates. * * @param fieldEditable * the editable value to set * * @see #isFieldEditable() */ public void setFieldEditable(boolean fieldEditable) { boolean old = this.fieldEditable; this.fieldEditable = fieldEditable; firePropertyChange(PROPERTY_NAME_FIELD_EDITABLE, old, fieldEditable); } /** * Is the dropdown focusable? *
* If not focusable, the dropdown calendar will lack some keyboard input
* capabilities.
*
* @return true
if the dropdown is focusable,
* false
otherwise
*
* @see #setDropdownFocusable(boolean)
*/
public boolean isDropdownFocusable() {
return dropdownFocusable;
}
/**
* Enables or disables focusability of the dropdown calendar.
*
* If not focusable, the dropdown calendar will lack some keyboard input * capabilities. * * @param popupFocusable * the focusable value to set * * @see #isDropdownFocusable() */ public void setDropdownFocusable(boolean popupFocusable) { boolean old = this.dropdownFocusable; this.dropdownFocusable = popupFocusable; firePropertyChange(PROPERTY_NAME_DROPDOWN_FOCUSABLE, old, popupFocusable); } /** * Does UI try to preserve time components entered in the edit field? *
* If true
and if the date format has some time fields
* (hours, minutes, seconds, fraction of second), the UI tries to respect
* the time fields' values entered by user as much as possible.
*
* Note: to be able to receive time portion of the date, make sure
* {@link #isStripTime()} is false
(the dafualt).
*
* @return true
if the UI respects time fields,
* false
otherwise
* @see #setKeepTime(boolean)
* @see #setStripTime(boolean)
* @see #isStripTime()
*
*/
public boolean isKeepTime() {
return keepTime;
}
/**
* Determines if the UI should try to preserve time components entered in
* the edit field.
*
* If true
and if the date format has some time fields
* (hours, minutes, seconds, fraction of second), the UI tries to respect
* the time fields' values entered by user as much as possible.
*
* Note: to be able to receive time portion of the date, make sure
* {@link #isStripTime()} is false
(the dafualt).
*
* @param keepTime
* true
to make the UI respects time fields,
* false
otherwise
* @see #isKeepTime()
* @see #setStripTime(boolean)
* @see #isStripTime()
*/
public void setKeepTime(boolean keepTime) {
boolean old = this.keepTime;
this.keepTime = keepTime;
firePropertyChange(PROPERTY_NAME_KEEP_TIME, old, keepTime);
}
/**
* Returns current visual style of the picker control.
*
* NOTE: do not confuse with {@link #getStyle()}. * * @return current visual style constant. */ public int getPickerStyle() { return pickerStyle; } /** * Sets the current visual style of the picker control. *
* The control is then updated to reflect the new style. *
* NOTE: do not confuse with {@link #getStyle()}.
*
* @param pickerStyle
* the style to set
* @see #PICKER_STYLE_BUTTON
* @see #PICKER_STYLE_FIELD_AND_BUTTON
*/
public void setPickerStyle(int pickerStyle) {
pickerStyle = checkPickerStyle(pickerStyle);
int oldValue = this.pickerStyle;
this.pickerStyle = pickerStyle;
firePropertyChange(PROPERTY_NAME_PICKER_STYLE, oldValue, pickerStyle);
}
/**
* A shortucut method to switch picker style between
* {@link #PICKER_STYLE_FIELD_AND_BUTTON} and {@link #PICKER_STYLE_BUTTON}
*
* @param buttonOnly
* true
to set {@link #PICKER_STYLE_BUTTON},
* false
to set
* {@link #PICKER_STYLE_FIELD_AND_BUTTON}
*/
public void showButtonOnly(boolean buttonOnly) {
if (buttonOnly)
setPickerStyle(PICKER_STYLE_BUTTON);
else
setPickerStyle(PICKER_STYLE_FIELD_AND_BUTTON);
}
/**
* Displays the calendar dropdown.
*/
public void showPopup() {
((DatePickerUI) getUI()).showPopup(true);
}
/**
* Hides the calendar dropdown without selecting a date.
*/
public void hidePopup() {
((DatePickerUI) getUI()).showPopup(false);
}
public boolean commitEdit() {
try {
((DatePickerUI) getUI()).commit();
fireCommitEvent(true);
return true;
} catch (Exception e) {
return false;
}
}
public void revertEdit() {
((DatePickerUI) getUI()).revert();
fireCommitEvent(false);
}
private void checkDateStyle(int style) {
if (style != DateFormat.SHORT && style != DateFormat.MEDIUM
&& style != DateFormat.LONG)
throw new IllegalArgumentException("dateStyle: unrecognized style");
}
private int checkPickerStyle(int style) {
if (style == 0)
style = PICKER_STYLE_FIELD_AND_BUTTON;
if (style != PICKER_STYLE_FIELD_AND_BUTTON
&& style != PICKER_STYLE_BUTTON)
throw new IllegalArgumentException(PROPERTY_NAME_PICKER_STYLE
+ ": unrecognized style");
return style;
}
private void checkDateFormat(DateFormat dateFormat) {
if (dateFormat == null)
throw new IllegalArgumentException("dateFormat: null value");
}
private DateFormat dateFormatFromStyle(int dateStyle) {
DateFormat df = DateFormat.getDateInstance(dateStyle, this.getLocale());
df.setTimeZone(this.getZone());
return df;
}
}
libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/ 0000755 0001750 0001750 00000000000 10634142132 027116 5 ustar gregoa gregoa libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/DatePickerUI.java 0000644 0001750 0001750 00000000334 10412660742 032240 0 ustar gregoa gregoa package com.michaelbaranov.microba.calendar.ui;
public abstract class DatePickerUI extends CalendarPaneUI {
public abstract void showPopup(boolean visible);
public abstract void setSimpeLook(boolean b);
}
././@LongLink 0000000 0000000 0000000 00000000146 00000000000 011566 L ustar root root libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/CalendarPaneUI.java libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/CalendarPaneUI.jav0000644 0001750 0001750 00000000632 11050305306 032371 0 ustar gregoa gregoa package com.michaelbaranov.microba.calendar.ui;
import java.beans.PropertyVetoException;
import java.text.ParseException;
import javax.swing.plaf.ComponentUI;
public abstract class CalendarPaneUI extends ComponentUI {
public abstract void commit() throws PropertyVetoException, ParseException;
public abstract void revert();
public abstract void observeMonth(int year, int month);
}
libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/ 0000755 0001750 0001750 00000000000 10634142132 030177 5 ustar gregoa gregoa ././@LongLink 0000000 0000000 0000000 00000000161 00000000000 011563 L ustar root root libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/BasicCalendarPaneUI.java libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/BasicCalenda0000644 0001750 0001750 00000033657 11050603126 032427 0 ustar gregoa gregoa package com.michaelbaranov.microba.calendar.ui.basic;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyVetoException;
import java.util.Date;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import java.util.TimeZone;
import javax.swing.AbstractAction;
import javax.swing.ActionMap;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.plaf.ComponentUI;
import com.michaelbaranov.microba.calendar.CalendarPane;
import com.michaelbaranov.microba.calendar.DatePicker;
import com.michaelbaranov.microba.calendar.HolidayPolicy;
import com.michaelbaranov.microba.calendar.VetoPolicy;
import com.michaelbaranov.microba.calendar.ui.CalendarPaneUI;
public class BasicCalendarPaneUI extends CalendarPaneUI implements
PropertyChangeListener, FocusListener {
protected static final String ESCAPE_KEY = "##CalendarPaneUI.escape##";
protected static final String ENTER_KEY = "##CalendarPaneUI.enter##";
protected CalendarPane peer;
protected ClassicCalendarPanel classicPanel;
protected ModernCalendarPanel modernPanel;
protected AuxPanel auxPanel;
protected CalendarGridPanel gridPanel;
protected CalendarNumberOfWeekPanel numberOfWeekPanel;
protected CalendarHeader headerPanel;
protected Set focusableComponents = new HashSet();
protected ComponentListener componentListener;
public static ComponentUI createUI(JComponent c) {
return new BasicCalendarPaneUI();
}
public void installUI(JComponent component) {
peer = (CalendarPane) component;
createNestedComponents();
addNestedComponents();
installListeners();
installKeyboardActions();
}
public void uninstallUI(JComponent component) {
uninstallKeyboardActions();
uninstallListeners();
removeNestedComponents();
destroyNestedComponents();
peer = null;
}
protected void uninstallKeyboardActions() {
InputMap input = peer
.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
ActionMap action = peer.getActionMap();
input.remove(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));
input.remove(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0));
action.remove(ENTER_KEY);
action.remove(ESCAPE_KEY);
}
protected void installKeyboardActions() {
InputMap input = peer
.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
ActionMap action = peer.getActionMap();
input.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), ENTER_KEY);
input.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), ESCAPE_KEY);
input.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0), "pgupkey");
input
.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0),
"pgdownkey");
action.put(ENTER_KEY, new AbstractAction() {
public void actionPerformed(ActionEvent e) {
peer.commitEdit();
}
});
action.put(ESCAPE_KEY, new AbstractAction() {
public void actionPerformed(ActionEvent e) {
peer.revertEdit();
}
});
action.put("pgupkey", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
classicPanel.addMonth(1);
}
});
action.put("pgdownkey", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
classicPanel.addMonth(-1);
}
});
}
protected void uninstallListeners() {
peer.removePropertyChangeListener(this);
peer.removeFocusListener(this);
}
protected void installListeners() {
peer.addPropertyChangeListener(this);
peer.addFocusListener(this);
}
protected void createNestedComponents() {
Date baseDate = peer.getDate() == null ? new Date() : peer.getDate();
classicPanel = new ClassicCalendarPanel(baseDate, peer.getLocale(),
peer.getZone());
modernPanel = new ModernCalendarPanel(baseDate, peer.getLocale(), peer
.getZone());
headerPanel = new CalendarHeader(peer, baseDate, peer.getLocale(), peer
.getZone(), peer.getHolidayPolicy());
auxPanel = new AuxPanel(peer.getLocale(), peer.getZone(), peer
.getVetoPolicy(), peer.isShowTodayButton(), peer
.isShowNoneButton(), peer.getResources());
gridPanel = new CalendarGridPanel(peer, peer.getDate(), peer
.getLocale(), peer.getZone(), peer.getVetoPolicy(), peer
.getHolidayPolicy());
numberOfWeekPanel = new CalendarNumberOfWeekPanel(peer.getDate(), peer
.getLocale(), peer.getZone());
focusableComponents.addAll(classicPanel.getFocusableComponents());
focusableComponents.addAll(modernPanel.getFocusableComponents());
focusableComponents.addAll(auxPanel.getFocusableComponents());
focusableComponents.addAll(gridPanel.getFocusableComponents());
focusableComponents.addAll(auxPanel.getFocusableComponents());
componentListener = new ComponentListener();
for (int i = 0; i < focusableComponents.size(); i++)
((JComponent) focusableComponents.toArray()[i])
.addFocusListener(componentListener);
gridPanel.addPropertyChangeListener(componentListener);
modernPanel.addPropertyChangeListener(componentListener);
classicPanel.addPropertyChangeListener(componentListener);
auxPanel.addPropertyChangeListener(componentListener);
classicPanel.setEnabled(peer.isEnabled());
modernPanel.setEnabled(peer.isEnabled());
headerPanel.setEnabled(peer.isEnabled());
auxPanel.setEnabled(peer.isEnabled());
numberOfWeekPanel.setEnabled(peer.isEnabled());
gridPanel.setEnabled(peer.isEnabled());
}
protected void destroyNestedComponents() {
gridPanel.removePropertyChangeListener(componentListener);
modernPanel.removePropertyChangeListener(componentListener);
classicPanel.removePropertyChangeListener(componentListener);
auxPanel.removePropertyChangeListener(componentListener);
componentListener = null;
for (int i = 0; i < focusableComponents.size(); i++)
((JComponent) focusableComponents.toArray()[i])
.removeFocusListener(componentListener);
focusableComponents.clear();
classicPanel = null;
modernPanel = null;
headerPanel = null;
auxPanel = null;
gridPanel = null;
numberOfWeekPanel = null;
}
protected void addNestedComponents() {
peer.removeAll();
peer.setLayout(new GridBagLayout());
if ((peer.getStyle() & CalendarPane.STYLE_CLASSIC) > 0) {
peer.add(classicPanel, new GridBagConstraints(0, 0, 2, 1, 1, 0,
GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(0, 0, 0, 0), 0, 0));
} else {
peer.add(modernPanel, new GridBagConstraints(0, 0, 2, 1, 1, 0,
GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(0, 0, 0, 0), 0, 0));
}
peer.add(headerPanel, new GridBagConstraints(1, 1, 1, 1, 1, 0,
GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(0, 0, 0, 0), 0, 0));
if (peer.isShowNumberOfWeek()) {
peer.add(numberOfWeekPanel, new GridBagConstraints(0, 2, 1, 1, 0,
1, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL,
new Insets(0, 0, 0, 0), 0, 0));
}
peer.add(gridPanel, new GridBagConstraints(1, 2, 1, 1, 1, 1,
GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(
0, 0, 0, 0), 0, 0));
if (peer.isShowTodayButton()) {
peer.add(auxPanel, new GridBagConstraints(0, 3, 2, 1, 1, 0,
GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(0, 0, 0, 0), 0, 0));
}
if (peer.isShowNumberOfWeek()) {
// TODO:
}
peer.revalidate();
peer.repaint();
}
protected void removeNestedComponents() {
peer.removeAll();
}
protected void widgetDateChanged(Date date) {
Date baseDate = date == null ? new Date() : date;
headerPanel.setDate(baseDate);
classicPanel.setDate(baseDate);
modernPanel.setDate(baseDate);
gridPanel.setBaseDate(baseDate);
gridPanel.setDate(date);
numberOfWeekPanel.setBaseDate(baseDate);
}
protected void widgetLocaleChanged(Locale newValue) {
classicPanel.setLocale(newValue);
modernPanel.setLocale(newValue);
gridPanel.setLocale(newValue);
headerPanel.setLocale(newValue);
auxPanel.setLocale(newValue);
numberOfWeekPanel.setLocale(newValue);
}
protected void widgetZoneChanged(TimeZone zone) {
classicPanel.setZone(zone);
modernPanel.setZone(zone);
gridPanel.setZone(zone);
headerPanel.setZone(zone);
auxPanel.setZone(zone);
numberOfWeekPanel.setZone(zone);
}
protected void widgetResourceChanged() {
auxPanel.setResources(peer.getResources());
}
public void commit() throws PropertyVetoException {
peer.setDate(gridPanel.getDateToCommit());
}
public void revert() {
widgetDateChanged(peer.getDate());
}
public void focusGained(FocusEvent e) {
gridPanel.requestFocus(true);
}
public void focusLost(FocusEvent e) {
}
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals(CalendarPane.PROPERTY_NAME_DATE)) {
widgetDateChanged((Date) evt.getNewValue());
} else if (evt.getPropertyName().equals(
CalendarPane.PROPERTY_NAME_LOCALE)) {
widgetLocaleChanged((Locale) evt.getNewValue());
} else if (evt.getPropertyName()
.equals(CalendarPane.PROPERTY_NAME_ZONE)) {
widgetZoneChanged((TimeZone) evt.getNewValue());
} else if (evt.getPropertyName().equals(
CalendarPane.PROPERTY_NAME_VETO_POLICY)) {
gridPanel.setVetoPolicy((VetoPolicy) evt.getNewValue());
auxPanel.setVetoModel((VetoPolicy) evt.getNewValue());
} else if (evt.getPropertyName().equals(
CalendarPane.PROPERTY_NAME_HOLIDAY_POLICY)) {
gridPanel.setHolidayPolicy((HolidayPolicy) evt.getNewValue());
headerPanel.setHolidayPolicy((HolidayPolicy) evt.getNewValue());
} else if (evt.getPropertyName().equals("enabled")) {
boolean value = ((Boolean) evt.getNewValue()).booleanValue();
classicPanel.setEnabled(value);
modernPanel.setEnabled(value);
headerPanel.setEnabled(value);
auxPanel.setEnabled(value);
numberOfWeekPanel.setEnabled(value);
gridPanel.setEnabled(value);
} else if (evt.getPropertyName().equals(
CalendarPane.PROPERTY_NAME_STYLE)) {
addNestedComponents();
} else if (evt.getPropertyName().equals(
CalendarPane.PROPERTY_NAME_SHOW_TODAY_BTN)) {
Boolean value = (Boolean) evt.getNewValue();
auxPanel.setShowTodayBtn(value.booleanValue());
} else if (evt.getPropertyName().equals(
DatePicker.PROPERTY_NAME_SHOW_NONE_BTN)) {
boolean value = ((Boolean) evt.getNewValue()).booleanValue();
auxPanel.setShowNoneButton(value);
} else if (evt.getPropertyName().equals(
DatePicker.PROPERTY_NAME_SHOW_NUMBER_WEEK)) {
addNestedComponents();
} else if (evt.getPropertyName().equals("focusable")) {
Boolean value = (Boolean) evt.getNewValue();
classicPanel.setFocusable(value.booleanValue());
modernPanel.setFocusable(value.booleanValue());
gridPanel.setFocusable(value.booleanValue());
auxPanel.setFocusable(value.booleanValue());
} else if (evt.getPropertyName().equals(
CalendarPane.PROPERTY_NAME_RESOURCES)) {
widgetResourceChanged();
} else if (evt.getPropertyName().equals("enabled"/*
* CalendarPane.PROPERTY_NAME_ENABLED
*/)) {
Boolean value = (Boolean) evt.getNewValue();
classicPanel.setEnabled(value.booleanValue());
modernPanel.setEnabled(value.booleanValue());
gridPanel.setEnabled(value.booleanValue());
auxPanel.setEnabled(value.booleanValue());
}
}
protected class ComponentListener implements FocusListener,
PropertyChangeListener {
public void focusGained(FocusEvent e) {
}
public void focusLost(FocusEvent e) {
boolean isFocusableComponent = focusableComponents.contains(e
.getSource());
boolean isNonEmptyOpposite = e.getOppositeComponent() != null;
if (isFocusableComponent
&& isNonEmptyOpposite
&& !SwingUtilities.isDescendingFrom(e
.getOppositeComponent(), peer)) {
peer.commitOrRevert();
}
}
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getSource() == gridPanel
&& evt.getPropertyName().equals(
CalendarGridPanel.PROPERTY_NAME_DATE)) {
Date newValue = (Date) evt.getNewValue();
try {
peer.setDate(newValue);
} catch (PropertyVetoException e) {
// Ignore. Just can not happen, beacause CalendarGridPanel
// already checked the date against current peer's
// vetoPolicy.
}
}
if (evt.getSource() == gridPanel
&& evt
.getPropertyName()
.equals(
CalendarGridPanel.PROPERTY_NAME_NOTIFY_SELECTED_DATE_CLICKED)) {
peer.fireActionEvent();
}
if (evt.getSource() == gridPanel
&& evt.getPropertyName().equals(
CalendarGridPanel.PROPERTY_NAME_BASE_DATE)) {
Date newValue = (Date) evt.getNewValue();
modernPanel.setDate(newValue);
classicPanel.setDate(newValue);
}
if (evt.getSource() == modernPanel
&& evt.getPropertyName().equals(
ModernCalendarPanel.PROPERTY_NAME_DATE)) {
Date newValue = (Date) evt.getNewValue();
gridPanel.setBaseDate(newValue);
classicPanel.setDate(newValue);
numberOfWeekPanel.setBaseDate(newValue);
}
if (evt.getSource() == classicPanel
&& evt.getPropertyName().equals(
ModernCalendarPanel.PROPERTY_NAME_DATE)) {
Date newValue = (Date) evt.getNewValue();
gridPanel.setBaseDate(newValue);
modernPanel.setDate(newValue);
numberOfWeekPanel.setBaseDate(newValue);
}
if (evt.getSource() == auxPanel
&& evt.getPropertyName()
.equals(AuxPanel.PROPERTY_NAME_DATE)) {
Date date = (Date) evt.getNewValue();
gridPanel.setDate(date);
peer.commitEdit();
}
}
}
public void observeMonth(int year, int month) {
modernPanel.goToMonth(year, month);
}
}
././@LongLink 0000000 0000000 0000000 00000000167 00000000000 011571 L ustar root root libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/CalendarNumberOfWeekPanel.java libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/CalendarNumb0000644 0001750 0001750 00000006223 10517524646 032476 0 ustar gregoa gregoa package com.michaelbaranov.microba.calendar.ui.basic;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.UIManager;
public class CalendarNumberOfWeekPanel extends JPanel /*
* implements
* PropertyChangeListener
*/{
public static final String PROPERTY_NAME_BASE_DATE = "baseDate";
public static final String PROPERTY_NAME_LOCALE = "locale";
public static final String PROPERTY_NAME_ZONE = "zone";
private Color backgroundColorActive = UIManager.getColor("activeCaption");
private Color backgroundColorInactive = UIManager
.getColor("inactiveCaption");
private Date baseDate;
private Locale locale;
private TimeZone zone;
private JLabel[] labels = new JLabel[6];
public CalendarNumberOfWeekPanel(Date baseDate, Locale locale,
TimeZone timeZone) {
super();
this.baseDate = baseDate == null ? new Date() : baseDate;
this.locale = locale;
this.zone = timeZone;
setLayout(new GridLayout(6, 1, 2, 2));
for (int i = 0; i < 6; i++) {
JLabel l = new JLabel();
labels[i] = l;
add(l);
}
setBorder(BorderFactory.createEmptyBorder(1, 4, 1, 4));
reflectBaseDate();
}
public void setBaseDate(Date baseDate) {
this.baseDate = baseDate;
reflectBaseDate();
}
private void reflectBaseDate() {
Calendar calendar = getCalendar(baseDate);
calendar.set(Calendar.DAY_OF_MONTH, 1);
int skipBefore = calendar.get(Calendar.DAY_OF_WEEK)
- calendar.getFirstDayOfWeek();
if (skipBefore < 0)
skipBefore = 7 + skipBefore;
int activeDays = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
int numActiveWeeks = (activeDays + skipBefore) / 7;
if ((activeDays + skipBefore) % 7 > 0)
numActiveWeeks++;
int startWeek = calendar.get(Calendar.WEEK_OF_YEAR);
for (int i = 0; i < 6; i++) {
labels[i].setText(startWeek > 0 && numActiveWeeks > 0 ? String
.valueOf(startWeek) : "");
labels[i].setForeground(isEnabled() ? UIManager
.getColor("controlText") : UIManager
.getColor("textInactiveText"));
startWeek++;
numActiveWeeks--;
}
setBackground(isEnabled() ? backgroundColorActive
: backgroundColorInactive);
}
private Calendar getCalendar(Date date) {
Calendar c = Calendar.getInstance(zone, locale);
c.setTime(date);
return c;
}
public void setLocale(Locale locale) {
this.locale = locale;
reflectBaseDate();
}
public void setZone(TimeZone zone) {
this.zone = zone;
reflectBaseDate();
}
public void paint(Graphics g) {
FontMetrics fm = g.getFontMetrics(labels[0].getFont());
Dimension dimension = new Dimension(fm.stringWidth("00") + 8, 1);
setMinimumSize(dimension);
setPreferredSize(dimension);
super.paint(g);
}
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
reflectBaseDate();
}
}
././@LongLink 0000000 0000000 0000000 00000000156 00000000000 011567 L ustar root root libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/YearSpinnerModel.java libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/YearSpinnerM0000644 0001750 0001750 00000010027 10412660742 032504 0 ustar gregoa gregoa package com.michaelbaranov.microba.calendar.ui.basic;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import javax.swing.SpinnerNumberModel;
class YearSpinnerModel extends SpinnerNumberModel {
public static final String PROPERTY_NAME_LOCALE = "locale";
public static final String PROPERTY_NAME_DATE = "date";
public static final String PROPERTY_NAME_ZONE = "zone";
private PropertyChangeSupport changeSupport = new PropertyChangeSupport(
this);
private Locale locale;
private TimeZone zone;
private Calendar calendar;
public YearSpinnerModel(Date date, Locale locale, TimeZone zone) {
this.locale = locale;
this.zone = zone;
createLocaleAndZoneSensitive();
calendar.setTime(date);
}
private void createLocaleAndZoneSensitive() {
if (calendar != null) {
Date old = calendar.getTime();
calendar = Calendar.getInstance(zone, locale);
calendar.setTime(old);
} else
calendar = Calendar.getInstance(zone, locale);
}
public Object getValue() {
return new Integer(calendar.get(Calendar.YEAR));
}
public void setValue(Object value) {
Number newVal = (Number) value;
Number oldVal = (Number) getValue();
if (oldVal.longValue() != newVal.longValue()) {
int diff = newVal.intValue() - oldVal.intValue();
int sign = diff > 0 ? 1 : -1;
if (diff < 0)
diff = -diff;
Date oldDate = calendar.getTime();
for (int i = 0; i < diff; i++)
calendar.add(Calendar.YEAR, sign);
changeSupport.firePropertyChange(PROPERTY_NAME_DATE, oldDate,
getDate());
fireStateChanged();
}
}
public Object getNextValue() {
Integer currVal = (Integer) getValue();
int newVal = currVal.intValue() + 1;
if (newVal <= calendar.getActualMaximum(Calendar.YEAR))
return new Integer(newVal);
return currVal;
}
public Object getPreviousValue() {
Integer currVal = (Integer) getValue();
int newVal = currVal.intValue() - 1;
if (newVal >= calendar.getActualMinimum(Calendar.YEAR))
return new Integer(newVal);
return currVal;
}
public Date getDate() {
return calendar.getTime();
}
public void setDate(Date date) {
Date old = calendar.getTime();
if (!old.equals(date)) {
calendar.setTime(date);
changeSupport.firePropertyChange(PROPERTY_NAME_DATE, old, date);
fireStateChanged();
}
}
public Locale getLocale() {
return locale;
}
public void setLocale(Locale locale) {
Locale old = this.locale;
this.locale = locale;
createLocaleAndZoneSensitive();
changeSupport.firePropertyChange(PROPERTY_NAME_LOCALE, old, locale);
fireStateChanged();
}
public TimeZone getZone() {
return zone;
}
public void setZone(TimeZone zone) {
TimeZone old = this.zone;
this.zone = zone;
createLocaleAndZoneSensitive();
changeSupport.firePropertyChange(PROPERTY_NAME_LOCALE, old, locale);
fireStateChanged();
}
public void addPropertyChangeListener(PropertyChangeListener listener) {
changeSupport.addPropertyChangeListener(listener);
}
public void addPropertyChangeListener(String propertyName,
PropertyChangeListener listener) {
changeSupport.addPropertyChangeListener(propertyName, listener);
}
public void removePropertyChangeListener(PropertyChangeListener listener) {
changeSupport.removePropertyChangeListener(listener);
}
public void removePropertyChangeListener(String propertyName,
PropertyChangeListener listener) {
changeSupport.removePropertyChangeListener(propertyName, listener);
}
public PropertyChangeListener[] getPropertyChangeListeners() {
return changeSupport.getPropertyChangeListeners();
}
public PropertyChangeListener[] getPropertyChangeListeners(
String propertyName) {
return changeSupport.getPropertyChangeListeners(propertyName);
}
public boolean hasListeners(String propertyName) {
return changeSupport.hasListeners(propertyName);
}
}
././@LongLink 0000000 0000000 0000000 00000000154 00000000000 011565 L ustar root root libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/CalendarHeader.java libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/CalendarHead0000644 0001750 0001750 00000010362 10537216170 032425 0 ustar gregoa gregoa package com.michaelbaranov.microba.calendar.ui.basic;
import java.awt.Color;
import java.awt.Font;
import java.awt.GridLayout;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import com.michaelbaranov.microba.Microba;
import com.michaelbaranov.microba.calendar.CalendarPane;
import com.michaelbaranov.microba.calendar.HolidayPolicy;
class CalendarHeader extends JPanel {
private Locale locale;
private TimeZone zone;
private Date date;
private HolidayPolicy holidayPolicy;
private Color backgroundColorActive;
private Color backgroundColorInactive;
private Color foregroundColorActive;
private Color foregroundColorInactive;
private Color foregroundColorWeekendEnabled;
private Color foregroundColorWeekendDisabled;
public CalendarHeader(CalendarPane peer, Date date, Locale locale,
TimeZone zone, HolidayPolicy holidayPolicy) {
super();
backgroundColorActive = Microba.getOverridenColor(
CalendarPane.COLOR_CALENDAR_HEADER_BACKGROUND_ENABLED, peer,
UIManager.getColor("activeCaption"));
backgroundColorInactive = Microba.getOverridenColor(
CalendarPane.COLOR_CALENDAR_HEADER_BACKGROUND_DISABLED, peer,
UIManager.getColor("inactiveCaption"));
foregroundColorActive = Microba.getOverridenColor(
CalendarPane.COLOR_CALENDAR_HEADER_FOREGROUND_ENABLED, peer,
UIManager.getColor("controlText"));
foregroundColorInactive = Microba.getOverridenColor(
CalendarPane.COLOR_CALENDAR_HEADER_FOREGROUND_DISABLED, peer,
UIManager.getColor("textInactiveText"));
foregroundColorWeekendEnabled = Microba.getOverridenColor(
CalendarPane.COLOR_CALENDAR_HEADER_FOREGROUND_WEEKEND_ENABLED,
peer, Color.RED);
foregroundColorWeekendDisabled = Microba.getOverridenColor(
CalendarPane.COLOR_CALENDAR_HEADER_FOREGROUND_WEEKEND_DISABLED,
peer, foregroundColorInactive);
this.locale = locale;
this.zone = zone;
this.date = date;
this.holidayPolicy = holidayPolicy;
reflectData();
}
private void reflectData() {
Calendar cal = Calendar.getInstance(zone, locale);
cal.setTime(date == null ? new Date() : date);
SimpleDateFormat fmt = new SimpleDateFormat("E", locale);
fmt.setTimeZone(zone);
int numDaysInWeek = cal.getActualMaximum(Calendar.DAY_OF_WEEK)
- cal.getActualMinimum(Calendar.DAY_OF_WEEK) + 1;
int firstDayOfWeek = cal.getFirstDayOfWeek();
cal.set(Calendar.DAY_OF_WEEK, firstDayOfWeek);
removeAll();
setLayout(new GridLayout(1, numDaysInWeek, 2, 2));
setBackground(isEnabled() ? backgroundColorActive
: backgroundColorInactive);
for (int i = 0; i < numDaysInWeek; i++) {
JLabel label = new JLabel();
// TODO: add option to control limit length:
label.setText(fmt.format(cal.getTime())/* .substring(0,1) */);
label.setForeground(isEnabled() ? foregroundColorActive
: foregroundColorInactive);
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setBorder(BorderFactory.createEmptyBorder(3, 0, 3, 0));
Font boldFont = label.getFont().deriveFont(Font.BOLD);
label.setFont(boldFont);
add(label);
boolean isHolliday = false;
if (holidayPolicy != null) {
isHolliday = holidayPolicy.isWeekend(this, cal);
}
if (isHolliday)
label.setForeground(isEnabled() ? foregroundColorWeekendEnabled
: foregroundColorWeekendDisabled);
cal.add(Calendar.DAY_OF_WEEK, 1);
}
setBorder(BorderFactory.createEmptyBorder(0, 1, 0, 1));
revalidate();
repaint();
}
public void setLocale(Locale locale) {
this.locale = locale;
reflectData();
}
public void setDate(Date date) {
this.date = date;
reflectData();
}
public TimeZone getZone() {
return zone;
}
public void setZone(TimeZone zone) {
this.zone = zone;
reflectData();
}
public void setHolidayPolicy(HolidayPolicy holidayPolicy) {
this.holidayPolicy = holidayPolicy;
reflectData();
}
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
reflectData();
}
}
././@LongLink 0000000 0000000 0000000 00000000162 00000000000 011564 L ustar root root libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/ClassicCalendarPanel.java libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/ClassicCalen0000644 0001750 0001750 00000017236 10517524646 032475 0 ustar gregoa gregoa package com.michaelbaranov.microba.calendar.ui.basic;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import java.util.TimeZone;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import com.michaelbaranov.microba.calendar.resource.Resource;
class ClassicCalendarPanel extends JPanel implements
PropertyChangeListener {
public static final String PROPERTY_NAME_DATE = "date";
public static final String PROPERTY_NAME_LOCALE = "locale";
public static final String PROPERTY_NAME_ZONE = "zone";
private Locale locale;
private TimeZone zone;
private Calendar calendar;
private JButton prevButton;
private JButton nextButton;
private JLabel selectedDateLabel;
private DateFormat format;
private Set focusableComponents = new HashSet();
private JButton fastPrevButton;
private JButton fastNextButton;
public ClassicCalendarPanel(Date aDate, Locale aLocale, TimeZone zone) {
this.locale = aLocale;
this.zone = zone;
prevButton = new JButton();
nextButton = new JButton();
fastPrevButton = new JButton();
fastNextButton = new JButton();
nextButton.setIcon(new ImageIcon(Resource.class.getResource("forward-16.png")));
prevButton.setIcon(new ImageIcon(Resource.class.getResource("back-16.png")));
fastNextButton.setIcon(new ImageIcon(Resource.class.getResource("forward-fast-16.png")));
fastPrevButton.setIcon(new ImageIcon(Resource.class.getResource("back-fast-16.png")));
prevButton.setMargin(new Insets(0, 0, 0, 0));
nextButton.setMargin(new Insets(0, 0, 0, 0));
fastPrevButton.setMargin(new Insets(0, 0, 0, 0));
fastNextButton.setMargin(new Insets(0, 0, 0, 0));
Dimension psz = nextButton.getPreferredSize();
Dimension npsz = new Dimension(psz.height, psz.height);
nextButton.setPreferredSize(npsz);
prevButton.setPreferredSize(npsz);
selectedDateLabel = new JLabel();
selectedDateLabel.setHorizontalAlignment(SwingConstants.CENTER);
selectedDateLabel.setFont(selectedDateLabel.getFont().deriveFont(
Font.BOLD));
setLayout(new GridBagLayout());
add(fastPrevButton, new GridBagConstraints(0, 0, 1, 1, 0, 0,
GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(
0, 0, 3, 0), 0, 0));
add(prevButton, new GridBagConstraints(1, 0, 1, 1, 0, 0,
GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(
0, 0, 3, 0), 0, 0));
add(selectedDateLabel, new GridBagConstraints(2, 0, 1, 1, 1.0, 0,
GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(0, 3, 3, 3), 0, 0));
add(nextButton, new GridBagConstraints(3, 0, 1, 1, 0, 0,
GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(
0, 0, 3, 0), 0, 0));
add(fastNextButton, new GridBagConstraints(4, 0, 1, 1, 0, 0,
GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(
0, 0, 3, 0), 0, 0));
nextButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Date old = calendar.getTime();
calendar.add(Calendar.MONTH, 1);
firePropertyChange(PROPERTY_NAME_DATE, old, getDate());
reflectData();
}
});
prevButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Date old = calendar.getTime();
calendar.add(Calendar.MONTH, -1);
firePropertyChange(PROPERTY_NAME_DATE, old, getDate());
reflectData();
}
});
fastNextButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Date old = calendar.getTime();
calendar.add(Calendar.YEAR, 1);
firePropertyChange(PROPERTY_NAME_DATE, old, getDate());
reflectData();
}
});
fastPrevButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Date old = calendar.getTime();
calendar.add(Calendar.YEAR, -1);
firePropertyChange(PROPERTY_NAME_DATE, old, getDate());
reflectData();
}
});
this.addPropertyChangeListener(this);
focusableComponents.add(prevButton);
focusableComponents.add(nextButton);
focusableComponents.add(fastNextButton);
focusableComponents.add(fastPrevButton);
createLocaleAndZoneSensitive();
calendar.setTime(aDate);
reflectData();
}
private void createLocaleAndZoneSensitive() {
if (calendar != null) {
Date old = calendar.getTime();
calendar = Calendar.getInstance(zone, locale);
calendar.setTime(old);
} else
calendar = Calendar.getInstance(zone, locale);
format = new SimpleDateFormat("MMMMM yyyy", locale);
format.setTimeZone(zone);
setPreferredLabelSize();
}
private void setPreferredLabelSize() {
Calendar c = Calendar.getInstance(zone, locale);
c.setTime(getDate());
JLabel l = new JLabel();
l.setFont(selectedDateLabel.getFont());
int maxWidth = Integer.MIN_VALUE;
for (int i = 0; i <= c.getActualMaximum(Calendar.MONTH); i++) {
c.set(Calendar.MONTH, i);
String text = format.format(c.getTime());
l.setText(text);
int w = l.getPreferredSize().width;
if (w > maxWidth)
maxWidth = w;
}
Dimension d = l.getPreferredSize();
d.width = maxWidth + 10;
selectedDateLabel.setMinimumSize(d);
selectedDateLabel.setPreferredSize(d);
this.revalidate();
}
private void reflectData() {
selectedDateLabel.setText(format.format(calendar.getTime()));
}
public Date getDate() {
return calendar.getTime();
}
public void setDate(Date date) {
Date old = getDate();
calendar.setTime(date);
firePropertyChange(PROPERTY_NAME_DATE, old, date);
reflectData();
}
public Locale getLocale() {
return locale;
}
public void setLocale(Locale locale) {
Locale old = this.locale;
this.locale = locale;
createLocaleAndZoneSensitive();
firePropertyChange(PROPERTY_NAME_LOCALE, old, locale);
reflectData();
}
public TimeZone getZone() {
return zone;
}
public void setZone(TimeZone zone) {
TimeZone old = this.zone;
this.zone = zone;
createLocaleAndZoneSensitive();
firePropertyChange(PROPERTY_NAME_ZONE, old, locale);
reflectData();
}
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("focusable")) {
Boolean value = (Boolean) evt.getNewValue();
prevButton.setFocusable(value.booleanValue());
nextButton.setFocusable(value.booleanValue());
fastNextButton.setFocusable(value.booleanValue());
fastPrevButton.setFocusable(value.booleanValue());
}
if (evt.getPropertyName().equals("enabled")) {
Boolean value = (Boolean) evt.getNewValue();
prevButton.setEnabled(value.booleanValue());
nextButton.setEnabled(value.booleanValue());
fastNextButton.setEnabled(value.booleanValue());
fastPrevButton.setEnabled(value.booleanValue());
}
}
public Collection getFocusableComponents() {
return focusableComponents;
}
public void addMonth(int m) {
int modM = m > 0 ? m : -m;
int sign = m > 0 ? 1 : -1;
Date old = calendar.getTime();
for (int i = 0; i < modM; i++) {
calendar.add(Calendar.MONTH, sign);
}
firePropertyChange(PROPERTY_NAME_DATE, old, getDate());
reflectData();
}
}
././@LongLink 0000000 0000000 0000000 00000000157 00000000000 011570 L ustar root root libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/CalendarGridPanel.java libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/CalendarGrid0000644 0001750 0001750 00000043446 10634145452 032464 0 ustar gregoa gregoa package com.michaelbaranov.microba.calendar.ui.basic;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import java.util.TimeZone;
import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.KeyStroke;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import com.michaelbaranov.microba.Microba;
import com.michaelbaranov.microba.calendar.CalendarColors;
import com.michaelbaranov.microba.calendar.CalendarPane;
import com.michaelbaranov.microba.calendar.HolidayPolicy;
import com.michaelbaranov.microba.calendar.VetoPolicy;
import com.michaelbaranov.microba.common.PolicyEvent;
import com.michaelbaranov.microba.common.PolicyListener;
class CalendarGridPanel extends JPanel implements FocusListener,
PolicyListener, PropertyChangeListener, MouseListener, KeyListener {
public static final String PROPERTY_NAME_DATE = "date";
public static final String PROPERTY_NAME_BASE_DATE = "baseDate";
public static final String PROPERTY_NAME_LOCALE = "locale";
public static final String PROPERTY_NAME_ZONE = "zone";
public static final String PROPERTY_NAME_VETO_POLICY = "vetoPolicy";
private static final String PROPERTY_NAME_HOLIDAY_POLICY = "holidayPolicy";
// Not a rela property, ad-hoc approach to notify about clicking selected
// date lable
public static final String PROPERTY_NAME_NOTIFY_SELECTED_DATE_CLICKED = "##same date clicked##";
private CalendarPane peer;
private Date date;
private Date baseDate;
private Date focusDate;
private Locale locale;
private TimeZone zone;
private VetoPolicy vetoPolicy;
private DateLabel labels[] = new DateLabel[42];
private Set focusableComponents = new HashSet();
private boolean explicitDateSetToNullFlag;
private HolidayPolicy holidayPolicy;
private Color focusColor;
private Color restrictedColor;
private Color gridBgEn;
private Color gridBgDis;
private Color gridFgEn;
private Color gridFgDis;
private Color selBgEn;
private Color selBgDis;
private Color wkFgEn;
private Color wkFgDis;
private Color holFgEn;
private Color holFgDis;
public CalendarGridPanel(CalendarPane peer, Date date, Locale locale,
TimeZone zone, VetoPolicy vetoDateModel, HolidayPolicy holidayPolicy) {
this.peer = peer;
focusColor = Microba.getOverridenColor(
CalendarColors.COLOR_CALENDAR_GRID_FOCUS, peer, UIManager
.getColor("TabbedPane.focus"));
restrictedColor = Microba.getOverridenColor(
CalendarColors.COLOR_CALENDAR_GRID_RESTRICTED, peer, Color.RED);
gridBgEn = Microba.getOverridenColor(
CalendarColors.COLOR_CALENDAR_GRID_BACKGROUND_ENABLED, peer,
UIManager.getColor("TextField.background"));
gridBgDis = Microba.getOverridenColor(
CalendarColors.COLOR_CALENDAR_GRID_BACKGROUND_DISABLED, peer,
UIManager.getColor("TextField.background"));
gridFgEn = Microba.getOverridenColor(
CalendarColors.COLOR_CALENDAR_GRID_FOREGROUND_ENABLED, peer,
UIManager.getColor("TextField.foreground"));
gridFgDis = Microba.getOverridenColor(
CalendarColors.COLOR_CALENDAR_GRID_FOREGROUND_DISABLED, peer,
UIManager.getColor("controlText"));
selBgEn = Microba
.getOverridenColor(
CalendarColors.COLOR_CALENDAR_GRID_SELECTION_BACKGROUND_ENABLED,
peer, UIManager
.getColor("ComboBox.selectionBackground"));
selBgDis = Microba
.getOverridenColor(
CalendarColors.COLOR_CALENDAR_GRID_SELECTION_BACKGROUND_DISABLED,
peer, UIManager
.getColor("ComboBox.selectionBackground"));
wkFgDis = Microba.getOverridenColor(
CalendarColors.COLOR_CALENDAR_GRID_WEEKEND_FOREGROUND_DISABLED,
peer, gridFgDis);
wkFgEn = Microba.getOverridenColor(
CalendarColors.COLOR_CALENDAR_GRID_WEEKEND_FOREGROUND_ENABLED,
peer, Color.RED);
holFgDis = Microba.getOverridenColor(
CalendarColors.COLOR_CALENDAR_GRID_HOLIDAY_FOREGROUND_DISABLED,
peer, gridFgDis);
holFgEn = Microba.getOverridenColor(
CalendarColors.COLOR_CALENDAR_GRID_HOLIDAY_FOREGROUND_ENABLED,
peer, Color.RED);
this.locale = locale;
this.zone = zone;
this.date = date;
this.baseDate = date == null ? new Date() : date;
this.explicitDateSetToNullFlag = date == null ? true : false;
this.focusDate = getFocusDateForDate(date);
this.vetoPolicy = vetoDateModel;
this.holidayPolicy = holidayPolicy;
if (this.vetoPolicy != null)
this.vetoPolicy.addVetoPolicyListener(this);
if (this.holidayPolicy != null)
this.holidayPolicy.addVetoPolicyListener(this);
this.addPropertyChangeListener(this);
setLayout(new GridLayout(6, 7, 2, 2));
for (int i = 0; i < 42; i++) {
DateLabel l = new DateLabel(i);
labels[i] = l;
l.setText(String.valueOf(i));
l.addMouseListener(this);
add(l);
}
focusableComponents.add(this);
addKeyListener(this);
setFocusable(true);
// TODO: move the following to key listeners?
InputMap input = this.getInputMap(JComponent.WHEN_FOCUSED);
input.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),
"##microba.commit##");
input.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0),
"##microba.commit##");
this.getActionMap().put("##microba.commit##", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
Calendar c = getCalendar(focusDate);
if (vetoPolicy == null || !vetoPolicy.isRestricted(this, c)) {
setDate(focusDate);
}
}
});
addFocusListener(this);
// addMouseListener(this);
setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
reflectData();
}
public void focusGained(FocusEvent e) {
setBorder(BorderFactory.createLineBorder(focusColor));
reflectFocusedDate();
}
public void focusLost(FocusEvent e) {
setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
reflectFocusedDate();
}
private void setSelectedByIndex(int i) {
DateLabel label = labels[i];
if (label.isVisible()) {
int day = Integer.parseInt(label.getText());
Calendar c = getCalendar(baseDate);
c.set(Calendar.DAY_OF_MONTH, day);
setDate(c.getTime());
}
}
private Calendar getCalendar(Date date) {
Calendar c = Calendar.getInstance(zone, locale);
c.setTime(date);
return c;
}
private int getSelectedIndex() {
if (date == null)
return -1;
Calendar bc = getCalendar(baseDate);
Calendar sc = getCalendar(date);
// selectd date visible in base month
if (bc.get(Calendar.ERA) == sc.get(Calendar.ERA)
&& bc.get(Calendar.YEAR) == sc.get(Calendar.YEAR)
&& bc.get(Calendar.MONTH) == sc.get(Calendar.MONTH)) {
bc.set(Calendar.DAY_OF_MONTH, 1);
int skipBefore = bc.get(Calendar.DAY_OF_WEEK)
- bc.getFirstDayOfWeek();
if (skipBefore < 0)
skipBefore = 7 + skipBefore;
int selDay = sc.get(Calendar.DAY_OF_MONTH);
return skipBefore + selDay - 1;
} else
return -1;
}
private void setFocusedByIndex(int i) {
DateLabel label = labels[i];
if (label.isVisible()) {
int day = Integer.parseInt(label.getText());
Calendar c = getCalendar(baseDate);
c.set(Calendar.DAY_OF_MONTH, day);
setFocusDate(c.getTime());
}
}
private int getFocusedIndex() {
Calendar bc = getCalendar(baseDate);
Calendar fc = getCalendar(focusDate);
bc.set(Calendar.DAY_OF_MONTH, 1);
int skipBefore = bc.get(Calendar.DAY_OF_WEEK) - bc.getFirstDayOfWeek();
if (skipBefore < 0)
skipBefore = 7 + skipBefore;
int selDay = fc.get(Calendar.DAY_OF_MONTH);
int maxDay = bc.getActualMaximum(Calendar.DAY_OF_MONTH);
if (selDay > maxDay)
selDay = maxDay;
return skipBefore + selDay - 1;
}
private void reflectData() {
setBackground(isEnabled() ? gridBgEn : gridBgDis);
reflectBaseDate();
reflectSelectedDate();
reflectFocusedDate();
}
private void reflectFocusedDate() {
int focusedIndex = getFocusedIndex();
DateLabel l = labels[focusedIndex];
l.setFocused(isFocusOwner());
}
private void reflectSelectedDate() {
int selIndex = getSelectedIndex();
if (selIndex > -1) {
DateLabel l = labels[selIndex];
l.setSelected(true);
}
}
private void reflectBaseDate() {
Calendar calendar = getCalendar(baseDate);
calendar.set(Calendar.DAY_OF_MONTH, 1);
int skipBefore = calendar.get(Calendar.DAY_OF_WEEK)
- calendar.getFirstDayOfWeek();
if (skipBefore < 0)
skipBefore = 7 + skipBefore;
int activeDays = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
int day = 1;
calendar.setTime(baseDate);
calendar.set(Calendar.DAY_OF_MONTH, 1);
for (int i = 0; i < 42; i++) {
DateLabel l = labels[i];
l.setBackground(isEnabled() ? selBgEn : selBgDis);
l.setSelected(false);
l.setFocused(false);
l.setEnabled(isEnabled());
if (i < skipBefore) {
l.setText("");
l.setVisible(false);
}
if (i >= skipBefore && i < skipBefore + activeDays) {
l.setVisible(true);
l.setText(String.valueOf(day));
if (vetoPolicy != null)
l.setBanned(vetoPolicy.isRestricted(this.peer, calendar));
else
l.setBanned(false);
if (holidayPolicy != null) {
l.setDate(calendar.getTime());
l
.setHolliday(holidayPolicy.isHolliday(this.peer,
calendar));
l.setWeekend(holidayPolicy.isWeekend(this.peer, calendar));
} else {
l.setHolliday(false);
l.setWeekend(false);
}
day++;
calendar.add(Calendar.DAY_OF_MONTH, 1);
}
if (i >= skipBefore + activeDays) {
l.setText("");
l.setVisible(false);
}
}
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
Date old = this.date;
this.date = date;
this.explicitDateSetToNullFlag = date == null ? true : false;
this.focusDate = getFocusDateForDate(date);
if (old != null || date != null)
firePropertyChange(PROPERTY_NAME_DATE, old, date);
reflectData();
}
private Date getFocusDateForDate(Date date) {
if (date == null) {
Calendar c = getCalendar(baseDate);
c.set(Calendar.DAY_OF_MONTH, 1);
return c.getTime();
}
return date;
}
public Locale getLocale() {
return locale;
}
public void setLocale(Locale locale) {
Locale old = this.locale;
this.locale = locale;
firePropertyChange(PROPERTY_NAME_LOCALE, old, locale);
reflectData();
}
public VetoPolicy getVetoPolicy() {
return vetoPolicy;
}
public void setVetoPolicy(VetoPolicy vetoModel) {
VetoPolicy old = this.getVetoPolicy();
this.vetoPolicy = vetoModel;
firePropertyChange(PROPERTY_NAME_VETO_POLICY, old, vetoModel);
reflectData();
}
public HolidayPolicy getHolidayPolicy() {
return holidayPolicy;
}
public void setHolidayPolicy(HolidayPolicy holidayPolicy) {
HolidayPolicy old = this.getHolidayPolicy();
this.holidayPolicy = holidayPolicy;
firePropertyChange(PROPERTY_NAME_HOLIDAY_POLICY, old, holidayPolicy);
reflectData();
}
public TimeZone getZone() {
return zone;
}
public void setZone(TimeZone zone) {
TimeZone old = this.zone;
this.zone = zone;
firePropertyChange(PROPERTY_NAME_ZONE, old, zone);
reflectData();
}
public Collection getFocusableComponents() {
return focusableComponents;
}
class DateLabel extends JLabel {
private Date date;
private int id;
private boolean focused;
private boolean selected;
private boolean weekend;
private boolean banned;
private boolean holliday;
public DateLabel(int id) {
super();
this.id = id;
setHorizontalAlignment(SwingConstants.CENTER);
setFocused(false);
setSelected(false);
setWeekend(false);
setBanned(false);
setHolliday(false);
}
public void setHolliday(boolean b) {
holliday = b;
update();
repaint();
}
public int getId() {
return id;
}
public boolean isFocused() {
return focused;
}
public void setFocused(boolean focused) {
this.focused = focused;
update();
repaint();
}
public boolean isSelected() {
return selected;
}
public void setSelected(boolean selected) {
this.selected = selected;
update();
repaint();
}
private void update() {
// background is determined by selected state
// foreground by the rest
updateBg();
updateFg();
udapteBorder();
// Tooltip:
updateTooltip();
}
private void updateTooltip() {
if (holidayPolicy != null && holliday) {
Calendar c = Calendar.getInstance(zone, locale);
c.setTime(date);
setToolTipText(holidayPolicy.getHollidayName(this, c));
} else
setToolTipText(null);
}
private void udapteBorder() {
if (isFocused() && isEnabled()) {
setBorder(BorderFactory
.createLineBorder(banned ? restrictedColor : focusColor));
} else
setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
}
private void updateFg() {
if (isHolliday()) {
setForeground(isEnabled() ? holFgEn : holFgDis);
} else {
if (isWeekend()) {
setForeground(isEnabled() ? wkFgEn : wkFgDis);
} else {
setForeground(isEnabled() ? gridFgEn : gridFgDis);
}
}
}
private void updateBg() {
if (isSelected()) {
setOpaque(true);
setBackground(isEnabled() ? selBgEn : selBgDis);
} else
setOpaque(false);
}
public boolean isWeekend() {
return weekend;
}
public void setWeekend(boolean weekend) {
this.weekend = weekend;
}
public boolean isBanned() {
return banned;
}
public void setBanned(boolean banned) {
this.banned = banned;
update();
repaint();
}
public void paint(Graphics g) {
if (isBanned()) {
g.setColor(restrictedColor);
// variant 1: full size cross
g.drawLine(2, 2, getWidth() - 4, getHeight() - 4);
g.drawLine(2, getHeight() - 4, getWidth() - 4, 2);
// variant 2: smaller cross (left upper corner)
// g.drawLine(1, 1, 8, 8);
// g.drawLine(1, 8, 8, 1);
}
super.paint(g);
}
public boolean isHolliday() {
return holliday;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
}
public void policyChanged(PolicyEvent event) {
reflectData();
}
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals(PROPERTY_NAME_VETO_POLICY)) {
VetoPolicy oldValue = (VetoPolicy) evt.getOldValue();
VetoPolicy newValue = (VetoPolicy) evt.getOldValue();
if (oldValue != null)
oldValue.removeVetoPolicyListener(this);
if (newValue != null)
newValue.addVetoPolicyListener(this);
reflectData();
}
}
public Date getBaseDate() {
return baseDate;
}
public void setBaseDate(Date baseDate) {
// TODO: throw away the following 2 lines?
// if (baseDate == null)
// baseDate = new Date();
Date old = this.baseDate;
this.baseDate = baseDate;
firePropertyChange(PROPERTY_NAME_BASE_DATE, old, baseDate);
// update focus date
Calendar bc = getCalendar(baseDate);
Calendar fc = getCalendar(focusDate);
int focDate = fc.get(Calendar.DAY_OF_MONTH);
int maxDay = bc.getActualMaximum(Calendar.DAY_OF_MONTH);
if (focDate > maxDay)
focDate = maxDay;
bc.set(Calendar.DAY_OF_MONTH, focDate);
focusDate = bc.getTime();
reflectData();
}
private Date getFocusDate() {
return focusDate;
}
private void setFocusDate(Date focusDate) {
this.focusDate = focusDate;
explicitDateSetToNullFlag = false;
reflectData();
}
public void mouseClicked(MouseEvent e) {
if (!isEnabled())
return;
requestFocusInWindow();
DateLabel l = (DateLabel) e.getSource();
if (l.isVisible()) {
int id = Integer.parseInt(l.getText());
Calendar c = getCalendar(baseDate);
c.set(Calendar.DAY_OF_MONTH, id);
if (vetoPolicy == null || !vetoPolicy.isRestricted(this, c)) {
boolean selected = l.isSelected();
setDate(c.getTime());
if (selected)
firePropertyChange(
PROPERTY_NAME_NOTIFY_SELECTED_DATE_CLICKED, null,
new Integer(id));
}
}
}
public void mousePressed(MouseEvent e) {
}
public void mouseReleased(MouseEvent e) {
}
public void mouseEntered(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
}
public void keyTyped(KeyEvent e) {
}
public void keyPressed(KeyEvent e) {
if (!isEnabled())
return;
int id = getFocusedIndex();
int row = id / 7;
int col = id % 7;
if (e.getKeyCode() == KeyEvent.VK_DOWN) {
row++;
if (row < 6) {
setFocusedByIndex(row * 7 + col);
}
}
if (e.getKeyCode() == KeyEvent.VK_UP) {
row--;
if (row >= 0) {
setFocusedByIndex(row * 7 + col);
}
}
if (e.getKeyCode() == KeyEvent.VK_LEFT) {
col--;
if (col >= 0) {
setFocusedByIndex(row * 7 + col);
}
}
if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
col++;
if (col < 7) {
setFocusedByIndex(row * 7 + col);
}
}
}
public void keyReleased(KeyEvent e) {
}
public Date getDateToCommit() {
Calendar c = getCalendar(focusDate);
if (explicitDateSetToNullFlag
|| (vetoPolicy != null && vetoPolicy.isRestricted(this, c)))
return date;
return focusDate;
}
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
reflectData();
}
}
././@LongLink 0000000 0000000 0000000 00000000157 00000000000 011570 L ustar root root libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/BasicDatePickerUI.java libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/BasicDatePic0000644 0001750 0001750 00000031720 11050305320 032371 0 ustar gregoa gregoa package com.michaelbaranov.microba.calendar.ui.basic;
import java.awt.BorderLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyVetoException;
import java.text.ParseException;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.InputMap;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFormattedTextField;
import javax.swing.JPopupMenu;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.JFormattedTextField.AbstractFormatter;
import javax.swing.plaf.ComponentUI;
import javax.swing.text.DateFormatter;
import javax.swing.text.DefaultFormatterFactory;
import com.michaelbaranov.microba.calendar.CalendarPane;
import com.michaelbaranov.microba.calendar.CalendarResources;
import com.michaelbaranov.microba.calendar.DatePicker;
import com.michaelbaranov.microba.calendar.HolidayPolicy;
import com.michaelbaranov.microba.calendar.VetoPolicy;
import com.michaelbaranov.microba.calendar.resource.Resource;
import com.michaelbaranov.microba.calendar.ui.CalendarPaneUI;
import com.michaelbaranov.microba.calendar.ui.DatePickerUI;
import com.michaelbaranov.microba.common.CommitEvent;
import com.michaelbaranov.microba.common.CommitListener;
public class BasicDatePickerUI extends DatePickerUI implements
PropertyChangeListener {
protected static final String POPUP_KEY = "##BasicVetoDatePickerUI.popup##";
protected DatePicker peer;
protected CalendarPane calendarPane;
protected JButton button;
protected JPopupMenu popup;
protected JFormattedTextField field;
protected ComponentListener componentListener;
public static ComponentUI createUI(JComponent c) {
return new BasicDatePickerUI();
}
public void installUI(JComponent c) {
peer = (DatePicker) c;
installComponents();
istallListeners();
installKeyboardActions();
}
public void uninstallUI(JComponent c) {
uninstallKeyboardActions();
uninstallListeners();
uninstallComponents();
peer = null;
}
protected void installKeyboardActions() {
InputMap input = peer
.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
input.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.ALT_MASK),
POPUP_KEY);
input.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0), POPUP_KEY);
peer.getActionMap().put(POPUP_KEY, new AbstractAction() {
public void actionPerformed(ActionEvent e) {
showPopup(true);
}
});
}
protected void uninstallKeyboardActions() {
InputMap input = peer
.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
input
.remove(KeyStroke.getKeyStroke(KeyEvent.VK_C,
InputEvent.ALT_MASK));
input.remove(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0));
peer.getActionMap().remove(POPUP_KEY);
}
protected void istallListeners() {
peer.addPropertyChangeListener(this);
}
protected void uninstallListeners() {
peer.removePropertyChangeListener(this);
}
protected void uninstallComponents() {
button.removeActionListener(componentListener);
field.removePropertyChangeListener(componentListener);
calendarPane.removePropertyChangeListener(componentListener);
calendarPane.removeCommitListener(componentListener);
calendarPane.removeActionListener(componentListener);
peer.remove(field);
peer.remove(button);
popup = null;
calendarPane = null;
button = null;
field = null;
}
protected void installComponents() {
field = new JFormattedTextField(createFormatterFactory());
field.setValue(peer.getDate());
field.setFocusLostBehavior(peer.getFocusLostBehavior());
field.setEditable(peer.isFieldEditable());
field.setToolTipText(peer.getToolTipText());
// button
button = new JButton();
button.setFocusable(false);
button.setMargin(new Insets(0, 0, 0, 0));
button.setToolTipText(peer.getToolTipText());
setSimpeLook(false);
// calendar
calendarPane = new CalendarPane(peer.getStyle());
calendarPane.setShowTodayButton(peer.isShowTodayButton());
calendarPane.setFocusLostBehavior(JFormattedTextField.REVERT);
calendarPane.setFocusCycleRoot(true);
calendarPane.setBorder(BorderFactory.createEmptyBorder(1, 3, 0, 3));
calendarPane.setStripTime(false);
calendarPane.setLocale(peer.getLocale());
calendarPane.setZone(peer.getZone());
calendarPane.setFocusable(peer.isDropdownFocusable());
calendarPane.setColorOverrideMap(peer.getColorOverrideMap());
// popup
popup = new JPopupMenu();
popup.setLayout(new BorderLayout());
popup.add(calendarPane, BorderLayout.CENTER);
popup.setLightWeightPopupEnabled(true);
// add
peer.setLayout(new BorderLayout());
switch (peer.getPickerStyle()) {
case DatePicker.PICKER_STYLE_FIELD_AND_BUTTON:
peer.add(field, BorderLayout.CENTER);
peer.add(button, BorderLayout.EAST);
break;
case DatePicker.PICKER_STYLE_BUTTON:
peer.add(button, BorderLayout.EAST);
break;
}
peer.revalidate();
peer.repaint();
componentListener = new ComponentListener();
button.addActionListener(componentListener);
field.addPropertyChangeListener(componentListener);
calendarPane.addPropertyChangeListener(componentListener);
calendarPane.addCommitListener(componentListener);
calendarPane.addActionListener(componentListener);
peerDateChanged(peer.getDate());
}
public void setSimpeLook(boolean b) {
if (b) {
field.setBorder(BorderFactory.createEmptyBorder());
button.setText("...");
button.setIcon(null);
} else {
field.setBorder(new JTextField().getBorder());
button.setText("");
button.setIcon(new ImageIcon(Resource.class
.getResource("picker-16.png")));
}
}
public void showPopup(boolean visible) {
if (visible) {
// try to apply date to calendar pane popup, but not cause commit
if (peer.isKeepTime())
try {
AbstractFormatter formatter = field.getFormatter();
Date value = (Date) formatter
.stringToValue(field.getText());
calendarPane
.removePropertyChangeListener(componentListener);
calendarPane.setDate(value);
calendarPane.addPropertyChangeListener(componentListener);
} catch (ParseException e) {
// ignore
} catch (PropertyVetoException e) {
// can not happen
}
popup.show(peer, 0, peer.getHeight());
calendarPane.requestFocus(false);
} else {
popup.setVisible(false);
}
}
public void propertyChange(PropertyChangeEvent evt) {
if (JComponent.TOOL_TIP_TEXT_KEY.equals(evt.getPropertyName())) {
field.setToolTipText((String) evt.getNewValue());
button.setToolTipText((String) evt.getNewValue());
} else if (evt.getPropertyName().equals(DatePicker.PROPERTY_NAME_DATE)) {
Date newValue = (Date) evt.getNewValue();
peerDateChanged(newValue);
} else if (evt.getPropertyName().equals(
DatePicker.PROPERTY_NAME_FIELD_EDITABLE)) {
field.setEditable(peer.isFieldEditable());
} else if (evt.getPropertyName().equals(
DatePicker.PROPERTY_NAME_FOCUS_LOST_BEHAVIOR)) {
field.setFocusLostBehavior(peer.getFocusLostBehavior());
} else if (evt.getPropertyName()
.equals(DatePicker.PROPERTY_NAME_LOCALE)) {
field.setFormatterFactory(createFormatterFactory());
calendarPane.setLocale(peer.getLocale());
} else if (evt.getPropertyName().equals(
DatePicker.PROPERTY_NAME_DATE_FORMAT)) {
field.setFormatterFactory(createFormatterFactory());
} else if (evt.getPropertyName().equals(DatePicker.PROPERTY_NAME_ZONE)) {
field.setFormatterFactory(createFormatterFactory());
calendarPane.setZone((TimeZone) evt.getNewValue());
} else if (evt.getPropertyName().equals(
DatePicker.PROPERTY_NAME_SHOW_TODAY_BTN)) {
boolean value = ((Boolean) evt.getNewValue()).booleanValue();
calendarPane.setShowTodayButton(value);
} else if (evt.getPropertyName().equals(
DatePicker.PROPERTY_NAME_SHOW_NONE_BTN)) {
boolean value = ((Boolean) evt.getNewValue()).booleanValue();
calendarPane.setShowNoneButton(value);
} else if (evt.getPropertyName().equals(
DatePicker.PROPERTY_NAME_SHOW_NUMBER_WEEK)) {
boolean value = ((Boolean) evt.getNewValue()).booleanValue();
calendarPane.setShowNumberOfWeek(value);
} else if (evt.getPropertyName().equals(DatePicker.PROPERTY_NAME_STYLE)) {
int value = ((Integer) evt.getNewValue()).intValue();
calendarPane.setStyle(value);
} else if (evt.getPropertyName().equals(
DatePicker.PROPERTY_NAME_VETO_POLICY)) {
calendarPane.setVetoPolicy((VetoPolicy) evt.getNewValue());
} else if (evt.getPropertyName().equals(
DatePicker.PROPERTY_NAME_HOLIDAY_POLICY)) {
calendarPane.setHolidayPolicy((HolidayPolicy) evt.getNewValue());
} else if (evt.getPropertyName().equals("focusable")) {
boolean value = ((Boolean) evt.getNewValue()).booleanValue();
field.setFocusable(value);
} else if (evt.getPropertyName().equals(
DatePicker.PROPERTY_NAME_RESOURCES)) {
CalendarResources resources = (CalendarResources) evt.getNewValue();
calendarPane.setResources(resources);
} else if (evt.getPropertyName().equals("enabled"/*
* DatePicker.PROPERTY_NAME_ENABLED
*/)) {
boolean value = ((Boolean) evt.getNewValue()).booleanValue();
field.setEnabled(value);
button.setEnabled(value);
} else if (evt.getPropertyName().equals(
DatePicker.PROPERTY_NAME_PICKER_STYLE)) {
peer.updateUI();
} else if (evt.getPropertyName().equals(
DatePicker.PROPERTY_NAME_DROPDOWN_FOCUSABLE)) {
calendarPane.setFocusable(peer.isDropdownFocusable());
}
}
private void peerDateChanged(Date newValue) {
try {
calendarPane.removePropertyChangeListener(componentListener);
calendarPane.setDate(newValue);
calendarPane.addPropertyChangeListener(componentListener);
} catch (PropertyVetoException e) {
// Ignore. CalendarPane has no VetoModel here.
}
field.removePropertyChangeListener(componentListener);
field.setValue(newValue);
field.addPropertyChangeListener(componentListener);
}
private DefaultFormatterFactory createFormatterFactory() {
return new DefaultFormatterFactory(new DateFormatter(peer
.getDateFormat()));
}
protected class ComponentListener implements ActionListener,
PropertyChangeListener, CommitListener {
public void actionPerformed(ActionEvent e) {
if (e.getSource() != calendarPane)
showPopup(true);
else
showPopup(false);
}
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getSource() == calendarPane) {
if (CalendarPane.PROPERTY_NAME_DATE.equals(evt
.getPropertyName())) {
showPopup(false);
Date fieldValue = null;
try {
AbstractFormatter formatter = field.getFormatter();
fieldValue = (Date) formatter.stringToValue(field
.getText());
} catch (ParseException e) {
fieldValue = (Date) field.getValue();
}
if (fieldValue != null || evt.getNewValue() != null) {
if (peer.isKeepTime() && fieldValue != null
&& evt.getNewValue() != null) {
Calendar fieldCal = Calendar.getInstance(peer
.getZone(), peer.getLocale());
fieldCal.setTime(fieldValue);
Calendar valueCal = Calendar.getInstance(peer
.getZone(), peer.getLocale());
valueCal.setTime((Date) evt.getNewValue());
// era
fieldCal.set(Calendar.ERA, valueCal
.get(Calendar.ERA));
// year
fieldCal.set(Calendar.YEAR, valueCal
.get(Calendar.YEAR));
// month
fieldCal.set(Calendar.MONTH, valueCal
.get(Calendar.MONTH));
// date
fieldCal.set(Calendar.DAY_OF_MONTH, valueCal
.get(Calendar.DAY_OF_MONTH));
field.setValue(fieldCal.getTime());
} else
field.setValue((Date) evt.getNewValue());
}
}
}
if (evt.getSource() == field) {
if ("value".equals(evt.getPropertyName())) {
Date value = (Date) field.getValue();
try {
peer.setDate(value);
} catch (PropertyVetoException e) {
field.setValue(peer.getDate());
}
}
}
}
public void commit(CommitEvent action) {
showPopup(false);
if (field.getValue() != null || calendarPane.getDate() != null)
field.setValue(calendarPane.getDate());
}
public void revert(CommitEvent action) {
showPopup(false);
}
}
public void commit() throws PropertyVetoException, ParseException {
field.commitEdit();
}
public void revert() {
peerDateChanged(peer.getDate());
}
public void observeMonth(int year, int month) {
CalendarPaneUI ui = (CalendarPaneUI) calendarPane.getUI();
ui.observeMonth(year, month);
}
}
././@LongLink 0000000 0000000 0000000 00000000160 00000000000 011562 L ustar root root libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/MonthComboBoxModel.java libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/MonthComboBo0000644 0001750 0001750 00000006635 10412660742 032470 0 ustar gregoa gregoa package com.michaelbaranov.microba.calendar.ui.basic;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel;
class MonthComboBoxModel extends AbstractListModel implements
ComboBoxModel {
public static final String PROPERTY_NAME_LOCALE = "locale";
public static final String PROPERTY_NAME_DATE = "date";
private PropertyChangeSupport changeSupport = new PropertyChangeSupport(
this);
private Calendar calendar;
private Locale locale;
private TimeZone zone;
public MonthComboBoxModel(Date date, Locale locale, TimeZone zone) {
super();
this.locale = locale;
this.zone = zone;
createLocaleAndZoneSensitive();
calendar.setTime(date);
}
private void createLocaleAndZoneSensitive() {
if (calendar != null) {
Date old = calendar.getTime();
calendar = Calendar.getInstance(zone, locale);
calendar.setTime(old);
} else
calendar = Calendar.getInstance(zone, locale);
}
public Locale getLocale() {
return locale;
}
public void setLocale(Locale locale) {
Locale old = this.locale;
this.locale = locale;
createLocaleAndZoneSensitive();
changeSupport.firePropertyChange(PROPERTY_NAME_LOCALE, old, locale);
fireContentsChanged(this, 0, getSize() - 1);
}
public Date getDate() {
return calendar.getTime();
}
public void setDate(Date date) {
Date old = getDate();
calendar.setTime(date);
changeSupport.firePropertyChange(PROPERTY_NAME_DATE, old, date);
fireContentsChanged(this, 0, getSize() - 1);
}
public void setSelectedItem(Object anItem) {
Date aDate = (Date) anItem;
setDate(aDate);
}
public Object getSelectedItem() {
return calendar.getTime();
}
public int getSize() {
return calendar.getActualMaximum(Calendar.MONTH) + 1;
}
public Object getElementAt(int index) {
Calendar c = Calendar.getInstance(locale);
c.setTime(calendar.getTime());
c.set(Calendar.MONTH, 0);
for (int i = 0; i < index; i++)
c.add(Calendar.MONTH, 1);
return c.getTime();
}
public TimeZone getZone() {
return zone;
}
public void setZone(TimeZone zone) {
this.zone = zone;
createLocaleAndZoneSensitive();
fireContentsChanged(this, 0, getSize() - 1);
}
public void addPropertyChangeListener(PropertyChangeListener listener) {
changeSupport.addPropertyChangeListener(listener);
}
public void addPropertyChangeListener(String propertyName,
PropertyChangeListener listener) {
changeSupport.addPropertyChangeListener(propertyName, listener);
}
public PropertyChangeListener[] getPropertyChangeListeners() {
return changeSupport.getPropertyChangeListeners();
}
public PropertyChangeListener[] getPropertyChangeListeners(
String propertyName) {
return changeSupport.getPropertyChangeListeners(propertyName);
}
public boolean hasListeners(String propertyName) {
return changeSupport.hasListeners(propertyName);
}
public void removePropertyChangeListener(PropertyChangeListener listener) {
changeSupport.removePropertyChangeListener(listener);
}
public void removePropertyChangeListener(String propertyName,
PropertyChangeListener listener) {
changeSupport.removePropertyChangeListener(propertyName, listener);
}
}
././@LongLink 0000000 0000000 0000000 00000000157 00000000000 011570 L ustar root root libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/NoGroupingSpinner.java libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/NoGroupingSp0000644 0001750 0001750 00000002200 10412660742 032514 0 ustar gregoa gregoa package com.michaelbaranov.microba.calendar.ui.basic;
import java.text.NumberFormat;
import javax.swing.JComponent;
import javax.swing.JFormattedTextField;
import javax.swing.JSpinner;
import javax.swing.SpinnerModel;
import javax.swing.SpinnerNumberModel;
import javax.swing.text.DefaultFormatterFactory;
import javax.swing.text.NumberFormatter;
class NoGroupingSpinner extends JSpinner {
public static class NoGroupingNumberEditor extends NumberEditor {
public NoGroupingNumberEditor(JSpinner spinner, SpinnerModel model) {
super(spinner);
JFormattedTextField ftf = (JFormattedTextField) this
.getComponent(0);
NumberFormat fmt = NumberFormat.getIntegerInstance();
fmt.setGroupingUsed(false);
ftf.setFormatterFactory(new DefaultFormatterFactory(
new NumberFormatter(fmt)));
revalidate();
}
}
public NoGroupingSpinner(SpinnerModel spinnerModel) {
super(spinnerModel);
}
protected JComponent createEditor(SpinnerModel model) {
if (model instanceof SpinnerNumberModel)
return new NoGroupingNumberEditor(this, model);
return super.createEditor(model);
}
}
././@LongLink 0000000 0000000 0000000 00000000161 00000000000 011563 L ustar root root libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/ModernCalendarPanel.java libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/ModernCalend0000644 0001750 0001750 00000011624 11050603744 032465 0 ustar gregoa gregoa package com.michaelbaranov.microba.calendar.ui.basic;
import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import java.util.TimeZone;
import javax.swing.JComboBox;
import javax.swing.JPanel;
class ModernCalendarPanel extends JPanel implements PropertyChangeListener {
public static final String PROPERTY_NAME_DATE = "date";
public static final String PROPERTY_NAME_LOCALE = "locale";
public static final String PROPERTY_NAME_ZONE = "zone";
private Date date;
private Locale locale;
private TimeZone zone;
private YearSpinnerModel yearSpinnerModel;
private NoGroupingSpinner yearSpinner;
private MonthComboBoxModel monthComboBoxModel;
private MonthComboBoxRenderer monthComboBoxRenderer;
private JComboBox monthCombo;
private Set focusableComponents = new HashSet();
public ModernCalendarPanel(Date aDate, Locale aLocale, TimeZone zone) {
this.date = aDate;
this.locale = aLocale;
this.zone = zone;
monthComboBoxModel = new MonthComboBoxModel(aDate, aLocale, zone);
monthComboBoxRenderer = new MonthComboBoxRenderer(aLocale, zone);
monthCombo = new JComboBox(monthComboBoxModel);
monthCombo.setRenderer(monthComboBoxRenderer);
yearSpinnerModel = new YearSpinnerModel(aDate, aLocale, zone);
yearSpinner = new NoGroupingSpinner(yearSpinnerModel);
setLayout(new GridBagLayout());
add(monthCombo, new GridBagConstraints(0, 0, 1, 1, 1.0, 0,
GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0,
0, 3, 0), 0, 0));
add(yearSpinner, new GridBagConstraints(1, 0, 1, 1, 0, 0,
GridBagConstraints.EAST, GridBagConstraints.VERTICAL,
new Insets(0, 3, 3, 0), 0, 0));
focusableComponents.add(yearSpinner);
focusableComponents.add(monthCombo);
monthComboBoxModel
.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals(
MonthComboBoxModel.PROPERTY_NAME_DATE)) {
Date newDate = (Date) evt.getNewValue();
setDate(newDate);
}
}
});
yearSpinnerModel
.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals(
YearSpinnerModel.PROPERTY_NAME_DATE)) {
Date newDate = (Date) evt.getNewValue();
setDate(newDate);
}
}
});
this.addPropertyChangeListener(this);
}
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
monthCombo.setEnabled(enabled);
yearSpinner.setEnabled(enabled);
}
public void setFocusable(boolean focusable) {
super.setFocusable(focusable);
monthCombo.setFocusable(focusable);
yearSpinner.setFocusable(focusable);
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
Date oldDate = this.date;
this.date = date;
firePropertyChange(PROPERTY_NAME_DATE, oldDate, date);
monthComboBoxModel.setDate(date);
yearSpinnerModel.setDate(date);
}
public Locale getLocale() {
return locale;
}
public void setLocale(Locale locale) {
Locale old = this.locale;
this.locale = locale;
monthComboBoxRenderer.setLocale(locale);
monthComboBoxModel.setLocale(locale);
yearSpinnerModel.setLocale(locale);
firePropertyChange(PROPERTY_NAME_LOCALE, old, locale);
}
public Collection getFocusableComponents() {
return focusableComponents;
}
public TimeZone getZone() {
return zone;
}
public void setZone(TimeZone zone) {
TimeZone old = this.zone;
this.zone = zone;
monthComboBoxRenderer.setZone(zone);
monthComboBoxModel.setZone(zone);
yearSpinnerModel.setZone(zone);
firePropertyChange(PROPERTY_NAME_ZONE, old, zone);
}
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("focusable")) {
boolean value = ((Boolean) evt.getNewValue()).booleanValue();
yearSpinner.setFocusable(value);
Component children[] = yearSpinner.getEditor().getComponents();
for (int i = 0; i < children.length; i++)
children[i].setFocusable(value);
monthCombo.setFocusable(value);
}
if (evt.getPropertyName().equals("enabled")) {
boolean value = ((Boolean) evt.getNewValue()).booleanValue();
yearSpinner.setEnabled(value);
monthCombo.setEnabled(value);
}
}
public void goToMonth(int year, int month) {
Date date = getDate();
Calendar calendar = Calendar.getInstance(zone,locale);
calendar.setTime(date);
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month);
setDate(calendar.getTime());
}
}
././@LongLink 0000000 0000000 0000000 00000000163 00000000000 011565 L ustar root root libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/MonthComboBoxRenderer.java libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/MonthComboBo0000644 0001750 0001750 00000002503 10412660742 032456 0 ustar gregoa gregoa package com.michaelbaranov.microba.calendar.ui.basic;
import java.awt.Component;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JList;
class MonthComboBoxRenderer extends DefaultListCellRenderer {
// private Locale locale;
private TimeZone zone;
private SimpleDateFormat dateFormat;
public MonthComboBoxRenderer(Locale locale, TimeZone zone) {
// this.locale = locale;
this.zone = zone;
dateFormat = new SimpleDateFormat("MMMM", locale);
dateFormat.setTimeZone(zone);
}
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected,
cellHasFocus);
Date date = (Date) value;
setText(dateFormat.format(date));
return this;
}
public void setLocale(Locale locale) {
// this.locale = locale;
dateFormat = new SimpleDateFormat("MMMM", locale);
dateFormat.setTimeZone(zone);
}
public void setZone(TimeZone zone) {
this.zone = zone;
dateFormat.setTimeZone(zone);
}
// public Locale getLocale() {
// return locale;
// }
//
// public TimeZone getZone() {
// return zone;
// }
}
././@LongLink 0000000 0000000 0000000 00000000146 00000000000 011566 L ustar root root libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/AuxPanel.java libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/AuxPanel.jav0000644 0001750 0001750 00000014626 10502757464 032445 0 ustar gregoa gregoa package com.michaelbaranov.microba.calendar.ui.basic;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import java.util.TimeZone;
import javax.swing.JButton;
import javax.swing.JPanel;
import com.michaelbaranov.microba.calendar.CalendarResources;
import com.michaelbaranov.microba.calendar.VetoPolicy;
import com.michaelbaranov.microba.common.PolicyEvent;
import com.michaelbaranov.microba.common.PolicyListener;
class AuxPanel extends JPanel implements PropertyChangeListener, PolicyListener {
public static final String PROPERTY_NAME_LOCALE = "locale";
public static final String PROPERTY_NAME_DATE = "date";
public static final String PROPERTY_NAME_ZONE = "zone";
public static final String PROPERTY_NAME_RESOURCES = "resources";
public static final String PROPERTY_NAME_VETO_MODEL = "vetoModel";
private Locale locale;
private TimeZone zone;
private JButton todayButton;
private JButton noneButton;
private DateFormat fullDateFormat;
private Date currentDate;
private Set focusableComponents = new HashSet();
private VetoPolicy vetoModel;
private boolean showTodayBtn;
private CalendarResources resources;
private boolean showNoneButton;
public AuxPanel(Locale locale, TimeZone zone, VetoPolicy vetoModel,
boolean showTodayBtn, boolean showNoneButton,
CalendarResources resources) {
this.locale = locale;
this.zone = zone;
this.vetoModel = vetoModel;
this.showTodayBtn = showTodayBtn;
this.showNoneButton = showNoneButton;
this.resources = resources;
if (vetoModel != null)
vetoModel.addVetoPolicyListener(this);
setLayout(new GridBagLayout());
todayButton = new JButton();
todayButton.setBorderPainted(false);
todayButton.setContentAreaFilled(false);
todayButton.setVisible(showTodayBtn);
noneButton = new JButton();
noneButton.setBorderPainted(false);
noneButton.setContentAreaFilled(false);
noneButton.setVisible(showNoneButton);
add(todayButton, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0,
GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,
0, 0, 0), 0, 0));
add(noneButton, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0,
GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0,
0, 0, 0), 0, 0));
currentDate = new Date();
validateAgainstVeto();
createLocaleAndZoneSensitive();
reflectData();
todayButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
currentDate = new Date();
firePropertyChange(PROPERTY_NAME_DATE, null, currentDate);
}
});
noneButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
firePropertyChange(PROPERTY_NAME_DATE, null, null);
}
});
focusableComponents.add(todayButton);
this.addPropertyChangeListener(this);
// Timer timer = new Timer(true);
// timer.schedule(new TimerTask() {
//
// public void run() {
// currentDate = new Date();
// validateAgainstVeto();
// }
// }, 0, 60000);
}
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("focusable")) {
Boolean value = (Boolean) evt.getNewValue();
todayButton.setFocusable(value.booleanValue());
noneButton.setFocusable(value.booleanValue());
}
if (evt.getPropertyName().equals("enabled")) {
Boolean value = (Boolean) evt.getNewValue();
todayButton.setEnabled(value.booleanValue());
noneButton.setEnabled(value.booleanValue());
}
if (evt.getPropertyName().equals(PROPERTY_NAME_VETO_MODEL)) {
VetoPolicy oldValue = (VetoPolicy) evt.getOldValue();
VetoPolicy newValue = (VetoPolicy) evt.getOldValue();
if (oldValue != null)
oldValue.removeVetoPolicyListener(this);
if (newValue != null)
newValue.addVetoPolicyListener(this);
validateAgainstVeto();
}
}
private void createLocaleAndZoneSensitive() {
fullDateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, locale);
fullDateFormat.setTimeZone(zone);
}
private void reflectData() {
String today = resources.getResource(CalendarResources.KEY_TODAY,
locale);
String none = resources.getResource(CalendarResources.KEY_NONE, locale);
todayButton.setText(today + ": " + fullDateFormat.format(currentDate));
noneButton.setText(none);
}
public Locale getLocale() {
return locale;
}
public void setLocale(Locale locale) {
Locale old = this.locale;
this.locale = locale;
firePropertyChange(PROPERTY_NAME_LOCALE, old, locale);
createLocaleAndZoneSensitive();
reflectData();
}
public Collection getFocusableComponents() {
return focusableComponents;
}
public TimeZone getZone() {
return zone;
}
public void setZone(TimeZone zone) {
this.zone = zone;
createLocaleAndZoneSensitive();
reflectData();
}
public Date getDate() {
return currentDate;
}
public VetoPolicy getVetoModel() {
return vetoModel;
}
public void setVetoModel(VetoPolicy vetoModel) {
VetoPolicy old = this.vetoModel;
this.vetoModel = vetoModel;
firePropertyChange(PROPERTY_NAME_VETO_MODEL, old, vetoModel);
}
public void policyChanged(PolicyEvent event) {
validateAgainstVeto();
}
private void validateAgainstVeto() {
Calendar c = Calendar.getInstance(zone, locale);
c.setTime(currentDate);
if (vetoModel != null) {
todayButton.setEnabled(!vetoModel.isRestricted(this, c));
noneButton.setEnabled(!vetoModel.isRestrictNull(this));
} else {
todayButton.setEnabled(this.isEnabled());
noneButton.setEnabled(this.isEnabled());
}
}
public void setShowTodayBtn(boolean value) {
showTodayBtn = value;
todayButton.setVisible(showTodayBtn);
}
public void setResources(CalendarResources resources) {
CalendarResources old = this.resources;
this.resources = resources;
firePropertyChange(PROPERTY_NAME_RESOURCES, old, resources);
reflectData();
}
public void setShowNoneButton(boolean value) {
showNoneButton = value;
noneButton.setVisible(showNoneButton);
}
}
libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/resource/ 0000755 0001750 0001750 00000000000 10634142132 030330 5 ustar gregoa gregoa ././@LongLink 0000000 0000000 0000000 00000000147 00000000000 011567 L ustar root root libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/resource/forward-16.png libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/resource/forward-16.p0000644 0001750 0001750 00000000263 10412660742 032410 0 ustar gregoa gregoa PNG
IHDR (-S gAMA 7 tEXtSoftware Adobe ImageReadyqe<