List of usage examples for javax.swing JToolBar add
public JButton add(Action a)
JButton
which dispatches the action. From source file:com.declarativa.interprolog.gui.ListenerWindow.java
private void UpdategraphComponents() throws IOException { jLayeredPane1.removeAll();/*from ww w . j a v a 2s .co m*/ List<String> heads = new ArrayList<>(); List<String> subgrph = new ArrayList<>(); ArgBuildManager manag = new ArgBuildManager(); Forest<String, Integer> graphGUI = new DelegateForest<>(); graphGUI = manag.getGraphJung(); System.out.println("\t \t NUM UF VERT:" + graphGUI.getVertexCount()); Forest<String, Integer> forest = new DelegateForest<>(); //ObservableGraph g = new ObservableGraph(new BalloonLayoutDemo().createTree(forest)); ObservableGraph g = new ObservableGraph(graphGUI); //Layout layout = new BalloonLayout(forest); Layout layout = new BalloonLayout(graphGUI); //Layout layout = new TreeLayout(forest, 70, 70); final BaseJungScene scene2 = new SceneImpl(g, layout); // jLayeredPane1.setLayout(new BorderLayout()); //jf.setLayout(new BorderLayout()); jLayeredPane1.add(new JScrollPane(scene2.createView()), BorderLayout.CENTER); //jf.add(new JScrollPane(scene2.createView()), BorderLayout.CENTER); JToolBar bar = new JToolBar(); bar.setMargin(new Insets(5, 5, 5, 5)); bar.setLayout(new FlowLayout(5)); DefaultComboBoxModel<Layout> mdl = new DefaultComboBoxModel<>(); mdl.addElement(new KKLayout(g)); mdl.addElement(layout); mdl.addElement(new BalloonLayout(forest)); mdl.addElement(new RadialTreeLayout(forest)); mdl.addElement(new CircleLayout(g)); mdl.addElement(new FRLayout(g)); mdl.addElement(new FRLayout2(g)); mdl.addElement(new ISOMLayout(g)); mdl.addElement(new edu.uci.ics.jung.algorithms.layout.SpringLayout(g)); mdl.addElement(new SpringLayout2(g)); mdl.addElement(new DAGLayout(g)); mdl.addElement(new XLayout(g)); mdl.setSelectedItem(layout); final JCheckBox checkbox = new JCheckBox("Animate iterative layouts"); scene2.setLayoutAnimationFramesPerSecond(48); final JComboBox<Layout> layouts = new JComboBox(mdl); layouts.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln, boolean bln1) { o = o.getClass().getSimpleName(); return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates. } }); bar.add(new JLabel(" Layout Type")); bar.add(layouts); layouts.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Layout layout = (Layout) layouts.getSelectedItem(); // These two layouts implement IterativeContext, but they do // not evolve toward anything, they just randomly rearrange // themselves. So disable animation for these. if (layout instanceof ISOMLayout || layout instanceof DAGLayout) { checkbox.setSelected(false); } scene2.setGraphLayout(layout, true); } }); bar.add(new JLabel(" Connection Shape")); DefaultComboBoxModel<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapes = new DefaultComboBoxModel<>(); shapes.addElement(new EdgeShape.QuadCurve<String, Number>()); shapes.addElement(new EdgeShape.BentLine<String, Number>()); shapes.addElement(new EdgeShape.CubicCurve<String, Number>()); shapes.addElement(new EdgeShape.Line<String, Number>()); shapes.addElement(new EdgeShape.Box<String, Number>()); shapes.addElement(new EdgeShape.Orthogonal<String, Number>()); shapes.addElement(new EdgeShape.Wedge<String, Number>(10)); final JComboBox<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapesBox = new JComboBox<>( shapes); shapesBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Transformer<Context<Graph<String, Number>, Number>, Shape> xform = (Transformer<Context<Graph<String, Number>, Number>, Shape>) shapesBox .getSelectedItem(); scene2.setConnectionEdgeShape(xform); } }); shapesBox.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln, boolean bln1) { o = o.getClass().getSimpleName(); return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates. } }); shapesBox.setSelectedItem(new EdgeShape.QuadCurve<>()); bar.add(shapesBox); //jf.add(bar, BorderLayout.NORTH); bar.add(new ListenerWindow.MinSizePanel(scene2.createSatelliteView())); bar.setFloatable(false); bar.setRollover(true); final JLabel selectionLabel = new JLabel("<html> </html>"); System.out.println("LOOKUP IS " + scene2.getLookup()); Lookup.Result<String> selectedNodes = scene2.getLookup().lookupResult(String.class); LookupListener listener = new LookupListener() { @Override public void resultChanged(LookupEvent le) { System.out.println("RES CHANGED"); Lookup.Result<String> res = (Lookup.Result<String>) le.getSource(); StringBuilder sb = new StringBuilder("<html>"); List<String> l = new ArrayList<>(res.allInstances()); Collections.sort(l); for (String s : l) { if (sb.length() != 0) { sb.append(", "); } sb.append(s); } sb.append("</html>"); selectionLabel.setText(sb.toString()); System.out.println("LOOKUP EVENT " + sb); } }; selectedNodes.addLookupListener(listener); selectedNodes.allInstances(); bar.add(selectionLabel); checkbox.setSelected(true); checkbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { scene2.setAnimateIterativeLayouts(checkbox.isSelected()); } }); bar.add(checkbox); jLayeredPane3.setLayout(new BorderLayout()); jLayeredPane3.add(bar); // jf.setSize(jf.getGraphicsConfiguration().getBounds().width - 120, 700); // jf.setSize(new Dimension(1280, 720)); // jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); this.repaint(); this.addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent we) { scene2.relayout(true); scene2.validate(); } }); }
From source file:com.declarativa.interprolog.gui.ListenerWindow.java
private void UpdategraphComponents(Forest<String, Integer> graph) throws IOException { jLayeredPane1.removeAll();/*from w w w . j a va 2 s . c o m*/ /* List<String> heads = new ArrayList<>(); List<String> subgrph = new ArrayList<>(); ArgBuildManager manag = new ArgBuildManager(); Forest<String, Integer> graphGUI = new DelegateForest<>(); graphGUI = manag.getGraphJung(); */ Forest<String, Integer> graphGUI = new DelegateForest<>(); graphGUI = graph; System.out.println("\t \t NUM UF VERT:" + graphGUI.getVertexCount()); //ObservableGraph g = new ObservableGraph(new BalloonLayoutDemo().createTree(forest)); ObservableGraph g = new ObservableGraph(graphGUI); //Layout layout = new BalloonLayout(forest); Layout layout = new BalloonLayout(graphGUI); //Layout layout = new TreeLayout(forest, 70, 70); final BaseJungScene scene2 = new SceneImpl(g, layout); jLayeredPane1.setLayout(new BorderLayout()); //jf.setLayout(new BorderLayout()); jLayeredPane1.add(new JScrollPane(scene2.createView()), BorderLayout.CENTER); //jf.add(new JScrollPane(scene2.createView()), BorderLayout.CENTER); JToolBar bar = new JToolBar(); bar.setMargin(new Insets(5, 5, 5, 5)); bar.setLayout(new FlowLayout(5)); DefaultComboBoxModel<Layout> mdl = new DefaultComboBoxModel<>(); mdl.addElement(new KKLayout(g)); mdl.addElement(layout); mdl.addElement(new BalloonLayout(forest)); mdl.addElement(new RadialTreeLayout(forest)); mdl.addElement(new CircleLayout(g)); mdl.addElement(new FRLayout(g)); mdl.addElement(new FRLayout2(g)); mdl.addElement(new ISOMLayout(g)); mdl.addElement(new edu.uci.ics.jung.algorithms.layout.SpringLayout(g)); mdl.addElement(new SpringLayout2(g)); mdl.addElement(new DAGLayout(g)); mdl.addElement(new XLayout(g)); mdl.setSelectedItem(layout); final JCheckBox checkbox = new JCheckBox("Animate iterative layouts"); scene2.setLayoutAnimationFramesPerSecond(48); final JComboBox<Layout> layouts = new JComboBox(mdl); layouts.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln, boolean bln1) { o = o.getClass().getSimpleName(); return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates. } }); bar.add(new JLabel(" Layout Type")); bar.add(layouts); layouts.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Layout layout = (Layout) layouts.getSelectedItem(); // These two layouts implement IterativeContext, but they do // not evolve toward anything, they just randomly rearrange // themselves. So disable animation for these. if (layout instanceof ISOMLayout || layout instanceof DAGLayout) { checkbox.setSelected(false); } scene2.setGraphLayout(layout, true); } }); bar.add(new JLabel(" Connection Shape")); DefaultComboBoxModel<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapes = new DefaultComboBoxModel<>(); shapes.addElement(new EdgeShape.QuadCurve<String, Number>()); shapes.addElement(new EdgeShape.BentLine<String, Number>()); shapes.addElement(new EdgeShape.CubicCurve<String, Number>()); shapes.addElement(new EdgeShape.Line<String, Number>()); shapes.addElement(new EdgeShape.Box<String, Number>()); shapes.addElement(new EdgeShape.Orthogonal<String, Number>()); shapes.addElement(new EdgeShape.Wedge<String, Number>(10)); final JComboBox<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapesBox = new JComboBox<>( shapes); shapesBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Transformer<Context<Graph<String, Number>, Number>, Shape> xform = (Transformer<Context<Graph<String, Number>, Number>, Shape>) shapesBox .getSelectedItem(); scene2.setConnectionEdgeShape(xform); } }); shapesBox.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln, boolean bln1) { o = o.getClass().getSimpleName(); return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates. } }); shapesBox.setSelectedItem(new EdgeShape.QuadCurve<>()); bar.add(shapesBox); //jf.add(bar, BorderLayout.NORTH); bar.add(new ListenerWindow.MinSizePanel(scene2.createSatelliteView())); bar.setFloatable(false); bar.setRollover(true); final JLabel selectionLabel = new JLabel("<html> </html>"); System.out.println("LOOKUP IS " + scene2.getLookup()); Lookup.Result<String> selectedNodes = scene2.getLookup().lookupResult(String.class); LookupListener listener = new LookupListener() { @Override public void resultChanged(LookupEvent le) { System.out.println("RES CHANGED"); Lookup.Result<String> res = (Lookup.Result<String>) le.getSource(); StringBuilder sb = new StringBuilder("<html>"); List<String> l = new ArrayList<>(res.allInstances()); Collections.sort(l); for (String s : l) { if (sb.length() != 0) { sb.append(", "); } sb.append(s); } sb.append("</html>"); selectionLabel.setText(sb.toString()); System.out.println("LOOKUP EVENT " + sb); } }; selectedNodes.addLookupListener(listener); selectedNodes.allInstances(); bar.add(selectionLabel); checkbox.setSelected(true); checkbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { scene2.setAnimateIterativeLayouts(checkbox.isSelected()); } }); bar.add(checkbox); jLayeredPane3.setLayout(new BorderLayout()); jLayeredPane3.add(bar); // jf.setSize(jf.getGraphicsConfiguration().getBounds().width - 120, 700); // jf.setSize(new Dimension(1280, 720)); // jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); // this.repaint(); this.addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent we) { scene2.relayout(true); scene2.validate(); } }); }
From source file:com.declarativa.interprolog.gui.ListenerWindow.java
private void UpdategraphComponents2(Forest<String, Integer> graph) throws IOException { jLayeredPane5.removeAll();/*from w ww . j a v a2 s . c o m*/ /* List<String> heads = new ArrayList<>(); List<String> subgrph = new ArrayList<>(); ArgBuildManager manag = new ArgBuildManager(); Forest<String, Integer> graphGUI = new DelegateForest<>(); graphGUI = manag.getGraphJung(); */ Forest<String, Integer> graphGUI = new DelegateForest<>(); graphGUI = graph; System.out.println("\t \t NUM UF VERT:" + graphGUI.getVertexCount()); //ObservableGraph g = new ObservableGraph(new BalloonLayoutDemo().createTree(forest)); ObservableGraph g = new ObservableGraph(graphGUI); //Layout layout = new BalloonLayout(forest); Layout layout = new BalloonLayout(graphGUI); //Layout layout = new TreeLayout(forest, 70, 70); final BaseJungScene scene2 = new SceneImpl(g, layout); jLayeredPane5.setLayout(new BorderLayout()); //jf.setLayout(new BorderLayout()); jLayeredPane5.add(new JScrollPane(scene2.createView()), BorderLayout.CENTER); //jf.add(new JScrollPane(scene2.createView()), BorderLayout.CENTER); JToolBar bar = new JToolBar(); bar.setMargin(new Insets(5, 5, 5, 5)); bar.setLayout(new FlowLayout(5)); DefaultComboBoxModel<Layout> mdl = new DefaultComboBoxModel<>(); mdl.addElement(new KKLayout(g)); mdl.addElement(layout); mdl.addElement(new BalloonLayout(forest)); mdl.addElement(new RadialTreeLayout(forest)); mdl.addElement(new CircleLayout(g)); mdl.addElement(new FRLayout(g)); mdl.addElement(new FRLayout2(g)); mdl.addElement(new ISOMLayout(g)); mdl.addElement(new edu.uci.ics.jung.algorithms.layout.SpringLayout(g)); mdl.addElement(new SpringLayout2(g)); mdl.addElement(new DAGLayout(g)); mdl.addElement(new XLayout(g)); mdl.setSelectedItem(layout); final JCheckBox checkbox = new JCheckBox("Animate iterative layouts"); scene2.setLayoutAnimationFramesPerSecond(48); final JComboBox<Layout> layouts = new JComboBox(mdl); layouts.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln, boolean bln1) { o = o.getClass().getSimpleName(); return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates. } }); bar.add(new JLabel(" Layout Type")); bar.add(layouts); layouts.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Layout layout = (Layout) layouts.getSelectedItem(); // These two layouts implement IterativeContext, but they do // not evolve toward anything, they just randomly rearrange // themselves. So disable animation for these. if (layout instanceof ISOMLayout || layout instanceof DAGLayout) { checkbox.setSelected(false); } scene2.setGraphLayout(layout, true); } }); bar.add(new JLabel(" Connection Shape")); DefaultComboBoxModel<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapes = new DefaultComboBoxModel<>(); shapes.addElement(new EdgeShape.QuadCurve<String, Number>()); shapes.addElement(new EdgeShape.BentLine<String, Number>()); shapes.addElement(new EdgeShape.CubicCurve<String, Number>()); shapes.addElement(new EdgeShape.Line<String, Number>()); shapes.addElement(new EdgeShape.Box<String, Number>()); shapes.addElement(new EdgeShape.Orthogonal<String, Number>()); shapes.addElement(new EdgeShape.Wedge<String, Number>(10)); final JComboBox<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapesBox = new JComboBox<>( shapes); shapesBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Transformer<Context<Graph<String, Number>, Number>, Shape> xform = (Transformer<Context<Graph<String, Number>, Number>, Shape>) shapesBox .getSelectedItem(); scene2.setConnectionEdgeShape(xform); } }); shapesBox.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln, boolean bln1) { o = o.getClass().getSimpleName(); return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates. } }); shapesBox.setSelectedItem(new EdgeShape.QuadCurve<>()); bar.add(shapesBox); //jf.add(bar, BorderLayout.NORTH); bar.add(new ListenerWindow.MinSizePanel(scene2.createSatelliteView())); bar.setFloatable(false); bar.setRollover(true); final JLabel selectionLabel = new JLabel("<html> </html>"); System.out.println("LOOKUP IS " + scene2.getLookup()); Lookup.Result<String> selectedNodes = scene2.getLookup().lookupResult(String.class); LookupListener listener = new LookupListener() { @Override public void resultChanged(LookupEvent le) { System.out.println("RES CHANGED"); Lookup.Result<String> res = (Lookup.Result<String>) le.getSource(); StringBuilder sb = new StringBuilder("<html>"); List<String> l = new ArrayList<>(res.allInstances()); Collections.sort(l); for (String s : l) { if (sb.length() != 0) { sb.append(", "); } sb.append(s); } sb.append("</html>"); selectionLabel.setText(sb.toString()); System.out.println("LOOKUP EVENT " + sb); } }; selectedNodes.addLookupListener(listener); selectedNodes.allInstances(); bar.add(selectionLabel); checkbox.setSelected(true); checkbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { scene2.setAnimateIterativeLayouts(checkbox.isSelected()); } }); bar.add(checkbox); jLayeredPane6.setLayout(new BorderLayout()); jLayeredPane6.add(bar); // jf.setSize(jf.getGraphicsConfiguration().getBounds().width - 120, 700); // jf.setSize(new Dimension(1280, 720)); // jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); // this.repaint(); this.addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent we) { scene2.relayout(true); scene2.validate(); } }); }
From source file:com.lynk.hrm.ui.dialog.InfoEmployee.java
private void initComponents() { addWindowListener(new WindowAdapter() { @Override// w w w. ja v a2 s . co m public void windowClosing(WindowEvent e) { thisWindowClosing(e); } }); setSize(836, 674); setTitle(""); setIconImage( Toolkit.getDefaultToolkit().getImage(InfoEmployee.class.getResource("/resource/image/icon.png"))); setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); getContentPane().setLayout(new BorderLayout(0, 0)); { JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false); getContentPane().add(toolBar, BorderLayout.NORTH); { JButton uiSave = new JButton("?"); uiSave.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { uiSaveActionPerformed(true); } }); uiSave.setFocusable(false); uiSave.setIcon(new ImageIcon(InfoEmployee.class.getResource("/resource/image/emp_save.png"))); uiSave.setFont(APP_FONT); toolBar.add(uiSave); } toolBar.addSeparator(); { JButton uiReadIdCard = new JButton("??"); uiReadIdCard.setFont(APP_FONT); uiReadIdCard.setIcon( new ImageIcon(InfoEmployee.class.getResource("/resource/image/manager_teacher.png"))); uiReadIdCard.setFocusable(false); uiReadIdCard.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { uiReadIdCardActionPerformed(e); } }); toolBar.add(uiReadIdCard); } toolBar.addSeparator(); { JButton uiInputFinger = new JButton(""); uiInputFinger.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { uiInputFingerActionPerformed(e); } }); uiInputFinger.setIcon(new ImageIcon(InfoEmployee.class.getResource("/resource/image/finger.png"))); uiInputFinger.setFont(APP_FONT); uiInputFinger.setFocusable(false); toolBar.add(uiInputFinger); } toolBar.addSeparator(); { JButton uiSetSuspend = new JButton("??"); uiSetSuspend.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { uiSetSuspendActionPerformed(e); } }); uiSetSuspend .setIcon(new ImageIcon(InfoEmployee.class.getResource("/resource/image/emp_retire.png"))); uiSetSuspend.setFont(APP_FONT); uiSetSuspend.setFocusable(false); toolBar.add(uiSetSuspend); } } { JPanel panel = new JPanel(); getContentPane().add(panel); panel.setLayout(new MigLayout("", "[]5[grow]25[]5[grow]25[]5[grow]5[102]", "[][][][]")); { JLabel label = new JLabel("?"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); panel.add(label, "cell 0 0"); } { uiId = new LynkTextField(); uiId.setEditable(false); uiId.setForeground(Color.BLUE); panel.add(uiId, "cell 1 0,growx"); } { JLabel label = new JLabel("??"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); panel.add(label, "cell 2 0"); } { uiName = new LynkTextField(); uiName.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { uiNameFocusLost(e); } }); panel.add(uiName, "cell 3 0,growx"); } { JLabel label = new JLabel("?"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); panel.add(label, "cell 4 0"); } { uiNamePy = new LynkTextField(); panel.add(uiNamePy, "cell 5 0,growx"); } { JLabel label = new JLabel("?"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); panel.add(label, "cell 0 1"); } { uiState = new JComboBox<String>(); uiState.setForeground(Color.BLUE); uiState.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { uiStateActionPerformed(e); } }); uiState.setModel(new DefaultComboBoxModel<String>(new String[] { "", Employee.STATE_PROBATION, Employee.STATE_CONTRACT, Employee.STATE_SUSPEND, Employee.STATE_LEAVE, Employee.STATE_RETIRE, Employee.STATE_DELETE })); uiState.setFont(APP_FONT); panel.add(uiState, "cell 1 1,growx"); } { uiInfoTab = new JideTabbedPane(JTabbedPane.TOP); uiInfoTab.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { uiInfoTabStateChanged(e); } }); uiInfoTab.setColorTheme(JideTabbedPane.COLOR_THEME_DEFAULT); uiInfoTab.setFont(APP_FONT); panel.add(uiInfoTab, "cell 0 3 7 1"); { JPanel uiInfoBasic = new JPanel(); uiInfoBasic.setLayout(new MigLayout("", "[473px,grow][307px,grow]", "[grow][289px][149px]")); uiInfoTab.addTab("?", uiInfoBasic); { JPanel uiIdCardPane = new JPanel(); uiIdCardPane.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); uiIdCardPane.setLayout(new MigLayout("", "[]5[grow]10[]", "[][][][][40px:40px:40px,grow]")); uiInfoBasic.add(uiIdCardPane, "cell 0 0,grow"); { JLabel label = new JLabel("??"); uiIdCardPane.add(label, "cell 0 0"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiIdCard = new LynkTextField(); uiIdCardPane.add(uiIdCard, "cell 1 0,growx"); } { JPanel pane = new JPanel(); uiIdCardPane.add(pane, "cell 2 0 1 5,grow"); pane.setLayout(new MigLayout("insets 0", "[102px:102px:102px]", "[126px:126px:126px]")); { uiPhoto = new ImagePane(); pane.add(uiPhoto, "cell 0 0,grow"); } } // { // JPanel photoPane = new JPanel(); // photoPane.setLayout(new MigLayout("insets 0", "[grow]", "[grow][]")); // uiIdCardPane.add(photoPane, "cell 2 0 2 4,grow"); // { // uiPhoto = new ImagePane(); // photoPane.add(uiPhoto, "cell 0 0,grow"); // } // { // JButton uiReadIdCardDirect = new JButton("??"); // uiReadIdCardDirect.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent e) { // uiReadIdCardDirectActionPerformed(e); // } // }); // uiReadIdCardDirect.setFont(APP_FONT); // uiReadIdCardDirect.setFocusable(false); // photoPane.add(uiReadIdCardDirect, "cell 0 1,grow"); // } // } { JLabel label = new JLabel(""); uiIdCardPane.add(label, "cell 0 1"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiBirthday = new LynkTextField(); uiIdCardPane.add(uiBirthday, "cell 1 1,growx"); } { JLabel label = new JLabel(""); uiIdCardPane.add(label, "cell 0 2"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiAge = new LynkTextField(); uiIdCardPane.add(uiAge, "cell 1 2,growx"); } { JLabel label = new JLabel(""); uiIdCardPane.add(label, "cell 0 3,aligny top"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiGender = new LynkTextField(); uiIdCardPane.add(uiGender, "cell 1 3,growx,aligny top"); } { JLabel label = new JLabel("??"); label.setFont(APP_FONT); label.setHorizontalAlignment(SwingConstants.RIGHT); uiIdCardPane.add(label, "cell 0 4"); } { JScrollPane scrollPane = new JScrollPane(); uiIdCardPane.add(scrollPane, "cell 1 4,grow"); { uiCensusAddress = new JTextArea(); uiCensusAddress.setWrapStyleWord(true); uiCensusAddress.setLineWrap(true); scrollPane.setViewportView(uiCensusAddress); uiCensusAddress.setFont(APP_FONT); } } } { JPanel uiIdCardPane = new JPanel(); uiIdCardPane.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); uiIdCardPane .setLayout(new MigLayout("", "[]5[grow]25[]5[grow]", "[][][40px:40px:40px,grow]")); uiInfoBasic.add(uiIdCardPane, "cell 0 1,grow"); { JLabel label = new JLabel(""); uiIdCardPane.add(label, "cell 0 0"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiMarital = new JComboBox<String>(); uiIdCardPane.add(uiMarital, "cell 1 0,growx"); uiMarital.setModel(new DefaultComboBoxModel<String>( new String[] { Employee.MARITAL_YES, Employee.MARITAL_NO })); uiMarital.setFont(APP_FONT); } { JLabel label = new JLabel("?"); uiIdCardPane.add(label, "cell 2 0"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiContact = new LynkTextField(); uiIdCardPane.add(uiContact, "cell 3 0,growx"); } { JLabel label = new JLabel("?"); uiIdCardPane.add(label, "cell 0 1"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiCensus = new JComboBox<String>(); uiIdCardPane.add(uiCensus, "cell 1 1,growx"); uiCensus.setModel(new DefaultComboBoxModel<String>( new String[] { Employee.CENSUS_A, Employee.CENSUS_B, Employee.CENSUS_C, Employee.CENSUS_D, Employee.CENSUS_E, Employee.CENSUS_F })); uiCensus.setFont(APP_FONT); } { JLabel label = new JLabel("??"); uiIdCardPane.add(label, "cell 2 1"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiResidencePermit = new JComboBox<String>(); uiIdCardPane.add(uiResidencePermit, "cell 3 1,growx"); uiResidencePermit .setModel(new DefaultComboBoxModel<String>(new String[] { "", "", "" })); uiResidencePermit.setFont(APP_FONT); } { JLabel label = new JLabel(""); uiIdCardPane.add(label, "cell 0 2"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { JScrollPane scrollPane = new JScrollPane(); uiIdCardPane.add(scrollPane, "cell 1 2 3 1,grow"); { uiAddress = new JTextArea(); uiAddress.setWrapStyleWord(true); uiAddress.setLineWrap(true); scrollPane.setViewportView(uiAddress); uiAddress.setFont(APP_FONT); } } } { JPanel uiCompanyPanel = new JPanel(); uiCompanyPanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); uiCompanyPanel.setLayout(new MigLayout("", "[]5[grow][]25[]5[grow][]", "[][][][][][][][]")); uiInfoBasic.add(uiCompanyPanel, "cell 0 2,growx,aligny top"); { JLabel label = new JLabel(Employee.SUSPEND_NOTE); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); uiCompanyPanel.add(label, "cell 0 0"); } { uiFactory = new JComboBox<String>(new DefaultComboBoxModel<String>( new String[] { Employee.FACROTY_TC, Employee.FACTORY_SX })); uiFactory.setFont(APP_FONT); uiCompanyPanel.add(uiFactory, "cell 1 0 2 1,growx"); } { JLabel label = new JLabel(""); uiCompanyPanel.add(label, "cell 3 0"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiDept = new LynkTextField(); uiDept.setEditable(false); uiCompanyPanel.add(uiDept, "cell 4 0,growx"); } { JButton uiChooseDept = new JButton(); uiChooseDept.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { uiChooseDeptActionPerformed(e); } }); uiChooseDept.setIcon(new ImageIcon( InfoEmployee.class.getResource("/resource/image/choose_more.png"))); uiChooseDept.setMargin(new Insets(1, 1, 1, 1)); uiCompanyPanel.add(uiChooseDept, "cell 5 0,growx"); } { JLabel label = new JLabel("?"); uiCompanyPanel.add(label, "cell 0 1"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiJob = new LynkTextField(); uiJob.setEditable(false); uiCompanyPanel.add(uiJob, "cell 1 1,growx"); } { JButton uiChooseJob = new JButton(); uiChooseJob.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { uiChooseJobActionPerformed(e); } }); uiChooseJob.setIcon(new ImageIcon( InfoEmployee.class.getResource("/resource/image/choose_more.png"))); uiChooseJob.setMargin(new Insets(1, 1, 1, 1)); uiCompanyPanel.add(uiChooseJob, "cell 2 1,growx"); } { JLabel label = new JLabel(Employee.SUSPEND_START); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); uiCompanyPanel.add(label, "cell 3 1"); } { uiDdg = new JComboBox<String>( new DefaultComboBoxModel<>(new String[] { Employee.DDG_N, Employee.DDG_Y })); uiDdg.setFont(APP_FONT); uiCompanyPanel.add(uiDdg, "cell 4 1 2 1,growx"); } { JLabel label = new JLabel(""); uiCompanyPanel.add(label, "cell 0 2"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiEntryDate = new JDateChooser(); uiCompanyPanel.add(uiEntryDate, "cell 1 2 2 1,growx"); uiEntryDate.setDateFormatString("yyyy-MM-dd"); uiEntryDate.setFont(APP_FONT); uiEntryDate.getJCalendar().setTodayButtonVisible(true); uiEntryDate.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if ("date".equals(evt.getPropertyName())) { setWorkAge(); } } }); } { JLabel label = new JLabel(""); uiCompanyPanel.add(label, "cell 3 2"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiWorkAge = new LynkTextField("0"); uiCompanyPanel.add(uiWorkAge, "cell 4 2 2 1,growx"); uiWorkAge.setEditable(false); } { JLabel label = new JLabel("?"); uiCompanyPanel.add(label, "cell 0 3"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiProbation = new JDateChooser(); uiCompanyPanel.add(uiProbation, "cell 1 3 2 1,growx"); uiProbation.setDateFormatString("yyyy-MM-dd"); uiProbation.setFont(APP_FONT); uiProbation.getJCalendar().setTodayButtonVisible(true); } { JLabel label = new JLabel("??"); uiCompanyPanel.add(label, "cell 3 3"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiExpiration = new JDateChooser(); uiCompanyPanel.add(uiExpiration, "cell 4 3 2 1,growx"); uiExpiration.setDateFormatString("yyyy-MM-dd"); uiExpiration.setFont(APP_FONT); uiExpiration.getJCalendar().setLeftButtonText(Employee.EXPIRATION_NO); uiExpiration.getJCalendar().setLeftButtonVisible(true); uiExpiration.getJCalendar().setRightButtonText(Employee.EXPIRATION_LONG); uiExpiration.getJCalendar().setRightButtonVisible(true); } { JLabel label = new JLabel(""); uiCompanyPanel.add(label, "cell 0 4"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiSchool = new LynkTextField(); uiCompanyPanel.add(uiSchool, "cell 1 4 2 1,growx"); } { JLabel label = new JLabel(""); uiCompanyPanel.add(label, "cell 3 4"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiDegree = new JComboBox<String>(); uiCompanyPanel.add(uiDegree, "cell 4 4 2 1,growx"); uiDegree.setMaximumRowCount(12); uiDegree.setModel(new DefaultComboBoxModel<String>(new String[] { "", Employee.DEGREE_A, Employee.DEGREE_B, Employee.DEGREE_C, Employee.DEGREE_D, Employee.DEGREE_E, Employee.DEGREE_F, Employee.DEGREE_G, Employee.DEGREE_H, Employee.DEGREE_I, Employee.DEGREE_J })); uiDegree.setFont(APP_FONT); } { JLabel label = new JLabel(""); uiCompanyPanel.add(label, "cell 0 5"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiMajor = new LynkTextField(); uiCompanyPanel.add(uiMajor, "cell 1 5 2 1,growx"); } { JLabel label = new JLabel(""); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); uiCompanyPanel.add(label, "cell 3 5"); } { uiGuide = new LynkTextField(); uiCompanyPanel.add(uiGuide, "cell 4 5 2 1,growx"); } { JLabel label = new JLabel("?"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT_BLOD); uiCompanyPanel.add(label, "cell 0 6"); } { uiPhoneShort = new LynkTextField(); uiPhoneShort.setFont(APP_FONT_BLOD); uiCompanyPanel.add(uiPhoneShort, "cell 1 6 2 1,growx"); } { JLabel label = new JLabel("?"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); uiCompanyPanel.add(label, "cell 3 6"); } { uiPerformance = new LynkTextField(); uiCompanyPanel.add(uiPerformance, "cell 4 6 2 1,growx"); } // { // JLabel label = new JLabel("??"); // label.setHorizontalAlignment(SwingConstants.RIGHT); // label.setFont(APP_FONT); // uiCompanyPanel.add(label, "cell 0 7"); // } // { // uiSuspendEnd = new LynkTextField(); // uiCompanyPanel.add(uiSuspendEnd, "cell 1 7 5 1,growx"); // } } { JPanel panel4 = new JPanel(); panel4.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); panel4.setLayout(new MigLayout("", "[]5[grow]", "[][][][grow][grow]")); uiInfoBasic.add(panel4, "cell 1 0 1 3,grow"); { JLabel label = new JLabel("???"); panel4.add(label, "cell 0 0,grow"); label.setFont(APP_FONT); } { uiSocialCard = new LynkTextField(); panel4.add(uiSocialCard, "cell 1 0,grow"); } { JLabel label = new JLabel("?"); panel4.add(label, "cell 0 1,grow"); label.setFont(APP_FONT); } { uiHousingCard = new LynkTextField(); panel4.add(uiHousingCard, "cell 1 1,grow"); } { JLabel label = new JLabel("??"); panel4.add(label, "cell 0 2,grow"); label.setFont(APP_FONT); } { uiBankCard = new LynkTextField(); panel4.add(uiBankCard, "cell 1 2,grow"); } { JLabel label = new JLabel("?"); panel4.add(label, "cell 0 3,growx,aligny top"); label.setFont(APP_FONT); } { JScrollPane scrollPane = new JScrollPane(); panel4.add(scrollPane, "cell 1 3,grow"); uiWorkExperience = new JTextArea(); uiWorkExperience.setFont(APP_FONT); scrollPane.setViewportView(uiWorkExperience); } { JLabel label = new JLabel(""); panel4.add(label, "cell 0 4,growx,aligny top"); label.setFont(APP_FONT); } { JScrollPane scrollPane = new JScrollPane(); panel4.add(scrollPane, "cell 1 4,grow"); { uiNote = new JTextArea(); uiNote.setFont(APP_FONT); scrollPane.setViewportView(uiNote); } } } } { JPanel uiInfoLeave = new JPanel(); uiInfoLeave.setLayout(new MigLayout("", "[]5[150px]25[]5[150px]", "[][][][grow][]")); uiInfoTab.addTab("??", uiInfoLeave); { uiLabelLeaveDate = new JLabel("?"); uiLabelLeaveDate.setFont(APP_FONT); uiInfoLeave.add(uiLabelLeaveDate, "cell 0 0,grow"); } { uiLeaveDate = new JDateChooser(); uiLeaveDate.setDateFormatString("yyyy-MM-dd"); uiLeaveDate.setFont(APP_FONT); uiLeaveDate.getJCalendar().setTodayButtonVisible(true); uiLeaveDate.getJCalendar().setNullDateButtonVisible(true); uiInfoLeave.add(uiLeaveDate, "cell 1 0,growx,aligny top"); } { uiLabelSocialEnd = new JLabel("??"); uiLabelSocialEnd.setFont(APP_FONT); uiInfoLeave.add(uiLabelSocialEnd, "cell 0 1,grow"); } { uiLabelHousingEnd = new JLabel("?"); uiLabelHousingEnd.setFont(APP_FONT); uiInfoLeave.add(uiLabelHousingEnd, "cell 2 1,grow"); } { uiHousingEndDate = new JDateChooser(); uiHousingEndDate.setDateFormatString("yyyy-MM-dd"); uiHousingEndDate.setFont(APP_FONT); uiHousingEndDate.getJCalendar().setLeftButtonText(""); uiHousingEndDate.getJCalendar().setLeftButtonVisible(true); uiHousingEndDate.getJCalendar().setTodayButtonVisible(true); uiHousingEndDate.getJCalendar().setNullDateButtonVisible(true); uiInfoLeave.add(uiHousingEndDate, "cell 3 1,growx,aligny top"); } { uiLabelLeaveType = new JLabel("?"); uiLabelLeaveType.setFont(APP_FONT); uiInfoLeave.add(uiLabelLeaveType, "cell 0 2,grow"); } { uiSocialEndDate = new JDateChooser(); uiSocialEndDate.setDateFormatString("yyyy-MM-dd"); uiSocialEndDate.setFont(APP_FONT); uiSocialEndDate.getJCalendar().setLeftButtonText(""); uiSocialEndDate.getJCalendar().setLeftButtonVisible(true); uiSocialEndDate.getJCalendar().setTodayButtonVisible(true); uiSocialEndDate.getJCalendar().setNullDateButtonVisible(true); uiInfoLeave.add(uiSocialEndDate, "cell 1 1,growx,aligny top"); } { uiLeaveType = new JComboBox<String>(new DefaultComboBoxModel<String>( new String[] { "", Employee.LEAVE_TYPE_A, Employee.LEAVE_TYPE_B, Employee.LEAVE_TYPE_C, Employee.LEAVE_TYPE_D, Employee.LEAVE_TYPE_E, Employee.LEAVE_TYPE_F, Employee.LEAVE_TYPE_G, Employee.LEAVE_TYPE_H })); uiLeaveType.setMaximumRowCount(10); uiLeaveType.setFont(APP_FONT); uiInfoLeave.add(uiLeaveType, "cell 1 2 3 1,grow"); } { uiLabelLeaveReason = new JLabel("?"); uiLabelLeaveReason.setFont(APP_FONT); uiInfoLeave.add(uiLabelLeaveReason, "cell 0 3,growx,aligny top"); } { JScrollPane scrollPane_2 = new JScrollPane(); uiInfoLeave.add(scrollPane_2, "cell 1 3 3 1,grow"); { uiLeaveReason = new JTextArea(); scrollPane_2.setViewportView(uiLeaveReason); uiLeaveReason.setFont(APP_FONT); } } { JLabel label = new JLabel("??"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); uiInfoLeave.add(label, "cell 0 4"); } { uiTimeCardLeaveCertify = new LynkTextField(); uiTimeCardLeaveCertify.setEditable(false); uiInfoLeave.add(uiTimeCardLeaveCertify, "cell 1 4 2 1,growx"); } { JButton uiPrintLeaveCertify = new JButton("???"); uiPrintLeaveCertify.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { uiPrintLeaveCertifyActionPerformed(e); } }); uiPrintLeaveCertify.setToolTipText("???!"); uiPrintLeaveCertify.setFont(APP_FONT); uiPrintLeaveCertify.setFocusable(false); uiInfoLeave.add(uiPrintLeaveCertify, "cell 3 4,alignx right"); } } { JPanel uiInfoSuspendHistory = new JPanel(); uiInfoSuspendHistory.setLayout(new BorderLayout(0, 0)); uiInfoTab.addTab("???", uiInfoSuspendHistory); { JScrollPane scrollPane = new JScrollPane(); uiInfoSuspendHistory.add(scrollPane, BorderLayout.CENTER); { suspendModel = new EmployeeSuspendModel(); uiEmpSuspend = new LynkTable(suspendModel); uiEmpSuspend.addHighlighter(UtilsClient.createAlignHighlighter()); uiEmpSuspend.setAutoResizeMode(LynkTable.AUTO_RESIZE_ALL_COLUMNS); scrollPane.setRowHeaderView(new TableRowHead(uiEmpSuspend)); scrollPane.setViewportView(uiEmpSuspend); } } } { JPanel uiInfoEmpHistory = new JPanel(); uiInfoEmpHistory.setLayout(new BorderLayout(0, 0)); uiInfoTab.addTab("?", uiInfoEmpHistory); { JPanel pane = new JPanel(); pane.setLayout(new MigLayout("", "[][][][100px:100px:100px][]", "[]")); uiInfoEmpHistory.add(pane, BorderLayout.NORTH); { JLabel label = new JLabel(""); label.setFont(APP_FONT); pane.add(label, "cell 0 0"); } { uiHistoryType = new JComboBox<String>(new DefaultComboBoxModel<>( new String[] { "", PraisePunish.TYPE_A, PraisePunish.TYPE_B, PraisePunish.TYPE_C, PraisePunish.TYPE_D, PraisePunish.TYPE_E, PraisePunish.TYPE_F, PraisePunish.TYPE_G, PraisePunish.TYPE_H })); uiHistoryType.setFont(APP_FONT); pane.add(uiHistoryType, "cell 1 0"); } { JLabel label = new JLabel("?"); label.setFont(APP_FONT); pane.add(label, "cell 2 0"); } { uiHistoryOperator = new LynkTextField(); pane.add(uiHistoryOperator, "cell 3 0,growx"); } { JButton uiRefresh = new JButton(""); uiRefresh.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { uiRefreshActionPerformed(e); } }); uiRefresh.setIcon( new ImageIcon(InfoEmployee.class.getResource("/resource/image/refresh.png"))); uiRefresh.setFont(APP_FONT); uiRefresh.setFocusable(false); pane.add(uiRefresh, "cell 4 0"); } } { JScrollPane scrollPane = new JScrollPane(); uiInfoEmpHistory.add(scrollPane, BorderLayout.CENTER); { historyModel = new EmployeeHistoryModel(); uiEmployeeHistory = new LynkTable(historyModel); uiEmployeeHistory.setColumnSize(70, 540, 50, 130, 90); scrollPane.setViewportView(uiEmployeeHistory); scrollPane.setRowHeaderView(new TableRowHead(uiEmployeeHistory)); } } } { JPanel uiInfoJobAdjustment = new JPanel(); uiInfoJobAdjustment.setLayout(new BorderLayout(0, 0)); uiInfoTab.addTab("?", uiInfoJobAdjustment); { JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false); uiInfoJobAdjustment.add(toolBar, BorderLayout.NORTH); { { JButton uiAddJobAdjust = new JButton("?"); uiAddJobAdjust.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { uiAddJobAdjustActionPerformed(e); } }); uiAddJobAdjust.setIcon( new ImageIcon(InfoEmployee.class.getResource("/resource/image/add.png"))); uiAddJobAdjust.setFont(APP_FONT); toolBar.add(uiAddJobAdjust); } } } { JScrollPane scrollPane = new JScrollPane(); uiInfoJobAdjustment.add(scrollPane, BorderLayout.CENTER); { jobAdjustmentModel = new JobAdjustmentModel(); uiJobAdjustment = new LynkTable(jobAdjustmentModel); uiJobAdjustment.setColumnSize(50, 100, 100, 100, 100, 100, 80, 100, 150); scrollPane.setRowHeaderView(new TableRowHead(uiJobAdjustment)); scrollPane.setViewportView(uiJobAdjustment); } } } { JPanel uiInfoPraisePunish = new JPanel(); uiInfoTab.addTab("", uiInfoPraisePunish); uiInfoPraisePunish.setLayout( new MigLayout("", "[]10[grow]30[]10[120]5[]5[120]20[]20[][grow]", "[][grow]")); { uiPraisePunishDateStart = new JDateChooser(); uiPraisePunishDateStart.setFont(APP_FONT); uiPraisePunishDateStart.setDateFormatString("yyyy-MM-dd"); uiInfoPraisePunish.add(uiPraisePunishDateStart, "cell 3 0,growx"); } { uiPraisePunishDateEnd = new JDateChooser(); uiPraisePunishDateEnd.setFont(APP_FONT); uiPraisePunishDateEnd.setDateFormatString("yyyy-MM-dd"); uiInfoPraisePunish.add(uiPraisePunishDateEnd, "cell 5 0,growx"); } JButton uiAddPraisePunish = new JButton(""); uiAddPraisePunish.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { uiAddPraisePunishActionPerformed(e); } }); { JButton uiFindPraisePunish = new JButton(""); uiFindPraisePunish.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { uiFindPraisePunishActionPerformed(e); } }); { JLabel label = new JLabel(""); label.setFont(APP_FONT); uiInfoPraisePunish.add(label, "cell 0 0,alignx trailing"); } { uiPraisePunishType = new JComboBox<String>( new DefaultComboBoxModel<String>(new String[] { "", PraisePunish.TYPE_A, PraisePunish.TYPE_B, PraisePunish.TYPE_C, PraisePunish.TYPE_D, PraisePunish.TYPE_E, PraisePunish.TYPE_F, PraisePunish.TYPE_G })); uiPraisePunishType.setEditable(true); uiPraisePunishType.setFont(APP_FONT); uiInfoPraisePunish.add(uiPraisePunishType, "cell 1 0,growx"); } { JLabel label = new JLabel(""); label.setFont(APP_FONT); uiInfoPraisePunish.add(label, "cell 2 0"); } { JLabel label = new JLabel(""); label.setFont(APP_FONT); uiInfoPraisePunish.add(label, "cell 4 0"); } uiFindPraisePunish.setFocusable(false); uiFindPraisePunish.setIcon( new ImageIcon(InfoEmployee.class.getResource("/resource/image/refresh.png"))); uiFindPraisePunish.setFont(APP_FONT); uiInfoPraisePunish.add(uiFindPraisePunish, "cell 6 0"); } uiAddPraisePunish .setIcon(new ImageIcon(InfoEmployee.class.getResource("/resource/image/add.png"))); uiAddPraisePunish.setFont(APP_FONT); uiAddPraisePunish.setFocusable(false); uiInfoPraisePunish.add(uiAddPraisePunish, "cell 7 0"); JScrollPane scrollPane = new JScrollPane(); uiInfoPraisePunish.add(scrollPane, "cell 0 1 9 1,grow"); { praisePunishModel = new PraisePunishModel( new String[] { PraisePunish.COLUMN_TYPE, PraisePunish.COLUMN_ACTION, PraisePunish.COLUMN_ACTION_DATE, PraisePunish.COLUMN_DEAL, PraisePunish.COLUMN_DEAL_DATE, PraisePunish.COLUMN_NOTE }); uiPraisePunish = new LynkTable(praisePunishModel); uiPraisePunish.setColumnVisible( new String[] { PraisePunish.COLUMN_TYPE, PraisePunish.COLUMN_ACTION, PraisePunish.COLUMN_ACTION_DATE, PraisePunish.COLUMN_DEAL, PraisePunish.COLUMN_DEAL_DATE, PraisePunish.COLUMN_NOTE }); uiPraisePunish.setDefaultRenderer(Object.class, new PraisePunishColorRenderer()); uiPraisePunish.setMouseDoubleClick(new MouseDoubleClick() { @Override public void doubleClick(int index) { if (index != -1) { index = uiPraisePunish.convertRowIndexToModel(index); PraisePunish pp = praisePunishModel.getPp(index); pp = InfoPraisePunish.showdialog(InfoEmployee.this, pp, null); if (pp != null) { praisePunishModel.updatePp(pp); } } } }); scrollPane.setViewportView(uiPraisePunish); scrollPane.setRowHeaderView(new TableRowHead(uiPraisePunish)); } } { JPanel uiPanelVacation = new JPanel(); uiPanelVacation.setLayout(new BorderLayout()); uiInfoTab.addTab("?", uiPanelVacation); { JToolBar uiVacationToolBar = new JToolBar(); uiVacationToolBar.setFloatable(false); uiPanelVacation.add(uiVacationToolBar, BorderLayout.NORTH); { JButton uiVacationRefresh = new JButton(""); uiVacationRefresh.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { uiVacationRefreshActionPerformed(e); } }); uiVacationRefresh.setIcon( new ImageIcon(InfoEmployee.class.getResource("/resource/image/refresh.png"))); uiVacationRefresh.setFocusable(false); uiVacationRefresh.setFont(APP_FONT); uiVacationToolBar.add(uiVacationRefresh); } uiVacationToolBar.addSeparator(); { uiVacationHistoryAdd = new JButton(""); uiVacationHistoryAdd.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { uiVacationAddActionPerformed(e); } }); uiVacationHistoryAdd.setIcon( new ImageIcon(InfoEmployee.class.getResource("/resource/image/add.png"))); uiVacationHistoryAdd.setFocusable(false); uiVacationHistoryAdd.setFont(APP_FONT); uiVacationToolBar.add(uiVacationHistoryAdd); } uiVacationToolBar.addSeparator(); { JButton uiEndLastLeft = new JButton(""); uiEndLastLeft.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { uiEndLastLeftActionPerformed(e); } }); uiEndLastLeft.setIcon( new ImageIcon(InfoEmployee.class.getResource("/resource/image/add.png"))); uiEndLastLeft.setFocusable(false); uiEndLastLeft.setFont(APP_FONT); uiVacationToolBar.add(uiEndLastLeft); } } { JPanel uiPanelVacationInfo = new JPanel(); uiPanelVacation.add(uiPanelVacationInfo, BorderLayout.CENTER); uiPanelVacationInfo.setLayout(new MigLayout("", "[grow]", "[][grow]")); JPanel paneAv = new JPanel(); uiPanelVacationInfo.add(paneAv, "cell 0 0,grow"); paneAv.setLayout(new MigLayout("", "[][grow]50[][grow]", "[][][]")); { uiVacationStartEnd = new JLabel("Time"); uiVacationStartEnd.setHorizontalAlignment(SwingConstants.CENTER); paneAv.add(uiVacationStartEnd, "cell 0 0 4 1,growx"); uiVacationStartEnd.setForeground(Color.BLUE); uiVacationStartEnd.setFont(APP_FONT.deriveFont(16f)); } { JLabel labe = new JLabel(":"); paneAv.add(labe, "cell 0 1"); labe.setFont(APP_FONT.deriveFont(16f)); } { uiLastTotal = new JLabel(""); paneAv.add(uiLastTotal, "cell 1 1,alignx left"); uiLastTotal.setForeground(Color.BLUE); uiLastTotal.setFont(APP_FONT.deriveFont(16f)); } { JLabel labe = new JLabel(":"); paneAv.add(labe, "cell 2 1"); labe.setFont(APP_FONT.deriveFont(16f)); } { uiLastLeft = new JLabel(""); paneAv.add(uiLastLeft, "cell 3 1,alignx left"); uiLastLeft.setForeground(Color.BLUE); uiLastLeft.setFont(APP_FONT.deriveFont(16f)); } { JLabel labe = new JLabel(":"); paneAv.add(labe, "cell 0 2"); labe.setFont(APP_FONT.deriveFont(16f)); } { uiCurrentTotal = new JLabel(""); paneAv.add(uiCurrentTotal, "cell 1 2,alignx left"); uiCurrentTotal.setForeground(Color.BLUE); uiCurrentTotal.setFont(APP_FONT.deriveFont(16f)); } { JLabel labe = new JLabel("?:"); paneAv.add(labe, "cell 2 2"); labe.setFont(APP_FONT.deriveFont(16f)); } { uiLeftHours = new JLabel(""); paneAv.add(uiLeftHours, "cell 3 2,alignx left"); uiLeftHours.setForeground(Color.BLUE); uiLeftHours.setFont(APP_FONT.deriveFont(16f)); } JScrollPane scrollPane = new JScrollPane(); uiPanelVacationInfo.add(scrollPane, "cell 0 1,grow"); { attendanceVacationModel = new AttendanceVacationHistoryModel(); uiAttendanceVacationHistory = new LynkTable(attendanceVacationModel); uiAttendanceVacationHistory.setAutoResizeMode(LynkTable.AUTO_RESIZE_ALL_COLUMNS); scrollPane.setViewportView(uiAttendanceVacationHistory); scrollPane.setRowHeaderView(new TableRowHead(uiAttendanceVacationHistory)); } } } } } }
From source file:com.declarativa.interprolog.gui.ListenerWindow.java
private void graphComponents() throws IOException { Forest<String, Integer> forest = new DelegateForest<>(); Forest<String, Integer> forest2 = new DelegateForest<>(); Forest<String, Integer> forest3 = new DelegateForest<>(); //ObservableGraph g = new ObservableGraph(new BalloonLayoutDemo().createTree(forest)); ObservableGraph g = new ObservableGraph(new GraphGenerator().createTree(forest)); ObservableGraph g2 = new ObservableGraph(new GraphGenerator().createTree2(forest2)); ObservableGraph g3 = new ObservableGraph(new GraphGenerator().createTree3(forest3)); //Layout layout = new BalloonLayout(forest); Layout layout = new BalloonLayout(forest); Layout layout2 = new BalloonLayout(forest2); Layout layout3 = new TreeLayout(forest3, 70, 70); final BaseJungScene scene = new SceneImpl(g, layout); final BaseJungScene scene2 = new SceneImpl(g2, layout2); final BaseJungScene scene3 = new SceneImpl(g3, layout3); jLayeredPane1.setLayout(new BorderLayout()); //jf.setLayout(new BorderLayout()); jLayeredPane5.setLayout(new BorderLayout()); jLayeredPane8.setLayout(new BorderLayout()); jLayeredPane1.add(new JScrollPane(scene.createView()), BorderLayout.CENTER); //jf.add(new JScrollPane(scene2.createView()), BorderLayout.CENTER); jLayeredPane5.add(new JScrollPane(scene2.createView()), BorderLayout.CENTER); jLayeredPane8.add(new JScrollPane(scene3.createView()), BorderLayout.CENTER); JToolBar bar = new JToolBar(); bar.setMargin(new Insets(5, 5, 5, 5)); bar.setLayout(new FlowLayout(5)); DefaultComboBoxModel<Layout> mdl = new DefaultComboBoxModel<>(); mdl.addElement(new KKLayout(g)); mdl.addElement(layout);//www . j a v a 2 s .com mdl.addElement(new BalloonLayout(forest)); mdl.addElement(new RadialTreeLayout(forest)); mdl.addElement(new CircleLayout(g)); mdl.addElement(new FRLayout(g)); mdl.addElement(new FRLayout2(g)); mdl.addElement(new ISOMLayout(g)); mdl.addElement(new edu.uci.ics.jung.algorithms.layout.SpringLayout(g)); mdl.addElement(new SpringLayout2(g)); mdl.addElement(new DAGLayout(g)); mdl.addElement(new XLayout(g)); mdl.setSelectedItem(layout); final JCheckBox checkbox = new JCheckBox("Animate iterative layouts"); scene.setLayoutAnimationFramesPerSecond(48); scene2.setLayoutAnimationFramesPerSecond(48); scene3.setLayoutAnimationFramesPerSecond(48); final JComboBox<Layout> layouts = new JComboBox(mdl); layouts.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln, boolean bln1) { o = o.getClass().getSimpleName(); return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates. } }); bar.add(new JLabel(" Layout Type")); bar.add(layouts); layouts.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Layout layout = (Layout) layouts.getSelectedItem(); // These two layouts implement IterativeContext, but they do // not evolve toward anything, they just randomly rearrange // themselves. So disable animation for these. if (layout instanceof ISOMLayout || layout instanceof DAGLayout) { checkbox.setSelected(false); } scene.setGraphLayout(layout, true); } }); bar.add(new JLabel(" Connection Shape")); DefaultComboBoxModel<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapes = new DefaultComboBoxModel<>(); shapes.addElement(new EdgeShape.QuadCurve<String, Number>()); shapes.addElement(new EdgeShape.BentLine<String, Number>()); shapes.addElement(new EdgeShape.CubicCurve<String, Number>()); shapes.addElement(new EdgeShape.Line<String, Number>()); shapes.addElement(new EdgeShape.Box<String, Number>()); shapes.addElement(new EdgeShape.Orthogonal<String, Number>()); shapes.addElement(new EdgeShape.Wedge<String, Number>(10)); final JComboBox<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapesBox = new JComboBox<>( shapes); shapesBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Transformer<Context<Graph<String, Number>, Number>, Shape> xform = (Transformer<Context<Graph<String, Number>, Number>, Shape>) shapesBox .getSelectedItem(); scene.setConnectionEdgeShape(xform); } }); shapesBox.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln, boolean bln1) { o = o.getClass().getSimpleName(); return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates. } }); shapesBox.setSelectedItem(new EdgeShape.QuadCurve<>()); bar.add(shapesBox); //jf.add(bar, BorderLayout.NORTH); bar.add(new ListenerWindow.MinSizePanel(scene.createSatelliteView())); bar.setFloatable(false); bar.setRollover(true); final JLabel selectionLabel = new JLabel("<html> </html>"); System.out.println("LOOKUP IS " + scene.getLookup()); Lookup.Result<String> selectedNodes = scene.getLookup().lookupResult(String.class); LookupListener listener = new LookupListener() { @Override public void resultChanged(LookupEvent le) { System.out.println("RES CHANGED"); Lookup.Result<String> res = (Lookup.Result<String>) le.getSource(); StringBuilder sb = new StringBuilder("<html>"); List<String> l = new ArrayList<>(res.allInstances()); Collections.sort(l); for (String s : l) { if (sb.length() != 0) { sb.append(", "); } sb.append(s); } sb.append("</html>"); selectionLabel.setText(sb.toString()); System.out.println("LOOKUP EVENT " + sb); } }; selectedNodes.addLookupListener(listener); selectedNodes.allInstances(); bar.add(selectionLabel); checkbox.setSelected(true); checkbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { scene.setAnimateIterativeLayouts(checkbox.isSelected()); } }); bar.add(checkbox); jLayeredPane3.setLayout(new BorderLayout()); jLayeredPane6.setLayout(new BorderLayout()); jLayeredPane3.add(bar); jLayeredPane6.add(bar); // jf.setSize(jf.getGraphicsConfiguration().getBounds().width - 120, 700); // jf.setSize(new Dimension(1280, 720)); // jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); this.addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent we) { scene.relayout(true); scene.validate(); scene2.relayout(true); scene2.validate(); scene3.relayout(true); scene3.validate(); } }); }
From source file:com.hexidec.ekit.EkitCore.java
/** * Convenience method for obtaining a custom toolbar *//*from ww w .j a v a 2 s . c o m*/ public JToolBar customizeToolBar(int whichToolBar, Vector<String> vcTools, boolean isShowing) { JToolBar jToolBarX = new JToolBar(JToolBar.HORIZONTAL); jToolBarX.setFloatable(false); for (int i = 0; i < vcTools.size(); i++) { String toolToAdd = vcTools.elementAt(i).toUpperCase(); if (toolToAdd.equals(KEY_TOOL_SEP)) { jToolBarX.add(new JToolBar.Separator()); } else if (htTools.containsKey(toolToAdd)) { if (htTools.get(toolToAdd) instanceof JButtonNoFocus) { jToolBarX.add((JButtonNoFocus) (htTools.get(toolToAdd))); } else if (htTools.get(toolToAdd) instanceof JToggleButtonNoFocus) { jToolBarX.add((JToggleButtonNoFocus) (htTools.get(toolToAdd))); } else if (htTools.get(toolToAdd) instanceof JComboBoxNoFocus) { jToolBarX.add((JComboBoxNoFocus) (htTools.get(toolToAdd))); } else { jToolBarX.add((JComponent) (htTools.get(toolToAdd))); } } else { Action a = null; for (HTMLDocumentBehavior b : behaviors) { a = b.getAction(toolToAdd); if (a != null) { JButtonNoFocus button = new JButtonNoFocus(a); button.setText(null); jToolBarX.add(button); break; } } } } if (whichToolBar == TOOLBAR_SINGLE) { jToolBar = jToolBarX; jToolBar.setVisible(isShowing); jcbmiViewToolbar.setSelected(isShowing); return jToolBar; } else if (whichToolBar == TOOLBAR_MAIN) { jToolBarMain = jToolBarX; jToolBarMain.setVisible(isShowing); jcbmiViewToolbarMain.setSelected(isShowing); return jToolBarMain; } else if (whichToolBar == TOOLBAR_FORMAT) { jToolBarFormat = jToolBarX; jToolBarFormat.setVisible(isShowing); jcbmiViewToolbarFormat.setSelected(isShowing); return jToolBarFormat; } else if (whichToolBar == TOOLBAR_STYLES) { jToolBarStyles = jToolBarX; jToolBarStyles.setVisible(isShowing); jcbmiViewToolbarStyles.setSelected(isShowing); return jToolBarStyles; } else { jToolBarMain = jToolBarX; jToolBarMain.setVisible(isShowing); jcbmiViewToolbarMain.setSelected(isShowing); return jToolBarMain; } }
From source file:com.net2plan.gui.tools.GUINetworkDesign.java
private JPanel configureLeftBottomPanel() { this.focusPanel = new FocusPane(this); final JPanel focusPanelContainer = new JPanel(new BorderLayout()); final JToolBar navigationToolbar = new JToolBar(JToolBar.VERTICAL); navigationToolbar.setRollover(true); navigationToolbar.setFloatable(false); navigationToolbar.setOpaque(false);/*from w ww. j a v a2 s . c o m*/ final JButton btn_pickNavigationUndo, btn_pickNavigationRedo; btn_pickNavigationUndo = new JButton(""); btn_pickNavigationUndo .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/undoPick.png"))); btn_pickNavigationUndo.setToolTipText("Navigate back to the previous element picked"); btn_pickNavigationRedo = new JButton(""); btn_pickNavigationRedo .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/redoPick.png"))); btn_pickNavigationRedo.setToolTipText("Navigate forward to the next element picked"); final ActionListener action = e -> { Pair<NetworkElement, Pair<Demand, Link>> backOrForward; do { backOrForward = (e.getSource() == btn_pickNavigationUndo) ? GUINetworkDesign.this.getVisualizationState().getPickNavigationBackElement() : GUINetworkDesign.this.getVisualizationState().getPickNavigationForwardElement(); if (backOrForward == null) break; final NetworkElement ne = backOrForward.getFirst(); // For network elements final Pair<Demand, Link> fr = backOrForward.getSecond(); // For forwarding rules if (ne != null) { if (ne.getNetPlan() != GUINetworkDesign.this.getDesign()) continue; if (ne.getNetPlan() == null) continue; break; } else if (fr != null) { if (fr.getFirst().getNetPlan() != GUINetworkDesign.this.getDesign()) continue; if (fr.getFirst().getNetPlan() == null) continue; if (fr.getSecond().getNetPlan() != GUINetworkDesign.this.getDesign()) continue; if (fr.getSecond().getNetPlan() == null) continue; break; } else break; // null,null => reset picked state } while (true); if (backOrForward != null) { if (backOrForward.getFirst() != null) GUINetworkDesign.this.getVisualizationState().pickElement(backOrForward.getFirst()); else if (backOrForward.getSecond() != null) GUINetworkDesign.this.getVisualizationState().pickForwardingRule(backOrForward.getSecond()); else GUINetworkDesign.this.getVisualizationState().resetPickedState(); GUINetworkDesign.this.updateVisualizationAfterPick(); } }; btn_pickNavigationUndo.addActionListener(action); btn_pickNavigationRedo.addActionListener(action); btn_pickNavigationRedo.setFocusable(false); btn_pickNavigationUndo.setFocusable(false); navigationToolbar.add(btn_pickNavigationUndo); navigationToolbar.add(btn_pickNavigationRedo); final JScrollPane scPane = new JScrollPane(focusPanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scPane.getVerticalScrollBar().setUnitIncrement(20); scPane.getHorizontalScrollBar().setUnitIncrement(20); scPane.setBorder(BorderFactory.createEmptyBorder()); // Control the scroll scPane.getHorizontalScrollBar().addAdjustmentListener(e -> { // Repaints the panel each time the horizontal scroll bar is moves, in order to avoid ghosting. focusPanelContainer.revalidate(); focusPanelContainer.repaint(); }); focusPanelContainer.add(navigationToolbar, BorderLayout.WEST); focusPanelContainer.add(scPane, BorderLayout.CENTER); JPanel pane = new JPanel(new MigLayout("fill, insets 0 0 0 0")); pane.setBorder(BorderFactory.createTitledBorder(new LineBorder(Color.BLACK), "Focus panel")); pane.add(focusPanelContainer, "grow"); return pane; }
From source file:com.igormaznitsa.ideamindmap.swing.PlainTextEditor.java
public PlainTextEditor(final Project project, final String text) { super(new BorderLayout()); this.editor = new EmptyTextEditor(project); final JToolBar menu = new JToolBar(); final JButton buttonImport = new JButton("Import", AllIcons.Buttons.IMPORT); final PlainTextEditor theInstance = this; buttonImport.addActionListener(new ActionListener() { @Override//from www . ja v a 2 s. c o m public void actionPerformed(ActionEvent e) { final File home = new File(System.getProperty("user.home")); //NOI18N final File toOpen = IdeaUtils.chooseFile(theInstance, true, BUNDLE.getString("PlainTextEditor.buttonLoadActionPerformed.title"), home, TEXT_FILE_FILTER); if (toOpen != null) { try { final String text = FileUtils.readFileToString(toOpen, "UTF-8"); //NOI18N editor.setText(text); } catch (Exception ex) { LOGGER.error("Error during text file loading", ex); //NOI18N Messages.showErrorDialog( BUNDLE.getString("PlainTextEditor.buttonLoadActionPerformed.msgError"), "Error"); } } } }); final JButton buttonExport = new JButton("Export", AllIcons.Buttons.EXPORT); buttonExport.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final File home = new File(System.getProperty("user.home")); //NOI18N final File toSave = IdeaUtils.chooseFile(theInstance, true, BUNDLE.getString("PlainTextEditor.buttonSaveActionPerformed.saveTitle"), home, TEXT_FILE_FILTER); if (toSave != null) { try { final String text = getText(); FileUtils.writeStringToFile(toSave, text, "UTF-8"); //NOI18N } catch (Exception ex) { LOGGER.error("Error during text file saving", ex); //NOI18N Messages.showErrorDialog( BUNDLE.getString("PlainTextEditor.buttonSaveActionPerformed.msgError"), "Error"); } } } }); final JButton buttonCopy = new JButton("Copy", AllIcons.Buttons.COPY); buttonCopy.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final StringSelection stringSelection = new StringSelection(editor.getSelectedText()); final Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard(); clpbrd.setContents(stringSelection, null); } }); final JButton buttonPaste = new JButton("Paste", AllIcons.Buttons.PASTE); buttonPaste.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { final String clipboardText = (String) Toolkit.getDefaultToolkit().getSystemClipboard() .getData(DataFlavor.stringFlavor); editor.replaceSelection(clipboardText); } catch (UnsupportedFlavorException ex) { // no text data in clipboard } catch (IOException ex) { LOGGER.error("Error during paste from clipboard", ex); //NOI18N } } }); final JButton buttonClearAll = new JButton("Clear All", AllIcons.Buttons.CLEARALL); buttonClearAll.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editor.clear(); } }); menu.add(buttonImport); menu.add(buttonExport); menu.add(buttonCopy); menu.add(buttonPaste); menu.add(buttonClearAll); this.add(menu, BorderLayout.NORTH); this.add(editor, BorderLayout.CENTER); // I made so strange trick to move the caret into the start of document, all other ways didn't work :( SwingUtilities.invokeLater(new Runnable() { @Override public void run() { editor.replaceSelection(text); } }); }
From source file:com.maxl.java.amikodesk.AMiKoDesk.java
private static void createAndShowFullGUI() { // Create and setup window final JFrame jframe = new JFrame(Constants.APP_NAME); jframe.setName(Constants.APP_NAME + ".main"); int min_width = CML_OPT_WIDTH; int min_height = CML_OPT_HEIGHT; jframe.setPreferredSize(new Dimension(min_width, min_height)); jframe.setMinimumSize(new Dimension(min_width, min_height)); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); int x = (screen.width - min_width) / 2; int y = (screen.height - min_height) / 2; jframe.setBounds(x, y, min_width, min_height); // Set application icon if (Utilities.appCustomization().equals("ywesee")) { ImageIcon img = new ImageIcon(Constants.AMIKO_ICON); jframe.setIconImage(img.getImage()); } else if (Utilities.appCustomization().equals("desitin")) { ImageIcon img = new ImageIcon(Constants.DESITIN_ICON); jframe.setIconImage(img.getImage()); } else if (Utilities.appCustomization().equals("meddrugs")) { ImageIcon img = new ImageIcon(Constants.MEDDRUGS_ICON); jframe.setIconImage(img.getImage()); } else if (Utilities.appCustomization().equals("zurrose")) { ImageIcon img = new ImageIcon(Constants.AMIKO_ICON); jframe.setIconImage(img.getImage()); }/*from w w w . jav a2 s .c o m*/ // ------ Setup menubar ------ JMenuBar menu_bar = new JMenuBar(); // menu_bar.add(Box.createHorizontalGlue()); // --> aligns menu items to the right! // -- Menu "Datei" -- JMenu datei_menu = new JMenu("Datei"); if (Utilities.appLanguage().equals("fr")) datei_menu.setText("Fichier"); menu_bar.add(datei_menu); JMenuItem print_item = new JMenuItem("Drucken..."); JMenuItem settings_item = new JMenuItem(m_rb.getString("settings") + "..."); JMenuItem quit_item = new JMenuItem("Beenden"); if (Utilities.appLanguage().equals("fr")) { print_item.setText("Imprimer"); quit_item.setText("Terminer"); } datei_menu.add(print_item); datei_menu.addSeparator(); datei_menu.add(settings_item); datei_menu.addSeparator(); datei_menu.add(quit_item); // -- Menu "Aktualisieren" -- JMenu update_menu = new JMenu("Aktualisieren"); if (Utilities.appLanguage().equals("fr")) update_menu.setText("Mise jour"); menu_bar.add(update_menu); final JMenuItem updatedb_item = new JMenuItem("Aktualisieren via Internet..."); updatedb_item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK)); JMenuItem choosedb_item = new JMenuItem("Aktualisieren via Datei..."); update_menu.add(updatedb_item); update_menu.add(choosedb_item); if (Utilities.appLanguage().equals("fr")) { updatedb_item.setText("Tlcharger la banque de donnes..."); updatedb_item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.CTRL_MASK)); choosedb_item.setText("Ajourner la banque de donnes..."); } // -- Menu "Hilfe" -- JMenu hilfe_menu = new JMenu("Hilfe"); if (Utilities.appLanguage().equals("fr")) hilfe_menu.setText("Aide"); menu_bar.add(hilfe_menu); JMenuItem about_item = new JMenuItem("ber " + Constants.APP_NAME + "..."); JMenuItem ywesee_item = new JMenuItem(Constants.APP_NAME + " im Internet"); if (Utilities.appCustomization().equals("meddrugs")) ywesee_item.setText("med-drugs im Internet"); JMenuItem report_item = new JMenuItem("Error Report..."); JMenuItem contact_item = new JMenuItem("Kontakt..."); if (Utilities.appLanguage().equals("fr")) { // Extrawunsch med-drugs if (Utilities.appCustomization().equals("meddrugs")) about_item.setText(Constants.APP_NAME); else about_item.setText("A propos de " + Constants.APP_NAME + "..."); contact_item.setText("Contact..."); if (Utilities.appCustomization().equals("meddrugs")) ywesee_item.setText("med-drugs sur Internet"); else ywesee_item.setText(Constants.APP_NAME + " sur Internet"); report_item.setText("Rapport d'erreur..."); } hilfe_menu.add(about_item); hilfe_menu.add(ywesee_item); hilfe_menu.addSeparator(); hilfe_menu.add(report_item); hilfe_menu.addSeparator(); hilfe_menu.add(contact_item); // Menu "Abonnieren" (only for ywesee) JMenu subscribe_menu = new JMenu("Abonnieren"); if (Utilities.appLanguage().equals("fr")) subscribe_menu.setText("Abonnement"); if (Utilities.appCustomization().equals("ywesee")) { menu_bar.add(subscribe_menu); } jframe.setJMenuBar(menu_bar); // ------ Setup toolbar ------ JToolBar toolBar = new JToolBar("Database"); toolBar.setPreferredSize(new Dimension(jframe.getWidth(), 64)); final JToggleButton selectAipsButton = new JToggleButton( new ImageIcon(Constants.IMG_FOLDER + "aips32x32_bright.png")); final JToggleButton selectFavoritesButton = new JToggleButton( new ImageIcon(Constants.IMG_FOLDER + "favorites32x32_bright.png")); final JToggleButton selectInteractionsButton = new JToggleButton( new ImageIcon(Constants.IMG_FOLDER + "interactions32x32_bright.png")); final JToggleButton selectShoppingCartButton = new JToggleButton( new ImageIcon(Constants.IMG_FOLDER + "shoppingcart32x32_bright.png")); final JToggleButton selectComparisonCartButton = new JToggleButton( new ImageIcon(Constants.IMG_FOLDER + "comparisoncart32x32_bright.png")); final JToggleButton list_of_buttons[] = { selectAipsButton, selectFavoritesButton, selectInteractionsButton, selectShoppingCartButton, selectComparisonCartButton }; if (Utilities.appLanguage().equals("de")) { setupButton(selectAipsButton, "Kompendium", "aips32x32_gray.png", "aips32x32_dark.png"); setupButton(selectFavoritesButton, "Favoriten", "favorites32x32_gray.png", "favorites32x32_dark.png"); setupButton(selectInteractionsButton, "Interaktionen", "interactions32x32_gray.png", "interactions32x32_dark.png"); setupButton(selectShoppingCartButton, "Warenkorb", "shoppingcart32x32_gray.png", "shoppingcart32x32_dark.png"); setupButton(selectComparisonCartButton, "Preisvergleich", "comparisoncart32x32_gray.png", "comparisoncart32x32_dark.png"); } else if (Utilities.appLanguage().equals("fr")) { setupButton(selectAipsButton, "Compendium", "aips32x32_gray.png", "aips32x32_dark.png"); setupButton(selectFavoritesButton, "Favorites", "favorites32x32_gray.png", "favorites32x32_dark.png"); setupButton(selectInteractionsButton, "Interactions", "interactions32x32_gray.png", "interactions32x32_dark.png"); setupButton(selectShoppingCartButton, "Panier", "shoppingcart32x32_gray.png", "shoppingcart32x32_dark.png"); setupButton(selectComparisonCartButton, "Preisvergleich", "comparisoncart32x32_gray.png", "comparisoncart32x32_dark.png"); } // Add to toolbar and set up toolBar.setBackground(m_toolbar_bg); toolBar.add(selectAipsButton); toolBar.addSeparator(); toolBar.add(selectFavoritesButton); toolBar.addSeparator(); toolBar.add(selectInteractionsButton); if (!Utilities.appCustomization().equals("zurrose")) { toolBar.addSeparator(); toolBar.add(selectShoppingCartButton); } if (Utilities.appCustomization().equals("zurrorse")) { toolBar.addSeparator(); toolBar.add(selectComparisonCartButton); } toolBar.setRollover(true); toolBar.setFloatable(false); // Progress indicator (not working...) toolBar.addSeparator(new Dimension(32, 32)); toolBar.add(m_progress_indicator); // ------ Setup settingspage ------ final SettingsPage settingsPage = new SettingsPage(jframe, m_rb); // Attach observer to it settingsPage.addObserver(new Observer() { public void update(Observable o, Object arg) { System.out.println(arg); if (m_shopping_cart != null) { // Refresh some stuff m_shopping_basket.clear(); int index = m_shopping_cart.getCartIndex(); if (index > 0) m_web_panel.saveShoppingCartWithIndex(index); m_web_panel.updateShoppingHtml(); } } }); jframe.addWindowListener(new WindowListener() { // Use WindowAdapter! @Override public void windowOpened(WindowEvent e) { } @Override public void windowClosed(WindowEvent e) { m_web_panel.dispose(); Runtime.getRuntime().exit(0); } @Override public void windowClosing(WindowEvent e) { // Save shopping cart int index = m_shopping_cart.getCartIndex(); if (index > 0 && m_web_panel != null) m_web_panel.saveShoppingCartWithIndex(index); } @Override public void windowIconified(WindowEvent e) { } @Override public void windowDeiconified(WindowEvent e) { } @Override public void windowActivated(WindowEvent e) { } @Override public void windowDeactivated(WindowEvent e) { } }); print_item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { m_web_panel.print(); } }); settings_item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { settingsPage.display(); } }); quit_item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { try { // Save shopping cart int index = m_shopping_cart.getCartIndex(); if (index > 0 && m_web_panel != null) m_web_panel.saveShoppingCartWithIndex(index); // Save settings WindowSaver.saveSettings(); m_web_panel.dispose(); Runtime.getRuntime().exit(0); } catch (Exception e) { System.out.println(e); } } }); subscribe_menu.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent event) { if (Utilities.appCustomization().equals("ywesee")) { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(new URI( "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3UM84Z6WLFKZE")); } catch (IOException e) { // TODO: } catch (URISyntaxException r) { // TODO: } } } } @Override public void menuDeselected(MenuEvent event) { // do nothing } @Override public void menuCanceled(MenuEvent event) { // do nothing } }); contact_item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (Utilities.appCustomization().equals("ywesee")) { if (Desktop.isDesktopSupported()) { try { URI mail_to_uri = URI .create("mailto:zdavatz@ywesee.com?subject=AmiKo%20Desktop%20Feedback"); Desktop.getDesktop().mail(mail_to_uri); } catch (IOException e) { // TODO: } } else { AmiKoDialogs cd = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization()); cd.ContactDialog(); } } else if (Utilities.appCustomization().equals("desitin")) { if (Desktop.isDesktopSupported()) { try { URI mail_to_uri = URI .create("mailto:info@desitin.ch?subject=AmiKo%20Desktop%20Desitin%20Feedback"); Desktop.getDesktop().mail(mail_to_uri); } catch (IOException e) { // TODO: } } else { AmiKoDialogs cd = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization()); cd.ContactDialog(); } } else if (Utilities.appCustomization().equals("meddrugs")) { if (Desktop.isDesktopSupported()) { try { URI mail_to_uri = URI.create( "mailto:med-drugs@just-medical.com?subject=med-drugs%20desktop%20Feedback"); Desktop.getDesktop().mail(mail_to_uri); } catch (IOException e) { // TODO: } } else { AmiKoDialogs cd = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization()); cd.ContactDialog(); } } else if (Utilities.appCustomization().equals("zurrose")) { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(new URI("www.zurrose.ch/amiko")); } catch (IOException e) { // TODO: } catch (URISyntaxException r) { // TODO: } } } } }); report_item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { // Check first m_application_folder otherwise resort to // pre-installed report String report_file = m_application_data_folder + "\\" + Constants.DEFAULT_AMIKO_REPORT_BASE + Utilities.appLanguage() + ".html"; if (!(new File(report_file)).exists()) report_file = System.getProperty("user.dir") + "/dbs/" + Constants.DEFAULT_AMIKO_REPORT_BASE + Utilities.appLanguage() + ".html"; // Open report file in browser if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(new File(report_file).toURI()); } catch (IOException e) { // TODO: } } } }); ywesee_item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (Utilities.appCustomization().equals("ywesee")) { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(new URI("http://www.ywesee.com/AmiKo/Desktop")); } catch (IOException e) { // TODO: } catch (URISyntaxException r) { // TODO: } } } else if (Utilities.appCustomization().equals("desitin")) { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse( new URI("http://www.desitin.ch/produkte/arzneimittel-kompendium-apps/")); } catch (IOException e) { // TODO: } catch (URISyntaxException r) { // TODO: } } } else if (Utilities.appCustomization().equals("meddrugs")) { if (Desktop.isDesktopSupported()) { try { if (Utilities.appLanguage().equals("de")) Desktop.getDesktop().browse(new URI("http://www.med-drugs.ch")); else if (Utilities.appLanguage().equals("fr")) Desktop.getDesktop() .browse(new URI("http://www.med-drugs.ch/index.cfm?&newlang=fr")); } catch (IOException e) { // TODO: } catch (URISyntaxException r) { // TODO: } } } else if (Utilities.appCustomization().equals("zurrose")) { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(new URI("www.zurrose.ch/amiko")); } catch (IOException e) { // TODO: } catch (URISyntaxException r) { // TODO: } } } } }); about_item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { AmiKoDialogs ad = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization()); ad.AboutDialog(); } }); // Container final Container container = jframe.getContentPane(); container.setBackground(Color.WHITE); container.setLayout(new BorderLayout()); // ==== Toolbar ===== container.add(toolBar, BorderLayout.NORTH); // ==== Left panel ==== JPanel left_panel = new JPanel(); left_panel.setBackground(Color.WHITE); left_panel.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(2, 2, 2, 2); // ---- Search field ---- final SearchField searchField = new SearchField("Suche Prparat"); if (Utilities.appLanguage().equals("fr")) searchField.setText("Recherche Specialit"); gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = gbc.gridheight = 1; gbc.weightx = gbc.weighty = 0.0; // --> container.add(searchField, gbc); left_panel.add(searchField, gbc); // ---- Buttons ---- // Names String l_title = "Prparat"; String l_author = "Inhaberin"; String l_atccode = "Wirkstoff / ATC Code"; String l_regnr = "Zulassungsnummer"; String l_ingredient = "Wirkstoff"; String l_therapy = "Therapie"; String l_search = "Suche"; if (Utilities.appLanguage().equals("fr")) { l_title = "Spcialit"; l_author = "Titulaire"; l_atccode = "Principe Active / Code ATC"; l_regnr = "Nombre Enregistration"; l_ingredient = "Principe Active"; l_therapy = "Thrapie"; l_search = "Recherche"; } ButtonGroup bg = new ButtonGroup(); JToggleButton but_title = new JToggleButton(l_title); setupToggleButton(but_title); bg.add(but_title); gbc.gridx = 0; gbc.gridy = 1; gbc.gridwidth = gbc.gridheight = 1; gbc.weightx = gbc.weighty = 0.0; // --> container.add(but_title, gbc); left_panel.add(but_title, gbc); JToggleButton but_auth = new JToggleButton(l_author); setupToggleButton(but_auth); bg.add(but_auth); gbc.gridx = 0; gbc.gridy += 1; gbc.gridwidth = gbc.gridheight = 1; gbc.weightx = gbc.weighty = 0.0; // --> container.add(but_auth, gbc); left_panel.add(but_auth, gbc); JToggleButton but_atccode = new JToggleButton(l_atccode); setupToggleButton(but_atccode); bg.add(but_atccode); gbc.gridx = 0; gbc.gridy += 1; gbc.gridwidth = gbc.gridheight = 1; gbc.weightx = gbc.weighty = 0.0; // --> container.add(but_atccode, gbc); left_panel.add(but_atccode, gbc); JToggleButton but_regnr = new JToggleButton(l_regnr); setupToggleButton(but_regnr); bg.add(but_regnr); gbc.gridx = 0; gbc.gridy += 1; gbc.gridwidth = gbc.gridheight = 1; gbc.weightx = gbc.weighty = 0.0; // --> container.add(but_regnr, gbc); left_panel.add(but_regnr, gbc); JToggleButton but_therapy = new JToggleButton(l_therapy); setupToggleButton(but_therapy); bg.add(but_therapy); gbc.gridx = 0; gbc.gridy += 1; gbc.gridwidth = gbc.gridheight = 1; gbc.weightx = gbc.weighty = 0.0; // --> container.add(but_therapy, gbc); left_panel.add(but_therapy, gbc); // ---- Card layout ---- final CardLayout cardl = new CardLayout(); cardl.setHgap(-4); // HACK to make things look better!! final JPanel p_results = new JPanel(cardl); m_list_titles = new ListPanel(); m_list_auths = new ListPanel(); m_list_regnrs = new ListPanel(); m_list_atccodes = new ListPanel(); m_list_ingredients = new ListPanel(); m_list_therapies = new ListPanel(); // Contraints gbc.fill = GridBagConstraints.BOTH; gbc.gridx = 0; gbc.gridy += 1; gbc.gridwidth = 1; gbc.gridheight = 10; gbc.weightx = 1.0; gbc.weighty = 1.0; // p_results.add(m_list_titles, l_title); p_results.add(m_list_auths, l_author); p_results.add(m_list_regnrs, l_regnr); p_results.add(m_list_atccodes, l_atccode); p_results.add(m_list_ingredients, l_ingredient); p_results.add(m_list_therapies, l_therapy); // --> container.add(p_results, gbc); left_panel.add(p_results, gbc); left_panel.setBorder(null); // First card to show cardl.show(p_results, l_title); // ==== Right panel ==== JPanel right_panel = new JPanel(); right_panel.setBackground(Color.WHITE); right_panel.setLayout(new GridBagLayout()); // ---- Section titles ---- m_section_titles = null; if (Utilities.appLanguage().equals("de")) { m_section_titles = new IndexPanel(SectionTitle_DE); } else if (Utilities.appLanguage().equals("fr")) { m_section_titles = new IndexPanel(SectionTitle_FR); } m_section_titles.setMinimumSize(new Dimension(150, 150)); m_section_titles.setMaximumSize(new Dimension(320, 1000)); // ---- Fachinformation ---- m_web_panel = new WebPanel2(); m_web_panel.setMinimumSize(new Dimension(320, 150)); // Add JSplitPane on the RIGHT final int Divider_location = 150; final int Divider_size = 10; final JSplitPane split_pane_right = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, m_section_titles, m_web_panel); split_pane_right.setOneTouchExpandable(true); split_pane_right.setDividerLocation(Divider_location); split_pane_right.setDividerSize(Divider_size); // Add JSplitPane on the LEFT JSplitPane split_pane_left = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left_panel, split_pane_right /* right_panel */); split_pane_left.setOneTouchExpandable(true); split_pane_left.setDividerLocation(320); // Sets the pane divider location split_pane_left.setDividerSize(Divider_size); container.add(split_pane_left, BorderLayout.CENTER); // Add status bar on the bottom JPanel statusPanel = new JPanel(); statusPanel.setPreferredSize(new Dimension(jframe.getWidth(), 16)); statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.X_AXIS)); container.add(statusPanel, BorderLayout.SOUTH); final JLabel m_status_label = new JLabel(""); m_status_label.setHorizontalAlignment(SwingConstants.LEFT); statusPanel.add(m_status_label); // Add mouse listener searchField.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { searchField.setText(""); } }); final String final_title = l_title; final String final_author = l_author; final String final_atccode = l_atccode; final String final_regnr = l_regnr; final String final_therapy = l_therapy; final String final_search = l_search; // Internal class that implements switching between buttons final class Toggle { public void toggleButton(JToggleButton jbn) { for (int i = 0; i < list_of_buttons.length; ++i) { if (jbn == list_of_buttons[i]) list_of_buttons[i].setSelected(true); else list_of_buttons[i].setSelected(false); } } } ; // ------ Add toolbar action listeners ------ selectAipsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { new Toggle().toggleButton(selectAipsButton); // Set state 'aips' if (!m_curr_uistate.getUseMode().equals("aips")) { m_curr_uistate.setUseMode("aips"); // Show middle pane split_pane_right.setDividerSize(Divider_size); split_pane_right.setDividerLocation(Divider_location); m_section_titles.setVisible(true); // SwingUtilities.invokeLater(new Runnable() { @Override public void run() { m_start_time = System.currentTimeMillis(); m_query_str = searchField.getText(); int num_hits = retrieveAipsSearchResults(false); m_status_label.setText(med_search.size() + " Suchresultate in " + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek."); // if (med_index < 0 && prev_med_index >= 0) med_index = prev_med_index; m_web_panel.updateText(); if (num_hits == 0) { m_web_panel.emptyPage(); } } }); } } }); selectFavoritesButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { new Toggle().toggleButton(selectFavoritesButton); // Set state 'favorites' if (!m_curr_uistate.getUseMode().equals("favorites")) { m_curr_uistate.setUseMode("favorites"); // Show middle pane split_pane_right.setDividerSize(Divider_size); split_pane_right.setDividerLocation(Divider_location); m_section_titles.setVisible(true); // SwingUtilities.invokeLater(new Runnable() { @Override public void run() { m_start_time = System.currentTimeMillis(); // m_query_str = searchField.getText(); // Clear the search container med_search.clear(); for (String regnr : favorite_meds_set) { List<Medication> meds = m_sqldb.searchRegNr(regnr); if (!meds.isEmpty()) { // Add med database ID med_search.add(meds.get(0)); } } // Sort list of meds Collections.sort(med_search, new Comparator<Medication>() { @Override public int compare(final Medication m1, final Medication m2) { return m1.getTitle().compareTo(m2.getTitle()); } }); sTitle(); cardl.show(p_results, final_title); m_status_label.setText(med_search.size() + " Suchresultate in " + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek."); } }); } } }); selectInteractionsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { new Toggle().toggleButton(selectInteractionsButton); // Set state 'interactions' if (!m_curr_uistate.getUseMode().equals("interactions")) { m_curr_uistate.setUseMode("interactions"); // Show middle pane split_pane_right.setDividerSize(Divider_size); split_pane_right.setDividerLocation(Divider_location); m_section_titles.setVisible(true); // SwingUtilities.invokeLater(new Runnable() { @Override public void run() { m_query_str = searchField.getText(); retrieveAipsSearchResults(false); // Switch to interaction mode m_web_panel.updateInteractionsCart(); m_web_panel.repaint(); m_web_panel.validate(); } }); } } }); selectShoppingCartButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { String email_adr = m_prefs.get("emailadresse", ""); if (email_adr != null && email_adr.length() > 2) // Two chars is the minimum lenght for an email address m_preferences_ok = true; if (m_preferences_ok) { m_preferences_ok = false; // Check always new Toggle().toggleButton(selectShoppingCartButton); // Set state 'shopping' if (!m_curr_uistate.getUseMode().equals("shopping")) { m_curr_uistate.setUseMode("shopping"); // Show middle pane split_pane_right.setDividerSize(Divider_size); split_pane_right.setDividerLocation(Divider_location); m_section_titles.setVisible(true); // Set right panel title m_web_panel.setTitle(m_rb.getString("shoppingCart")); // Switch to shopping cart int index = 1; if (m_shopping_cart != null) { index = m_shopping_cart.getCartIndex(); m_web_panel.loadShoppingCartWithIndex(index); // m_shopping_cart.printShoppingBasket(); } // m_web_panel.updateShoppingHtml(); m_web_panel.updateListOfPackages(); if (m_first_pass == true) { m_first_pass = false; if (Utilities.appCustomization().equals("ywesee")) med_search = m_sqldb.searchAuth("ibsa"); else if (Utilities.appCustomization().equals("desitin")) med_search = m_sqldb.searchAuth("desitin"); sAuth(); cardl.show(p_results, final_author); } } } else { selectShoppingCartButton.setSelected(false); settingsPage.display(); } } }); selectComparisonCartButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { new Toggle().toggleButton(selectComparisonCartButton); // Set state 'comparison' if (!m_curr_uistate.getUseMode().equals("comparison")) { m_curr_uistate.setUseMode("comparison"); // Hide middle pane m_section_titles.setVisible(false); split_pane_right.setDividerLocation(0); split_pane_right.setDividerSize(0); // SwingUtilities.invokeLater(new Runnable() { @Override public void run() { m_start_time = System.currentTimeMillis(); // Set right panel title m_web_panel.setTitle(getTitle("priceComp")); if (med_index >= 0) { if (med_id != null && med_index < med_id.size()) { Medication m = m_sqldb.getMediWithId(med_id.get(med_index)); String atc_code = m.getAtcCode(); if (atc_code != null) { String atc = atc_code.split(";")[0]; m_web_panel.fillComparisonBasket(atc); m_web_panel.updateComparisonCartHtml(); // Update pane on the left retrieveAipsSearchResults(false); } } } m_status_label.setText(rose_search.size() + " Suchresultate in " + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek."); } }); } } }); // ------ Add keylistener to text field (type as you go feature) ------ searchField.addKeyListener(new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { // keyReleased(KeyEvent e) // invokeLater potentially in the wrong place... more testing // required SwingUtilities.invokeLater(new Runnable() { @Override public void run() { if (m_curr_uistate.isLoadCart()) m_curr_uistate.restoreUseMode(); m_start_time = System.currentTimeMillis(); m_query_str = searchField.getText(); // Queries for SQLite DB if (!m_query_str.isEmpty()) { if (m_query_type == 0) { if (m_curr_uistate.isComparisonMode()) { rose_search = m_rosedb.searchTitle(m_query_str); } else { med_search = m_sqldb.searchTitle(m_query_str); if (m_curr_uistate.databaseUsed().equals("favorites")) retrieveFavorites(); } sTitle(); cardl.show(p_results, final_title); } else if (m_query_type == 1) { if (m_curr_uistate.isComparisonMode()) { rose_search = m_rosedb.searchSupplier(m_query_str); } else { med_search = m_sqldb.searchAuth(m_query_str); if (m_curr_uistate.databaseUsed().equals("favorites")) retrieveFavorites(); } sAuth(); cardl.show(p_results, final_author); } else if (m_query_type == 2) { if (m_curr_uistate.isComparisonMode()) { rose_search = m_rosedb.searchATC(m_query_str); } else { med_search = m_sqldb.searchATC(m_query_str); if (m_curr_uistate.databaseUsed().equals("favorites")) retrieveFavorites(); } sATC(); cardl.show(p_results, final_atccode); } else if (m_query_type == 3) { if (m_curr_uistate.isComparisonMode()) { rose_search = m_rosedb.searchEan(m_query_str); } else { med_search = m_sqldb.searchRegNr(m_query_str); if (m_curr_uistate.databaseUsed().equals("favorites")) retrieveFavorites(); } sRegNr(); cardl.show(p_results, final_regnr); } else if (m_query_type == 4) { if (m_curr_uistate.isComparisonMode()) { rose_search = m_rosedb.searchTherapy(m_query_str); } else { med_search = m_sqldb.searchApplication(m_query_str); if (m_curr_uistate.databaseUsed().equals("favorites")) retrieveFavorites(); } sTherapy(); cardl.show(p_results, final_therapy); } else { // do nothing } int num_hits = 0; if (m_curr_uistate.isComparisonMode()) num_hits = rose_search.size(); else num_hits = med_search.size(); m_status_label.setText(num_hits + " Suchresultate in " + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek."); } } }); } }); // Add actionlisteners but_title.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (m_curr_uistate.isLoadCart()) m_curr_uistate.restoreUseMode(); searchField.setText(final_search + " " + final_title); m_curr_uistate.setQueryType(m_query_type = 0); sTitle(); cardl.show(p_results, final_title); } }); but_auth.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (m_curr_uistate.isLoadCart()) m_curr_uistate.restoreUseMode(); searchField.setText(final_search + " " + final_author); m_curr_uistate.setQueryType(m_query_type = 1); sAuth(); cardl.show(p_results, final_author); } }); but_atccode.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (m_curr_uistate.isLoadCart()) m_curr_uistate.restoreUseMode(); searchField.setText(final_search + " " + final_atccode); m_curr_uistate.setQueryType(m_query_type = 2); sATC(); cardl.show(p_results, final_atccode); } }); but_regnr.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (m_curr_uistate.isLoadCart()) m_curr_uistate.restoreUseMode(); searchField.setText(final_search + " " + final_regnr); m_curr_uistate.setQueryType(m_query_type = 3); sRegNr(); cardl.show(p_results, final_regnr); } }); but_therapy.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (m_curr_uistate.isLoadCart()) m_curr_uistate.restoreUseMode(); searchField.setText(final_search + " " + final_therapy); m_curr_uistate.setQueryType(m_query_type = 4); sTherapy(); cardl.show(p_results, final_therapy); } }); // Display window jframe.pack(); // jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jframe.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // jframe.setAlwaysOnTop(true); jframe.setVisible(true); // Check if user has selected an alternative database /* * NOTE: 21/11/2013: This solution is put on ice. Favored is a solution * where the database selected by the user is saved in a default folder * (see variable "m_application_data_folder") */ /* * try { WindowSaver.loadSettings(jframe); String database_path = * WindowSaver.getDbPath(); if (database_path!=null) * m_sqldb.loadDBFromPath(database_path); } catch(IOException e) { * e.printStackTrace(); } */ // Load AIPS database selectAipsButton.setSelected(true); selectFavoritesButton.setSelected(false); m_curr_uistate.setUseMode("aips"); med_search = m_sqldb.searchTitle(""); sTitle(); // Used instead of sTitle (which is slow) cardl.show(p_results, final_title); // Add menu item listeners updatedb_item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (m_mutex_update == false) { m_mutex_update = true; String db_file = m_maindb_update.doIt(jframe, Utilities.appLanguage(), Utilities.appCustomization(), m_application_data_folder, m_full_db_update); // ... and update time if (m_full_db_update == true) { DateTime dT = new DateTime(); m_prefs.put("updateTime", dT.now().toString()); } // if (!db_file.isEmpty()) { // Save db path (can't hurt) WindowSaver.setDbPath(db_file); } } } }); choosedb_item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { String db_file = m_maindb_update.chooseFromFile(jframe, Utilities.appLanguage(), Utilities.appCustomization(), m_application_data_folder); // ... and update time DateTime dT = new DateTime(); m_prefs.put("updateTime", dT.now().toString()); // if (!db_file.isEmpty()) { // Save db path (can't hurt) WindowSaver.setDbPath(db_file); } } }); /** * Observers */ // Attach observer to 'm_update' m_maindb_update.addObserver(new Observer() { @Override public void update(Observable o, Object arg) { System.out.println(arg); // Reset flag m_full_db_update = true; m_mutex_update = false; // Refresh some stuff after update loadAuthors(); m_emailer.loadMap(); settingsPage.load_gln_codes(); if (m_shopping_cart != null) { m_shopping_cart.load_conditions(); m_shopping_cart.load_glns(); } // Empty shopping basket if (m_curr_uistate.isShoppingMode()) { m_shopping_basket.clear(); int index = m_shopping_cart.getCartIndex(); if (index > 0) m_web_panel.saveShoppingCartWithIndex(index); m_web_panel.updateShoppingHtml(); } if (m_curr_uistate.isComparisonMode()) m_web_panel.setTitle(getTitle("priceComp")); } }); // Attach observer to 'm_emailer' m_emailer.addObserver(new Observer() { @Override public void update(Observable o, Object arg) { System.out.println(arg); // Empty shopping basket m_shopping_basket.clear(); int index = m_shopping_cart.getCartIndex(); if (index > 0) m_web_panel.saveShoppingCartWithIndex(index); m_web_panel.updateShoppingHtml(); } }); // Attach observer to "m_comparison_cart" m_comparison_cart.addObserver(new Observer() { @Override public void update(Observable o, Object arg) { System.out.println(arg); m_web_panel.setTitle(getTitle("priceComp")); m_comparison_cart.clearUploadList(); m_web_panel.updateComparisonCartHtml(); new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization()).UploadDialog((String) arg); } }); // If command line options are provided start app with a particular title or eancode if (commandLineOptionsProvided()) { if (!CML_OPT_TITLE.isEmpty()) startAppWithTitle(but_title); else if (!CML_OPT_EANCODE.isEmpty()) startAppWithEancode(but_regnr); else if (!CML_OPT_REGNR.isEmpty()) startAppWithRegnr(but_regnr); } // Start timer Timer global_timer = new Timer(); // Time checks all 2 minutes (120'000 milliseconds) global_timer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { checkIfUpdateRequired(updatedb_item); } }, 2 * 60 * 1000, 2 * 60 * 1000); }
From source file:com.projity.pm.graphic.frames.GraphicManager.java
public void setToolBarAndMenus(final Container contentPane) { JToolBar toolBar; if (Environment.isRibbonUI()) { if (Environment.isNeedToRestart()) { contentPane.add(new JLabel(Messages.getString("Error.restart")), BorderLayout.CENTER); return; }/*from w ww . ja v a 2s.co m*/ setRibbon((JRibbonFrame) container, getMenuManager()); // JToolBar viewToolBar = getMenuManager().getToolBar(MenuManager.VIEW_TOOL_BAR_WITH_NO_SUB_VIEW_OPTION); // topTabs = new TabbedNavigation(); // JComponent tabs = topTabs.createContentPanel(getMenuManager(),viewToolBar,0,JTabbedPane.TOP,true); // tabs.setAlignmentX(0.0f); // so it is left justified // // // Box top = new Box(BoxLayout.Y_AXIS); // JComponent bottom; // top.add(tabs); // bottom = new TabbedNavigation().createContentPanel(getMenuManager(),viewToolBar,1,JTabbedPane.BOTTOM,false); // contentPane.add(top, BorderLayout.BEFORE_FIRST_LINE); // contentPane.add(bottom,BorderLayout.AFTER_LAST_LINE); // if (Environment.isNewLaf()) // contentPane.setBackground(Color.WHITE); // if (Environment.isMac()){ // //System.setProperty("apple.laf.useScreenMenuBar","true"); // //System.setProperty("com.apple.mrj.application.apple.menu.about.name", Messages.getMetaString("Text.ShortTitle")); // JMenuBar menu = getMenuManager().getMenu(Environment.getStandAlone()?MenuManager.MAC_STANDARD_MENU:MenuManager.SERVER_STANDARD_MENU); // //((JComponent)menu).setBorder(BorderFactory.createEmptyBorder()); // // ((JFrame)container).setJMenuBar(menu); // projectListMenu = (JMenu) menu.getComponent(5); // } } else if (Environment.isNewLook()) { if (Environment.isNeedToRestart()) { contentPane.add(new JLabel(Messages.getString("Error.restart")), BorderLayout.CENTER); return; } toolBar = getMenuManager().getToolBar(MenuManager.BIG_TOOL_BAR); if (!getLafManager().isToolbarOpaque()) toolBar.setOpaque(false); if (!isApplet()) getMenuManager().setActionVisible(ACTION_FULL_SCREEN, false); if (Environment.isExternal()) // external users only see project team getMenuManager().setActionVisible(ACTION_TEAM_FILTER, false); toolBar.addSeparator(new Dimension(20, 20)); toolBar.add(new Box.Filler(new Dimension(0, 0), new Dimension(0, 0), new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE))); toolBar.add(((DefaultFrameManager) getFrameManager()).getProjectComboPanel()); toolBar.add(Box.createRigidArea(new Dimension(20, 20))); if (Environment.isNewLaf()) toolBar.setBackground(Color.WHITE); toolBar.setFloatable(false); toolBar.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); Box top; JComponent bottom; top = new Box(BoxLayout.Y_AXIS); toolBar.setAlignmentX(0.0f); // so it is left justified top.add(toolBar); JToolBar viewToolBar = getMenuManager().getToolBar(MenuManager.VIEW_TOOL_BAR_WITH_NO_SUB_VIEW_OPTION); topTabs = new TabbedNavigation(); JComponent tabs = topTabs.createContentPanel(getMenuManager(), viewToolBar, 0, JTabbedPane.TOP, true); tabs.setAlignmentX(0.0f); // so it is left justified top.add(tabs); bottom = new TabbedNavigation().createContentPanel(getMenuManager(), viewToolBar, 1, JTabbedPane.BOTTOM, false); contentPane.add(top, BorderLayout.BEFORE_FIRST_LINE); contentPane.add(bottom, BorderLayout.AFTER_LAST_LINE); if (Environment.isNewLaf()) contentPane.setBackground(Color.WHITE); if (Environment.isMac()) { //System.setProperty("apple.laf.useScreenMenuBar","true"); //System.setProperty("com.apple.mrj.application.apple.menu.about.name", Messages.getMetaString("Text.ShortTitle")); JMenuBar menu = getMenuManager().getMenu(Environment.getStandAlone() ? MenuManager.MAC_STANDARD_MENU : MenuManager.SERVER_STANDARD_MENU); //((JComponent)menu).setBorder(BorderFactory.createEmptyBorder()); ((JFrame) container).setJMenuBar(menu); projectListMenu = (JMenu) menu.getComponent(5); } } else { toolBar = getMenuManager().getToolBar( Environment.isMac() ? MenuManager.MAC_STANDARD_TOOL_BAR : MenuManager.STANDARD_TOOL_BAR); filterToolBarManager = FilterToolBarManager.create(getMenuManager()); filterToolBarManager.addButtons(toolBar); contentPane.add(toolBar, BorderLayout.BEFORE_FIRST_LINE); JToolBar viewToolBar = getMenuManager().getToolBar(MenuManager.VIEW_TOOL_BAR); viewToolBar.setOrientation(JToolBar.VERTICAL); viewToolBar.setRollover(true); contentPane.add(viewToolBar, BorderLayout.WEST); JMenuBar menu = getMenuManager().getMenu(Environment.getStandAlone() ? (Environment.isMac() ? MenuManager.MAC_STANDARD_MENU : MenuManager.STANDARD_MENU) : MenuManager.SERVER_STANDARD_MENU); if (!Environment.isMac()) { ((JComponent) menu).setBorder(BorderFactory.createEmptyBorder()); JMenuItem logo = (JMenuItem) menu.getComponent(0); logo.setBorder(BorderFactory.createEmptyBorder()); logo.setMaximumSize(new Dimension(124, 52)); logo.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } ((JFrame) container).setJMenuBar(menu); projectListMenu = (JMenu) menu.getComponent(Environment.isMac() ? 5 : 6); } //accelerators addCtrlAccel(KeyEvent.VK_G, ACTION_GOTO, null); addCtrlAccel(KeyEvent.VK_L, ACTION_GOTO, null); addCtrlAccel(KeyEvent.VK_F, ACTION_FIND, null); addCtrlAccel(KeyEvent.VK_Z, ACTION_UNDO, null); //- Sanhita addCtrlAccel(KeyEvent.VK_Y, ACTION_REDO, null); addCtrlAccel(KeyEvent.VK_N, ACTION_NEW_PROJECT, null); addCtrlAccel(KeyEvent.VK_O, ACTION_OPEN_PROJECT, null); addCtrlAccel(KeyEvent.VK_S, ACTION_SAVE_PROJECT, null); addCtrlAccel(KeyEvent.VK_P, ACTION_PRINT, null); //-Sanhita addCtrlAccel(KeyEvent.VK_I, ACTION_INSERT_TASK, null); addCtrlAccel(KeyEvent.VK_PERIOD, ACTION_INDENT, null); addCtrlAccel(KeyEvent.VK_COMMA, ACTION_OUTDENT, null); addCtrlAccel(KeyEvent.VK_PLUS, ACTION_EXPAND, new ExpandAction()); addCtrlAccel(KeyEvent.VK_ADD, ACTION_EXPAND, new ExpandAction()); addCtrlAccel(KeyEvent.VK_EQUALS, ACTION_EXPAND, new ExpandAction()); addCtrlAccel(KeyEvent.VK_MINUS, ACTION_COLLAPSE, new CollapseAction()); addCtrlAccel(KeyEvent.VK_SUBTRACT, ACTION_COLLAPSE, new CollapseAction()); // To force a recalculation. This normally shouldn't be needed. addCtrlAccel(KeyEvent.VK_R, ACTION_RECALCULATE, new RecalculateAction()); }