Search in sources :

Example 36 with BevelBorder

use of javax.swing.border.BevelBorder in project hortonmachine by TheHortonMachine.

the class GeopaparazziController method addJtreeContextMenu.

private void addJtreeContextMenu() {
    JPopupMenu popupMenu = new JPopupMenu();
    popupMenu.setBorder(new BevelBorder(BevelBorder.RAISED));
    popupMenu.addPopupMenuListener(new PopupMenuListener() {

        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
            if (currentSelectedImage != null) {
                Logger.INSTANCE.insertDebug("", "PopupMenuEvent on image: " + currentSelectedImage.getName());
                List<Action> tableActions = makeImageAction(currentSelectedImage);
                if (tableActions != null)
                    for (Action action : tableActions) {
                        if (action != null) {
                            JMenuItem item = new JMenuItem(action);
                            popupMenu.add(item);
                            item.setHorizontalTextPosition(JMenuItem.RIGHT);
                        } else {
                            popupMenu.add(new JSeparator());
                        }
                    }
            } else if (currentSelectedGpsLog != null) {
                Logger.INSTANCE.insertDebug("", "PopupMenuEvent on log: " + currentSelectedGpsLog.text);
                List<Action> logActions = makeGpsLogActions(currentSelectedGpsLog);
                if (logActions != null)
                    for (Action action : logActions) {
                        if (action != null) {
                            JMenuItem item = new JMenuItem(action);
                            popupMenu.add(item);
                            item.setHorizontalTextPosition(JMenuItem.RIGHT);
                        } else {
                            popupMenu.add(new JSeparator());
                        }
                    }
            } else if (currentSelectedNote != null) {
                Logger.INSTANCE.insertDebug("", "PopupMenuEvent on note: " + currentSelectedNote.simpleText);
                List<Action> notesActions = makeNotesActions(currentSelectedNote);
                if (notesActions != null)
                    for (Action action : notesActions) {
                        if (action != null) {
                            JMenuItem item = new JMenuItem(action);
                            popupMenu.add(item);
                            item.setHorizontalTextPosition(JMenuItem.RIGHT);
                        } else {
                            popupMenu.add(new JSeparator());
                        }
                    }
            } else if (currentSelectedProject != null) {
                Logger.INSTANCE.insertDebug("", "PopupMenuEvent on project: " + currentSelectedProject.fileName);
                List<Action> dbActions = makeProjectAction(currentSelectedProject);
                if (dbActions != null)
                    for (Action action : dbActions) {
                        if (action != null) {
                            JMenuItem item = new JMenuItem(action);
                            popupMenu.add(item);
                            item.setHorizontalTextPosition(JMenuItem.RIGHT);
                        } else {
                            popupMenu.add(new JSeparator());
                        }
                    }
            }
            Logger.INSTANCE.insertDebug("", "PopupMenuEvent with no available object to load menu from");
        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            popupMenu.removeAll();
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent e) {
            popupMenu.removeAll();
        }
    });
    _databaseTree.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (SwingUtilities.isRightMouseButton(e)) {
                int row = _databaseTree.getClosestRowForLocation(e.getX(), e.getY());
                _databaseTree.setSelectionRow(row);
                popupMenu.show(e.getComponent(), e.getX(), e.getY());
            }
        }
    });
}
Also used : Action(javax.swing.Action) MouseEvent(java.awt.event.MouseEvent) BevelBorder(javax.swing.border.BevelBorder) PopupMenuListener(javax.swing.event.PopupMenuListener) MouseAdapter(java.awt.event.MouseAdapter) EventListenerList(javax.swing.event.EventListenerList) List(java.util.List) ArrayList(java.util.ArrayList) JMenuItem(javax.swing.JMenuItem) PopupMenuEvent(javax.swing.event.PopupMenuEvent) JPopupMenu(javax.swing.JPopupMenu) JSeparator(javax.swing.JSeparator)

Example 37 with BevelBorder

use of javax.swing.border.BevelBorder in project hortonmachine by TheHortonMachine.

the class MainController method addJtreeContextMenu.

private void addJtreeContextMenu() {
    _rulesTree.addTreeSelectionListener(new TreeSelectionListener() {

        public void valueChanged(TreeSelectionEvent evt) {
            TreePath[] paths = evt.getPaths();
            if (paths.length > 0) {
                Object selectedItem = paths[0].getLastPathComponent();
                currentSelectedSW = null;
                currentSelectedFSW = null;
                currentSelectedRW = null;
                currentSelectedSymW = null;
                currentSelectedFeatureAttributeNode = null;
                if (selectedItem instanceof DefaultMutableTreeNode) {
                    DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectedItem;
                    Object userObject = node.getUserObject();
                    if (userObject instanceof StyleWrapper) {
                        currentSelectedSW = (StyleWrapper) userObject;
                    } else if (userObject instanceof FeatureTypeStyleWrapper) {
                        currentSelectedFSW = (FeatureTypeStyleWrapper) userObject;
                    } else if (userObject instanceof RuleWrapper) {
                        currentSelectedRW = (RuleWrapper) userObject;
                    } else if (userObject instanceof SymbolizerWrapper) {
                        currentSelectedSymW = (SymbolizerWrapper) userObject;
                    } else if (userObject instanceof FeatureAttributeNode) {
                        currentSelectedFeatureAttributeNode = (FeatureAttributeNode) userObject;
                    }
                }
            }
        }
    });
    JPopupMenu popupMenu = new JPopupMenu();
    popupMenu.setBorder(new BevelBorder(BevelBorder.RAISED));
    popupMenu.addPopupMenuListener(new PopupMenuListener() {

        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
            createMenuActions(popupMenu);
        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            popupMenu.removeAll();
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent e) {
            popupMenu.removeAll();
        }
    });
    _rulesTree.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (SwingUtilities.isRightMouseButton(e)) {
                int row = _rulesTree.getClosestRowForLocation(e.getX(), e.getY());
                _rulesTree.setSelectionRow(row);
                popupMenu.show(e.getComponent(), e.getX(), e.getY());
            }
        }
    });
}
Also used : RasterSymbolizerWrapper(org.hortonmachine.gears.utils.style.RasterSymbolizerWrapper) TextSymbolizerWrapper(org.hortonmachine.gears.utils.style.TextSymbolizerWrapper) PolygonSymbolizerWrapper(org.hortonmachine.gears.utils.style.PolygonSymbolizerWrapper) PointSymbolizerWrapper(org.hortonmachine.gears.utils.style.PointSymbolizerWrapper) SymbolizerWrapper(org.hortonmachine.gears.utils.style.SymbolizerWrapper) LineSymbolizerWrapper(org.hortonmachine.gears.utils.style.LineSymbolizerWrapper) MouseEvent(java.awt.event.MouseEvent) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) BevelBorder(javax.swing.border.BevelBorder) PopupMenuListener(javax.swing.event.PopupMenuListener) FeatureTypeStyleWrapper(org.hortonmachine.gears.utils.style.FeatureTypeStyleWrapper) MouseAdapter(java.awt.event.MouseAdapter) TreeSelectionListener(javax.swing.event.TreeSelectionListener) PopupMenuEvent(javax.swing.event.PopupMenuEvent) RuleWrapper(org.hortonmachine.gears.utils.style.RuleWrapper) JPopupMenu(javax.swing.JPopupMenu) FeatureTypeStyleWrapper(org.hortonmachine.gears.utils.style.FeatureTypeStyleWrapper) StyleWrapper(org.hortonmachine.gears.utils.style.StyleWrapper) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent)

Example 38 with BevelBorder

use of javax.swing.border.BevelBorder in project RomRaider by RomRaider.

the class RamTuneTestApp method buildInputPanel.

private Component buildInputPanel() {
    GridBagLayout gridBagLayout = new GridBagLayout();
    JPanel inputPanel = new JPanel(gridBagLayout);
    inputPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Command"));
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.insets = new Insets(0, 5, 5, 5);
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 1;
    constraints.weighty = 1;
    inputPanel.add(commandComboBox, constraints);
    JPanel addressFieldPanel = new JPanel(new FlowLayout());
    addressFieldPanel.add(new JLabel("Address (eg. 020000):"));
    addressFieldPanel.add(addressField);
    JPanel lengthPanel = new JPanel(new FlowLayout());
    lengthPanel.add(new JLabel("   Read Length:"));
    lengthField.setText("1");
    lengthPanel.add(lengthField);
    lengthPanel.add(new JLabel("byte(s)"));
    JPanel blockReadPanel = new JPanel(new FlowLayout());
    blockRead.setSelected(true);
    blockRead.setToolTipText("uncheck to read range byte at a time");
    blockReadPanel.add(blockRead);
    blockReadPanel.add(new JLabel("Block Size:"));
    blocksize.setText("128");
    blocksize.setToolTipText("Set to value allowed by the ECU");
    blockReadPanel.add(blocksize);
    JPanel addressPanel = new JPanel(new FlowLayout(LEFT));
    addressPanel.add(addressFieldPanel);
    addressPanel.add(lengthPanel);
    addressPanel.add(blockReadPanel);
    constraints.gridx = 1;
    constraints.gridy = 0;
    constraints.gridwidth = 4;
    constraints.gridheight = 1;
    constraints.weightx = 1;
    constraints.weighty = 1;
    inputPanel.add(addressPanel, constraints);
    dataField.setFont(new Font("Monospaced", PLAIN, 12));
    dataField.setLineWrap(true);
    dataField.setBorder(new BevelBorder(LOWERED));
    constraints.gridx = 0;
    constraints.gridy = 1;
    constraints.gridwidth = 5;
    constraints.gridheight = 1;
    constraints.weightx = 1;
    constraints.weighty = 1;
    inputPanel.add(new JScrollPane(dataField, VERTICAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_NEVER), constraints);
    constraints.gridx = 0;
    constraints.gridy = 2;
    constraints.gridwidth = 5;
    constraints.gridheight = 1;
    constraints.weightx = 1;
    constraints.weighty = 1;
    inputPanel.add(buildSendButton(), constraints);
    return inputPanel;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) EtchedBorder(javax.swing.border.EtchedBorder) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) FlowLayout(java.awt.FlowLayout) GridBagLayout(java.awt.GridBagLayout) BevelBorder(javax.swing.border.BevelBorder) JLabel(javax.swing.JLabel) TitledBorder(javax.swing.border.TitledBorder) Font(java.awt.Font)

Example 39 with BevelBorder

use of javax.swing.border.BevelBorder in project RomRaider by RomRaider.

the class RamTuneTestApp method buildOutputPanel.

private Component buildOutputPanel() {
    responseField.setFont(new Font("Monospaced", PLAIN, 12));
    responseField.setLineWrap(true);
    responseField.setEditable(false);
    responseField.setBorder(new BevelBorder(LOWERED));
    JScrollPane responseScrollPane = new JScrollPane(responseField, VERTICAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_NEVER);
    responseScrollPane.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Trace"));
    return responseScrollPane;
}
Also used : JScrollPane(javax.swing.JScrollPane) EtchedBorder(javax.swing.border.EtchedBorder) BevelBorder(javax.swing.border.BevelBorder) TitledBorder(javax.swing.border.TitledBorder) Font(java.awt.Font)

Example 40 with BevelBorder

use of javax.swing.border.BevelBorder in project borg_calendar by mikeberger.

the class AppointmentPanel method initComponents.

/**
 * initialize many of the UI components. This started as very very bad
 * generated code. It's been cleaned up somewhat
 */
private void initComponents() {
    // lots of components are created here. This is how the code-gen lumped
    // them.
    // not worth it to move them all where they are used.
    JLabel subjectLabel = new JLabel();
    subjectLabel.setText(Resource.getResourceString("subject"));
    newAppointmentIndicatorLabel = new JLabel();
    JScrollPane apptTextScroll = new JScrollPane();
    appointmentBodyTextArea = new JTextArea(new LimitDocument(Prefs.getIntPref(PrefName.MAX_TEXT_SIZE)));
    prioritySpinner = new JSpinner();
    JLabel starttimeLabel = new JLabel();
    JLabel endTimeLabel = new JLabel();
    untimedCheckBox = new JCheckBox();
    JLabel newDateLabel = new JLabel();
    newdatefield = new JDateChooser(new PlainDateEditor());
    newdatefield.setDateFormatString("MMM dd, yyyy");
    dateChangeCheckBox = new JCheckBox();
    JPanel appointmentPropetiesPanel = new JPanel();
    todoCheckBox = new JCheckBox();
    vacationCheckBox = new JCheckBox();
    halfDayVacationCheckBox = new JCheckBox();
    holidayCheckBox = new JCheckBox();
    privateCheckBox = new JCheckBox();
    JLabel lblColor = new JLabel();
    categoryBox = new JComboBox<String>();
    JLabel lblCategory = new JLabel();
    JLabel lblPriority = new JLabel();
    JPanel buttonPanel = new JPanel();
    saveButton = new JButton();
    saveCloseButton = new JButton();
    JButton savedefaultsbutton = new JButton();
    apptTitleField = new JTextField();
    lblCategory.setLabelFor(categoryBox);
    lblColor.setLabelFor(colorComboBox);
    newDateLabel.setLabelFor(newdatefield);
    setLayout(new GridBagLayout());
    newAppointmentIndicatorLabel.setForeground(java.awt.Color.red);
    add(newAppointmentIndicatorLabel, GridBagConstraintsFactory.create(0, 0, GridBagConstraints.BOTH));
    // ********************************************************************
    // appt text panel
    // ********************************************************************
    JPanel appointmentTextPanel = new JPanel();
    appointmentTextPanel.setLayout(new GridBagLayout());
    appointmentTextPanel.setBorder(new TitledBorder(Resource.getResourceString("appttext")));
    appointmentBodyTextArea.setColumns(40);
    appointmentBodyTextArea.setLineWrap(true);
    appointmentBodyTextArea.setRows(5);
    appointmentBodyTextArea.setWrapStyleWord(true);
    appointmentBodyTextArea.setBorder(new BevelBorder(BevelBorder.LOWERED));
    appointmentBodyTextArea.setMinimumSize(new java.awt.Dimension(284, 140));
    apptTextScroll.setViewportView(appointmentBodyTextArea);
    appointmentTextPanel.add(subjectLabel, GridBagConstraintsFactory.create(0, 0));
    appointmentTextPanel.add(apptTitleField, GridBagConstraintsFactory.create(1, 0, GridBagConstraints.BOTH, 1.0, 0.0));
    appointmentTextPanel.add(apptTextScroll, GridBagConstraintsFactory.create(1, 1, GridBagConstraints.BOTH, 0.5, 0.5));
    GridBagConstraints gridBagConstraints3 = GridBagConstraintsFactory.create(0, 1, GridBagConstraints.BOTH);
    gridBagConstraints3.gridwidth = java.awt.GridBagConstraints.REMAINDER;
    gridBagConstraints3.weightx = 1.5;
    gridBagConstraints3.weighty = 2.0;
    add(appointmentTextPanel, gridBagConstraints3);
    // ********************************************************************
    // appointment time panel
    // ********************************************************************
    JPanel appointmentTimePanel = new JPanel();
    appointmentTimePanel.setLayout(new java.awt.GridBagLayout());
    appointmentTimePanel.setBorder(new TitledBorder(Resource.getResourceString("appttime")));
    ResourceHelper.setText(starttimeLabel, "Start_Time:");
    appointmentTimePanel.add(starttimeLabel, GridBagConstraintsFactory.create(0, 0, GridBagConstraints.BOTH));
    startTimePanel = new DateTimePanel(false, Prefs.getBoolPref(PrefName.MILTIME));
    appointmentTimePanel.add(startTimePanel, GridBagConstraintsFactory.create(1, 0, GridBagConstraints.BOTH));
    ResourceHelper.setText(untimedCheckBox, "No_Specific_Time");
    untimedCheckBox.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            untimedCheckBoxActionPerformed();
        }
    });
    GridBagConstraints gridBagConstraints12 = GridBagConstraintsFactory.create(2, 0, GridBagConstraints.BOTH);
    appointmentTimePanel.add(untimedCheckBox, gridBagConstraints12);
    endTimeLabel.setText(Resource.getResourceString("EndTime") + ":");
    appointmentTimePanel.add(endTimeLabel, GridBagConstraintsFactory.create(0, 1, GridBagConstraints.BOTH));
    endTimePanel = new DateTimePanel(false, Prefs.getBoolPref(PrefName.MILTIME));
    appointmentTimePanel.add(endTimePanel, GridBagConstraintsFactory.create(1, 1, GridBagConstraints.BOTH));
    durationLabel.setText("1/2 hour");
    appointmentTimePanel.add(durationLabel, GridBagConstraintsFactory.create(2, 1, GridBagConstraints.BOTH));
    ResourceHelper.setText(dateChangeCheckBox, "changedate");
    dateChangeCheckBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            newdatefield.setEnabled(dateChangeCheckBox.isSelected());
        }
    });
    appointmentTimePanel.add(new JLabel("       "), GridBagConstraintsFactory.create(3, 0, GridBagConstraints.HORIZONTAL));
    appointmentTimePanel.add(dateChangeCheckBox, GridBagConstraintsFactory.create(4, 0, GridBagConstraints.HORIZONTAL));
    ResourceHelper.setText(newDateLabel, "newDate:");
    appointmentTimePanel.add(newDateLabel, GridBagConstraintsFactory.create(5, 0, GridBagConstraints.BOTH));
    appointmentTimePanel.add(newdatefield, GridBagConstraintsFactory.create(6, 0, GridBagConstraints.BOTH));
    // ********************************************************************
    // appt properties panel
    // ********************************************************************
    appointmentPropetiesPanel.setLayout(new GridBagLayout());
    appointmentPropetiesPanel.setBorder(new TitledBorder(Resource.getResourceString("Properties")));
    appointmentPropetiesPanel.setMinimumSize(new java.awt.Dimension(539, 128));
    ResourceHelper.setText(todoCheckBox, "To_Do");
    todoCheckBox.setOpaque(false);
    appointmentPropetiesPanel.add(todoCheckBox, GridBagConstraintsFactory.create(0, 0, GridBagConstraints.BOTH, 1.0, 0.0));
    vacationCheckBox.setForeground(new java.awt.Color(0, 102, 0));
    ResourceHelper.setText(vacationCheckBox, "Vacation");
    vacationCheckBox.setOpaque(false);
    appointmentPropetiesPanel.add(vacationCheckBox, GridBagConstraintsFactory.create(1, 0, GridBagConstraints.BOTH, 1.0, 0.0));
    halfDayVacationCheckBox.setForeground(new java.awt.Color(0, 102, 102));
    ResourceHelper.setText(halfDayVacationCheckBox, "Half_Day");
    halfDayVacationCheckBox.setOpaque(false);
    appointmentPropetiesPanel.add(halfDayVacationCheckBox, GridBagConstraintsFactory.create(2, 0, GridBagConstraints.BOTH, 1.0, 0.0));
    ResourceHelper.setText(holidayCheckBox, "Holiday");
    holidayCheckBox.setOpaque(false);
    appointmentPropetiesPanel.add(holidayCheckBox, GridBagConstraintsFactory.create(3, 0, GridBagConstraints.BOTH, 1.0, 0.0));
    ResourceHelper.setText(privateCheckBox, "Private");
    privateCheckBox.setOpaque(false);
    appointmentPropetiesPanel.add(privateCheckBox, GridBagConstraintsFactory.create(4, 0, GridBagConstraints.BOTH, 1.0, 0.0));
    JPanel subPanel = new JPanel();
    subPanel.setLayout(new GridBagLayout());
    subPanel.add(new JLabel(), // spacer
    GridBagConstraintsFactory.create(GridBagConstraints.RELATIVE, 0, GridBagConstraints.BOTH, 1.0, 0.0));
    lblColor.setHorizontalAlignment(SwingConstants.RIGHT);
    ResourceHelper.setText(lblColor, "Color");
    subPanel.add(lblColor, GridBagConstraintsFactory.create(GridBagConstraints.RELATIVE, 0, GridBagConstraints.BOTH));
    subPanel.add(colorComboBox, GridBagConstraintsFactory.create(GridBagConstraints.RELATIVE, 0, GridBagConstraints.BOTH));
    lblCategory.setHorizontalAlignment(SwingConstants.RIGHT);
    ResourceHelper.setText(lblCategory, "Category");
    subPanel.add(lblCategory, GridBagConstraintsFactory.create(GridBagConstraints.RELATIVE, 0, GridBagConstraints.BOTH, 1.0, 0.0));
    subPanel.add(categoryBox, GridBagConstraintsFactory.create(GridBagConstraints.RELATIVE, 0, GridBagConstraints.BOTH));
    lblPriority.setHorizontalAlignment(SwingConstants.RIGHT);
    ResourceHelper.setText(lblPriority, "Priority");
    subPanel.add(lblPriority, GridBagConstraintsFactory.create(GridBagConstraints.RELATIVE, 0, GridBagConstraints.BOTH, 1.0, 0.0));
    subPanel.add(prioritySpinner, GridBagConstraintsFactory.create(GridBagConstraints.RELATIVE, 0, GridBagConstraints.BOTH));
    subPanel.add(new JLabel(), // spacer
    GridBagConstraintsFactory.create(GridBagConstraints.RELATIVE, 0, GridBagConstraints.BOTH, 1.0, 0.0));
    GridBagConstraints subPanelConstraints = GridBagConstraintsFactory.create(0, 1, GridBagConstraints.BOTH, 1.0, 0.0);
    subPanelConstraints.gridwidth = 5;
    appointmentPropetiesPanel.add(subPanel, subPanelConstraints);
    // ********************************************************************
    // button panel
    // ********************************************************************
    saveButton.setIcon(new ImageIcon(getClass().getResource("/resource/Save16.gif")));
    ResourceHelper.setText(saveButton, "Save");
    saveButton.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            try {
                if (currentlyShownAppointmentKey == -1) {
                    add_appt();
                } else {
                    chg_appt();
                }
            } catch (Warning w) {
                Errmsg.getErrorHandler().notice(w.getMessage());
            } catch (Exception e) {
                Errmsg.getErrorHandler().errmsg(e);
            }
        }
    });
    buttonPanel.add(saveButton);
    saveCloseButton.setIcon(new ImageIcon(getClass().getResource("/resource/Save16.gif")));
    ResourceHelper.setText(saveCloseButton, "Save_&_Close");
    saveCloseButton.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            try {
                if (currentlyShownAppointmentKey == -1) {
                    add_appt();
                } else {
                    chg_appt();
                }
            } catch (Warning w) {
                Errmsg.getErrorHandler().notice(w.getMessage());
                return;
            } catch (Exception e) {
                Errmsg.getErrorHandler().errmsg(e);
                return;
            }
            DockableView parent = DockableView.findDockableParent(saveCloseButton);
            if (parent != null)
                parent.close();
        }
    });
    buttonPanel.add(saveCloseButton);
    encryptBox = new JCheckBox();
    encryptBox.setText(Resource.getResourceString("EncryptOnSave"));
    buttonPanel.add(encryptBox, null);
    decryptButton = new JButton();
    decryptButton.setText(Resource.getResourceString("decrypt"));
    decryptButton.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            try {
                Appointment appt = AppointmentModel.getReference().getAppt(currentlyShownAppointmentKey);
                if (appt == null)
                    return;
                String pw = PasswordHelper.getReference().getPassword();
                if (pw == null)
                    return;
                appt.decrypt(pw);
                // set appt text, split apart title and body
                String t = appt.getText();
                String title = "";
                String body = "";
                if (t == null)
                    t = "";
                int newlineIndex = t.indexOf('\n');
                if (newlineIndex != -1) {
                    title = t.substring(0, newlineIndex);
                    body = t.substring(newlineIndex + 1);
                } else {
                    title = t;
                }
                appointmentBodyTextArea.setText(body);
                apptTitleField.setText(title);
                appointmentBodyTextArea.setEditable(true);
                apptTitleField.setEditable(true);
                decryptButton.setEnabled(false);
                saveButton.setEnabled(true);
                saveCloseButton.setEnabled(true);
            } catch (Exception e1) {
                Errmsg.getErrorHandler().errmsg(e1);
            }
        }
    });
    buttonPanel.add(decryptButton, null);
    savedefaultsbutton.setIcon(new ImageIcon(getClass().getResource("/resource/SaveAs16.gif")));
    ResourceHelper.setText(savedefaultsbutton, "save_Def");
    savedefaultsbutton.setToolTipText(Resource.getResourceString("sd_tip"));
    savedefaultsbutton.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            Appointment appt = new Appointment();
            try {
                setAppt(appt, false);
            } catch (Exception e) {
                Errmsg.getErrorHandler().errmsg(e);
                return;
            }
            AppointmentModel.getReference().saveDefaultAppointment(appt);
        }
    });
    // add a spacer
    buttonPanel.add(new JLabel("          "));
    buttonPanel.add(savedefaultsbutton);
    // ********************************************************************
    // popup reminders panel
    // ********************************************************************
    popupTimesLabel = new JLabel();
    popupTimesLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    JButton popupTimesBtn = new JButton();
    ResourceHelper.setText(popupTimesBtn, "Change");
    final AppointmentPanel thisPanel = this;
    popupTimesBtn.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            String apptTitle = apptTitleField.getText();
            if (apptTitle.equals("")) {
                apptTitle = Resource.getResourceString("*****_NEW_APPT_*****");
            }
            PopupOptionsView pv = new PopupOptionsView(new String(custRemTimes), apptTitle, thisPanel);
            pv.setVisible(true);
        }
    });
    JPanel popupReminderPanel = new JPanel();
    popupReminderPanel.setBorder(new TitledBorder(Resource.getResourceString("popup_reminders")));
    popupReminderPanel.add(popupTimesLabel);
    popupReminderPanel.add(popupTimesBtn);
    // ********************************************************************
    // add panels to the top level
    // ********************************************************************
    GridBagConstraints gridBagConstraints17 = GridBagConstraintsFactory.create(0, 2, GridBagConstraints.BOTH, 1.0, 1.0);
    gridBagConstraints17.gridwidth = GridBagConstraints.REMAINDER;
    this.add(appointmentTimePanel, gridBagConstraints17);
    this.setSize(648, 590);
    GridBagConstraints gridBagConstraints38 = GridBagConstraintsFactory.create(0, 3, GridBagConstraints.BOTH);
    gridBagConstraints38.gridwidth = 2;
    this.add(appointmentPropetiesPanel, gridBagConstraints38);
    this.add(createRepeatPanel(), GridBagConstraintsFactory.create(0, 5, GridBagConstraints.BOTH));
    GridBagConstraints gridBagConstraints91 = GridBagConstraintsFactory.create(0, 6, GridBagConstraints.BOTH);
    gridBagConstraints91.gridwidth = 2;
    this.add(buttonPanel, gridBagConstraints91);
    GridBagConstraints gridBagConstraints87 = GridBagConstraintsFactory.create(0, 4, GridBagConstraints.BOTH, 9.0, 1.0);
    gridBagConstraints87.gridwidth = 2;
    this.add(popupReminderPanel, gridBagConstraints87);
    linkPanel = new LinkPanel();
    linkPanel.setBorder(new TitledBorder(Resource.getResourceString("links")));
    this.add(linkPanel, GridBagConstraintsFactory.create(1, 5, GridBagConstraints.BOTH));
}
Also used : Appointment(net.sf.borg.model.entity.Appointment) ActionListener(java.awt.event.ActionListener) PopupOptionsView(net.sf.borg.ui.popup.PopupOptionsView) BevelBorder(javax.swing.border.BevelBorder) TitledBorder(javax.swing.border.TitledBorder) LinkPanel(net.sf.borg.ui.link.LinkPanel) JDateChooser(com.toedter.calendar.JDateChooser) DockableView(net.sf.borg.ui.DockableView) ActionEvent(java.awt.event.ActionEvent) ActionListener(java.awt.event.ActionListener) java.awt(java.awt)

Aggregations

BevelBorder (javax.swing.border.BevelBorder)51 JPanel (javax.swing.JPanel)18 JScrollPane (javax.swing.JScrollPane)14 Dimension (java.awt.Dimension)13 ActionEvent (java.awt.event.ActionEvent)13 JLabel (javax.swing.JLabel)13 BorderLayout (java.awt.BorderLayout)12 JButton (javax.swing.JButton)11 MouseAdapter (java.awt.event.MouseAdapter)10 MouseEvent (java.awt.event.MouseEvent)10 FlowLayout (java.awt.FlowLayout)9 Insets (java.awt.Insets)9 JPopupMenu (javax.swing.JPopupMenu)9 TitledBorder (javax.swing.border.TitledBorder)9 Font (java.awt.Font)8 IOException (java.io.IOException)8 JMenuItem (javax.swing.JMenuItem)8 Color (java.awt.Color)7 EtchedBorder (javax.swing.border.EtchedBorder)7 ActionListener (java.awt.event.ActionListener)6