/** * Create a choicbox for link line thickness options and return the panel it is in. * * @return JPanel the panel holding the new choicebox for the line thickness options. */ private JPanel createWeightChoiceBox() { JPanel drawPanel = new JPanel(new BorderLayout()); CSH.setHelpIDString(drawPanel, "toolbars.formatlink"); // $NON-NLS-1$ cbLineWeight = new JComboBox(); cbLineWeight.setToolTipText( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.selectWeight")); // $NON-NLS-1$ cbLineWeight.setOpaque(true); cbLineWeight.setEditable(false); cbLineWeight.setEnabled(false); cbLineWeight.setMaximumRowCount(10); cbLineWeight.setFont(new Font("Dialog", Font.PLAIN, 10)); // $NON-NLS-1$ cbLineWeight.addItem(new String("1 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("2 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("3 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("4 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("5 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("6 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("7 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("8 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("9 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("10 px")); // $NON-NLS-1$ cbLineWeight.validate(); cbLineWeight.setSelectedIndex(0); DefaultListCellRenderer drawRenderer = new DefaultListCellRenderer() { public Component getListCellRendererComponent( JList list, Object value, int modelIndex, boolean isSelected, boolean cellHasFocus) { if (list != null) { if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } } setText((String) value); return this; } }; cbLineWeight.setRenderer(drawRenderer); ActionListener drawActionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { int ind = cbLineWeight.getSelectedIndex(); if (ind == 0) onUpdateLinkWeight(1); else if (ind == 1) onUpdateLinkWeight(2); else if (ind == 2) onUpdateLinkWeight(3); else if (ind == 3) onUpdateLinkWeight(4); else if (ind == 4) onUpdateLinkWeight(5); else if (ind == 5) onUpdateLinkWeight(6); else if (ind == 6) onUpdateLinkWeight(7); else if (ind == 7) onUpdateLinkWeight(8); else if (ind == 8) onUpdateLinkWeight(9); else if (ind == 9) onUpdateLinkWeight(10); } }; cbLineWeight.addActionListener(drawActionListener); drawPanel.add(new JLabel(" "), BorderLayout.WEST); // $NON-NLS-1$ drawPanel.add(cbLineWeight, BorderLayout.CENTER); return drawPanel; }
/** * Create a choicebox for link line style options and return the panel it is in. * * @return JPanel the panel holding the new choicebox for the link style options. */ private JPanel createLinkDashedChoiceBox() { JPanel drawPanel = new JPanel(new BorderLayout()); CSH.setHelpIDString(drawPanel, "toolbars.formatlink"); // $NON-NLS-1$ cbLinkDashed = new JComboBox(); cbLinkDashed.setToolTipText( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.selectDashed")); // $NON-NLS-1$ cbLinkDashed.setOpaque(true); cbLinkDashed.setEditable(false); cbLinkDashed.setEnabled(false); cbLinkDashed.setMaximumRowCount(10); cbLinkDashed.setFont(new Font("Dialog", Font.PLAIN, 10)); // $NON-NLS-1$ cbLinkDashed.addItem( new String( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.plainLine"))); //$NON-NLS-1$ cbLinkDashed.addItem( new String( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.largeDashes"))); //$NON-NLS-1$ cbLinkDashed.addItem( new String( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.smallDashes"))); //$NON-NLS-1$ cbLinkDashed.validate(); cbLinkDashed.setSelectedIndex(0); DefaultListCellRenderer drawRenderer = new DefaultListCellRenderer() { public Component getListCellRendererComponent( JList list, Object value, int modelIndex, boolean isSelected, boolean cellHasFocus) { if (list != null) { if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } } setText((String) value); return this; } }; cbLinkDashed.setRenderer(drawRenderer); ActionListener drawActionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { onUpdateLinkDashed(cbLinkDashed.getSelectedIndex()); } }; cbLinkDashed.addActionListener(drawActionListener); drawPanel.add(new JLabel(" "), BorderLayout.WEST); // $NON-NLS-1$ drawPanel.add(cbLinkDashed, BorderLayout.CENTER); return drawPanel; }
@Override public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("Acties")) { controller.add(new Actiescreen()); } if (e.getActionCommand().equals("Editmenu")) { JDialog dialog = new JDialog(); dialog.setBounds(0, 0, 300, 500); dialog.add(new EditScreen(1)); dialog.pack(); dialog.setLocationRelativeTo(null); dialog.setVisible(true); } if (e.getActionCommand().equals("Kalenderoverzicht")) { controller.add(new Kalenderscreen()); } if (e.getActionCommand().equals("Gedachte toevoegen")) { JDialog dialog = new JDialog(); dialog.setTitle("Gedachte Toevoegen"); dialog.setModal(true); dialog.setBounds(0, 0, 300, 500); dialog.add(new EditScreen(2)); dialog.pack(); dialog.setLocationRelativeTo(null); dialog.setVisible(true); dialog.validate(); } if (e.getActionCommand().equals("Edit gedachte")) { final JDialog dialog = new JDialog(); dialog.setTitle("Edit gedachte"); dialog.setModal(true); dialog.setBounds(0, 0, 300, 500); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); final JTextField text = new JTextField(); JButton button = new JButton("Toepassen"); panel.add(text, BorderLayout.NORTH); panel.add(button, BorderLayout.SOUTH); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { String change = text.getText(); int gedachte = controller.getCurrentThought(); DataLayer.changeThought(gedachte, change); dialog.setVisible(false); controller.updateThouhts(); } }); dialog.add(panel); dialog.pack(); dialog.setLocationRelativeTo(null); dialog.setVisible(true); dialog.validate(); } if (e.getActionCommand().equals("Gedachte omzetten naar actie")) { ArrayList<Projectscreen> test = controller.getProjects(); if (test.get(0).getList().getSelectedIndex() == -1) { JOptionPane.showMessageDialog(null, "Selecteer eerst een gedachte", "Error", JOptionPane.ERROR_MESSAGE); } else { final JDialog dialog = new JDialog(); dialog.setPreferredSize(new Dimension(500, 200)); dialog.setTitle("Gedachte omzetten naar actie"); dialog.setModal(true); JPanel master = new JPanel(); dialog.add(master); master.setLayout(new GridLayout(0, 1)); // Project kiezen JPanel projects = new JPanel(); projects.setLayout(new BorderLayout()); JLabel projectnaam = new JLabel("Project"); final JComboBox box = new JComboBox(); final ArrayList<Projectscreen> arraylist = controller.getProjects(); Projectscreen thoughts = arraylist.get(0); for (Projectscreen s : arraylist) { if (!s.getNaam().equals("Gedachten")){ String naam = s.getNaam(); box.addItem(naam); box.validate(); } } projects.add(projectnaam, BorderLayout.WEST); projects.add(box, BorderLayout.CENTER); master.add(projects); //gedachte JPanel gedachten = new JPanel(); gedachten.setLayout(new BorderLayout()); JLabel n = new JLabel("Gedachte: "); final JTextField n1 = new JTextField(); final int id = controller.getCurrentThought(); final JList list = thoughts.getList(); final String s = (String) list.getSelectedValue(); String[] s1 = s.split(" "); String s2 = s1[0]; n1.setText(s.replaceFirst(s2, "")); n1.setText(n1.getText().trim()); gedachten.add(n, BorderLayout.WEST); gedachten.add(n1, BorderLayout.CENTER); master.add(gedachten); // beschrijving JPanel beschrijving = new JPanel(); beschrijving.setLayout(new BorderLayout()); JLabel b = new JLabel("Beschrijving"); final JTextArea b1 = new JTextArea(0, 3); b1.setLineWrap(true); b1.setRows(3); b1.setWrapStyleWord(true); b1.setColumns(0); JScrollPane scroll = new JScrollPane(); scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scroll.getViewport().setView(b1); beschrijving.add(b, BorderLayout.WEST); beschrijving.add(scroll, BorderLayout.CENTER); master.add(beschrijving); // context JPanel context = new JPanel(); context.setLayout(new BorderLayout()); JLabel co = new JLabel("Context"); final JComboBox co1 = new JComboBox(); co1.setEditable(true); final ArrayList<String> co2 = DataLayer.getContexts(); if (!co2.isEmpty()){ for (String t : co2){ co1.addItem(t); } } context.add(co, BorderLayout.WEST); context.add(co1, BorderLayout.CENTER); master.add(context); // status JPanel status = new JPanel(); status.setLayout(new BorderLayout()); JLabel st = new JLabel("Status"); final JComboBox box1 = new JComboBox(); ArrayList<String> arrayStatus = DataLayer.getStatuses(); for (String t : arrayStatus) { box1.addItem(t.toString()); box1.validate(); } status.add(st, BorderLayout.WEST); status.add(box1, BorderLayout.CENTER); master.add(status); // datum JPanel datum = new JPanel(); datum.setLayout(new BorderLayout()); JLabel d = new JLabel("Datum"); final JFormattedTextField d1 = new JFormattedTextField(new SimpleDateFormat("yyyy-mm-dd")); d1.setText("yyyy-mm-dd"); datum.add(d, BorderLayout.WEST); datum.add(d1, BorderLayout.CENTER); master.add(datum); // button JButton toepassen = new JButton("Toepassen"); master.add(toepassen); toepassen.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { String description = n1.getText(); String notes = b1.getText(); String co3 = (String) co1.getSelectedItem(); boolean bestaat = false; for (String t : co2){ if (t.equals(co3)){ bestaat = true; } } if (!bestaat){ DataLayer.addContext(co3); } String context = co3; String status = box1.getSelectedItem().toString(); int projectid = arraylist.get(box.getSelectedIndex()).getID() + 1; String datum = d1.getText(); int idGedachte = Integer.parseInt("" + s.charAt(0)) - 1; if (datum.equals("yyyy-mm-dd") | datum.equals("")) { JOptionPane.showMessageDialog(null, "Vul een datum in", "Error", JOptionPane.ERROR_MESSAGE); } else { DataLayer.addAction(description, notes, context, status, projectid, datum); DataLayer.deleteThought(idGedachte); controller.updateThouhts(); controller.updateProjects(); dialog.setVisible(false); ArrayList<Projectscreen> project = controller.getProjects(); Projectscreen t = project.get(0); int i = t.getList().getModel().getSize(); int x = t.getList().getSelectedIndex(); } } }); dialog.pack(); dialog.setLocationRelativeTo(null); dialog.setVisible(true); dialog.validate(); } } if (e.getActionCommand().equals("Wis gedachte")) { DataLayer.deleteThought(controller.getCurrentThought()); controller.updateThouhts(); } if (e.getActionCommand().equals("Voeg project toe")) { final JDialog dialog = new JDialog(); dialog.setTitle("Project toevoegen"); dialog.setModal(true); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); final JTextField naam = new JTextField(); JPanel projectnaam = new JPanel(); projectnaam.setLayout(new BorderLayout()); projectnaam.add(new JLabel("Projectnaam"), BorderLayout.WEST); projectnaam.add(naam, BorderLayout.CENTER); JButton button = new JButton("Aanmaken"); panel.add(projectnaam, BorderLayout.NORTH); panel.add(button, BorderLayout.SOUTH); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { String e = DataLayer.addProject(naam.getText()); controller.updateProjects(e); dialog.setVisible(false); validate(); } }); dialog.add(panel); dialog.pack(); dialog.setLocationRelativeTo(null); dialog.setVisible(true); dialog.validate(); } if (e.getActionCommand().equals("Bewerk project")) { final JDialog dialog = new JDialog(); dialog.setTitle("Bewerk project"); dialog.setModal(true); dialog.setBounds(0, 0, 300, 500); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); final JTextField naam = new JTextField(); final JComboBox box = new JComboBox(); box.setEditable(false); final ArrayList<Projectscreen> projects = controller.getProjects(); projects.remove(0); for (Projectscreen t : projects) { box.addItem(t.getNaam()); box.validate(); } JPanel projectid = new JPanel(); projectid.setLayout(new BorderLayout()); projectid.add(new JLabel("Kies project"), BorderLayout.WEST); projectid.add(box, BorderLayout.CENTER); JPanel projectnaam = new JPanel(); projectnaam.setLayout(new BorderLayout()); projectnaam.add(new JLabel("Nieuwe projectnaam"), BorderLayout.WEST); projectnaam.add(naam, BorderLayout.CENTER); JButton button = new JButton("Bewerk"); panel.add(projectid, BorderLayout.NORTH); panel.add(projectnaam, BorderLayout.CENTER); panel.add(button, BorderLayout.SOUTH); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { int d = box.getSelectedIndex(); projects.get(d).changeName(naam.getText()); DataLayer.changeProject(projects.get(d).getID(), naam.getText()); dialog.setVisible(false); validate(); } }); dialog.add(panel); dialog.pack(); dialog.setLocationRelativeTo(null); dialog.setVisible(true); dialog.validate(); } if (e.getActionCommand().equals("Verwijder project")) { final JDialog dialog = new JDialog(); dialog.setTitle("Wis project"); dialog.setModal(true); dialog.setBounds(0, 0, 300, 500); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); final JTextField naam = new JTextField(); final JComboBox box = new JComboBox(); box.setEditable(false); final ArrayList<Projectscreen> projects = controller.getProjects(); projects.remove(0); for (Projectscreen t : projects) { box.addItem(t.getNaam()); box.validate(); } JPanel projectnaam = new JPanel(); projectnaam.setLayout(new BorderLayout()); projectnaam.add(new JLabel("Project"), BorderLayout.WEST); projectnaam.add(box, BorderLayout.CENTER); JButton button = new JButton("Wissen"); panel.add(projectnaam, BorderLayout.NORTH); panel.add(button, BorderLayout.SOUTH); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { //pj.deleteProject(naam.getText(), id.getNumber().intValue()); int d = box.getSelectedIndex(); projects.get(d).changeName(naam.getText()); DataLayer.deleteProject(projects.get(d).getID()); controller.updateIDprojects(d); dialog.setVisible(false); validate(); } }); dialog.add(panel); dialog.pack(); dialog.setLocationRelativeTo(null); dialog.setVisible(true); dialog.validate(); } if (e.getActionCommand().equals("Uitloggen")) { controller.logOff(); } if (e.getActionCommand().equals("Afsluiten")) { controller.quit(); } }