diff --git a/bin/.gitignore b/bin/.gitignore deleted file mode 100644 index c2d9872..0000000 --- a/bin/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/com/ diff --git a/bin/com/langtech/plm/batchRename/BatchRenameDialog.class b/bin/com/langtech/plm/batchRename/BatchRenameDialog.class new file mode 100644 index 0000000..f5f3854 Binary files /dev/null and b/bin/com/langtech/plm/batchRename/BatchRenameDialog.class differ diff --git a/bin/com/langtech/plm/batchRename/BatchRenameHandler.class b/bin/com/langtech/plm/batchRename/BatchRenameHandler.class new file mode 100644 index 0000000..4afb8ce Binary files /dev/null and b/bin/com/langtech/plm/batchRename/BatchRenameHandler.class differ diff --git a/bin/com/langtech/plm/createProjectStruct/CheckBoxTreeCellRenderer.class b/bin/com/langtech/plm/createProjectStruct/CheckBoxTreeCellRenderer.class new file mode 100644 index 0000000..11015a3 Binary files /dev/null and b/bin/com/langtech/plm/createProjectStruct/CheckBoxTreeCellRenderer.class differ diff --git a/bin/com/langtech/plm/createProjectStruct/CheckBoxTreeLabel.class b/bin/com/langtech/plm/createProjectStruct/CheckBoxTreeLabel.class new file mode 100644 index 0000000..42a1b26 Binary files /dev/null and b/bin/com/langtech/plm/createProjectStruct/CheckBoxTreeLabel.class differ diff --git a/bin/com/langtech/plm/createProjectStruct/CheckBoxTreeNode.class b/bin/com/langtech/plm/createProjectStruct/CheckBoxTreeNode.class new file mode 100644 index 0000000..032f306 Binary files /dev/null and b/bin/com/langtech/plm/createProjectStruct/CheckBoxTreeNode.class differ diff --git a/bin/com/langtech/plm/createProjectStruct/CheckBoxTreeNodeSelectionListener.class b/bin/com/langtech/plm/createProjectStruct/CheckBoxTreeNodeSelectionListener.class new file mode 100644 index 0000000..3201eaa Binary files /dev/null and b/bin/com/langtech/plm/createProjectStruct/CheckBoxTreeNodeSelectionListener.class differ diff --git a/bin/com/langtech/plm/createProjectStruct/CreateProjectStructDialog.class b/bin/com/langtech/plm/createProjectStruct/CreateProjectStructDialog.class new file mode 100644 index 0000000..899f273 Binary files /dev/null and b/bin/com/langtech/plm/createProjectStruct/CreateProjectStructDialog.class differ diff --git a/bin/com/langtech/plm/createProjectStruct/CreateProjectStructHandler.class b/bin/com/langtech/plm/createProjectStruct/CreateProjectStructHandler.class new file mode 100644 index 0000000..19be34c Binary files /dev/null and b/bin/com/langtech/plm/createProjectStruct/CreateProjectStructHandler.class differ diff --git a/bin/com/langtech/plm/createProjectStruct/KUtil.class b/bin/com/langtech/plm/createProjectStruct/KUtil.class new file mode 100644 index 0000000..821d635 Binary files /dev/null and b/bin/com/langtech/plm/createProjectStruct/KUtil.class differ diff --git a/bin/com/langtech/plm/mpart/CheckHeaderCellRenderer$1.class b/bin/com/langtech/plm/mpart/CheckHeaderCellRenderer$1.class new file mode 100644 index 0000000..e5d7db3 Binary files /dev/null and b/bin/com/langtech/plm/mpart/CheckHeaderCellRenderer$1.class differ diff --git a/bin/com/langtech/plm/mpart/CheckHeaderCellRenderer.class b/bin/com/langtech/plm/mpart/CheckHeaderCellRenderer.class new file mode 100644 index 0000000..97ffa78 Binary files /dev/null and b/bin/com/langtech/plm/mpart/CheckHeaderCellRenderer.class differ diff --git a/bin/com/langtech/plm/mpart/ChoosePartDialog.class b/bin/com/langtech/plm/mpart/ChoosePartDialog.class new file mode 100644 index 0000000..14b88f8 Binary files /dev/null and b/bin/com/langtech/plm/mpart/ChoosePartDialog.class differ diff --git a/bin/com/langtech/plm/mpart/DialogFrame$1.class b/bin/com/langtech/plm/mpart/DialogFrame$1.class new file mode 100644 index 0000000..2a63d6a Binary files /dev/null and b/bin/com/langtech/plm/mpart/DialogFrame$1.class differ diff --git a/bin/com/langtech/plm/mpart/DialogFrame.class b/bin/com/langtech/plm/mpart/DialogFrame.class new file mode 100644 index 0000000..2e14d07 Binary files /dev/null and b/bin/com/langtech/plm/mpart/DialogFrame.class differ diff --git a/bin/com/langtech/plm/mpart/MainFrame$1$1.class b/bin/com/langtech/plm/mpart/MainFrame$1$1.class new file mode 100644 index 0000000..f73af31 Binary files /dev/null and b/bin/com/langtech/plm/mpart/MainFrame$1$1.class differ diff --git a/bin/com/langtech/plm/mpart/MainFrame$1.class b/bin/com/langtech/plm/mpart/MainFrame$1.class new file mode 100644 index 0000000..769e77a Binary files /dev/null and b/bin/com/langtech/plm/mpart/MainFrame$1.class differ diff --git a/bin/com/langtech/plm/mpart/MainFrame.class b/bin/com/langtech/plm/mpart/MainFrame.class new file mode 100644 index 0000000..b7ff4a6 Binary files /dev/null and b/bin/com/langtech/plm/mpart/MainFrame.class differ diff --git a/bin/com/langtech/plm/mpart/MpartDialog.class b/bin/com/langtech/plm/mpart/MpartDialog.class new file mode 100644 index 0000000..ef2dbbb Binary files /dev/null and b/bin/com/langtech/plm/mpart/MpartDialog.class differ diff --git a/bin/com/langtech/plm/mpart/MpartHandler.class b/bin/com/langtech/plm/mpart/MpartHandler.class new file mode 100644 index 0000000..50635e7 Binary files /dev/null and b/bin/com/langtech/plm/mpart/MpartHandler.class differ diff --git a/bin/com/langtech/plm/mpart/TableCellCheckboxRenderer.class b/bin/com/langtech/plm/mpart/TableCellCheckboxRenderer.class new file mode 100644 index 0000000..0a0d191 Binary files /dev/null and b/bin/com/langtech/plm/mpart/TableCellCheckboxRenderer.class differ diff --git a/bin/com/langtech/plm/synchronize/SynchronizeDialog.class b/bin/com/langtech/plm/synchronize/SynchronizeDialog.class new file mode 100644 index 0000000..bb63121 Binary files /dev/null and b/bin/com/langtech/plm/synchronize/SynchronizeDialog.class differ diff --git a/bin/com/langtech/plm/synchronize/SynchronizeHandler.class b/bin/com/langtech/plm/synchronize/SynchronizeHandler.class new file mode 100644 index 0000000..a69997e Binary files /dev/null and b/bin/com/langtech/plm/synchronize/SynchronizeHandler.class differ diff --git a/bin/com/langtech/plm/template/TemplateDialog.class b/bin/com/langtech/plm/template/TemplateDialog.class new file mode 100644 index 0000000..4907859 Binary files /dev/null and b/bin/com/langtech/plm/template/TemplateDialog.class differ diff --git a/bin/com/langtech/plm/template/TemplateHandler.class b/bin/com/langtech/plm/template/TemplateHandler.class new file mode 100644 index 0000000..4db69cf Binary files /dev/null and b/bin/com/langtech/plm/template/TemplateHandler.class differ diff --git a/bin/com/langtech/plm/tqsx/Activator.class b/bin/com/langtech/plm/tqsx/Activator.class new file mode 100644 index 0000000..e3dd115 Binary files /dev/null and b/bin/com/langtech/plm/tqsx/Activator.class differ diff --git a/bin/com/langtech/plm/tqsx/DateUtil$FormatEnum.class b/bin/com/langtech/plm/tqsx/DateUtil$FormatEnum.class new file mode 100644 index 0000000..571f34a Binary files /dev/null and b/bin/com/langtech/plm/tqsx/DateUtil$FormatEnum.class differ diff --git a/bin/com/langtech/plm/tqsx/DateUtil.class b/bin/com/langtech/plm/tqsx/DateUtil.class new file mode 100644 index 0000000..3488e5c Binary files /dev/null and b/bin/com/langtech/plm/tqsx/DateUtil.class differ diff --git a/bin/com/langtech/plm/tqsx/KAction.class b/bin/com/langtech/plm/tqsx/KAction.class new file mode 100644 index 0000000..8073dff Binary files /dev/null and b/bin/com/langtech/plm/tqsx/KAction.class differ diff --git a/bin/com/langtech/plm/tqsx/KCommand.class b/bin/com/langtech/plm/tqsx/KCommand.class new file mode 100644 index 0000000..56f8d9e Binary files /dev/null and b/bin/com/langtech/plm/tqsx/KCommand.class differ diff --git a/bin/com/langtech/plm/tqsx/KHandler.class b/bin/com/langtech/plm/tqsx/KHandler.class new file mode 100644 index 0000000..aa152e8 Binary files /dev/null and b/bin/com/langtech/plm/tqsx/KHandler.class differ diff --git a/bin/com/langtech/plm/tqsx/KLocale.class b/bin/com/langtech/plm/tqsx/KLocale.class new file mode 100644 index 0000000..e7cffad Binary files /dev/null and b/bin/com/langtech/plm/tqsx/KLocale.class differ diff --git a/bin/com/langtech/plm/tqsx/KOperation.class b/bin/com/langtech/plm/tqsx/KOperation.class new file mode 100644 index 0000000..1bb2f1a Binary files /dev/null and b/bin/com/langtech/plm/tqsx/KOperation.class differ diff --git a/bin/com/langtech/plm/tqsx/KOperation2.class b/bin/com/langtech/plm/tqsx/KOperation2.class new file mode 100644 index 0000000..ba62fee Binary files /dev/null and b/bin/com/langtech/plm/tqsx/KOperation2.class differ diff --git a/bin/com/langtech/plm/tqsx/KUtil.class b/bin/com/langtech/plm/tqsx/KUtil.class new file mode 100644 index 0000000..3850b97 Binary files /dev/null and b/bin/com/langtech/plm/tqsx/KUtil.class differ diff --git a/bin/com/langtech/plm/tqsx/PropertyToWordOrExcelCommand.class b/bin/com/langtech/plm/tqsx/PropertyToWordOrExcelCommand.class new file mode 100644 index 0000000..340889d Binary files /dev/null and b/bin/com/langtech/plm/tqsx/PropertyToWordOrExcelCommand.class differ diff --git a/bin/com/langtech/plm/tqsx/PropertyToWordOrExcelOperation.class b/bin/com/langtech/plm/tqsx/PropertyToWordOrExcelOperation.class new file mode 100644 index 0000000..fa91e48 Binary files /dev/null and b/bin/com/langtech/plm/tqsx/PropertyToWordOrExcelOperation.class differ diff --git a/bin/com/langtech/plm/tqsx/WordUtils.class b/bin/com/langtech/plm/tqsx/WordUtils.class new file mode 100644 index 0000000..b83e640 Binary files /dev/null and b/bin/com/langtech/plm/tqsx/WordUtils.class differ diff --git a/bin/com/teamcenter/rac/stylesheet/stylesheet_user.properties b/bin/com/teamcenter/rac/stylesheet/stylesheet_user.properties new file mode 100644 index 0000000..93ef268 --- /dev/null +++ b/bin/com/teamcenter/rac/stylesheet/stylesheet_user.properties @@ -0,0 +1 @@ +LD6_NewProdForm.FORMJAVARENDERING=com.langtech.plm.form.LD6_NewProdForm \ No newline at end of file diff --git a/src/com/langtech/plm/project/DateChooser.java b/src/com/langtech/plm/project/DateChooser.java new file mode 100644 index 0000000..6a18a93 --- /dev/null +++ b/src/com/langtech/plm/project/DateChooser.java @@ -0,0 +1,700 @@ +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 list = new ArrayList(); + + public LabelManager() { + } + + public List 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, 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); + } + } +} diff --git a/src/com/langtech/plm/project/ProjectECRDialog.java b/src/com/langtech/plm/project/ProjectECRDialog.java new file mode 100644 index 0000000..9bfba05 --- /dev/null +++ b/src/com/langtech/plm/project/ProjectECRDialog.java @@ -0,0 +1,405 @@ +package com.langtech.plm.project; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Vector; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.table.DefaultTableModel; + +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.jdesktop.swingx.JXDatePicker; +import com.connor.sbplm.plm1.util.TCUtil; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class ProjectECRDialog extends AbstractAIFDialog { + private static final long serialVersionUID = 1L; + private TCSession session; + private JTextField field; + private JTextField dateAfterField; + private JTextField dateBeforeField; + private JButton searchBtn; + private JButton exportBtn; + private JTable impTable; + private DefaultTableModel impModel; + private Vector exports; + private Vector excludes; + private String[] tableHeader; + + public ProjectECRDialog(TCSession session, String[] options) throws Exception { + super(AIFUtility.getActiveDesktop()); + this.session = session; + Vector props = new Vector<>(); + this.exports = new Vector<>(); + setTitle("项目变更单查询"); +// 查询条目 + JLabel label = new JLabel("项目&产品名称"); + JLabel appDateLabel0 = new JLabel("申请日期早于"); + JLabel appDateLabel1 = new JLabel("申请日期晚于"); + + // 定义输入框 + field = new JTextField(); + dateAfterField = new JTextField(10); + dateBeforeField = new JTextField(10); + field.setPreferredSize(new Dimension(118, 23)); + + //日期选择器 + DateChooser dateAfterChooser = DateChooser.getInstance("yyyy-M-dd"); + dateAfterChooser.register(this.dateAfterField); + DateChooser dateBeforeChooser = DateChooser.getInstance("yyyy-M-dd"); + dateBeforeChooser.register(this.dateBeforeField); + + JPanel msgPanel = new JPanel(new FlowLayout()); + msgPanel.add(label); + msgPanel.add(field); + msgPanel.add(appDateLabel1);//申请日期晚于 + msgPanel.add(dateBeforeField); + msgPanel.add(appDateLabel0);//申请日期早于 + msgPanel.add(dateAfterField); + + + searchBtn = new JButton("查询"); + exportBtn = new JButton("导出"); + JPanel btnPanel = new JPanel(new FlowLayout()); + btnPanel.add(searchBtn); + btnPanel.add(exportBtn); + + JPanel topPanel = new JPanel(new BorderLayout()); + topPanel.add(BorderLayout.WEST, msgPanel); + topPanel.add(BorderLayout.EAST, btnPanel); +// 根据首选项配置的值获取表头信息 + tableHeader = new String[options.length-1]; + int[] weights = new int[options.length-1]; + for(int i=0; i props) { + + + searchBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + String dateString0 = dateBeforeField.getText(); + String dateString1 = dateAfterField.getText(); + try { + String project = field.getText(); + if(project.isEmpty() && dateString0.isEmpty() && dateString1.isEmpty()) { + MessageBox.post(ProjectECRDialog.this, "至少输入一个查询条件", "ERROR", MessageBox.ERROR); + return; + } + if(impModel.getRowCount()>0) { + for(int i=impModel.getRowCount(); i>0; i--) + impModel.removeRow(i-1); + } + Vector keyV = new Vector<>(); + Vector valueV = new Vector<>(); +// 封装查询条件:项目号、申请日期 + if (!project.isEmpty()) { + keyV.add("projnum"); + valueV.add(project); + }else if (!dateString0.isEmpty()) { + keyV.add("dateafter"); + valueV.add(dateString0+" 00:00"); + }else if (!dateString1.isEmpty()) { + keyV.add("datebefore"); + valueV.add(dateString1+" 23:59"); + } + + //调用查询构建器:条件查询的结果(ecn)-result + TCComponent[] result = TCUtil.query(session, "CONNOR_SearchProjectECN", keyV, valueV); + System.out.println("查询构建器共查询出"+result.length+"条数据"); + for(int i=0; i v = new Vector<>(); + for(String[] prop:props) { + if (prop[0].equals("序号")){ + v.add(impTable.getRowCount()+1+""); + } else if (prop[0].equals("ecn")) { + if (prop[1].equals("rev")){ + //ecn.rev.*:只能通过ecn版本对象取值 + v.add(ecn.getProperty(prop[2])); + } else if (prop[1].equals("master")) { + //ecn.master.*:只能通过ecnform取值 + v.add(ecnform.getProperty(prop[2])); + } + } else if (prop[0].equals("ecr")) { + if (prop[1].equals("rev")) { + v.add(ercBM); + } + }else if (prop[0].equals("状态")) { + // 获取ECN发布状态:发布-关闭,未发布-未关闭 + String releaseStatus = ecn.getProperty("date_released"); +// if (releaseStatus.equals("发布")){ + if (releaseStatus == null || releaseStatus.isEmpty()){ + //未发布状态 + v.add("未关闭"); + }else { + v.add("关闭"); + } + } + } + impModel.addRow(v); + } + } catch (Exception e1) { + e1.printStackTrace(); + MessageBox.post(ProjectECRDialog.this, "错误::"+e1.getMessage(), "ERROR", MessageBox.ERROR); + } + } + }); + exportBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + FileOutputStream output = null; + InputStream input = null; + try { + if(impTable.getRowCount()==0) + throw new Exception("表格内容为空,无法导出"); + TCComponentItem[] item = ((TCComponentItemType) session.getTypeService().getTypeComponent("Item")).findItems(id); + if(item==null || item.length==0) + throw new Exception("未找到模板Item"); + TCComponentDataset dataset = null; + AIFComponentContext[] contexts = item[0].getLatestItemRevision().getChildren(); + for(AIFComponentContext c : contexts) { + TCComponent child = (TCComponent) c.getComponent(); + if(child instanceof TCComponentDataset && child.isTypeOf("MSExcelX")) { + dataset = (TCComponentDataset) child; + break; + } + } + if(dataset == null) + throw new Exception("未找到模板数据集"); + System.out.println("export"); + TCComponentTcFile[] files = dataset.getTcFiles(); + if (files==null || files.length==0) + return; + File directory = TCUtil.saveExcelChooser(); + if(directory == null) + return; + String path = directory.getPath(); + if (!path.endsWith(".xlsx")) { + path = path+".xlsx"; + } + File file = files[0].getFile(directory.getParent()); + input = new FileInputStream(file); + XSSFWorkbook wb = new XSSFWorkbook(input); + XSSFSheet sheet = wb.getSheetAt(0); + XSSFRow row = sheet.getRow(0); + if(row == null) + row = sheet.createRow(0); + int col = 0; + for(int i=0; i boxes = new Vector<>(); + for(int i=0; i(); + for(JCheckBox box : boxes) { + if(!box.isSelected()) { + excludes.add(box.getText()); + } + } + dispose(); + } + }); + JButton cancelBtn = new JButton("取消"); + cancelBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + excludes = null; + dispose(); + } + }); + JPanel btnPanel = new JPanel(new FlowLayout()); + btnPanel.add(okBtn); + btnPanel.add(cancelBtn); + + setLayout(new BorderLayout()); + add(BorderLayout.CENTER, boxPanel); + add(BorderLayout.SOUTH, btnPanel); + pack(); + setSize(new Dimension(200, 200)); + setDefaultLookAndFeelDecorated(true); + Dimension screen = getToolkit().getScreenSize(); + setLocation((screen.width - getSize().width) / 2, (screen.height - getSize().height) / 2); +// setAlwaysOnTop(true); + setVisible(true); + } + } +} \ No newline at end of file diff --git a/src/com/langtech/plm/project/ProjectECRHandler.java b/src/com/langtech/plm/project/ProjectECRHandler.java new file mode 100644 index 0000000..06f8c39 --- /dev/null +++ b/src/com/langtech/plm/project/ProjectECRHandler.java @@ -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; + } +}