parent
06d789f062
commit
bf8c9d277d
@ -0,0 +1,232 @@
|
|||||||
|
package com.connor.plm.CostListManagement.pojo;
|
||||||
|
|
||||||
|
public class GzxqBean {
|
||||||
|
private String instanceId;
|
||||||
|
private String factory;
|
||||||
|
private String sfId;
|
||||||
|
private String head;
|
||||||
|
private String scheduledtime;
|
||||||
|
private String model;
|
||||||
|
private String productname;
|
||||||
|
private String toolnumber;
|
||||||
|
private String toolname;
|
||||||
|
private String toolinglevel;
|
||||||
|
private String reason;
|
||||||
|
private String jsgyrequirements;
|
||||||
|
private String link;
|
||||||
|
private String state;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public GzxqBean() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getInstanceId() {
|
||||||
|
return instanceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void setInstanceId(String instanceId) {
|
||||||
|
this.instanceId = instanceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getFactory() {
|
||||||
|
return factory;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void setFactory(String factory) {
|
||||||
|
this.factory = factory;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getSfId() {
|
||||||
|
return sfId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void setSfId(String sfId) {
|
||||||
|
this.sfId = sfId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getHead() {
|
||||||
|
return head;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void setHead(String head) {
|
||||||
|
this.head = head;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getScheduledtime() {
|
||||||
|
return scheduledtime;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void setScheduledtime(String scheduledtime) {
|
||||||
|
this.scheduledtime = scheduledtime;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getModel() {
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void setModel(String model) {
|
||||||
|
this.model = model;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getProductname() {
|
||||||
|
return productname;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void setProductname(String productname) {
|
||||||
|
this.productname = productname;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getToolnumber() {
|
||||||
|
return toolnumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void setToolnumber(String toolnumber) {
|
||||||
|
this.toolnumber = toolnumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getToolname() {
|
||||||
|
return toolname;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void setToolname(String toolname) {
|
||||||
|
this.toolname = toolname;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getToolinglevel() {
|
||||||
|
return toolinglevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void setToolinglevel(String toolinglevel) {
|
||||||
|
this.toolinglevel = toolinglevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getReason() {
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void setReason(String reason) {
|
||||||
|
this.reason = reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getJsgyrequirements() {
|
||||||
|
return jsgyrequirements;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void setJsgyrequirements(String jsgyrequirements) {
|
||||||
|
this.jsgyrequirements = jsgyrequirements;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getLink() {
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void setLink(String link) {
|
||||||
|
this.link = link;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void setState(String state) {
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public GzxqBean(String instanceId, String factory, String sfId, String head, String scheduledtime, String model,
|
||||||
|
String productname, String toolnumber, String toolname, String toolinglevel, String reason,
|
||||||
|
String jsgyrequirements, String link, String state) {
|
||||||
|
super();
|
||||||
|
this.instanceId = instanceId;
|
||||||
|
this.factory = factory;
|
||||||
|
this.sfId = sfId;
|
||||||
|
this.head = head;
|
||||||
|
this.scheduledtime = scheduledtime;
|
||||||
|
this.model = model;
|
||||||
|
this.productname = productname;
|
||||||
|
this.toolnumber = toolnumber;
|
||||||
|
this.toolname = toolname;
|
||||||
|
this.toolinglevel = toolinglevel;
|
||||||
|
this.reason = reason;
|
||||||
|
this.jsgyrequirements = jsgyrequirements;
|
||||||
|
this.link = link;
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "GzxqBean [instanceId=" + instanceId + ", factory=" + factory + ", sfId=" + sfId + ", head=" + head
|
||||||
|
+ ", scheduledtime=" + scheduledtime + ", model=" + model + ", productname=" + productname
|
||||||
|
+ ", toolnumber=" + toolnumber + ", toolname=" + toolname + ", toolinglevel=" + toolinglevel
|
||||||
|
+ ", reason=" + reason + ", jsgyrequirements=" + jsgyrequirements + ", link=" + link + ", state="
|
||||||
|
+ state + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,124 @@
|
|||||||
|
package com.connor.plm.GZXQ;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Desktop;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.swing.AbstractCellEditor;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.table.TableCellEditor;
|
||||||
|
|
||||||
|
import com.connor.plm.CostListManagement.pojo.Cusquotation;
|
||||||
|
import com.connor.plm.CostListManagement.pojo.GzxqBean;
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||||
|
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||||
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponent;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentFolder;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentItem;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentItemType;
|
||||||
|
import com.teamcenter.rac.kernel.TCSession;
|
||||||
|
|
||||||
|
public class ButtonCellEditor extends AbstractCellEditor implements TableCellEditor{
|
||||||
|
|
||||||
|
|
||||||
|
private JButton button;
|
||||||
|
private JTable table;
|
||||||
|
private List<GzxqBean> quotations;
|
||||||
|
private Boolean flag = false;
|
||||||
|
public static GzxqBean quotation;
|
||||||
|
public static Cusquotation cusquotation;
|
||||||
|
public static TCSession session;
|
||||||
|
|
||||||
|
public ButtonCellEditor(JTable jTable2,List<GzxqBean> quotations,TCSession session, TCComponent f) {
|
||||||
|
button = new JButton();
|
||||||
|
this.table = jTable2;
|
||||||
|
this.quotations = quotations;
|
||||||
|
this.session = session;
|
||||||
|
button.addActionListener(e -> {
|
||||||
|
// 这里可以添加按钮的点击事件响应逻辑
|
||||||
|
int selectedRow = table.getSelectedRow();
|
||||||
|
System.out.println("点击了第"+selectedRow+"行");
|
||||||
|
String text = button.getText();
|
||||||
|
System.out.println("点击按钮名称:"+text);
|
||||||
|
if("打开".equals(text)) {
|
||||||
|
String url = quotations.get(selectedRow).getLink();
|
||||||
|
try {
|
||||||
|
browse2(url);
|
||||||
|
} catch (Exception e1) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
}else if("设计".equals(text)){
|
||||||
|
String formnumber = quotations.get(selectedRow).getInstanceId();
|
||||||
|
String sfid = quotations.get(selectedRow).getSfId();
|
||||||
|
AbstractAIFApplication app = AIFUtility.getCurrentApplication();
|
||||||
|
InterfaceAIFComponent target = app.getTargetComponent();
|
||||||
|
if(target instanceof TCComponentFolder) {
|
||||||
|
TCComponentFolder folder = (TCComponentFolder)target;
|
||||||
|
try {
|
||||||
|
TCComponentItemType typeComponent = (TCComponentItemType) session.getTypeComponent("ZT2_Frock");
|
||||||
|
String newID = typeComponent.getNewID();
|
||||||
|
TCComponentItem item = typeComponent.create(newID, "A", "ZT2_Frock", "", "", null);
|
||||||
|
TCComponentItemRevision itemRev = item.getLatestItemRevision();
|
||||||
|
if(itemRev != null && formnumber != null && !formnumber.isEmpty()) {
|
||||||
|
itemRev.setStringProperty("zt2_formnumber", formnumber);
|
||||||
|
}
|
||||||
|
if(itemRev != null && sfid != null && !sfid.isEmpty()) {
|
||||||
|
itemRev.setStringProperty("zt2_sfid", sfid);
|
||||||
|
}
|
||||||
|
folder.add("contents", item);
|
||||||
|
folder.refresh();
|
||||||
|
} catch (Exception e2) {
|
||||||
|
// TODO: handle exception
|
||||||
|
e2.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}else {
|
||||||
|
try {
|
||||||
|
TCComponentItemType typeComponent = (TCComponentItemType) session.getTypeComponent("ZT2_Frock");
|
||||||
|
String newID = typeComponent.getNewID();
|
||||||
|
TCComponentItem item = typeComponent.create(newID, "A", "ZT2_Frock", "", "", null);
|
||||||
|
TCComponentItemRevision itemRev = item.getLatestItemRevision();
|
||||||
|
if(itemRev != null && formnumber != null && !formnumber.isEmpty()) {
|
||||||
|
itemRev.setStringProperty("zt2_formnumber", formnumber);
|
||||||
|
|
||||||
|
}
|
||||||
|
if(itemRev != null && sfid != null && !sfid.isEmpty()) {
|
||||||
|
itemRev.setStringProperty("zt2_sfid", sfid);
|
||||||
|
}
|
||||||
|
session.getUser().getNewStuffFolder().add("contents", item);
|
||||||
|
} catch (Exception e2) {
|
||||||
|
// TODO: handle exception
|
||||||
|
e2.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
private void browse2(String url) throws Exception {
|
||||||
|
Desktop desktop = Desktop.getDesktop();
|
||||||
|
if (Desktop.isDesktopSupported() && desktop.isSupported(Desktop.Action.BROWSE)) {
|
||||||
|
URI uri = new URI(url);
|
||||||
|
desktop.browse(uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected,
|
||||||
|
int row, int column) {
|
||||||
|
button.setText(value != null ? value.toString() : "");
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getCellEditorValue() {
|
||||||
|
return button.getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
package com.connor.plm.GZXQ;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Desktop;
|
||||||
|
import java.awt.Panel;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.swing.AbstractCellEditor;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
import javax.swing.table.DefaultTableCellRenderer;
|
||||||
|
import javax.swing.table.TableCellEditor;
|
||||||
|
import javax.swing.table.TableCellRenderer;
|
||||||
|
|
||||||
|
import com.connor.plm.CostListManagement.pojo.GzxqBean;
|
||||||
|
import com.connor.plm.CostListManagement.pojo.Quotation;
|
||||||
|
import com.connor.plm.CreateOuotation.JDBFrame;
|
||||||
|
import com.connor.plm.CreateOuotation.MainApp;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponent;
|
||||||
|
import com.teamcenter.rac.kernel.TCSession;
|
||||||
|
import com.teamcenter.soaictstubs.booleanSeq_tHolder;
|
||||||
|
|
||||||
|
import javafx.application.Platform;
|
||||||
|
import javafx.embed.swing.JFXPanel;
|
||||||
|
import javafx.event.EventHandler;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
import javafx.stage.WindowEvent;
|
||||||
|
|
||||||
|
class ButtonCellRenderer extends DefaultTableCellRenderer implements TableCellRenderer {
|
||||||
|
|
||||||
|
private JButton button;
|
||||||
|
private JTable table;
|
||||||
|
private List<GzxqBean> quotations;
|
||||||
|
private TCSession session;
|
||||||
|
private TCComponent f;
|
||||||
|
public ButtonCellRenderer(JTable jTable2, List<GzxqBean> quotations,TCSession session, TCComponent f) {
|
||||||
|
button = new JButton();
|
||||||
|
this.quotations = quotations;
|
||||||
|
this.table = jTable2;
|
||||||
|
this.session = session;
|
||||||
|
this.f = f;
|
||||||
|
}
|
||||||
|
public interface CostPageCallback {
|
||||||
|
void onOpenCostPage();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
|
||||||
|
boolean hasFocus, int row, int column) {
|
||||||
|
button.setText(value != null ? value.toString() : "");
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,698 @@
|
|||||||
|
package com.connor.plm.GZXQ;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
private 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,53 @@
|
|||||||
|
package com.connor.plm.GZXQ;
|
||||||
|
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Toolkit;
|
||||||
|
|
||||||
|
import org.eclipse.core.commands.AbstractHandler;
|
||||||
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
|
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||||
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||||
|
import com.teamcenter.rac.kernel.TCSession;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 成本单管理
|
||||||
|
* @author admin
|
||||||
|
* 2023/11/16
|
||||||
|
*/
|
||||||
|
public class GZXQHandler extends AbstractHandler{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object execute(ExecutionEvent arg0) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
AbstractAIFApplication app = AIFUtility.getCurrentApplication();
|
||||||
|
TCSession session = (TCSession)app.getSession();
|
||||||
|
try {
|
||||||
|
new Thread() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
NewJFrame newJFrame = new NewJFrame(session);
|
||||||
|
int width2 = newJFrame.getWidth();
|
||||||
|
int height2 = newJFrame.getHeight();
|
||||||
|
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // 获取屏幕尺寸
|
||||||
|
int screenWidth = screenSize.width; // 获取屏幕宽度
|
||||||
|
int screenHeight = screenSize.height; // 获取屏幕高度
|
||||||
|
int x = (screenWidth - width2) / 2; // 计算Frame的左上角x坐标
|
||||||
|
int y = (screenHeight - height2) / 2; // 计算Frame的左上角y坐标
|
||||||
|
newJFrame.setTitle("工装需求查询");
|
||||||
|
// this.getContentPane().setBackground(Color.red);
|
||||||
|
newJFrame.getContentPane().setBackground(new java.awt.Color(255, 255, 255));
|
||||||
|
newJFrame.setSize(950, height2); // 设置Frame的大小
|
||||||
|
newJFrame.setLocation(x, y); // 设置Frame的位置
|
||||||
|
newJFrame.setResizable(false);
|
||||||
|
newJFrame.setDefaultCloseOperation(2); // 设置窗口关闭时的默认操作
|
||||||
|
newJFrame.setVisible(true);
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue