List of usage examples for javax.swing JButton setEnabled
public void setEnabled(boolean b)
From source file:op.care.values.PnlValues.java
private CollapsiblePane createCP4Type(final ResValueTypes vtype) { final String keyType = vtype.getID() + ".xtypes"; final CollapsiblePane cpType = getCP(keyType); final DefaultCPTitle cptitle = new DefaultCPTitle(vtype.getText(), new ActionListener() { @Override//from w w w . j a v a 2 s. c om public void actionPerformed(ActionEvent e) { try { cpType.setCollapsed(!cpType.isCollapsed()); } catch (PropertyVetoException pve) { // BAH! } } }); cptitle.getButton().setFont(SYSConst.ARIAL24); cptitle.getButton().setForeground(vtype.getColor()); cpType.setBackground(Color.white); cpType.setTitleLabelComponent(cptitle.getMain()); cpType.setSlidingDirection(SwingConstants.SOUTH); if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) { /*** * _ _ _ __ _____ __ * / \ __| | __| | / /_ __ ___ _ __ |_ _| _ _ __ __\ \ * / _ \ / _` |/ _` | | || '_ \ / _ \ '__| | || | | | '_ \ / _ \ | * / ___ \ (_| | (_| | | || |_) | __/ | | || |_| | |_) | __/ | * /_/ \_\__,_|\__,_| | || .__/ \___|_| |_| \__, | .__/ \___| | * \_\_| |___/|_| /_/ */ final JButton btnAdd = new JButton(SYSConst.icon22add); btnAdd.setPressedIcon(SYSConst.icon22addPressed); btnAdd.setAlignmentX(Component.RIGHT_ALIGNMENT); btnAdd.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnAdd.setContentAreaFilled(false); btnAdd.setBorder(null); btnAdd.setToolTipText( SYSTools.xx("nursingrecords.vitalparameters.btnAdd.tooltip") + " (" + vtype.getText() + ")"); btnAdd.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { addValue(vtype); } }); cptitle.getRight().add(btnAdd); btnAdd.setEnabled(resident.isActive()); } cpType.addCollapsiblePaneListener(new CollapsiblePaneAdapter() { @Override public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) { cpType.setContentPane(createContentPanel4Type(vtype)); } }); if (!cpType.isCollapsed()) { cpType.setContentPane(createContentPanel4Type(vtype)); } if (!ResValueTools.getYearsWithValues(resident, vtype).isEmpty()) { // cptitle.getTitleButton().setIcon(SYSConst.icon22ledGreenOn); cpType.setCollapsible(true); } else { // cptitle.getTitleButton().setIcon(SYSConst.icon22ledGreenOff); cpType.setCollapsible(false); } cpType.setHorizontalAlignment(SwingConstants.LEADING); cpType.setOpaque(false); // cpType.setBackground(getColor(vtype, SYSConst.medium1)); return cpType; }
From source file:op.care.values.PnlValues.java
private JPanel createContentPanel4Year(final ResValueTypes vtype, final int year) { final String keyYears = vtype.getID() + ".xtypes." + Integer.toString(year) + ".year"; java.util.List<ResValue> myValues; synchronized (mapType2Values) { if (!mapType2Values.containsKey(keyYears)) { mapType2Values.put(keyYears, ResValueTools.getResValues(resident, vtype, year)); }// w w w .ja v a2s. c o m if (mapType2Values.get(keyYears).isEmpty()) { JLabel lbl = new JLabel(SYSTools.xx("misc.msg.novalue")); JPanel pnl = new JPanel(); pnl.add(lbl); return pnl; } myValues = mapType2Values.get(keyYears); } JPanel pnlYear = new JPanel(new VerticalLayout()); pnlYear.setOpaque(false); for (final ResValue resValue : myValues) { String title = "<html><table border=\"0\">" + "<tr>" + "<td width=\"200\" align=\"left\">" + DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.SHORT).format(resValue.getPit()) + " [" + resValue.getID() + "]</td>" + "<td width=\"340\" align=\"left\">" + ResValueTools.getValueAsHTML(resValue) + "</td>" + "<td width=\"200\" align=\"left\">" + resValue.getUser().getFullname() + "</td>" + "</tr>" + "</table>" + "</html>"; final DefaultCPTitle pnlTitle = new DefaultCPTitle(title, null); pnlTitle.getMain().setBackground(GUITools.blend(vtype.getColor(), Color.WHITE, 0.1f)); pnlTitle.getMain().setOpaque(true); if (resValue.isObsolete()) { pnlTitle.getAdditionalIconPanel().add(new JLabel(SYSConst.icon22eraser)); } if (resValue.isReplacement()) { pnlTitle.getAdditionalIconPanel().add(new JLabel(SYSConst.icon22edited)); } if (!resValue.getText().trim().isEmpty()) { pnlTitle.getAdditionalIconPanel().add(new JLabel(SYSConst.icon22info)); } if (pnlTitle.getAdditionalIconPanel().getComponentCount() > 0) { pnlTitle.getButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { GUITools.showPopup( GUITools.getHTMLPopup(pnlTitle.getButton(), ResValueTools.getInfoAsHTML(resValue)), SwingConstants.NORTH); } }); } if (!resValue.getAttachedFilesConnections().isEmpty()) { /*** * _ _ _____ _ _ * | |__ | |_ _ __ | ___(_) | ___ ___ * | '_ \| __| '_ \| |_ | | |/ _ \/ __| * | |_) | |_| | | | _| | | | __/\__ \ * |_.__/ \__|_| |_|_| |_|_|\___||___/ * */ final JButton btnFiles = new JButton( Integer.toString(resValue.getAttachedFilesConnections().size()), SYSConst.icon22greenStar); btnFiles.setToolTipText(SYSTools.xx("misc.btnfiles.tooltip")); btnFiles.setForeground(Color.BLUE); btnFiles.setHorizontalTextPosition(SwingUtilities.CENTER); btnFiles.setFont(SYSConst.ARIAL18BOLD); btnFiles.setPressedIcon(SYSConst.icon22Pressed); btnFiles.setAlignmentX(Component.RIGHT_ALIGNMENT); btnFiles.setAlignmentY(Component.TOP_ALIGNMENT); btnFiles.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnFiles.setContentAreaFilled(false); btnFiles.setBorder(null); btnFiles.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgFiles(resValue, new Closure() { @Override public void execute(Object o) { EntityManager em = OPDE.createEM(); final ResValue myValue = em.find(ResValue.class, resValue.getID()); em.close(); synchronized (mapType2Values) { mapType2Values.get(keyYears).remove(resValue); mapType2Values.get(keyYears).add(myValue); Collections.sort(mapType2Values.get(keyYears)); } createCP4Year(vtype, year); buildPanel(); } }); } }); btnFiles.setEnabled(OPDE.isFTPworking()); pnlTitle.getRight().add(btnFiles); } if (!resValue.getAttachedProcessConnections().isEmpty()) { /*** * _ _ ____ * | |__ | |_ _ __ | _ \ _ __ ___ ___ ___ ___ ___ * | '_ \| __| '_ \| |_) | '__/ _ \ / __/ _ \/ __/ __| * | |_) | |_| | | | __/| | | (_) | (_| __/\__ \__ \ * |_.__/ \__|_| |_|_| |_| \___/ \___\___||___/___/ * */ final JButton btnProcess = new JButton( Integer.toString(resValue.getAttachedProcessConnections().size()), SYSConst.icon22redStar); btnProcess.setToolTipText(SYSTools.xx("misc.btnprocess.tooltip")); btnProcess.setForeground(Color.YELLOW); btnProcess.setHorizontalTextPosition(SwingUtilities.CENTER); btnProcess.setFont(SYSConst.ARIAL18BOLD); btnProcess.setPressedIcon(SYSConst.icon22Pressed); btnProcess.setAlignmentX(Component.RIGHT_ALIGNMENT); btnProcess.setAlignmentY(Component.TOP_ALIGNMENT); btnProcess.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnProcess.setContentAreaFilled(false); btnProcess.setBorder(null); btnProcess.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgProcessAssign(resValue, new Closure() { @Override public void execute(Object o) { if (o == null) { return; } Pair<ArrayList<QProcess>, ArrayList<QProcess>> result = (Pair<ArrayList<QProcess>, ArrayList<QProcess>>) o; ArrayList<QProcess> assigned = result.getFirst(); ArrayList<QProcess> unassigned = result.getSecond(); EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); ResValue myValue = em.merge(resValue); em.lock(myValue, LockModeType.OPTIMISTIC_FORCE_INCREMENT); ArrayList<SYSVAL2PROCESS> attached = new ArrayList<SYSVAL2PROCESS>( resValue.getAttachedProcessConnections()); for (SYSVAL2PROCESS linkObject : attached) { if (unassigned.contains(linkObject.getQProcess())) { linkObject.getQProcess().getAttachedNReportConnections() .remove(linkObject); linkObject.getResValue().getAttachedProcessConnections() .remove(linkObject); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_REMOVE_ELEMENT) + ": " + myValue.getTitle() + " ID: " + myValue.getID(), PReportTools.PREPORT_TYPE_REMOVE_ELEMENT, linkObject.getQProcess())); em.remove(linkObject); } } attached.clear(); for (QProcess qProcess : assigned) { java.util.List<QProcessElement> listElements = qProcess.getElements(); if (!listElements.contains(myValue)) { QProcess myQProcess = em.merge(qProcess); SYSVAL2PROCESS myLinkObject = em .merge(new SYSVAL2PROCESS(myQProcess, myValue)); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_ASSIGN_ELEMENT) + ": " + myValue.getTitle() + " ID: " + myValue.getID(), PReportTools.PREPORT_TYPE_ASSIGN_ELEMENT, myQProcess)); qProcess.getAttachedResValueConnections().add(myLinkObject); myValue.getAttachedProcessConnections().add(myLinkObject); } } em.getTransaction().commit(); synchronized (mapType2Values) { mapType2Values.get(keyYears).remove(resValue); mapType2Values.get(keyYears).add(myValue); Collections.sort(mapType2Values.get(keyYears)); } createCP4Year(vtype, year); buildPanel(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (RollbackException ole) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } }); } }); btnProcess.setEnabled(OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)); pnlTitle.getRight().add(btnProcess); } /*** * __ __ * | \/ | ___ _ __ _ _ * | |\/| |/ _ \ '_ \| | | | * | | | | __/ | | | |_| | * |_| |_|\___|_| |_|\__,_| * */ final JButton btnMenu = new JButton(SYSConst.icon22menu); btnMenu.setPressedIcon(SYSConst.icon22Pressed); btnMenu.setAlignmentX(Component.RIGHT_ALIGNMENT); btnMenu.setAlignmentY(Component.TOP_ALIGNMENT); btnMenu.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnMenu.setContentAreaFilled(false); btnMenu.setBorder(null); btnMenu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JidePopup popup = new JidePopup(); popup.setMovable(false); popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS)); popup.setOwner(btnMenu); popup.removeExcludedComponent(btnMenu); JPanel pnl = getMenu(resValue); popup.getContentPane().add(pnl); popup.setDefaultFocusComponent(pnl); GUITools.showPopup(popup, SwingConstants.WEST); } }); btnMenu.setEnabled(!resValue.isObsolete()); pnlTitle.getRight().add(btnMenu); pnlYear.add(pnlTitle.getMain()); synchronized (linemap) { linemap.put(resValue, pnlTitle.getMain()); } } return pnlYear; }
From source file:op.care.values.PnlValues.java
private JPanel getMenu(final ResValue resValue) { final ResValueTypes vtype = resValue.getType(); JPanel pnlMenu = new JPanel(new VerticalLayout()); boolean doesNotBelongToResInfos = ResInfoTools.getInfosFor(resValue).isEmpty(); if (doesNotBelongToResInfos && OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) { /*** * _____ _ _ _/* ww w . j a va 2s.c o m*/ * | ____|__| (_) |_ * | _| / _` | | __| * | |__| (_| | | |_ * |_____\__,_|_|\__| * */ final JButton btnEdit = GUITools.createHyperlinkButton("nursingrecords.vitalparameters.btnEdit.tooltip", SYSConst.icon22edit3, null); btnEdit.setAlignmentX(Component.RIGHT_ALIGNMENT); btnEdit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgValue(resValue.clone(), DlgValue.MODE_EDIT, new Closure() { @Override public void execute(Object o) { if (o != null) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); final ResValue newValue = em.merge((ResValue) o); ResValue oldValue = em.merge(resValue); em.lock(oldValue, LockModeType.OPTIMISTIC); newValue.setReplacementFor(oldValue); for (SYSVAL2FILE oldAssignment : oldValue.getAttachedFilesConnections()) { em.remove(oldAssignment); } oldValue.getAttachedFilesConnections().clear(); for (SYSVAL2PROCESS oldAssignment : oldValue.getAttachedProcessConnections()) { em.remove(oldAssignment); } oldValue.getAttachedProcessConnections().clear(); oldValue.setEditedBy(em.merge(OPDE.getLogin().getUser())); oldValue.setEditDate(new Date()); oldValue.setReplacedBy(newValue); em.getTransaction().commit(); DateTime dt = new DateTime(newValue.getPit()); final String keyType = vtype.getID() + ".xtypes"; final String key = vtype.getID() + ".xtypes." + Integer.toString(dt.getYear()) + ".year"; synchronized (mapType2Values) { mapType2Values.get(key).remove(resValue); mapType2Values.get(key).add(oldValue); mapType2Values.get(key).add(newValue); Collections.sort(mapType2Values.get(key)); } createCP4Year(vtype, dt.getYear()); try { synchronized (cpMap) { cpMap.get(keyType).setCollapsed(false); cpMap.get(key).setCollapsed(false); } } catch (PropertyVetoException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } buildPanel(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } } }); } }); btnEdit.setEnabled(!resValue.isObsolete()); pnlMenu.add(btnEdit); /*** * ____ _ _ * | _ \ ___| | ___| |_ ___ * | | | |/ _ \ |/ _ \ __/ _ \ * | |_| | __/ | __/ || __/ * |____/ \___|_|\___|\__\___| * */ final JButton btnDelete = GUITools.createHyperlinkButton( "nursingrecords.vitalparameters.btnDelete.tooltip", SYSConst.icon22delete, null); btnDelete.setAlignmentX(Component.RIGHT_ALIGNMENT); btnDelete.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgYesNo(SYSTools.xx("misc.questions.delete1") + "<br/><i>" + DateFormat.getDateTimeInstance().format(resValue.getPit()) + "</i><br/>" + SYSTools.xx("misc.questions.delete2"), SYSConst.icon48delete, new Closure() { @Override public void execute(Object o) { if (o.equals(JOptionPane.YES_OPTION)) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); ResValue myValue = em.merge(resValue); myValue.setDeletedBy(em.merge(OPDE.getLogin().getUser())); for (SYSVAL2FILE file : myValue.getAttachedFilesConnections()) { em.remove(file); } myValue.getAttachedFilesConnections().clear(); // Vorgangszuordnungen entfernen for (SYSVAL2PROCESS connObj : myValue.getAttachedProcessConnections()) { em.remove(connObj); } myValue.getAttachedProcessConnections().clear(); myValue.getAttachedProcesses().clear(); em.getTransaction().commit(); DateTime dt = new DateTime(myValue.getPit()); final String keyType = vtype.getID() + ".xtypes"; final String key = vtype.getID() + ".xtypes." + Integer.toString(dt.getYear()) + ".year"; synchronized (mapType2Values) { mapType2Values.get(key).remove(resValue); mapType2Values.get(key).add(myValue); Collections.sort(mapType2Values.get(key)); } createCP4Year(vtype, dt.getYear()); try { synchronized (cpMap) { cpMap.get(keyType).setCollapsed(false); cpMap.get(key).setCollapsed(false); } } catch (PropertyVetoException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } buildPanel(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } } }); } }); btnDelete.setEnabled(!resValue.isObsolete()); pnlMenu.add(btnDelete); pnlMenu.add(new JSeparator()); /*** * _ _ _____ _ _ * | |__ | |_ _ __ | ___(_) | ___ ___ * | '_ \| __| '_ \| |_ | | |/ _ \/ __| * | |_) | |_| | | | _| | | | __/\__ \ * |_.__/ \__|_| |_|_| |_|_|\___||___/ * */ final JButton btnFiles = GUITools.createHyperlinkButton("misc.btnfiles.tooltip", SYSConst.icon22attach, null); btnFiles.setAlignmentX(Component.RIGHT_ALIGNMENT); btnFiles.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgFiles(resValue, new Closure() { @Override public void execute(Object o) { EntityManager em = OPDE.createEM(); final ResValue myValue = em.find(ResValue.class, resValue.getID()); em.close(); DateTime dt = new DateTime(myValue.getPit()); final String key = vtype.getID() + ".xtypes." + Integer.toString(dt.getYear()) + ".year"; synchronized (mapType2Values) { mapType2Values.get(key).remove(resValue); mapType2Values.get(key).add(myValue); Collections.sort(mapType2Values.get(key)); } buildPanel(); } }); } }); btnFiles.setEnabled(!resValue.isObsolete() && OPDE.isFTPworking()); pnlMenu.add(btnFiles); /*** * _ _ ____ * | |__ | |_ _ __ | _ \ _ __ ___ ___ ___ ___ ___ * | '_ \| __| '_ \| |_) | '__/ _ \ / __/ _ \/ __/ __| * | |_) | |_| | | | __/| | | (_) | (_| __/\__ \__ \ * |_.__/ \__|_| |_|_| |_| \___/ \___\___||___/___/ * */ final JButton btnProcess = GUITools.createHyperlinkButton("misc.btnprocess.tooltip", SYSConst.icon22link, null); btnProcess.setAlignmentX(Component.RIGHT_ALIGNMENT); btnProcess.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgProcessAssign(resValue, new Closure() { @Override public void execute(Object o) { if (o == null) { return; } Pair<ArrayList<QProcess>, ArrayList<QProcess>> result = (Pair<ArrayList<QProcess>, ArrayList<QProcess>>) o; ArrayList<QProcess> assigned = result.getFirst(); ArrayList<QProcess> unassigned = result.getSecond(); EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); ResValue myValue = em.merge(resValue); em.lock(myValue, LockModeType.OPTIMISTIC_FORCE_INCREMENT); ArrayList<SYSVAL2PROCESS> attached = new ArrayList<SYSVAL2PROCESS>( resValue.getAttachedProcessConnections()); for (SYSVAL2PROCESS linkObject : attached) { if (unassigned.contains(linkObject.getQProcess())) { linkObject.getQProcess().getAttachedNReportConnections().remove(linkObject); linkObject.getResValue().getAttachedProcessConnections().remove(linkObject); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_REMOVE_ELEMENT) + ": " + myValue.getTitle() + " ID: " + myValue.getID(), PReportTools.PREPORT_TYPE_REMOVE_ELEMENT, linkObject.getQProcess())); em.remove(linkObject); } } attached.clear(); for (QProcess qProcess : assigned) { java.util.List<QProcessElement> listElements = qProcess.getElements(); if (!listElements.contains(myValue)) { QProcess myQProcess = em.merge(qProcess); SYSVAL2PROCESS myLinkObject = em .merge(new SYSVAL2PROCESS(myQProcess, myValue)); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_ASSIGN_ELEMENT) + ": " + myValue.getTitle() + " ID: " + myValue.getID(), PReportTools.PREPORT_TYPE_ASSIGN_ELEMENT, myQProcess)); qProcess.getAttachedResValueConnections().add(myLinkObject); myValue.getAttachedProcessConnections().add(myLinkObject); } } em.getTransaction().commit(); DateTime dt = new DateTime(myValue.getPit()); final String key = vtype.getID() + ".xtypes." + Integer.toString(dt.getYear()) + ".year"; synchronized (mapType2Values) { mapType2Values.get(key).remove(resValue); mapType2Values.get(key).add(myValue); Collections.sort(mapType2Values.get(key)); } createCP4Year(vtype, dt.getYear()); buildPanel(); //GUITools.flashBackground(contentmap.get(keyMonth), Color.YELLOW, 2); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (RollbackException ole) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } }); } }); btnProcess.setEnabled(!resValue.isObsolete()); pnlMenu.add(btnProcess); } return pnlMenu; }
From source file:op.controlling.PnlControlling.java
private JPanel createContentPanel4Staff() { JPanel pnlContent = new JPanel(new VerticalLayout()); /***/*from w w w.j av a 2s .co m*/ * ____ _ __ __ * / ___|| |_ __ _ / _|/ _| * \___ \| __/ _` | |_| |_ * ___) | || (_| | _| _| * |____/ \__\__,_|_| |_| * */ JPanel pnlTraining = new JPanel(new BorderLayout()); final JButton btnTrainings = GUITools.createHyperlinkButton("opde.controlling.staff.training", null, null); Pair<LocalDate, LocalDate> minmax = TrainingTools.getMinMax(); btnTrainings.setEnabled(minmax != null); final JComboBox cmbYears = new JComboBox(); if (minmax == null) { cmbYears.setModel(new DefaultComboBoxModel()); } else { ArrayList<Integer> years = new ArrayList<>(); for (int year = minmax.getSecond().getYear(); year >= minmax.getFirst().getYear(); year--) { years.add(year); } cmbYears.setModel(SYSTools.list2cmb(years)); cmbYears.setSelectedIndex(0); } btnTrainings.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OPDE.getMainframe().setBlocked(true); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { SYSFilesTools.print( TrainingTools.getTraining2Attendees((Integer) cmbYears.getSelectedItem()), false); return null; } @Override protected void done() { OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); } }); pnlTraining.add(btnTrainings, BorderLayout.WEST); pnlTraining.add(cmbYears, BorderLayout.EAST); pnlContent.add(pnlTraining); return pnlContent; }
From source file:op.users.PnlUser.java
private CollapsiblePane createCP4(final Users user) { final String key = user.getUID() + ".xusers"; if (!cpMap.containsKey(key)) { cpMap.put(key, new CollapsiblePane()); try {//from www . ja va 2s. c om cpMap.get(key).setCollapsed(true); } catch (PropertyVetoException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } final CollapsiblePane cp = cpMap.get(key); DefaultCPTitle cptitle = new DefaultCPTitle("<html><font size=+1>" + user.toString() + (UsersTools.isQualified(user) ? ", " + SYSTools.xx("opde.users.qualifiedNurse") : "") + "</font></html>", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { cp.setCollapsed(!cp.isCollapsed()); } catch (PropertyVetoException pve) { // BAH! } } }); /*** * ____ _ ______ __ * / ___| |__ __ _ _ __ __ _ ___| _ \ \ / / * | | | '_ \ / _` | '_ \ / _` |/ _ \ |_) \ \ /\ / / * | |___| | | | (_| | | | | (_| | __/ __/ \ V V / * \____|_| |_|\__,_|_| |_|\__, |\___|_| \_/\_/ * |___/ */ final JButton btnChangePW = new JButton(SYSConst.icon22password); btnChangePW.setPressedIcon(SYSConst.icon22passwordPressed); btnChangePW.setAlignmentX(Component.RIGHT_ALIGNMENT); btnChangePW.setContentAreaFilled(false); btnChangePW.setBorder(null); btnChangePW.setToolTipText(SYSTools.xx("opde.users.btnChangePW.tooltip")); btnChangePW.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); Users myUser = em.merge(usermap.get(user.getUID())); String newpw = SYSTools.generatePassword(myUser.getVorname(), myUser.getName()); em.lock(myUser, LockModeType.OPTIMISTIC); myUser.setMd5pw(SYSTools.hashword(newpw)); em.getTransaction().commit(); lstUsers.remove(user); lstUsers.add(myUser); usermap.put(key, myUser); Collections.sort(lstUsers); SYSTools.printpw(newpw, myUser); OPDE.getDisplayManager().addSubMessage(new DisplayMessage(SYSTools.xx("opde.users.pwchanged"))); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } }); btnChangePW.setEnabled(user.isActive()); cptitle.getRight().add(btnChangePW); /*** * _ _ _ _ _ ___ _ _ * | |__ | |_ _ __ / \ ___| |_(_)_ _____|_ _|_ __ __ _ ___| |_(_)_ _____ * | '_ \| __| '_ \ / _ \ / __| __| \ \ / / _ \| || '_ \ / _` |/ __| __| \ \ / / _ \ * | |_) | |_| | | |/ ___ \ (__| |_| |\ V / __/| || | | | (_| | (__| |_| |\ V / __/ * |_.__/ \__|_| |_/_/ \_\___|\__|_| \_/ \___|___|_| |_|\__,_|\___|\__|_| \_/ \___| * */ final JButton btnActiveInactive = new JButton( user.isActive() ? SYSConst.icon22stop : SYSConst.icon22playerPlay); btnActiveInactive .setPressedIcon(user.isActive() ? SYSConst.icon22stopPressed : SYSConst.icon22playerPlayPressed); btnActiveInactive.setAlignmentX(Component.RIGHT_ALIGNMENT); btnActiveInactive.setContentAreaFilled(false); btnActiveInactive.setBorder(null); btnActiveInactive.setToolTipText(SYSTools .xx(internalClassID + (user.isActive() ? ".btnActiveInactive.stop" : ".btnActiveInactive.play"))); btnActiveInactive.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); Users myUser = em.merge(usermap.get(user.getUID())); em.lock(myUser, LockModeType.OPTIMISTIC); myUser.setStatus(myUser.isActive() ? UsersTools.STATUS_INACTIVE : UsersTools.STATUS_ACTIVE); em.getTransaction().commit(); lstUsers.remove(user); lstUsers.add(myUser); usermap.put(myUser.getUID(), myUser); Collections.sort(lstUsers); CollapsiblePane cp = createCP4(myUser); boolean wasCollapsed = cpMap.get(key).isCollapsed(); cpMap.put(key, cp); cp.setCollapsed(myUser.isActive() ? wasCollapsed : true); buildPanel(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } }); cptitle.getRight().add(btnActiveInactive); /*** * _ _ _ * ___ __| (_) |_ * / _ \/ _` | | __| * | __/ (_| | | |_ * \___|\__,_|_|\__| * */ final JButton btnEdit = new JButton(SYSConst.icon22edit3); btnEdit.setPressedIcon(SYSConst.icon22edit3Pressed); btnEdit.setAlignmentX(Component.RIGHT_ALIGNMENT); btnEdit.setContentAreaFilled(false); btnEdit.setBorder(null); btnEdit.setToolTipText(SYSTools.xx("opde.users.btnEdit")); btnEdit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgUser(user, new Closure() { @Override public void execute(Object o) { if (o != null) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); Users myUser = em.merge((Users) o); em.lock(myUser, LockModeType.OPTIMISTIC); em.getTransaction().commit(); lstUsers.remove(user); lstUsers.add(myUser); usermap.put(myUser.getUID(), myUser); Collections.sort(lstUsers); CollapsiblePane cp = createCP4(myUser); boolean wasCollapsed = cpMap.get(key).isCollapsed(); cpMap.put(key, cp); cp.setCollapsed(myUser.isActive() ? wasCollapsed : true); buildPanel(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } } }); } }); cptitle.getRight().add(btnEdit); cp.setTitleLabelComponent(cptitle.getMain()); cp.setSlidingDirection(SwingConstants.SOUTH); /*** * ___ ___ _ _ _____ ___ _ _ _____ * / __/ _ \| \| |_ _| __| \| |_ _| * | (_| (_) | .` | | | | _|| .` | | | * \___\___/|_|\_| |_| |___|_|\_| |_| * */ cp.addCollapsiblePaneListener(new CollapsiblePaneAdapter() { @Override public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) { if (!contentMap.containsKey(key)) { contentMap.put(key, new PnlEditMemberships(user, lstGroups)); } cp.setContentPane(contentMap.get(key)); cp.setOpaque(false); } } ); cp.setBackground(UsersTools.getBG1(user)); cp.setCollapsible(user.isActive()); cp.setHorizontalAlignment(SwingConstants.LEADING); cp.setOpaque(false); return cp; }
From source file:op.users.PnlUser.java
private CollapsiblePane createCP4(final Groups group) { final String key = group.getGID() + ".xgroups"; if (!cpMap.containsKey(key)) { cpMap.put(key, new CollapsiblePane()); cpMap.get(key).setSlidingDirection(SwingConstants.SOUTH); cpMap.get(key).setBackground(bg); cpMap.get(key).setForeground(fg); cpMap.get(key).addCollapsiblePaneListener(new CollapsiblePaneAdapter() { @Override// w w w .j a v a 2s. c o m public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) { if (!contentMap.containsKey(key)) { contentMap.put(key, createContentPanel4(group)); } cpMap.get(key).setContentPane(contentMap.get(key)); } }); cpMap.get(key).setHorizontalAlignment(SwingConstants.LEADING); cpMap.get(key).setOpaque(false); try { cpMap.get(key).setCollapsed(true); } catch (PropertyVetoException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } final CollapsiblePane cp = cpMap.get(key); DefaultCPTitle cpTitle = new DefaultCPTitle("<html><font size=+1>" + group.getGID().toUpperCase() + (group.isQualified() ? ", " + SYSTools.xx("opde.users.qualifiedGroup") : "") + "</font></html>", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { cp.setCollapsed(!cp.isCollapsed()); } catch (PropertyVetoException pve) { // BAH! } } }); /*** * _ _ _ * __| | ___| | ___| |_ ___ __ _ _ __ ___ _ _ _ __ * / _` |/ _ \ |/ _ \ __/ _ \ / _` | '__/ _ \| | | | '_ \ * | (_| | __/ | __/ || __/ | (_| | | | (_) | |_| | |_) | * \__,_|\___|_|\___|\__\___| \__, |_| \___/ \__,_| .__/ * |___/ |_| */ final JButton btnDeleteGroup = new JButton(SYSConst.icon22delete); btnDeleteGroup.setPressedIcon(SYSConst.icon22deletePressed); btnDeleteGroup.setAlignmentX(Component.RIGHT_ALIGNMENT); btnDeleteGroup.setContentAreaFilled(false); btnDeleteGroup.setBorder(null); btnDeleteGroup.setToolTipText(SYSTools.xx("opde.users.btnDeleteGroup")); btnDeleteGroup.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgYesNo(SYSTools.xx("misc.questions.delete1") + "<br/><i>" + group.getGID() + "</i><br/>" + SYSTools.xx("misc.questions.delete2"), SYSConst.icon48delete, new Closure() { @Override public void execute(Object o) { if (o.equals(JOptionPane.YES_OPTION)) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); Groups myGroup = em.merge(group); em.remove(myGroup); em.getTransaction().commit(); lstGroups.remove(group); cpMap.remove(key); buildPanel(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } } }); } }); btnDeleteGroup.setEnabled(!group.isSystem()); cpTitle.getRight().add(btnDeleteGroup); cp.setTitleLabelComponent(cpTitle.getMain()); if (!cp.isCollapsed()) { if (!contentMap.containsKey(key)) { contentMap.put(key, createContentPanel4(group)); } cp.setContentPane(contentMap.get(key)); } return cp; }
From source file:org.apache.jmeter.config.gui.ArgumentsPanel.java
/** * Create a panel containing the add and delete buttons. * * @return a GUI panel containing the buttons *//*from w w w . ja v a 2s. co m*/ private JPanel makeButtonPanel() { showDetail = new JButton(JMeterUtils.getResString("detail")); // $NON-NLS-1$ showDetail.setActionCommand(DETAIL); showDetail.setEnabled(true); add = new JButton(JMeterUtils.getResString("add")); // $NON-NLS-1$ add.setActionCommand(ADD); add.setEnabled(true); // A button for adding new arguments to the table from the clipboard JButton addFromClipboard = new JButton(JMeterUtils.getResString("add_from_clipboard")); // $NON-NLS-1$ addFromClipboard.setActionCommand(ADD_FROM_CLIPBOARD); addFromClipboard.setEnabled(true); delete = new JButton(JMeterUtils.getResString("delete")); // $NON-NLS-1$ delete.setActionCommand(DELETE); if (enableUpDown) { up = new JButton(JMeterUtils.getResString("up")); // $NON-NLS-1$ up.setActionCommand(UP); down = new JButton(JMeterUtils.getResString("down")); // $NON-NLS-1$ down.setActionCommand(DOWN); } checkButtonsStatus(); JPanel buttonPanel = new JPanel(); buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10)); if (this.background != null) { buttonPanel.setBackground(this.background); } showDetail.addActionListener(this); add.addActionListener(this); addFromClipboard.addActionListener(this); delete.addActionListener(this); buttonPanel.add(showDetail); buttonPanel.add(add); buttonPanel.add(addFromClipboard); buttonPanel.add(delete); if (enableUpDown) { up.addActionListener(this); down.addActionListener(this); buttonPanel.add(up); buttonPanel.add(down); } return buttonPanel; }
From source file:org.apache.jmeter.protocol.http.gui.CookiePanel.java
private JButton createButton(String resName, char mnemonic, String command, boolean enabled) { JButton button = new JButton(JMeterUtils.getResString(resName)); button.setMnemonic(mnemonic);/*from ww w . j av a 2s. co m*/ button.setActionCommand(command); button.setEnabled(enabled); button.addActionListener(this); return button; }
From source file:org.datavyu.views.DataControllerV.java
/** * Initialize the view for Macs./*from ww w. j av a2 s .c om*/ */ private void initComponentsMac() { gridButtonPanel = new javax.swing.JPanel(); goBackTextField = new javax.swing.JTextField(); findTextField = new javax.swing.JTextField(); addDataButton = new javax.swing.JButton(); timestampLabel = new javax.swing.JLabel(); lblSpeed = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); findOffsetField = new javax.swing.JTextField(); showTracksButton = new javax.swing.JButton(); tracksPanel = new javax.swing.JPanel(new MigLayout("fill")); final int fontSize = 11; org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application .getInstance(org.datavyu.Datavyu.class).getContext().getResourceMap(DataControllerV.class); setTitle(resourceMap.getString("title")); addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(final java.awt.event.WindowEvent evt) { formWindowClosing(evt); } }); gridButtonPanel.setBackground(Color.WHITE); gridButtonPanel.setLayout(new MigLayout("wrap 5, ins 15 2 15 2")); // Add data button addDataButton.setText(resourceMap.getString("addDataButton.text")); addDataButton.setFont(new Font("Tahoma", Font.PLAIN, fontSize)); addDataButton.setFocusPainted(false); addDataButton.setName("addDataButton"); addDataButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent evt) { openVideoButtonActionPerformed(evt); } }); gridButtonPanel.add(addDataButton, "span 2, w 90!, h 25!"); // Timestamp panel JPanel timestampPanel = new JPanel(new MigLayout("", "push[][][]0![]push")); timestampPanel.setOpaque(false); // Timestamp label timestampLabel.setFont(new Font("Tahoma", Font.BOLD, fontSize)); timestampLabel.setHorizontalAlignment(SwingConstants.CENTER); timestampLabel.setText("00:00:00:000"); timestampLabel.setHorizontalTextPosition(SwingConstants.CENTER); timestampLabel.setName("timestampLabel"); timestampPanel.add(timestampLabel); jLabel1.setText("@"); timestampPanel.add(jLabel1); lblSpeed.setFont(new Font("Tahoma", Font.BOLD, fontSize)); lblSpeed.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 2)); lblSpeed.setName("lblSpeed"); lblSpeed.setText("0"); timestampPanel.add(lblSpeed); jLabel2.setFont(new Font("Tahoma", Font.BOLD, fontSize)); jLabel2.setText("x"); timestampPanel.add(jLabel2); // Set cell onset button javax.swing.ActionMap actionMap = org.jdesktop.application.Application .getInstance(org.datavyu.Datavyu.class).getContext().getActionMap(DataControllerV.class, this); gridButtonPanel.add(timestampPanel, "span 3, pushx, growx"); // placeholder setCellOnsetButton = buildButton(resourceMap, actionMap, "setCellOnset", null); gridButtonPanel.add(setCellOnsetButton, "w 45!, h 45!"); // Sync button pointCellButton = buildButton(resourceMap, actionMap, "pointCell", null); gridButtonPanel.add(pointCellButton, "w 45!, h 45!"); // Set cell onset button. osxsetCellOffsetButton = buildButton(resourceMap, actionMap, "setCellOffset", "osx"); gridButtonPanel.add(osxsetCellOffsetButton, "w 45!, h 45!"); // Instant cell button. JButton placeholder2 = new JButton(); placeholder2.setEnabled(false); placeholder2.setFocusPainted(false); gridButtonPanel.add(placeholder2, "w 45!, h 45!"); // Sync video button JButton placeholder3 = new JButton(); placeholder3.setEnabled(false); placeholder3.setFocusPainted(false); gridButtonPanel.add(placeholder3, "w 80!, h 45!"); // Rewind video button rewindButton = buildButton(resourceMap, actionMap, "rewind", null); gridButtonPanel.add(rewindButton, "w 45!, h 45!"); // Play video button playButton = buildButton(resourceMap, actionMap, "play", null); playButton.setRequestFocusEnabled(false); gridButtonPanel.add(playButton, "w 45!, h 45!"); // Fast forward button forwardButton = buildButton(resourceMap, actionMap, "forward", null); gridButtonPanel.add(forwardButton, "w 45!, h 45!"); // Go back button goBackButton = buildButton(resourceMap, actionMap, "goBack", null); gridButtonPanel.add(goBackButton, "w 45!, h 45!"); // Go back text field goBackTextField.setHorizontalAlignment(SwingConstants.CENTER); goBackTextField.setText("00:00:05:000"); goBackTextField.setName("goBackTextField"); gridButtonPanel.add(goBackTextField, "w 80!, h 45!"); // Shuttle back button shuttleBackButton = buildButton(resourceMap, actionMap, "shuttleBack", null); gridButtonPanel.add(shuttleBackButton, "w 45!, h 45!"); // Stop button stopButton = buildButton(resourceMap, actionMap, "stop", null); gridButtonPanel.add(stopButton, "w 45!, h 45!"); // Shuttle forward button shuttleForwardButton = buildButton(resourceMap, actionMap, "shuttleForward", null); gridButtonPanel.add(shuttleForwardButton, "w 45!, h 45!"); // Find button findButton = buildButton(resourceMap, actionMap, "find", null); gridButtonPanel.add(findButton, "w 45!, h 45!"); // Find text field findTextField.setHorizontalAlignment(SwingConstants.CENTER); findTextField.setText("00:00:00:000"); findTextField.setName("findOnsetLabel"); gridButtonPanel.add(findTextField, "w 80!, h 45!"); // Jog back button jogBackButton = buildButton(resourceMap, actionMap, "jogBack", null); gridButtonPanel.add(jogBackButton, "w 45!, h 45!"); // Pause button pauseButton = buildButton(resourceMap, actionMap, "pause", null); gridButtonPanel.add(pauseButton, "w 45!, h 45!"); // Jog forward button jogForwardButton = buildButton(resourceMap, actionMap, "jogForward", null); gridButtonPanel.add(jogForwardButton, "w 45!, h 45!"); // Create new cell button createNewCell = buildButton(resourceMap, actionMap, "createNewCell", null); createNewCell.setAlignmentY(0.0F); createNewCell.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); gridButtonPanel.add(createNewCell, "span 1 2, w 45!, h 92!"); // Find offset field findOffsetField.setHorizontalAlignment(SwingConstants.CENTER); findOffsetField.setText("00:00:00:000"); findOffsetField.setToolTipText(resourceMap.getString("findOffsetField.toolTipText")); findOffsetField.setEnabled(false); findOffsetField.setName("findOffsetLabel"); gridButtonPanel.add(findOffsetField, "w 80!, h 45!"); // Create new cell setting offset button createNewCellSettingOffset = buildButton(resourceMap, actionMap, "createNewCellAndSetOnset", null); gridButtonPanel.add(createNewCellSettingOffset, "span 2, w 92!, h 45!"); // Set cell offset button setCellOffsetButton = buildButton(resourceMap, actionMap, "setCellOffset", null); gridButtonPanel.add(setCellOffsetButton, "w 45!, h 45!"); // Show tracks button showTracksButton.setIcon(resourceMap.getIcon("showTracksButton.hide.icon")); showTracksButton.setName("showTracksButton"); showTracksButton.getAccessibleContext().setAccessibleName("Show Tracks"); showTracksButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent evt) { showTracksButtonActionPerformed(evt); } }); gridButtonPanel.add(showTracksButton, "w 80!, h 45!"); getContentPane().setLayout(new MigLayout("hidemode 3, fillx", "[growprio 0]0[]", "")); getContentPane().add(gridButtonPanel, ""); getContentPane().setBackground(Color.WHITE); tracksPanel.setBackground(Color.WHITE); tracksPanel.setVisible(false); getContentPane().add(tracksPanel, "growx"); pack(); }
From source file:org.datavyu.views.DataControllerV.java
/** * Initialize the view for OS other than Macs. */// w w w. j a v a 2 s. c om private void initComponents() { gridButtonPanel = new javax.swing.JPanel(); goBackTextField = new javax.swing.JTextField(); findTextField = new javax.swing.JTextField(); addDataButton = new javax.swing.JButton(); timestampLabel = new javax.swing.JLabel(); lblSpeed = new javax.swing.JLabel(); createNewCell = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); findOffsetField = new javax.swing.JTextField(); showTracksButton = new javax.swing.JButton(); tracksPanel = new javax.swing.JPanel(new MigLayout("fill")); final int fontSize = 11; org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application .getInstance(org.datavyu.Datavyu.class).getContext().getResourceMap(DataControllerV.class); setTitle(resourceMap.getString("title")); addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(final java.awt.event.WindowEvent evt) { formWindowClosing(evt); } }); gridButtonPanel.setBackground(Color.WHITE); gridButtonPanel.setLayout(new MigLayout("wrap 5")); // Add data button addDataButton.setText(resourceMap.getString("addDataButton.text")); addDataButton.setFont(new Font("Tahoma", Font.PLAIN, fontSize)); addDataButton.setFocusPainted(false); addDataButton.setName("addDataButton"); addDataButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent evt) { openVideoButtonActionPerformed(evt); } }); gridButtonPanel.add(addDataButton, "span 2, w 90!, h 25!"); // Timestamp panel JPanel timestampPanel = new JPanel(new MigLayout("", "push[][][]0![]push")); timestampPanel.setOpaque(false); // Timestamp label timestampLabel.setFont(new Font("Tahoma", Font.BOLD, fontSize)); timestampLabel.setHorizontalAlignment(SwingConstants.CENTER); timestampLabel.setText("00:00:00:000"); timestampLabel.setHorizontalTextPosition(SwingConstants.CENTER); timestampLabel.setName("timestampLabel"); timestampPanel.add(timestampLabel); jLabel1.setText("@"); timestampPanel.add(jLabel1); lblSpeed.setFont(new Font("Tahoma", Font.BOLD, fontSize)); lblSpeed.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 2)); lblSpeed.setName("lblSpeed"); lblSpeed.setText("0"); timestampPanel.add(lblSpeed); jLabel2.setFont(new Font("Tahoma", Font.BOLD, fontSize)); jLabel2.setText("x"); timestampPanel.add(jLabel2); javax.swing.ActionMap actionMap = org.jdesktop.application.Application .getInstance(org.datavyu.Datavyu.class).getContext().getActionMap(DataControllerV.class, this); gridButtonPanel.add(timestampPanel, "span 3, pushx, growx"); JButton placeholder = new JButton(); placeholder.setEnabled(false); placeholder.setFocusPainted(false); gridButtonPanel.add(placeholder, "w 45!, h 45!"); // Set cell onset button setCellOnsetButton = buildButton(resourceMap, actionMap, "setCellOnset", "win"); gridButtonPanel.add(setCellOnsetButton, "w 45!, h 45!"); // Set new cell offset button pointCellButton = buildButton(resourceMap, actionMap, "pointCell", "win"); gridButtonPanel.add(pointCellButton, "w 45!, h 45!"); // Go back button goBackButton = buildButton(resourceMap, actionMap, "goBack", null); gridButtonPanel.add(goBackButton, "w 45!, h 45!"); // Sync video button JButton placeholder2 = new JButton(); placeholder2.setEnabled(false); placeholder2.setFocusPainted(false); gridButtonPanel.add(placeholder2, "w 80!, h 45!"); // Rewind video button rewindButton = buildButton(resourceMap, actionMap, "rewind", null); gridButtonPanel.add(rewindButton, "w 45!, h 45!"); // Play video button playButton = buildButton(resourceMap, actionMap, "play", null); playButton.setRequestFocusEnabled(false); gridButtonPanel.add(playButton, "w 45!, h 45!"); // Fast forward button forwardButton = buildButton(resourceMap, actionMap, "forward", null); gridButtonPanel.add(forwardButton, "w 45!, h 45!"); // Find button findButton = buildButton(resourceMap, actionMap, "find", "win"); gridButtonPanel.add(findButton, "span 1 2, w 45!, h 95!"); // Go back text field goBackTextField.setHorizontalAlignment(SwingConstants.CENTER); goBackTextField.setText("00:00:05:000"); goBackTextField.setName("goBackTextField"); gridButtonPanel.add(goBackTextField, "w 80!, h 45!"); // Shuttle back button shuttleBackButton = buildButton(resourceMap, actionMap, "shuttleBack", null); gridButtonPanel.add(shuttleBackButton, "w 45!, h 45!"); // Stop button stopButton = buildButton(resourceMap, actionMap, "stop", null); gridButtonPanel.add(stopButton, "w 45!, h 45!"); // Shuttle forward button shuttleForwardButton = buildButton(resourceMap, actionMap, "shuttleForward", null); gridButtonPanel.add(shuttleForwardButton, "w 45!, h 45!"); // Find text field findTextField.setHorizontalAlignment(SwingConstants.CENTER); findTextField.setText("00:00:00:000"); findTextField.setName("findOnsetLabel"); gridButtonPanel.add(findTextField, "w 80!, h 45!"); // Jog back button jogBackButton = buildButton(resourceMap, actionMap, "jogBack", null); gridButtonPanel.add(jogBackButton, "w 45!, h 45!"); // Pause button pauseButton = buildButton(resourceMap, actionMap, "pause", null); gridButtonPanel.add(pauseButton, "w 45!, h 45!"); // Jog forward button jogForwardButton = buildButton(resourceMap, actionMap, "jogForward", null); gridButtonPanel.add(jogForwardButton, "w 45!, h 45!"); // Create new cell button createNewCell = buildButton(resourceMap, actionMap, "createNewCell", null); createNewCell.setAlignmentY(0.0F); createNewCell.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); gridButtonPanel.add(createNewCell, "span 1 2, w 45!, h 95!"); // Find offset field findOffsetField.setHorizontalAlignment(SwingConstants.CENTER); findOffsetField.setText("00:00:00:000"); findOffsetField.setToolTipText(resourceMap.getString("findOffsetField.toolTipText")); findOffsetField.setEnabled(false); findOffsetField.setName("findOffsetLabel"); gridButtonPanel.add(findOffsetField, "w 80!, h 45!"); // Create new cell setting offset button createNewCellSettingOffset = buildButton(resourceMap, actionMap, "createNewCellAndSetOnset", null); gridButtonPanel.add(createNewCellSettingOffset, "span 2, w 95!, h 45!"); // Set cell offset button setCellOffsetButton = buildButton(resourceMap, actionMap, "setCellOffset", null); gridButtonPanel.add(setCellOffsetButton, "w 45!, h 45!"); // Show tracks button showTracksButton.setIcon(resourceMap.getIcon("showTracksButton.hide.icon")); showTracksButton.setName("showTracksButton"); showTracksButton.getAccessibleContext().setAccessibleName("Show Tracks"); showTracksButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent evt) { showTracksButtonActionPerformed(evt); } }); gridButtonPanel.add(showTracksButton, "w 80!, h 45!"); getContentPane().setLayout(new MigLayout("ins 0, hidemode 3, fillx", "[growprio 0]0[]", "")); getContentPane().add(gridButtonPanel, ""); getContentPane().setBackground(Color.WHITE); tracksPanel.setBackground(Color.WHITE); tracksPanel.setVisible(false); getContentPane().add(tracksPanel, "growx"); pack(); }