List of usage examples for javax.swing BoxLayout LINE_AXIS
int LINE_AXIS
To view the source code for javax.swing BoxLayout LINE_AXIS.
Click Source Link
From source file:net.technicpack.launcher.ui.LauncherFrame.java
private void initComponents() { BorderLayout layout = new BorderLayout(); setLayout(layout);// w w w . j a v a2 s . c o m ///////////////////////////////////////////////////////////// //HEADER ///////////////////////////////////////////////////////////// JPanel header = new JPanel(); header.setLayout(new BoxLayout(header, BoxLayout.LINE_AXIS)); header.setBackground(COLOR_BLUE); header.setForeground(COLOR_WHITE_TEXT); header.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 10)); this.add(header, BorderLayout.PAGE_START); ImageIcon headerIcon = resources.getIcon("platform_icon_title.png"); JButton headerLabel = new JButton(headerIcon); headerLabel.setBorder(BorderFactory.createEmptyBorder(5, 8, 5, 0)); headerLabel.setContentAreaFilled(false); headerLabel.setFocusPainted(false); headerLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); headerLabel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { DesktopUtils.browseUrl("http://beta.technicpack.net/"); } }); header.add(headerLabel); header.add(Box.createRigidArea(new Dimension(6, 0))); ActionListener tabListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectTab(e.getActionCommand()); } }; discoverTab = new HeaderTab(resources.getString("launcher.title.discover"), resources); header.add(discoverTab); discoverTab.setActionCommand(TAB_DISCOVER); discoverTab.addActionListener(tabListener); modpacksTab = new HeaderTab(resources.getString("launcher.title.modpacks"), resources); modpacksTab.setIsActive(true); modpacksTab.setHorizontalTextPosition(SwingConstants.LEADING); modpacksTab.addActionListener(tabListener); modpacksTab.setActionCommand(TAB_MODPACKS); header.add(modpacksTab); newsTab = new HeaderTab(resources.getString("launcher.title.news"), resources); newsTab.setLayout(null); newsTab.addActionListener(tabListener); newsTab.setActionCommand(TAB_NEWS); header.add(newsTab); CountCircle newsCircle = new CountCircle(); newsCircle.setBackground(COLOR_RED); newsCircle.setForeground(COLOR_WHITE_TEXT); newsCircle.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS_BOLD, 14)); newsTab.add(newsCircle); newsCircle.setBounds(10, 17, 25, 25); header.add(Box.createHorizontalGlue()); JPanel rightHeaderPanel = new JPanel(); rightHeaderPanel.setOpaque(false); rightHeaderPanel.setLayout(new BoxLayout(rightHeaderPanel, BoxLayout.PAGE_AXIS)); rightHeaderPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); JPanel windowGadgetPanel = new JPanel(); windowGadgetPanel.setOpaque(false); windowGadgetPanel.setLayout(new BoxLayout(windowGadgetPanel, BoxLayout.LINE_AXIS)); windowGadgetPanel.setAlignmentX(RIGHT_ALIGNMENT); ImageIcon minimizeIcon = resources.getIcon("minimize.png"); JButton minimizeButton = new JButton(minimizeIcon); minimizeButton.setBorder(BorderFactory.createEmptyBorder()); minimizeButton.setContentAreaFilled(false); minimizeButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); minimizeButton.setFocusable(false); minimizeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { minimizeWindow(); } }); windowGadgetPanel.add(minimizeButton); ImageIcon closeIcon = resources.getIcon("close.png"); JButton closeButton = new JButton(closeIcon); closeButton.setBorder(BorderFactory.createEmptyBorder()); closeButton.setContentAreaFilled(false); closeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { closeWindow(); } }); closeButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); closeButton.setFocusable(false); windowGadgetPanel.add(closeButton); rightHeaderPanel.add(windowGadgetPanel); rightHeaderPanel.add(Box.createVerticalGlue()); JButton launcherOptionsLabel = new JButton(resources.getString("launcher.title.options")); launcherOptionsLabel.setIcon(resources.getIcon("options_cog.png")); launcherOptionsLabel.setFont(resources.getFont(ResourceLoader.FONT_RALEWAY, 14)); launcherOptionsLabel.setForeground(COLOR_WHITE_TEXT); launcherOptionsLabel.setHorizontalAlignment(SwingConstants.RIGHT); launcherOptionsLabel.setHorizontalTextPosition(SwingConstants.LEADING); launcherOptionsLabel.setAlignmentX(RIGHT_ALIGNMENT); launcherOptionsLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); launcherOptionsLabel.setBorder(BorderFactory.createEmptyBorder()); launcherOptionsLabel.setContentAreaFilled(false); launcherOptionsLabel.setFocusPainted(false); launcherOptionsLabel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openLauncherOptions(); } }); rightHeaderPanel.add(launcherOptionsLabel); header.add(rightHeaderPanel); ///////////////////////////////////////////////////////////// // CENTRAL AREA ///////////////////////////////////////////////////////////// centralPanel = new TintablePanel(); centralPanel.setBackground(COLOR_CHARCOAL); centralPanel.setForeground(COLOR_WHITE_TEXT); centralPanel.setTintColor(COLOR_CENTRAL_BACK); this.add(centralPanel, BorderLayout.CENTER); centralPanel.setLayout(new BorderLayout()); modpackPanel = new ModpackInfoPanel(resources, iconRepo, logoRepo, backgroundRepo, avatarRepo, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openModpackOptions((ModpackModel) e.getSource()); } }, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { refreshModpackOptions((ModpackModel) e.getSource()); } }); modpackSelector.setInfoPanel(modpackPanel); playButton = modpackPanel.getPlayButton(); playButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof ModpackModel) { setupPlayButtonText((ModpackModel) e.getSource(), userModel.getCurrentUser()); } else if (installer.isCurrentlyRunning()) { installer.cancel(); setupPlayButtonText(modpackSelector.getSelectedPack(), userModel.getCurrentUser()); } else { launchModpack(); } } }); modpackPanel.getDeleteButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(LauncherFrame.this, resources.getString("modpackoptions.delete.confirmtext"), resources.getString("modpackoptions.delete.confirmtitle"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { modpackSelector.getSelectedPack().delete(); modpackSelector.forceRefresh(); } } }); infoSwap = new JPanel(); infoLayout = new CardLayout(); infoSwap.setLayout(infoLayout); infoSwap.setOpaque(false); newsInfoPanel = new NewsInfoPanel(resources, avatarRepo); infoSwap.add(discoverInfoPanel, "discover"); JPanel newsHost = new JPanel(); infoSwap.add(newsHost, "news"); JPanel modpackHost = new JPanel(); infoSwap.add(modpackHost, "modpacks"); centralPanel.add(infoSwap, BorderLayout.CENTER); newsSelector = new NewsSelector(resources, newsInfoPanel, platformApi, avatarRepo, newsCircle, settings); newsHost.setLayout(new BorderLayout()); newsHost.add(newsInfoPanel, BorderLayout.CENTER); newsHost.add(newsSelector, BorderLayout.WEST); modpackHost.setLayout(new BorderLayout()); modpackHost.add(modpackPanel, BorderLayout.CENTER); modpackHost.add(modpackSelector, BorderLayout.WEST); footer = new TintablePanel(); footer.setTintColor(COLOR_CENTRAL_BACK); footer.setBackground(COLOR_FOOTER); footer.setLayout(new BoxLayout(footer, BoxLayout.LINE_AXIS)); footer.setForeground(COLOR_WHITE_TEXT); footer.setBorder(BorderFactory.createEmptyBorder(3, 6, 3, 12)); userWidget = new UserWidget(resources, skinRepository); userWidget.setMaximumSize(userWidget.getPreferredSize()); footer.add(userWidget); JLabel dashText = new JLabel("| "); dashText.setForeground(LauncherFrame.COLOR_WHITE_TEXT); dashText.setFont(resources.getFont(ResourceLoader.FONT_RALEWAY, 15)); footer.add(dashText); JButton logout = new JButton(resources.getString("launcher.user.logout")); logout.setBorder(BorderFactory.createEmptyBorder()); logout.setContentAreaFilled(false); logout.setFocusable(false); logout.setForeground(LauncherFrame.COLOR_WHITE_TEXT); logout.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); logout.setFont(resources.getFont(ResourceLoader.FONT_RALEWAY, 15)); logout.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { logout(); } }); footer.add(logout); installProgress = new ProgressBar(); installProgress.setForeground(Color.white); installProgress.setBackground(LauncherFrame.COLOR_GREEN); installProgress.setBorder(BorderFactory.createEmptyBorder(5, 45, 4, 45)); installProgress.setIcon(resources.getIcon("download_icon.png")); installProgress.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 12)); installProgress.setVisible(false); footer.add(installProgress); installProgressPlaceholder = Box.createHorizontalGlue(); footer.add(installProgressPlaceholder); JLabel buildCtrl = new JLabel(resources.getString("launcher.build.text", resources.getLauncherBuild(), resources.getString("launcher.build." + settings.getBuildStream()))); buildCtrl.setForeground(COLOR_WHITE_TEXT); buildCtrl.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 14)); buildCtrl.setHorizontalTextPosition(SwingConstants.RIGHT); buildCtrl.setHorizontalAlignment(SwingConstants.RIGHT); footer.add(buildCtrl); this.add(footer, BorderLayout.PAGE_END); }
From source file:ome.formats.importer.gui.ErrorTable.java
/** * Constructor for class//from w w w .j a v a2 s . c om */ public ErrorTable() { // set to layout that will maximize on resizing setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); this.setOpaque(false); // Main Panel containing all elements // Set up the main panel layout double mainTable[][] = { { 5, 200, 140, TableLayout.FILL, 140, 5 }, // columns { 5, TableLayout.PREFERRED, TableLayout.FILL, 5, 29, 5 } }; // rows mainPanel = GuiCommonElements.addMainPanel(this, mainTable, 0, 0, 0, 0, debug); String message = "All errors accumulated during your import are displayed here, " + "and will be uploaded to us if check-marked. You can send us feedback on " + "these problems by clicking the 'Send Feedback' button."; JTextPane instructions = GuiCommonElements.addTextPane(mainPanel, message, "1,1,4,0", debug); instructions.setMargin(new Insets(10, 10, 10, 10)); TableColumnModel cModel = eTable.getColumnModel(); // *** remove last 3 rows from display *** TableColumn hiddenColumn = cModel.getColumn(6); cModel.removeColumn(hiddenColumn); hiddenColumn = cModel.getColumn(5); cModel.removeColumn(hiddenColumn); hiddenColumn = cModel.getColumn(4); cModel.removeColumn(hiddenColumn); MyTableHeaderRenderer myHeader = new MyTableHeaderRenderer(); //LeftTableHeaderRenderer leftHeader = new LeftTableHeaderRenderer(); // Create a custom header for the table cModel.getColumn(0).setHeaderRenderer(myHeader); cModel.getColumn(1).setHeaderRenderer(myHeader); cModel.getColumn(2).setHeaderRenderer(myHeader); cModel.getColumn(3).setHeaderRenderer(myHeader); cbe = new CheckboxCellEditor(new JCheckBox()); cbe.checkbox.addMouseListener(this); cbr = new CheckboxRenderer(); cModel.getColumn(0).setCellEditor(cbe); cModel.getColumn(0).setCellRenderer(cbr); cModel.getColumn(1).setCellRenderer(new LeftDotRenderer()); cModel.getColumn(2).setCellRenderer(new TextLeftRenderer()); cModel.getColumn(3).setCellRenderer(new StatusRenderer()); // Set the width of the status column TableColumn statusColumn = eTable.getColumnModel().getColumn(3); statusColumn.setPreferredWidth(statusWidth); statusColumn.setMaxWidth(statusWidth); statusColumn.setMinWidth(statusWidth); // Set the width of the error column TableColumn dateColumn = eTable.getColumnModel().getColumn(2); dateColumn.setPreferredWidth(errorWidth); dateColumn.setMaxWidth(errorWidth); dateColumn.setMinWidth(errorWidth); // Set the width of the upload column TableColumn uploadColumn = eTable.getColumnModel().getColumn(0); uploadColumn.setPreferredWidth(uploadWidth); uploadColumn.setMaxWidth(uploadWidth); uploadColumn.setMinWidth(uploadWidth); eTable.setRowSelectionAllowed(false); // Add the table to the scollpane JScrollPane scrollPane = new JScrollPane(eTable); mainPanel.add(scrollPane, "1,2,4,1"); double progressTable[][] = { { 200 }, // columns { 12, 5, 12 } }; // rows progressPanel = GuiCommonElements.addPlanePanel(mainPanel, progressTable, debug); runThread = new Thread() { public void run() { try { bytesProgressBar = new JProgressBar(); progressPanel.add(bytesProgressBar, "0,0"); filesProgressBar = new JProgressBar(0, 20); progressPanel.add(filesProgressBar, "0,2"); } catch (Throwable error) { } } }; runThread.start(); mainPanel.add(progressPanel, "1,4"); progressPanel.setVisible(false); cancelBtn = GuiCommonElements.addButton(mainPanel, "Cancel", 'c', "Cancel sending", "2,4,L,C", debug); cancelBtn.addActionListener(this); cancelBtn.setVisible(false); clearDoneBtn = GuiCommonElements.addButton(mainPanel, "Clear Done", 'd', "Clear done", "3,4,R,C", debug); clearDoneBtn.addActionListener(this); clearDoneBtn.setOpaque(false); clearDoneBtn.setEnabled(false); //clearDoneBtn.setVisible(false); // Disabled (See #5250) sendBtn = GuiCommonElements.addButton(mainPanel, "Send Feedback", 's', "Send your errors to the OMERO team", "4,4,R,C", debug); sendBtn.setOpaque(false); sendBtn.addActionListener(this); sendBtn.setEnabled(false); this.add(mainPanel); }
From source file:ome.formats.importer.gui.FileQueueTable.java
/** * Set up and display the file queue table */// ww w.j a va 2 s . com FileQueueTable() { // ----- Variables ----- // Debug Borders Boolean debugBorders = false; // Size of the add/remove/refresh buttons (which are square). int buttonSize = 40; // Add graphic for the refresh button //String refreshIcon = "gfx/recycled.png"; // Add graphic for add button String addIcon = "gfx/add.png"; // Remove graphics for remove button String removeIcon = "gfx/remove.png"; // Width of the status columns int statusWidth = 100; // ----- GUI Layout Elements ----- // Start layout here setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); setBorder(BorderFactory.createEmptyBorder(6, 5, 9, 8)); JPanel buttonPanel = new JPanel(); if (debugBorders == true) buttonPanel.setBorder(BorderFactory.createLineBorder(Color.red, 1)); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.PAGE_AXIS)); // refreshBtn = addButton("+", refreshIcon, null); // refreshBtn.setMaximumSize(new Dimension(buttonSize, buttonSize)); // refreshBtn.setPreferredSize(new Dimension(buttonSize, buttonSize)); // refreshBtn.setMinimumSize(new Dimension(buttonSize, buttonSize)); // refreshBtn.setSize(new Dimension(buttonSize, buttonSize)); // refreshBtn.setActionCommand(Actions.REFRESH); // refreshBtn.addActionListener(this); addBtn = GuiCommonElements.addBasicButton(null, addIcon, null); addBtn.setMaximumSize(new Dimension(buttonSize, buttonSize)); addBtn.setPreferredSize(new Dimension(buttonSize, buttonSize)); addBtn.setMinimumSize(new Dimension(buttonSize, buttonSize)); addBtn.setSize(new Dimension(buttonSize, buttonSize)); addBtn.setActionCommand(FileQueueHandler.ADD); addBtn.addActionListener(this); addBtn.setToolTipText("Add files to the import queue."); removeBtn = GuiCommonElements.addBasicButton(null, removeIcon, null); removeBtn.setMaximumSize(new Dimension(buttonSize, buttonSize)); removeBtn.setPreferredSize(new Dimension(buttonSize, buttonSize)); removeBtn.setMinimumSize(new Dimension(buttonSize, buttonSize)); removeBtn.setSize(new Dimension(buttonSize, buttonSize)); removeBtn.setActionCommand(FileQueueHandler.REMOVE); removeBtn.addActionListener(this); removeBtn.setToolTipText("Remove files from the import queue."); buttonPanel.add(Box.createRigidArea(new Dimension(0, 60))); //buttonPanel.add(refreshBtn); buttonPanel.add(Box.createVerticalGlue()); buttonPanel.add(addBtn); buttonPanel.add(Box.createRigidArea(new Dimension(0, 5))); buttonPanel.add(removeBtn); buttonPanel.add(Box.createVerticalGlue()); buttonPanel.add(Box.createRigidArea(new Dimension(0, 60))); add(buttonPanel); add(Box.createRigidArea(new Dimension(5, 0))); JPanel queuePanel = new JPanel(); if (debugBorders == true) queuePanel.setBorder(BorderFactory.createLineBorder(Color.red, 1)); queuePanel.setLayout(new BoxLayout(queuePanel, BoxLayout.PAGE_AXIS)); //queuePanel.add(Box.createRigidArea(new Dimension(0,10))); JPanel labelPanel = new JPanel(); labelPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.LINE_AXIS)); JLabel label = new JLabel("Import Queue:"); labelPanel.add(label); labelPanel.add(Box.createHorizontalGlue()); groupBtn = GuiCommonElements.addBasicButton("Group: ", null, "Current Group"); groupBtn.setToolTipText("The user group you are logged into."); //groupBtn.setEnabled(false); labelPanel.add(groupBtn); queuePanel.add(labelPanel); queuePanel.add(Box.createRigidArea(new Dimension(0, 5))); TableColumnModel cModel = getQueue().getColumnModel(); headerCellRenderer = new MyTableHeaderRenderer(); fileCellRenderer = new LeftDotRenderer(); dpCellRenderer = new CenterTextRenderer(); statusCellRenderer = new CenterTextRenderer(); // Create a custom header for the table cModel.getColumn(0).setHeaderRenderer(headerCellRenderer); cModel.getColumn(1).setHeaderRenderer(headerCellRenderer); cModel.getColumn(2).setHeaderRenderer(headerCellRenderer); cModel.getColumn(0).setCellRenderer(fileCellRenderer); cModel.getColumn(1).setCellRenderer(dpCellRenderer); cModel.getColumn(2).setCellRenderer(statusCellRenderer); // Set the width of the status column TableColumn statusColumn = getQueue().getColumnModel().getColumn(2); statusColumn.setPreferredWidth(statusWidth); statusColumn.setMaxWidth(statusWidth); statusColumn.setMinWidth(statusWidth); SelectionListener listener = new SelectionListener(getQueue()); getQueue().getSelectionModel().addListSelectionListener(listener); //queue.getColumnModel().getSelectionModel() // .addListSelectionListener(listener); // Hide 3rd to 6th columns TableColumnModel tcm = getQueue().getColumnModel(); TableColumn projectColumn = tcm.getColumn(6); tcm.removeColumn(projectColumn); TableColumn userPixelColumn = tcm.getColumn(6); tcm.removeColumn(userPixelColumn); TableColumn userSpecifiedNameColumn = tcm.getColumn(6); tcm.removeColumn(userSpecifiedNameColumn); TableColumn datasetColumn = tcm.getColumn(3); tcm.removeColumn(datasetColumn); TableColumn pathColumn = tcm.getColumn(3); tcm.removeColumn(pathColumn); TableColumn archiveColumn = tcm.getColumn(3); tcm.removeColumn(archiveColumn); // Add the table to the scollpane JScrollPane scrollPane = new JScrollPane(getQueue()); queuePanel.add(scrollPane); JPanel importPanel = new JPanel(); importPanel.setLayout(new BoxLayout(importPanel, BoxLayout.LINE_AXIS)); clearDoneBtn = GuiCommonElements.addBasicButton("Clear Done", null, null); clearFailedBtn = GuiCommonElements.addBasicButton("Clear Failed", null, null); importBtn = GuiCommonElements.addBasicButton("Import", null, null); importPanel.add(Box.createHorizontalGlue()); importPanel.add(clearDoneBtn); clearDoneBtn.setEnabled(false); clearDoneBtn.setActionCommand(FileQueueHandler.CLEARDONE); clearDoneBtn.addActionListener(this); clearDoneBtn.setToolTipText("Clear all 'done' entries from the import queue."); importPanel.add(Box.createRigidArea(new Dimension(0, 5))); importPanel.add(clearFailedBtn); clearFailedBtn.setEnabled(false); clearFailedBtn.setActionCommand(FileQueueHandler.CLEARFAILED); clearFailedBtn.addActionListener(this); clearFailedBtn.setToolTipText("Clear all 'failed' entries from the import queue."); importPanel.add(Box.createRigidArea(new Dimension(0, 10))); importPanel.add(importBtn); importBtn.setEnabled(false); importBtn.setActionCommand(FileQueueHandler.IMPORT); importBtn.addActionListener(this); importBtn.setToolTipText("Begin importing files."); GuiCommonElements.enterPressesWhenFocused(importBtn); queuePanel.add(Box.createRigidArea(new Dimension(0, 5))); queuePanel.add(importPanel); add(queuePanel); }
From source file:ome.formats.importer.gui.HistoryTable.java
/** * Create history table/*from w w w. j ava 2 s. co m*/ * * @param viewer- GuiImporter parent */ HistoryTable(GuiImporter viewer) { this.viewer = viewer; try { historyTaskBar.addPropertyChangeListener(this); } catch (Exception ex) { log.error("Exception adding property change listener.", ex); } HistoryTableStore db = null; //HistoryDB db = null; try { db = new HistoryTableStore(); db.addObserver(this); } catch (Exception e) { db = null; log.error("Could not start history DB.", e); if (HistoryDB.alertOnce == false) { JOptionPane.showMessageDialog(null, "We were not able to connect to the history DB.\n" + "In the meantime, you will still be able to use \n" + "the importer, but the history feature will be disable.", "Warning", JOptionPane.ERROR_MESSAGE); HistoryDB.alertOnce = true; } } this.db = db; // set to layout that will maximize on resizing setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); this.setOpaque(false); // Main Panel containing all elements // Set up the main panel layout /* Disabled till #2308 fixed double mainTable[][] = {{170, 10, TableLayout.FILL, 80}, // columns { 5, 30, 35, 40, TableLayout.FILL, 35, 5}}; // rows */ double mainTable[][] = { { 170, 10, TableLayout.FILL, 90 }, // columns { 5, 30, 35, 70, TableLayout.FILL, 35, 5 } }; // rows mainPanel = GuiCommonElements.addMainPanel(this, mainTable, 0, 0, 0, 0, debug); // *****Side Panel**** double topSideTable[][] = { { TableLayout.FILL }, // columns { 20, 20, 20, 20, 35 } }; // rows topSidePanel = GuiCommonElements.addBorderedPanel(mainPanel, topSideTable, " Date Filter ", debug); String[] dateFormats = new String[1]; dateFormats[0] = DATE_FORMAT; fromDate = new JXDatePicker(); fromDate.setToolTipText("Pick a from date."); //fromDate.getEditor().setEditable(false); //fromDate.setEditable(false); fromDate.setFormats(dateFormats); toDate = new JXDatePicker(); toDate.setToolTipText("Pick a to date."); //toDate.getEditor().setEditable(false); //toDate.setEditable(false); toDate.setFormats(dateFormats); fromLabel = new JLabel("From (yy/mm/dd):"); topSidePanel.add(fromLabel, "0,0"); topSidePanel.add(fromDate, "0,1"); toLabel = new JLabel("To (yy/mm/dd):"); topSidePanel.add(toLabel, "0,2"); topSidePanel.add(toDate, "0,3"); double bottomSideTable[][] = { { TableLayout.FILL }, // columns { TableLayout.FILL } }; // rows historyTaskBar.addTaskPane("Today", historyTaskBar.getList(todayList)); historyTaskBar.addTaskPane("Yesterday", historyTaskBar.getList(yesterdayList)); historyTaskBar.addTaskPane("This Week", historyTaskBar.getList(thisWeekList)); historyTaskBar.addTaskPane("Last Week", historyTaskBar.getList(lastWeekList)); historyTaskBar.addTaskPane("This Month", historyTaskBar.getList(thisMonthList)); bottomSidePanel = GuiCommonElements.addBorderedPanel(mainPanel, bottomSideTable, " Quick Date ", debug); /* JPanel taskPanel = new JPanel( new BorderLayout() ); JScrollPane taskScrollPane = new JScrollPane(); taskScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); taskScrollPane.getViewport().add(historyTaskBar); taskPanel.add(taskScrollPane); bottomSidePanel.add(taskPanel, "f,f"); taskPanel.validate(); */ bottomSidePanel.add(historyTaskBar, "0,0"); clearBtn = GuiCommonElements.addIconButton(mainPanel, "Wipe History", clearIcon, 130, 32, (int) 'S', "Click here to clear your history log.", "0,5,C,C", debug); clearBtn.setActionCommand(HistoryHandler.CLEARHISTORY); clearBtn.addActionListener(this); // *****Top right most row containing search field and buttons***** /*// Disabled till #2308 fixed searchField = GuiCommonElements.addTextField(mainPanel, "Name Filter: ", "*.*", 'N', "Type in a file name to search for here.", "", TableLayout.PREFERRED, "2,1, 0, 0", debug); */ searchField = new JTextField("*.*"); searchField.setVisible(false); searchBtn = GuiCommonElements.addButton(topSidePanel, "Search", 'S', "Click here to search", "0,4,C,C", debug); searchBtn.setActionCommand(HistoryHandler.HISTORYSEARCH); searchBtn.addActionListener(this); // *****Middle right row containing the filter options***** // Since this panel has a different layout, use a new panel for it /* Disabled till #2308 fixed // Set up the filterTable layout double filterTable[][] = {{100, 80, 80, 80, 90, TableLayout.FILL}, // columns { 30 }}; // rows filterPanel = GuiCommonElements.addPlanePanel(mainPanel, filterTable, debug); filterLabel = GuiCommonElements.addTextPane(filterPanel, "Status Filters: ", "0,0,r,c", debug); doneCheckBox = GuiCommonElements.addCheckBox(filterPanel, "Done", "1,0,L,C", debug); failedCheckBox = GuiCommonElements.addCheckBox(filterPanel, "Failed", "2,0,L,C", debug); invalidCheckBox = GuiCommonElements.addCheckBox(filterPanel, "Invalid", "3,0,L,C", debug); pendingCheckBox = GuiCommonElements.addCheckBox(filterPanel, "Pending", "4,0,L,C", debug); // Default filters to 'on' doneCheckBox.setSelected(true); failedCheckBox.setSelected(true); invalidCheckBox.setSelected(true); pendingCheckBox.setSelected(true); doneCheckBox.addActionListener(this); failedCheckBox.addActionListener(this); invalidCheckBox.addActionListener(this); pendingCheckBox.addActionListener(this); filterPanel.setVisible(false); */ // *****Bottom right most row containing the history table***** TableColumnModel cModel = eTable.getColumnModel(); // *** remove last 4 rows from display *** TableColumn hiddenColumn = cModel.getColumn(6); cModel.removeColumn(hiddenColumn); hiddenColumn = cModel.getColumn(5); cModel.removeColumn(hiddenColumn); hiddenColumn = cModel.getColumn(4); cModel.removeColumn(hiddenColumn); MyTableHeaderRenderer myHeader = new MyTableHeaderRenderer(); // Create a custom header for the table cModel.getColumn(0).setHeaderRenderer(myHeader); cModel.getColumn(1).setHeaderRenderer(myHeader); cModel.getColumn(2).setHeaderRenderer(myHeader); cModel.getColumn(3).setHeaderRenderer(myHeader); cModel.getColumn(0).setCellRenderer(new LeftDotRenderer()); cModel.getColumn(1).setCellRenderer(new TextCellCenter()); cModel.getColumn(2).setCellRenderer(new TextCellCenter()); cModel.getColumn(3).setCellRenderer(new TextCellCenter()); // Set the width of the status column TableColumn statusColumn = eTable.getColumnModel().getColumn(3); statusColumn.setPreferredWidth(statusWidth); statusColumn.setMaxWidth(statusWidth); statusColumn.setMinWidth(statusWidth); // Set the width of the status column TableColumn dateColumn = eTable.getColumnModel().getColumn(2); dateColumn.setPreferredWidth(dateWidth); dateColumn.setMaxWidth(dateWidth); dateColumn.setMinWidth(dateWidth); // Add the table to the scollpane JScrollPane scrollPane = new JScrollPane(eTable); // disabled till #2308 fixed //reimportBtn = GuiCommonElements.addButton(filterPanel, "Reimport", 'R', "Click here to reimport selected images", "5,0,R,C", debug); reimportBtn = GuiCommonElements.addButton(mainPanel, "Reimport", 'R', "Click here to reimport selected images", "3,5,C,C", debug); reimportBtn.setEnabled(false); reimportBtn.setActionCommand(HistoryHandler.HISTORYREIMPORT); reimportBtn.addActionListener(this); // Handle the listener ListSelectionModel selectionModel = this.eTable.getSelectionModel(); selectionModel.addListSelectionListener(this); //mainPanel.add(scrollPane, "2,3,3,5"); Disabled till #2308 fixed mainPanel.add(scrollPane, "2,1,3,4"); mainPanel.add(bottomSidePanel, "0,4,0,0"); mainPanel.add(topSidePanel, "0,0,0,3"); //mainPanel.add(filterPanel, "2,2,3,1"); this.add(mainPanel); }
From source file:op.care.dfn.PnlDFN.java
private CollapsiblePane createCP4(final DFN dfn) { final CollapsiblePane dfnPane = new CollapsiblePane(); ActionListener applyActionListener = new ActionListener() { @Override/*from w w w .j a va 2 s .c o m*/ public void actionPerformed(ActionEvent actionEvent) { if (dfn.getState() == DFNTools.STATE_DONE) { return; } if (!dfn.isOnDemand() && dfn.getNursingProcess().isClosed()) { return; } if (DFNTools.isChangeable(dfn)) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); DFN myDFN = em.merge(dfn); em.lock(myDFN, LockModeType.OPTIMISTIC); if (!myDFN.isOnDemand()) { em.lock(myDFN.getNursingProcess(), LockModeType.OPTIMISTIC); } myDFN.setState(DFNTools.STATE_DONE); myDFN.setUser(em.merge(OPDE.getLogin().getUser())); myDFN.setIst(new Date()); myDFN.setiZeit(SYSCalendar.whatTimeIDIs(new Date())); myDFN.setMdate(new Date()); em.getTransaction().commit(); CollapsiblePane cp1 = createCP4(myDFN); synchronized (mapDFN2Pane) { mapDFN2Pane.put(myDFN, cp1); } synchronized (mapShift2DFN) { int position = mapShift2DFN.get(myDFN.getShift()).indexOf(myDFN); mapShift2DFN.get(myDFN.getShift()).remove(position); mapShift2DFN.get(myDFN.getShift()).add(position, myDFN); } CollapsiblePane cp2 = createCP4(myDFN.getShift()); synchronized (mapShift2Pane) { mapShift2Pane.put(myDFN.getShift(), cp2); } buildPanel(false); } 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(); } } else { OPDE.getDisplayManager() .addSubMessage(new DisplayMessage(SYSTools.xx("nursingrecords.dfn.notchangeable"))); } } }; String title = "<html><font size=+1>" + // (dfn.isFloating() ? (dfn.isActive() ? "(!) " : "(OK) ") : "") + SYSTools.left(dfn.getIntervention().getBezeichnung(), MAX_TEXT_LENGTH) + DFNTools.getScheduleText(dfn, " [", "]") + ", " + dfn.getMinutes() + " " + SYSTools.xx("misc.msg.Minute(s)") + (dfn.getUser() != null ? ", <i>" + SYSTools.anonymizeUser(dfn.getUser().getUID()) + "</i>" : "") + "</font></html>"; DefaultCPTitle cptitle = new DefaultCPTitle(title, OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID) ? applyActionListener : null); dfnPane.setCollapseOnTitleClick(false); // cptitle.getTitleButton().setIcon(DFNTools.getIcon(dfn)); JLabel icon1 = new JLabel(DFNTools.getIcon(dfn)); icon1.setOpaque(false); JLabel icon2 = new JLabel(DFNTools.getFloatingIcon(dfn)); icon2.setOpaque(false); cptitle.getAdditionalIconPanel().add(icon1); cptitle.getAdditionalIconPanel().add(icon2); if (dfn.isFloating()) { cptitle.getButton().setToolTipText(SYSTools.xx("nursingrecords.dfn.enforced.tooltip") + ": " + DateFormat.getDateInstance().format(dfn.getStDatum())); } if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID) && (dfn.isOnDemand() || !dfn.getNursingProcess().isClosed())) { /*** * _ _ _ _ * | |__ | |_ _ __ / \ _ __ _ __ | |_ _ * | '_ \| __| '_ \ / _ \ | '_ \| '_ \| | | | | * | |_) | |_| | | |/ ___ \| |_) | |_) | | |_| | * |_.__/ \__|_| |_/_/ \_\ .__/| .__/|_|\__, | * |_| |_| |___/ */ JButton btnApply = new JButton(SYSConst.icon22apply); btnApply.setPressedIcon(SYSConst.icon22applyPressed); btnApply.setAlignmentX(Component.RIGHT_ALIGNMENT); btnApply.setContentAreaFilled(false); btnApply.setBorder(null); btnApply.addActionListener(applyActionListener); btnApply.setEnabled(!dfn.isOnDemand() && dfn.isOpen()); cptitle.getRight().add(btnApply); // JPanel spacer = new JPanel(); // spacer.setOpaque(false); // cptitle.getRight().add(spacer); /*** * _ _ ____ _ * | |__ | |_ _ __ / ___|__ _ _ __ ___ ___| | * | '_ \| __| '_ \| | / _` | '_ \ / __/ _ \ | * | |_) | |_| | | | |__| (_| | | | | (_| __/ | * |_.__/ \__|_| |_|\____\__,_|_| |_|\___\___|_| * */ final JButton btnCancel = new JButton(SYSConst.icon22cancel); btnCancel.setPressedIcon(SYSConst.icon22cancelPressed); btnCancel.setAlignmentX(Component.RIGHT_ALIGNMENT); btnCancel.setContentAreaFilled(false); btnCancel.setBorder(null); // btnCancel.setToolTipText(SYSTools.xx("nursingrecords.dfn.btneval.tooltip")); btnCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (dfn.getState() == DFNTools.STATE_REFUSED) { return; } if (DFNTools.isChangeable(dfn)) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); DFN myDFN = em.merge(dfn); em.lock(myDFN, LockModeType.OPTIMISTIC); if (!myDFN.isOnDemand()) { em.lock(myDFN.getNursingProcess(), LockModeType.OPTIMISTIC); } myDFN.setState(DFNTools.STATE_REFUSED); myDFN.setUser(em.merge(OPDE.getLogin().getUser())); myDFN.setIst(new Date()); myDFN.setiZeit(SYSCalendar.whatTimeIDIs(new Date())); myDFN.setMdate(new Date()); em.getTransaction().commit(); CollapsiblePane cp1 = createCP4(myDFN); synchronized (mapDFN2Pane) { mapDFN2Pane.put(myDFN, cp1); } synchronized (mapShift2DFN) { int position = mapShift2DFN.get(myDFN.getShift()).indexOf(myDFN); mapShift2DFN.get(myDFN.getShift()).remove(position); mapShift2DFN.get(myDFN.getShift()).add(position, myDFN); } CollapsiblePane cp2 = createCP4(myDFN.getShift()); synchronized (mapShift2Pane) { mapShift2Pane.put(myDFN.getShift(), cp2); } buildPanel(false); } 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(); } } else { OPDE.getDisplayManager() .addSubMessage(new DisplayMessage(SYSTools.xx("nursingrecords.dfn.notchangeable"))); } } }); btnCancel.setEnabled(!dfn.isOnDemand() && dfn.isOpen()); cptitle.getRight().add(btnCancel); /*** * _ _ _____ _ * | |__ | |_ _ __ | ____|_ __ ___ _ __ | |_ _ _ * | '_ \| __| '_ \| _| | '_ ` _ \| '_ \| __| | | | * | |_) | |_| | | | |___| | | | | | |_) | |_| |_| | * |_.__/ \__|_| |_|_____|_| |_| |_| .__/ \__|\__, | * |_| |___/ */ final JButton btnEmpty = new JButton(SYSConst.icon22empty); btnEmpty.setPressedIcon(SYSConst.icon22emptyPressed); btnEmpty.setAlignmentX(Component.RIGHT_ALIGNMENT); btnEmpty.setContentAreaFilled(false); btnEmpty.setBorder(null); // btnCancel.setToolTipText(SYSTools.xx("nursingrecords.dfn.btneval.tooltip")); btnEmpty.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (dfn.getState() == DFNTools.STATE_OPEN) { return; } if (DFNTools.isChangeable(dfn)) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); DFN myDFN = em.merge(dfn); em.lock(myDFN, LockModeType.OPTIMISTIC); if (!myDFN.isOnDemand()) { em.lock(myDFN.getNursingProcess(), LockModeType.OPTIMISTIC); } // on demand DFNs are deleted if they not wanted anymore if (myDFN.isOnDemand()) { em.remove(myDFN); synchronized (mapDFN2Pane) { mapDFN2Pane.remove(myDFN); } synchronized (mapShift2DFN) { mapShift2DFN.get(myDFN.getShift()).remove(myDFN); } } else { // the normal DFNs (those assigned to a NursingProcess) are reset to the OPEN state. myDFN.setState(DFNTools.STATE_OPEN); myDFN.setUser(null); myDFN.setIst(null); myDFN.setiZeit(null); myDFN.setMdate(new Date()); CollapsiblePane cp1 = createCP4(myDFN); synchronized (mapDFN2Pane) { mapDFN2Pane.put(myDFN, cp1); } synchronized (mapShift2DFN) { int position = mapShift2DFN.get(myDFN.getShift()).indexOf(myDFN); mapShift2DFN.get(myDFN.getShift()).remove(position); mapShift2DFN.get(myDFN.getShift()).add(position, myDFN); } } em.getTransaction().commit(); CollapsiblePane cp2 = createCP4(myDFN.getShift()); synchronized (mapShift2Pane) { mapShift2Pane.put(myDFN.getShift(), cp2); } buildPanel(false); } 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(); } } else { OPDE.getDisplayManager() .addSubMessage(new DisplayMessage(SYSTools.xx("nursingrecords.dfn.notchangeable"))); } } }); btnEmpty.setEnabled(!dfn.isOpen()); cptitle.getRight().add(btnEmpty); /*** * _ _ __ __ _ _ * | |__ | |_ _ __ | \/ (_)_ __ _ _| |_ ___ ___ * | '_ \| __| '_ \| |\/| | | '_ \| | | | __/ _ \/ __| * | |_) | |_| | | | | | | | | | | |_| | || __/\__ \ * |_.__/ \__|_| |_|_| |_|_|_| |_|\__,_|\__\___||___/ * */ final JButton btnMinutes = new JButton(SYSConst.icon22clock); btnMinutes.setPressedIcon(SYSConst.icon22clockPressed); btnMinutes.setAlignmentX(Component.RIGHT_ALIGNMENT); btnMinutes.setContentAreaFilled(false); btnMinutes.setBorder(null); // btnCancel.setToolTipText(SYSTools.xx("nursingrecords.dfn.btneval.tooltip")); btnMinutes.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (!DFNTools.isChangeable(dfn)) { OPDE.getDisplayManager() .addSubMessage(new DisplayMessage(SYSTools.xx("nursingrecords.dfn.notchangeable"))); return; } final JPopupMenu menu = SYSCalendar.getMinutesMenu( new int[] { 1, 2, 3, 4, 5, 10, 15, 20, 30, 45, 60, 120, 240, 360 }, new Closure() { @Override public void execute(Object o) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); DFN myDFN = em.merge(dfn); em.lock(myDFN, LockModeType.OPTIMISTIC); if (!myDFN.isOnDemand()) { em.lock(myDFN.getNursingProcess(), LockModeType.OPTIMISTIC); } myDFN.setMinutes(new BigDecimal((Integer) o)); myDFN.setUser(em.merge(OPDE.getLogin().getUser())); myDFN.setMdate(new Date()); em.getTransaction().commit(); CollapsiblePane cp1 = createCP4(myDFN); synchronized (mapDFN2Pane) { mapDFN2Pane.put(myDFN, cp1); } synchronized (mapShift2DFN) { int position = mapShift2DFN.get(myDFN.getShift()).indexOf(myDFN); mapShift2DFN.get(myDFN.getShift()).remove(position); mapShift2DFN.get(myDFN.getShift()).add(position, myDFN); } CollapsiblePane cp2 = createCP4(myDFN.getShift()); synchronized (mapShift2Pane) { mapShift2Pane.put(myDFN.getShift(), cp2); } buildPanel(false); } 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(); } } }); menu.show(btnMinutes, 0, btnMinutes.getHeight()); } }); btnMinutes.setEnabled(dfn.getState() != DFNTools.STATE_OPEN); cptitle.getRight().add(btnMinutes); } /*** * _ _ ___ __ * | |__ | |_ _ __ |_ _|_ __ / _| ___ * | '_ \| __| '_ \ | || '_ \| |_ / _ \ * | |_) | |_| | | || || | | | _| (_) | * |_.__/ \__|_| |_|___|_| |_|_| \___/ * */ final JButton btnInfo = new JButton(SYSConst.icon22info); final JidePopup popupInfo = new JidePopup(); btnInfo.setPressedIcon(SYSConst.icon22infoPressed); btnInfo.setAlignmentX(Component.RIGHT_ALIGNMENT); btnInfo.setContentAreaFilled(false); btnInfo.setBorder(null); final JTextPane txt = new JTextPane(); txt.setContentType("text/html"); txt.setEditable(false); popupInfo.setMovable(false); popupInfo.getContentPane().setLayout(new BoxLayout(popupInfo.getContentPane(), BoxLayout.LINE_AXIS)); popupInfo.getContentPane().add(new JScrollPane(txt)); popupInfo.removeExcludedComponent(txt); popupInfo.setDefaultFocusComponent(txt); btnInfo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { popupInfo.setOwner(btnInfo); txt.setText(SYSTools.toHTML(SYSConst.html_div(dfn.getInterventionSchedule().getBemerkung()))); GUITools.showPopup(popupInfo, SwingConstants.WEST); } }); btnInfo.setEnabled( !dfn.isOnDemand() && !SYSTools.catchNull(dfn.getInterventionSchedule().getBemerkung()).isEmpty()); cptitle.getRight().add(btnInfo); dfnPane.setTitleLabelComponent(cptitle.getMain()); dfnPane.setBackground(dfn.getBG()); dfnPane.setForeground(dfn.getFG()); try { dfnPane.setCollapsed(true); } catch (PropertyVetoException e) { OPDE.error(e); } dfnPane.addCollapsiblePaneListener(new CollapsiblePaneAdapter() { @Override public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) { JTextPane contentPane = new JTextPane(); contentPane.setContentType("text/html"); contentPane.setEditable(false); contentPane.setText(SYSTools .toHTML(NursingProcessTools.getAsHTML(dfn.getNursingProcess(), false, true, false, false))); dfnPane.setContentPane(contentPane); } }); dfnPane.setCollapsible(dfn.getNursingProcess() != null); dfnPane.setHorizontalAlignment(SwingConstants.LEADING); dfnPane.setOpaque(false); return dfnPane; }
From source file:op.care.dfn.PnlDFN.java
private java.util.List<Component> addCommands() { java.util.List<Component> list = new ArrayList<Component>(); /***/* w w w . j a v a2s. co m*/ * _ _ _ _ _ * | |__ | |_ _ __ / \ __| | __| | * | '_ \| __| '_ \ / _ \ / _` |/ _` | * | |_) | |_| | | |/ ___ \ (_| | (_| | * |_.__/ \__|_| |_/_/ \_\__,_|\__,_| * */ if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) { final JideButton btnAdd = GUITools.createHyperlinkButton(SYSTools.xx("nursingrecords.dfn.btnadd"), SYSConst.icon22add, null); btnAdd.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (!resident.isActive()) { OPDE.getDisplayManager() .addSubMessage(new DisplayMessage("misc.msg.cantChangeInactiveResident")); return; } final JidePopup popup = new JidePopup(); popup.setMovable(false); PnlSelectIntervention pnl = new PnlSelectIntervention(new Closure() { @Override public void execute(Object o) { popup.hidePopup(); if (o != null) { Object[] objects = (Object[]) o; EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); for (Object obj : objects) { Intervention intervention = em.merge((Intervention) obj); DFN dfn = em.merge(new DFN(resident, intervention)); // Set Target and Actual according to the setting of JDCDate DateTime now = new DateTime(); DateMidnight onDemandPIT = new DateMidnight(jdcDate.getDate()); DateTime newDateTime = onDemandPIT.toDateTime() .plusHours(now.getHourOfDay()).plusMinutes(now.getMinuteOfHour()) .plusSeconds(now.getSecondOfMinute()); dfn.setSoll(newDateTime.toDate()); dfn.setIst(newDateTime.toDate()); CollapsiblePane cp1 = createCP4(dfn); synchronized (mapDFN2Pane) { mapDFN2Pane.put(dfn, cp1); } synchronized (mapShift2DFN) { mapShift2DFN.get(dfn.getShift()).add(dfn); } } em.getTransaction().commit(); CollapsiblePane cp2 = createCP4(DFNTools.SHIFT_ON_DEMAND); synchronized (mapShift2Pane) { mapShift2Pane.put(DFNTools.SHIFT_ON_DEMAND, cp2); } buildPanel(false); try { synchronized (mapShift2Pane) { mapShift2Pane.get(DFNTools.SHIFT_ON_DEMAND).setCollapsed(false); } } catch (PropertyVetoException e) { OPDE.debug(e); } } 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(); } } } }); popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS)); popup.getContentPane().add(pnl); popup.setOwner(btnAdd); popup.removeExcludedComponent(pnl); popup.setDefaultFocusComponent(pnl); GUITools.showPopup(popup, SwingConstants.NORTH); } }); list.add(btnAdd); } final JideButton printPrescription = GUITools.createHyperlinkButton("nursingrecords.dfn.print", SYSConst.icon22print2, new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { String html = ""; synchronized (mapShift2DFN) { html += "<h1 id=\"fonth1\" >" + ResidentTools.getFullName(resident) + "</h1>"; html += SYSConst.html_h2(SYSTools.xx("nursingrecords.bhp") + ": " + SYSConst.html_bold(DateFormat.getDateInstance().format(jdcDate.getDate()))); for (Byte shift : new Byte[] { DFNTools.SHIFT_ON_DEMAND, DFNTools.SHIFT_VERY_EARLY, DFNTools.SHIFT_EARLY, DFNTools.SHIFT_LATE, DFNTools.SHIFT_VERY_LATE }) { html += DFNTools.getDFNsAsHTMLtable(mapShift2DFN.get(shift)); } } SYSFilesTools.print(html, true); } }); list.add(printPrescription); return list; }
From source file:op.care.med.inventory.DlgNewStocks.java
/** * This method is called from within the constructor to * initialize the form.//from ww w. ja va2s . com * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the PrinterForm Editor. */ // <editor-fold defaultstate="collapsed" desc=" Erzeugter Quelltext ">//GEN-BEGIN:initComponents private void initComponents() { mainPane = new JPanel(); lblPZN = new JLabel(); panel2 = new JPanel(); txtMedSuche = new JXSearchField(); hSpacer1 = new JPanel(null); btnMed = new JButton(); lblProd = new JLabel(); cmbMProdukt = new JComboBox<>(); lblInventory = new JLabel(); lblResident = new JLabel(); txtBWSuche = new JTextField(); lblAmount = new JLabel(); lblPack = new JLabel(); cmbPackung = new JComboBox<>(); lblExpires = new JLabel(); txtExpires = new JTextField(); panel3 = new JPanel(); lblWeightControl = new JLabel(); txtWeightControl = new JTextField(); lblRemark = new JLabel(); txtBemerkung = new JTextField(); btnPrint = new JToggleButton(); panel1 = new JPanel(); btnClose = new JButton(); btnApply = new JButton(); //======== this ======== setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setTitle("Medikamente einbuchen"); setMinimumSize(new Dimension(640, 300)); Container contentPane = getContentPane(); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS)); //======== mainPane ======== { mainPane.setLayout(new FormLayout( "14dlu, $lcgap, default, $lcgap, 39dlu:grow, $lcgap, default:grow, $lcgap, 14dlu", "14dlu, 2*($lgap, fill:17dlu), $lgap, fill:default, $lgap, 17dlu, 4*($lgap, fill:17dlu), 10dlu, fill:default, $lgap, 14dlu")); //---- lblPZN ---- lblPZN.setText("PZN oder Suchbegriff"); lblPZN.setFont(new Font("Arial", Font.PLAIN, 14)); mainPane.add(lblPZN, CC.xy(3, 3)); //======== panel2 ======== { panel2.setLayout(new BoxLayout(panel2, BoxLayout.LINE_AXIS)); //---- txtMedSuche ---- txtMedSuche.setFont(new Font("Arial", Font.PLAIN, 14)); txtMedSuche.addActionListener(e -> txtMedSucheActionPerformed(e)); panel2.add(txtMedSuche); panel2.add(hSpacer1); //---- btnMed ---- btnMed.setBackground(Color.white); btnMed.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png"))); btnMed.setToolTipText("Medikamente bearbeiten"); btnMed.setBorder(null); btnMed.setSelectedIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add-pressed.png"))); btnMed.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnMed.addActionListener(e -> btnMedActionPerformed(e)); panel2.add(btnMed); } mainPane.add(panel2, CC.xywh(5, 3, 4, 1)); //---- lblProd ---- lblProd.setText("Produkt"); lblProd.setFont(new Font("Arial", Font.PLAIN, 14)); mainPane.add(lblProd, CC.xy(3, 5)); //---- cmbMProdukt ---- cmbMProdukt.setModel(new DefaultComboBoxModel<>(new String[] { })); cmbMProdukt.setFont(new Font("Arial", Font.PLAIN, 14)); cmbMProdukt.addItemListener(e -> cmbMProduktItemStateChanged(e)); mainPane.add(cmbMProdukt, CC.xywh(5, 5, 4, 1)); //---- lblInventory ---- lblInventory.setText("vorhandene Vorr\u00e4te"); lblInventory.setFont(new Font("Arial", Font.PLAIN, 14)); mainPane.add(lblInventory, CC.xy(3, 13)); //---- lblResident ---- lblResident.setText("Zuordnung zu Bewohner"); lblResident.setFont(new Font("Arial", Font.PLAIN, 14)); mainPane.add(lblResident, CC.xy(3, 17)); //---- txtBWSuche ---- txtBWSuche.setFont(new Font("Arial", Font.PLAIN, 14)); txtBWSuche.addCaretListener(e -> txtBWSucheCaretUpdate(e)); mainPane.add(txtBWSuche, CC.xy(5, 17)); //---- lblAmount ---- lblAmount.setText("Buchungsmenge"); lblAmount.setFont(new Font("Arial", Font.PLAIN, 14)); mainPane.add(lblAmount, CC.xy(3, 11)); //---- lblPack ---- lblPack.setText("Packung"); lblPack.setFont(new Font("Arial", Font.PLAIN, 14)); mainPane.add(lblPack, CC.xy(3, 7)); //---- cmbPackung ---- cmbPackung.setModel(new DefaultComboBoxModel<>(new String[] { })); cmbPackung.setFont(new Font("Arial", Font.PLAIN, 14)); cmbPackung.addItemListener(e -> cmbPackungItemStateChanged(e)); mainPane.add(cmbPackung, CC.xywh(5, 7, 4, 1)); //---- lblExpires ---- lblExpires.setText("expires"); lblExpires.setFont(new Font("Arial", Font.PLAIN, 14)); mainPane.add(lblExpires, CC.xy(3, 9)); //---- txtExpires ---- txtExpires.setFont(new Font("Arial", Font.PLAIN, 14)); txtExpires.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtExpiresFocusGained(e); } @Override public void focusLost(FocusEvent e) { txtExpiresFocusLost(e); } }); txtExpires.addActionListener(e -> txtExpiresActionPerformed(e)); mainPane.add(txtExpires, CC.xywh(5, 9, 3, 1, CC.DEFAULT, CC.FILL)); //======== panel3 ======== { panel3.setLayout(new FormLayout("pref, $lcgap, default:grow", "fill:17dlu")); //---- lblWeightControl ---- lblWeightControl.setText("weightcontrol"); lblWeightControl.setFont(new Font("Arial", Font.PLAIN, 14)); lblWeightControl.setBackground(Color.pink); panel3.add(lblWeightControl, CC.xy(1, 1)); //---- txtWeightControl ---- txtWeightControl.setFont(new Font("Arial", Font.PLAIN, 14)); txtWeightControl.setBackground(Color.pink); txtWeightControl.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtWeightControlFocusGained(e); } }); txtWeightControl.addCaretListener(e -> txtWeightControlCaretUpdate(e)); panel3.add(txtWeightControl, CC.xy(3, 1, CC.DEFAULT, CC.FILL)); } mainPane.add(panel3, CC.xy(7, 11)); //---- lblRemark ---- lblRemark.setText("Bemerkung"); lblRemark.setFont(new Font("Arial", Font.PLAIN, 14)); mainPane.add(lblRemark, CC.xy(3, 15)); //---- txtBemerkung ---- txtBemerkung.setFont(new Font("Arial", Font.PLAIN, 14)); txtBemerkung.addCaretListener(e -> txtBemerkungCaretUpdate(e)); mainPane.add(txtBemerkung, CC.xywh(5, 15, 4, 1)); //---- btnPrint ---- btnPrint.setSelectedIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/printer-on.png"))); btnPrint.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/printer-off.png"))); btnPrint.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnPrint.setEnabled(false); btnPrint.addItemListener(e -> btnPrintItemStateChanged(e)); mainPane.add(btnPrint, CC.xy(3, 19, CC.RIGHT, CC.DEFAULT)); //======== panel1 ======== { panel1.setLayout(new BoxLayout(panel1, BoxLayout.X_AXIS)); //---- btnClose ---- btnClose.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/cancel.png"))); btnClose.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnClose.addActionListener(e -> btnCloseActionPerformed(e)); panel1.add(btnClose); //---- btnApply ---- btnApply.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/apply.png"))); btnApply.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnApply.addActionListener(e -> btnApplyActionPerformed(e)); panel1.add(btnApply); } mainPane.add(panel1, CC.xywh(7, 19, 2, 1, CC.RIGHT, CC.DEFAULT)); } contentPane.add(mainPane); pack(); setLocationRelativeTo(getOwner()); }
From source file:op.care.med.inventory.DlgNewStocks.java
private void btnMedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMedActionPerformed // String pzn = MedPackageTools.parsePZN(txtMedSuche.getText()); final JidePopup popup = new JidePopup(); WizardDialog wizard = new MedProductWizard(new Closure() { @Override// www . j a va 2 s .c om public void execute(Object o) { if (o != null) { MedPackage aPackage = (MedPackage) o; txtMedSuche.setText(aPackage.getPzn()); } popup.hidePopup(); } }).getWizard(); popup.setMovable(false); popup.setPreferredSize((new Dimension(800, 450))); popup.setResizable(false); popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS)); popup.getContentPane().add(wizard.getContentPane()); popup.setOwner(btnMed); popup.removeExcludedComponent(btnMed); popup.setTransient(true); popup.setDefaultFocusComponent(wizard.getContentPane()); popup.addPropertyChangeListener("visible", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent propertyChangeEvent) { OPDE.debug("popup property: " + propertyChangeEvent.getPropertyName() + " value: " + propertyChangeEvent.getNewValue() + " compCount: " + popup.getContentPane().getComponentCount()); popup.getContentPane().getComponentCount(); } }); GUITools.showPopup(popup, SwingConstants.WEST); // popup.showPopup(new Insets(-5, wizard.getPreferredSize().width * -1 - 200, -5, -100), btnMed); }
From source file:op.care.med.inventory.PnlInventory.java
private CollapsiblePane createCP4(final MedStock stock) { /***//from ww w . j a va 2 s. c o m * _ ____ ____ _ _ __ _ _ __ * ___ _ __ ___ __ _| |_ ___ / ___| _ \| || | / /__| |_ ___ ___| | _\ \ * / __| '__/ _ \/ _` | __/ _ \ | | |_) | || |_| / __| __/ _ \ / __| |/ /| | * | (__| | | __/ (_| | || __/ |___| __/|__ _| \__ \ || (_) | (__| < | | * \___|_| \___|\__,_|\__\___|\____|_| |_| | |___/\__\___/ \___|_|\_\| | * \_\ /_/ */ final String key = stock.getID() + ".xstock"; synchronized (cpMap) { if (!cpMap.containsKey(key)) { cpMap.put(key, new CollapsiblePane()); try { cpMap.get(key).setCollapsed(true); } catch (PropertyVetoException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } cpMap.get(key).setName("stock"); BigDecimal sumStock = BigDecimal.ZERO; try { EntityManager em = OPDE.createEM(); sumStock = MedStockTools.getSum(em, stock); em.close(); } catch (Exception e) { OPDE.fatal(e); } String title = "<html><table border=\"0\">" + "<tr>" + (stock.isClosed() ? "<s>" : "") + "<td width=\"600\" align=\"left\">" + MedStockTools.getAsHTML(stock) + "</td>" + "<td width=\"200\" align=\"right\">" + NumberFormat.getNumberInstance().format(sumStock) + " " + DosageFormTools.getPackageText(MedInventoryTools.getForm(stock.getInventory())) + "</td>" + (stock.isClosed() ? "</s>" : "") + "</tr>" + "</table>" + "</html>"; DefaultCPTitle cptitle = new DefaultCPTitle(title, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { cpMap.get(key).setCollapsed(!cpMap.get(key).isCollapsed()); } catch (PropertyVetoException pve) { // BAH! } } }); cpMap.get(key).setTitleLabelComponent(cptitle.getMain()); cpMap.get(key).setSlidingDirection(SwingConstants.SOUTH); cptitle.getRight().add(new StockPanel(stock)); if (!stock.getInventory().isClosed()) { /*** * ____ _ _ _ _ _ * | _ \ _ __(_)_ __ | |_| | __ _| |__ ___| | * | |_) | '__| | '_ \| __| | / _` | '_ \ / _ \ | * | __/| | | | | | | |_| |__| (_| | |_) | __/ | * |_| |_| |_|_| |_|\__|_____\__,_|_.__/ \___|_| * */ final JButton btnPrintLabel = new JButton(SYSConst.icon22print2); btnPrintLabel.setPressedIcon(SYSConst.icon22print2Pressed); btnPrintLabel.setAlignmentX(Component.RIGHT_ALIGNMENT); btnPrintLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnPrintLabel.setContentAreaFilled(false); btnPrintLabel.setBorder(null); btnPrintLabel.setToolTipText(SYSTools.xx("nursingrecords.inventory.stock.btnprintlabel.tooltip")); btnPrintLabel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { LogicalPrinter logicalPrinter = OPDE.getLogicalPrinters().getMapName2LogicalPrinter() .get(OPDE.getProps().getProperty(SYSPropsTools.KEY_LOGICAL_PRINTER)); PrinterForm printerForm1 = logicalPrinter.getForms() .get(OPDE.getProps().getProperty(SYSPropsTools.KEY_MEDSTOCK_LABEL)); OPDE.getPrintProcessor().addPrintJob(new PrintListElement(stock, logicalPrinter, printerForm1, OPDE.getProps().getProperty(SYSPropsTools.KEY_PHYSICAL_PRINTER))); } }); btnPrintLabel.setEnabled(OPDE.getPrintProcessor().isWorking()); cptitle.getRight().add(btnPrintLabel); } /*** * __ __ * | \/ | ___ _ __ _ _ * | |\/| |/ _ \ '_ \| | | | * | | | | __/ | | | |_| | * |_| |_|\___|_| |_|\__,_| * */ 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(stock); popup.getContentPane().add(pnl); popup.setDefaultFocusComponent(pnl); GUITools.showPopup(popup, SwingConstants.WEST); } }); cptitle.getRight().add(btnMenu); CollapsiblePaneAdapter adapter = new CollapsiblePaneAdapter() { @Override public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) { cpMap.get(key).setContentPane(createContentPanel4(stock)); } }; synchronized (cpListener) { if (cpListener.containsKey(key)) { cpMap.get(key).removeCollapsiblePaneListener(cpListener.get(key)); } cpListener.put(key, adapter); cpMap.get(key).addCollapsiblePaneListener(adapter); } if (!cpMap.get(key).isCollapsed()) { JPanel contentPane = createContentPanel4(stock); cpMap.get(key).setContentPane(contentPane); } cpMap.get(key).setHorizontalAlignment(SwingConstants.LEADING); cpMap.get(key).setOpaque(false); cpMap.get(key).setBackground( getColor(SYSConst.light3, lstInventories.indexOf(stock.getInventory()) % 2 != 0)); return cpMap.get(key); } }
From source file:op.care.med.structure.DlgProduct.java
private void btnAddActionPerformed(ActionEvent e) { final JidePopup popup = new JidePopup(); DlgACME dlg = new DlgACME(new Closure() { @Override//from w w w. j a v a 2 s. com public void execute(Object o) { if (o != null) { cmbAcme.setModel(new DefaultComboBoxModel(new ACME[] { (ACME) o })); cmbAcme.setSelectedIndex(0); popup.hidePopup(); } } }); popup.setMovable(false); popup.setResizable(false); popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS)); popup.getContentPane().add(dlg); popup.setOwner(btnAdd); popup.removeExcludedComponent(btnAdd); popup.setTransient(true); popup.setDefaultFocusComponent(dlg); popup.showPopup(new Insets(-5, 0, -5, 0), btnAdd); }