Compare commits
3 Commits
53a9af372c
...
7b35c56dcf
Author | SHA1 | Date |
---|---|---|
|
7b35c56dcf | 7 months ago |
|
afb644a5ad | 7 months ago |
|
cdffc110ed | 7 months ago |
@ -1 +0,0 @@
|
||||
/com/
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1 @@
|
||||
LD6_NewProdForm.FORMJAVARENDERING=com.langtech.plm.form.LD6_NewProdForm
|
@ -0,0 +1,699 @@
|
||||
package com.langtech.plm.project;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.Point;
|
||||
import java.awt.Polygon;
|
||||
import java.awt.Stroke;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.event.MouseMotionListener;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.Popup;
|
||||
import javax.swing.PopupFactory;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.event.AncestorEvent;
|
||||
import javax.swing.event.AncestorListener;
|
||||
|
||||
public class DateChooser extends JPanel {
|
||||
private static final long serialVersionUID = 4529266044762990227L;
|
||||
private Date initDate;
|
||||
private Calendar now;
|
||||
private Calendar select;
|
||||
private JPanel monthPanel;
|
||||
private DateChooser.JP1 jp1;
|
||||
private DateChooser.JP2 jp2;
|
||||
private DateChooser.JP3 jp3;
|
||||
private DateChooser.JP4 jp4;
|
||||
private Font font;
|
||||
private final DateChooser.LabelManager lm;
|
||||
private SimpleDateFormat sdf;
|
||||
private boolean isShow;
|
||||
private Popup pop;
|
||||
private JComponent showDate;
|
||||
|
||||
public static DateChooser getInstance() {
|
||||
return new DateChooser();
|
||||
|
||||
}
|
||||
|
||||
public static DateChooser getInstance(Date date) {
|
||||
return new DateChooser(date);
|
||||
}
|
||||
|
||||
public static DateChooser getInstance(String format) {
|
||||
return new DateChooser(format);
|
||||
}
|
||||
|
||||
public static DateChooser getInstance(Date date, String format) {
|
||||
return new DateChooser(date, format);
|
||||
}
|
||||
|
||||
DateChooser() {
|
||||
this(new Date());
|
||||
}
|
||||
|
||||
private DateChooser(Date date) {
|
||||
this(date, "yyyy年MM月dd日");
|
||||
}
|
||||
|
||||
private DateChooser(String format) {
|
||||
this(new Date(), format);
|
||||
}
|
||||
|
||||
private DateChooser(Date date, String format) {
|
||||
this.now = Calendar.getInstance();
|
||||
this.font = new Font("宋体", 0, 12);
|
||||
this.lm = new DateChooser.LabelManager();
|
||||
this.isShow = false;
|
||||
this.initDate = date;
|
||||
this.sdf = new SimpleDateFormat(format);
|
||||
this.select = Calendar.getInstance();
|
||||
this.select.setTime(this.initDate);
|
||||
this.initPanel();
|
||||
}
|
||||
|
||||
public void setEnabled(boolean b) {
|
||||
super.setEnabled(b);
|
||||
this.showDate.setEnabled(b);
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return this.select.getTime();
|
||||
}
|
||||
|
||||
public String getStrDate() {
|
||||
return this.sdf.format(this.select.getTime());
|
||||
}
|
||||
|
||||
public String getStrDate(String format) {
|
||||
this.sdf = new SimpleDateFormat(format);
|
||||
return this.sdf.format(this.select.getTime());
|
||||
}
|
||||
|
||||
private void initPanel() {
|
||||
this.monthPanel = new JPanel(new BorderLayout());
|
||||
this.monthPanel.setBorder(BorderFactory.createLineBorder(Color.BLUE));
|
||||
JPanel up = new JPanel(new BorderLayout());
|
||||
up.add(this.jp1 = new DateChooser.JP1(), "North");
|
||||
up.add(this.jp2 = new DateChooser.JP2(), "Center");
|
||||
this.monthPanel.add(this.jp3 = new DateChooser.JP3(), "Center");
|
||||
this.monthPanel.add(up, "North");
|
||||
this.monthPanel.add(this.jp4 = new DateChooser.JP4(), "South");
|
||||
this.addAncestorListener(new AncestorListener() {
|
||||
public void ancestorAdded(AncestorEvent event) {
|
||||
}
|
||||
|
||||
public void ancestorRemoved(AncestorEvent event) {
|
||||
}
|
||||
|
||||
public void ancestorMoved(AncestorEvent event) {
|
||||
DateChooser.this.hidePanel();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void register(final JComponent showDate) {
|
||||
this.showDate = showDate;
|
||||
showDate.setRequestFocusEnabled(true);
|
||||
showDate.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent me) {
|
||||
showDate.requestFocusInWindow();
|
||||
}
|
||||
});
|
||||
this.setBackground(Color.WHITE);
|
||||
this.add(showDate, "Center");
|
||||
this.setPreferredSize(new Dimension(90, 25));
|
||||
this.setBorder(BorderFactory.createLineBorder(Color.GRAY));
|
||||
showDate.addMouseListener(new MouseAdapter() {
|
||||
public void mouseEntered(MouseEvent me) {
|
||||
if (showDate.isEnabled()) {
|
||||
showDate.setCursor(new Cursor(12));
|
||||
showDate.setForeground(Color.RED);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent me) {
|
||||
if (showDate.isEnabled()) {
|
||||
showDate.setCursor(new Cursor(0));
|
||||
showDate.setForeground(Color.BLACK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent me) {
|
||||
if (showDate.isEnabled()) {
|
||||
showDate.setForeground(Color.CYAN);
|
||||
if (DateChooser.this.isShow) {
|
||||
DateChooser.this.hidePanel();
|
||||
} else {
|
||||
DateChooser.this.showPanel(showDate);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent me) {
|
||||
if (showDate.isEnabled()) {
|
||||
showDate.setForeground(Color.BLACK);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
showDate.addFocusListener(new FocusListener() {
|
||||
public void focusLost(FocusEvent e) {
|
||||
DateChooser.this.hidePanel();
|
||||
}
|
||||
|
||||
public void focusGained(FocusEvent e) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void refresh() {
|
||||
this.jp1.updateDate();
|
||||
this.jp2.updateDate();
|
||||
this.jp3.updateDate();
|
||||
this.jp4.updateDate();
|
||||
SwingUtilities.updateComponentTreeUI(this);
|
||||
}
|
||||
|
||||
private void commit() {
|
||||
if (this.showDate instanceof JTextField) {
|
||||
((JTextField) this.showDate).setText(this.sdf.format(this.select.getTime()));
|
||||
} else if (this.showDate instanceof JLabel) {
|
||||
((JLabel) this.showDate).setText(this.sdf.format(this.select.getTime()));
|
||||
}
|
||||
|
||||
this.hidePanel();
|
||||
}
|
||||
|
||||
private void hidePanel() {
|
||||
if (this.pop != null) {
|
||||
this.isShow = false;
|
||||
this.pop.hide();
|
||||
this.pop = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void showPanel(Component owner) {
|
||||
if (this.pop != null) {
|
||||
this.pop.hide();
|
||||
}
|
||||
|
||||
Point show = new Point(0, this.showDate.getHeight());
|
||||
SwingUtilities.convertPointToScreen(show, this.showDate);
|
||||
Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
int x = show.x;
|
||||
int y = show.y;
|
||||
if (x < 0) {
|
||||
x = 0;
|
||||
}
|
||||
|
||||
if (x > size.width - 295) {
|
||||
x = size.width - 295;
|
||||
}
|
||||
|
||||
if (y >= size.height - 170) {
|
||||
y -= 188;
|
||||
}
|
||||
|
||||
this.pop = PopupFactory.getSharedInstance().getPopup(owner, this.monthPanel, x, y);
|
||||
this.pop.show();
|
||||
this.isShow = true;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
DateChooser dateChooser1 = getInstance("yyyy-MM-dd HH:mm");
|
||||
DateChooser dateChooser2 = getInstance("yyyy-MM-dd");
|
||||
JTextField showDate1 = new JTextField("单击选择日期");
|
||||
JLabel showDate2 = new JLabel("单击选择日期");
|
||||
dateChooser1.register(showDate1);
|
||||
dateChooser2.register(showDate2);
|
||||
JFrame jf = new JFrame("测试日期选择器");
|
||||
jf.add(showDate1, "North");
|
||||
jf.add(showDate2, "South");
|
||||
jf.pack();
|
||||
jf.setLocationRelativeTo((Component) null);
|
||||
jf.setVisible(true);
|
||||
jf.setDefaultCloseOperation(3);
|
||||
}
|
||||
|
||||
private class JP1 extends JPanel {
|
||||
private static final long serialVersionUID = -5638853772805561174L;
|
||||
JLabel yearleft;
|
||||
JLabel yearright;
|
||||
JLabel monthleft;
|
||||
JLabel monthright;
|
||||
JLabel center;
|
||||
JLabel centercontainer;
|
||||
|
||||
public JP1() {
|
||||
super(new BorderLayout());
|
||||
this.setBackground(new Color(160, 185, 215));
|
||||
this.initJP1();
|
||||
}
|
||||
|
||||
private void initJP1() {
|
||||
this.yearleft = new JLabel(" <<", 0);
|
||||
this.yearleft.setToolTipText("上一年");
|
||||
this.yearright = new JLabel(">> ", 0);
|
||||
this.yearright.setToolTipText("下一年");
|
||||
this.yearleft.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));
|
||||
this.yearright.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));
|
||||
this.monthleft = new JLabel(" <", 4);
|
||||
this.monthleft.setToolTipText("上一月");
|
||||
this.monthright = new JLabel("> ", 2);
|
||||
this.monthright.setToolTipText("下一月");
|
||||
this.monthleft.setBorder(BorderFactory.createEmptyBorder(2, 30, 0, 0));
|
||||
this.monthright.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 30));
|
||||
this.centercontainer = new JLabel("", 0);
|
||||
this.centercontainer.setLayout(new BorderLayout());
|
||||
this.center = new JLabel("", 0);
|
||||
this.centercontainer.add(this.monthleft, "West");
|
||||
this.centercontainer.add(this.center, "Center");
|
||||
this.centercontainer.add(this.monthright, "East");
|
||||
this.add(this.yearleft, "West");
|
||||
this.add(this.centercontainer, "Center");
|
||||
this.add(this.yearright, "East");
|
||||
this.setPreferredSize(new Dimension(295, 25));
|
||||
this.updateDate();
|
||||
this.yearleft.addMouseListener(new MouseAdapter() {
|
||||
public void mouseEntered(MouseEvent me) {
|
||||
JP1.this.yearleft.setCursor(new Cursor(12));
|
||||
JP1.this.yearleft.setForeground(Color.RED);
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent me) {
|
||||
JP1.this.yearleft.setCursor(new Cursor(0));
|
||||
JP1.this.yearleft.setForeground(Color.BLACK);
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent me) {
|
||||
DateChooser.this.select.add(1, -1);
|
||||
JP1.this.yearleft.setForeground(Color.WHITE);
|
||||
DateChooser.this.refresh();
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent me) {
|
||||
JP1.this.yearleft.setForeground(Color.BLACK);
|
||||
}
|
||||
});
|
||||
this.yearright.addMouseListener(new MouseAdapter() {
|
||||
public void mouseEntered(MouseEvent me) {
|
||||
JP1.this.yearright.setCursor(new Cursor(12));
|
||||
JP1.this.yearright.setForeground(Color.RED);
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent me) {
|
||||
JP1.this.yearright.setCursor(new Cursor(0));
|
||||
JP1.this.yearright.setForeground(Color.BLACK);
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent me) {
|
||||
DateChooser.this.select.add(1, 1);
|
||||
JP1.this.yearright.setForeground(Color.WHITE);
|
||||
DateChooser.this.refresh();
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent me) {
|
||||
JP1.this.yearright.setForeground(Color.BLACK);
|
||||
}
|
||||
});
|
||||
this.monthleft.addMouseListener(new MouseAdapter() {
|
||||
public void mouseEntered(MouseEvent me) {
|
||||
JP1.this.monthleft.setCursor(new Cursor(12));
|
||||
JP1.this.monthleft.setForeground(Color.RED);
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent me) {
|
||||
JP1.this.monthleft.setCursor(new Cursor(0));
|
||||
JP1.this.monthleft.setForeground(Color.BLACK);
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent me) {
|
||||
DateChooser.this.select.add(2, -1);
|
||||
JP1.this.monthleft.setForeground(Color.WHITE);
|
||||
DateChooser.this.refresh();
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent me) {
|
||||
JP1.this.monthleft.setForeground(Color.BLACK);
|
||||
}
|
||||
});
|
||||
this.monthright.addMouseListener(new MouseAdapter() {
|
||||
public void mouseEntered(MouseEvent me) {
|
||||
JP1.this.monthright.setCursor(new Cursor(12));
|
||||
JP1.this.monthright.setForeground(Color.RED);
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent me) {
|
||||
JP1.this.monthright.setCursor(new Cursor(0));
|
||||
JP1.this.monthright.setForeground(Color.BLACK);
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent me) {
|
||||
DateChooser.this.select.add(2, 1);
|
||||
JP1.this.monthright.setForeground(Color.WHITE);
|
||||
DateChooser.this.refresh();
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent me) {
|
||||
JP1.this.monthright.setForeground(Color.BLACK);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateDate() {
|
||||
this.center.setText(DateChooser.this.select.get(1) + "年" + (DateChooser.this.select.get(2) + 1) + "月");
|
||||
}
|
||||
}
|
||||
|
||||
private class JP2 extends JPanel {
|
||||
private static final long serialVersionUID = -8176264838786175724L;
|
||||
|
||||
public JP2() {
|
||||
this.setPreferredSize(new Dimension(295, 20));
|
||||
}
|
||||
|
||||
protected void paintComponent(Graphics g) {
|
||||
g.setFont(DateChooser.this.font);
|
||||
g.drawString("星期日 星期一 星期二 星期三 星期四 星期五 星期六", 5, 10);
|
||||
g.drawLine(0, 15, this.getWidth(), 15);
|
||||
}
|
||||
|
||||
private void updateDate() {
|
||||
}
|
||||
}
|
||||
|
||||
private class JP3 extends JPanel {
|
||||
private static final long serialVersionUID = 43157272447522985L;
|
||||
|
||||
public JP3() {
|
||||
super(new GridLayout(6, 7));
|
||||
this.setPreferredSize(new Dimension(295, 100));
|
||||
this.initJP3();
|
||||
}
|
||||
|
||||
private void initJP3() {
|
||||
this.updateDate();
|
||||
}
|
||||
|
||||
public void updateDate() {
|
||||
this.removeAll();
|
||||
DateChooser.this.lm.clear();
|
||||
Date temp = DateChooser.this.select.getTime();
|
||||
Calendar select = Calendar.getInstance();
|
||||
select.setTime(temp);
|
||||
select.set(5, 1);
|
||||
int index = select.get(7);
|
||||
int sum = index == 1 ? 8 : index;
|
||||
select.add(5, 0 - sum);
|
||||
|
||||
for (int i = 0; i < 42; ++i) {
|
||||
select.add(5, 1);
|
||||
DateChooser.this.lm.addLabel(DateChooser.this.new MyLabel(select.get(1), select.get(2), select.get(5)));
|
||||
}
|
||||
|
||||
Iterator var6 = DateChooser.this.lm.getLabels().iterator();
|
||||
|
||||
while (var6.hasNext()) {
|
||||
DateChooser.MyLabel my = (DateChooser.MyLabel) var6.next();
|
||||
this.add(my);
|
||||
}
|
||||
|
||||
select.setTime(temp);
|
||||
}
|
||||
}
|
||||
|
||||
private class JP4 extends JPanel {
|
||||
private static final long serialVersionUID = -6391305687575714469L;
|
||||
|
||||
public JP4() {
|
||||
super(new BorderLayout());
|
||||
this.setPreferredSize(new Dimension(295, 20));
|
||||
this.setBackground(new Color(160, 185, 215));
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
|
||||
final JLabel jl = new JLabel("今天: " + sdf.format(new Date()));
|
||||
jl.setToolTipText("点击选择今天日期");
|
||||
this.add(jl, "Center");
|
||||
jl.addMouseListener(new MouseAdapter() {
|
||||
public void mouseEntered(MouseEvent me) {
|
||||
jl.setCursor(new Cursor(12));
|
||||
jl.setForeground(Color.RED);
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent me) {
|
||||
jl.setCursor(new Cursor(0));
|
||||
jl.setForeground(Color.BLACK);
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent me) {
|
||||
jl.setForeground(Color.WHITE);
|
||||
DateChooser.this.select.setTime(new Date());
|
||||
DateChooser.this.refresh();
|
||||
DateChooser.this.commit();
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent me) {
|
||||
jl.setForeground(Color.BLACK);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateDate() {
|
||||
}
|
||||
}
|
||||
|
||||
private class LabelManager {
|
||||
private List<DateChooser.MyLabel> list = new ArrayList();
|
||||
|
||||
public LabelManager() {
|
||||
}
|
||||
|
||||
public List<DateChooser.MyLabel> getLabels() {
|
||||
return this.list;
|
||||
}
|
||||
|
||||
public void addLabel(DateChooser.MyLabel my) {
|
||||
this.list.add(my);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
this.list.clear();
|
||||
}
|
||||
|
||||
public void setSelect(DateChooser.MyLabel my, boolean b) {
|
||||
Iterator var4 = this.list.iterator();
|
||||
|
||||
while (var4.hasNext()) {
|
||||
DateChooser.MyLabel m = (DateChooser.MyLabel) var4.next();
|
||||
if (m.equals(my)) {
|
||||
m.setSelected(true, b);
|
||||
} else {
|
||||
m.setSelected(false, b);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setSelect(Point p, boolean b) {
|
||||
if (b) {
|
||||
boolean findPrevious = false;
|
||||
boolean findNext = false;
|
||||
Iterator var6 = this.list.iterator();
|
||||
|
||||
while (var6.hasNext()) {
|
||||
DateChooser.MyLabel mx = (DateChooser.MyLabel) var6.next();
|
||||
if (mx.contains(p)) {
|
||||
findNext = true;
|
||||
if (mx.getIsSelected()) {
|
||||
findPrevious = true;
|
||||
} else {
|
||||
mx.setSelected(true, b);
|
||||
}
|
||||
} else if (mx.getIsSelected()) {
|
||||
findPrevious = true;
|
||||
mx.setSelected(false, b);
|
||||
}
|
||||
|
||||
if (findPrevious && findNext) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
DateChooser.MyLabel temp = null;
|
||||
Iterator var9 = this.list.iterator();
|
||||
|
||||
while (var9.hasNext()) {
|
||||
DateChooser.MyLabel m = (DateChooser.MyLabel) var9.next();
|
||||
if (m.contains(p)) {
|
||||
temp = m;
|
||||
} else if (m.getIsSelected()) {
|
||||
m.setSelected(false, b);
|
||||
}
|
||||
}
|
||||
|
||||
if (temp != null) {
|
||||
temp.setSelected(true, b);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private class MyLabel extends JLabel
|
||||
implements Comparator<DateChooser.MyLabel>, MouseListener, MouseMotionListener {
|
||||
private static final long serialVersionUID = 3668734399227577214L;
|
||||
private int year;
|
||||
private int month;
|
||||
private int day;
|
||||
private boolean isSelected;
|
||||
|
||||
public MyLabel(int year, int month, int day) {
|
||||
super("" + day, 0);
|
||||
this.year = year;
|
||||
this.day = day;
|
||||
this.month = month;
|
||||
this.addMouseListener(this);
|
||||
this.addMouseMotionListener(this);
|
||||
this.setFont(DateChooser.this.font);
|
||||
if (month == DateChooser.this.select.get(2)) {
|
||||
this.setForeground(Color.BLACK);
|
||||
} else {
|
||||
this.setForeground(Color.LIGHT_GRAY);
|
||||
}
|
||||
|
||||
if (day == DateChooser.this.select.get(5)) {
|
||||
this.setBackground(new Color(160, 185, 215));
|
||||
} else {
|
||||
this.setBackground(Color.WHITE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean getIsSelected() {
|
||||
return this.isSelected;
|
||||
}
|
||||
|
||||
public void setSelected(boolean b, boolean isDrag) {
|
||||
this.isSelected = b;
|
||||
if (b && !isDrag) {
|
||||
int temp = DateChooser.this.select.get(2);
|
||||
DateChooser.this.select.set(this.year, this.month, this.day);
|
||||
if (temp == this.month) {
|
||||
SwingUtilities.updateComponentTreeUI(DateChooser.this.jp3);
|
||||
} else {
|
||||
DateChooser.this.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
protected void paintComponent(Graphics g) {
|
||||
if (this.day == DateChooser.this.select.get(5) && this.month == DateChooser.this.select.get(2)) {
|
||||
g.setColor(new Color(160, 185, 215));
|
||||
g.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||
}
|
||||
|
||||
if (this.year == DateChooser.this.now.get(1) && this.month == DateChooser.this.now.get(2)
|
||||
&& this.day == DateChooser.this.now.get(5)) {
|
||||
Graphics2D gdx = (Graphics2D) g;
|
||||
gdx.setColor(Color.RED);
|
||||
Polygon p = new Polygon();
|
||||
p.addPoint(0, 0);
|
||||
p.addPoint(this.getWidth() - 1, 0);
|
||||
p.addPoint(this.getWidth() - 1, this.getHeight() - 1);
|
||||
p.addPoint(0, this.getHeight() - 1);
|
||||
gdx.drawPolygon(p);
|
||||
}
|
||||
|
||||
if (this.isSelected) {
|
||||
Stroke s = new BasicStroke(1.0F, 2, 2, 1.0F, new float[] { 2.0F, 2.0F }, 1.0F);
|
||||
Graphics2D gd = (Graphics2D) g;
|
||||
gd.setStroke(s);
|
||||
gd.setColor(Color.BLACK);
|
||||
Polygon px = new Polygon();
|
||||
px.addPoint(0, 0);
|
||||
px.addPoint(this.getWidth() - 1, 0);
|
||||
px.addPoint(this.getWidth() - 1, this.getHeight() - 1);
|
||||
px.addPoint(0, this.getHeight() - 1);
|
||||
gd.drawPolygon(px);
|
||||
}
|
||||
|
||||
super.paintComponent(g);
|
||||
}
|
||||
|
||||
public boolean contains(Point p) {
|
||||
return this.getBounds().contains(p);
|
||||
}
|
||||
|
||||
private void update() {
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent e) {
|
||||
this.isSelected = true;
|
||||
this.update();
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
Point p = SwingUtilities.convertPoint(this, e.getPoint(), DateChooser.this.jp3);
|
||||
DateChooser.this.lm.setSelect(p, false);
|
||||
DateChooser.this.commit();
|
||||
}
|
||||
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent e) {
|
||||
}
|
||||
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
Point p = SwingUtilities.convertPoint(this, e.getPoint(), DateChooser.this.jp3);
|
||||
DateChooser.this.lm.setSelect(p, true);
|
||||
}
|
||||
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
}
|
||||
|
||||
public int compare(DateChooser.MyLabel o1, DateChooser.MyLabel o2) {
|
||||
Calendar c1 = Calendar.getInstance();
|
||||
c1.set(o1.year, o2.month, o1.day);
|
||||
Calendar c2 = Calendar.getInstance();
|
||||
c2.set(o2.year, o2.month, o2.day);
|
||||
return c1.compareTo(c2);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.langtech.plm.project;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.core.commands.IHandler;
|
||||
|
||||
import com.teamcenter.rac.aif.AIFDesktop;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
//创建常规文件夹结构
|
||||
public class ProjectECRHandler extends AbstractHandler implements IHandler {
|
||||
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
System.out.println("ProjectECRHandler");
|
||||
TCSession session = (TCSession) AIFUtility.getCurrentApplication().getSession();
|
||||
AIFDesktop desktop = AIFUtility.getActiveDesktop();
|
||||
try {
|
||||
//获取首选项中的值:表头=查询数据源=列宽
|
||||
String[] option = session.getPreferenceService().getStringValues("CONNOR_ProjectECR");//A3oJ8Bs_J19vPC
|
||||
if(option==null || option.length<2) {
|
||||
MessageBox.post(desktop, "首选项CONNOR_ProjectECR配置不正确", "ERROR", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
new ProjectECRDialog(session, option);
|
||||
}catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
MessageBox.post(desktop, "错误:"+e.getMessage(), "ERROR", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue