/** * This function is used to re-run the analyser, and re-create the rows corresponding the its * results. */ private void refreshReviewTable() { reviewPanel.removeAll(); rows.clear(); GridBagLayout gbl = new GridBagLayout(); reviewPanel.setLayout(gbl); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridy = 0; try { Map<String, Long> sums = analyser.processLogFile(config.getLogFilename(), fromDate.getDate(), toDate.getDate()); for (Entry<String, Long> entry : sums.entrySet()) { String project = entry.getKey(); double hours = 1.0 * entry.getValue() / (1000 * 3600); addRow(gbl, gbc, project, hours); } for (String project : main.getProjectsTree().getTopLevelProjects()) if (!rows.containsKey(project)) addRow(gbl, gbc, project, 0); gbc.insets = new Insets(10, 0, 0, 0); addLeftLabel(gbl, gbc, "TOTAL"); gbc.gridx = 1; gbc.weightx = 1; totalLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 3)); gbl.setConstraints(totalLabel, gbc); reviewPanel.add(totalLabel); gbc.weightx = 0; addRightLabel(gbl, gbc); } catch (IOException e) { e.printStackTrace(); } recomputeTotal(); pack(); }
/** Initializes contained components. */ private void initComponents() { final SimpleDateFormat format = new SimpleDateFormat("mm:ss"); final Calendar c = Calendar.getInstance(); final JLabel counter = new JLabel(); counter.setForeground(Color.red); counter.setFont(counter.getFont().deriveFont((float) (counter.getFont().getSize() + 5))); setLayout(new GridBagLayout()); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); GridBagConstraints constraints = new GridBagConstraints(); JLabel messageLabel = new JLabel( GuiActivator.getResources().getI18NString("service.gui.security.SECURITY_ALERT")); messageLabel.setForeground(Color.WHITE); constraints.anchor = GridBagConstraints.CENTER; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 0; constraints.gridy = 0; add(messageLabel, constraints); constraints.anchor = GridBagConstraints.CENTER; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 0; constraints.gridy = 1; add(counter, constraints); ZrtpControl zrtpControl = null; if (securityControl instanceof ZrtpControl) zrtpControl = (ZrtpControl) securityControl; long initialSeconds = 0; if (zrtpControl != null) initialSeconds = zrtpControl.getTimeoutValue(); c.setTimeInMillis(initialSeconds); counter.setText(format.format(c.getTime())); if (initialSeconds > 0) timer.schedule( new TimerTask() { @Override public void run() { if (c.getTimeInMillis() - 1000 > 0) { c.add(Calendar.SECOND, -1); counter.setText(format.format(c.getTime())); } } }, 1000, 1000); }
/* public void addMiniChart(Plugin p){ components.add(p); rebuild(); } public void removeMiniChart(Plugin p){ components.remove(p); rebuild(); } */ public void rebuild() { // remove everything from main panel mainpanel.removeAll(); GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); mainpanel.setLayout(gbl); gbc.anchor = gbc.NORTHWEST; gbc.fill = gbc.BOTH; gbc.weightx = 1; gbc.gridx = 0; int i = 0; // add chart gbc.weighty = 1; gbc.gridy = i; gbl.setConstraints(chartPanel, gbc); mainpanel.add(chartPanel); // add all other plugins/components validate(); }
public ChartWindow(String title) { this.symbol = title; thisp = this; // initialize the main layout setTitle(title); mainpanel = new JPanel(); GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); mainpanel.setLayout(gbl); // build a toolbar // add a plain status bar this.statusLine = new JLabel("Done"); this.getContentPane().add(statusLine, BorderLayout.SOUTH); statusLine.setBackground(new Color(0, 0, 0)); statusLine.setForeground(new Color(255, 255, 255)); statusLine.setOpaque(true); // x1 = new TimeSeries("symbol", FixedMillisecond.class); dataset1.addSeries(x1); System.out.println("Populated."); // chart = createChart(dataset1); System.out.println("constr."); // chart.getXYPlot().setOrientation(PlotOrientation.VERTICAL); chart.setAntiAlias(false); chartPanel = new ChartPanel(chart); // int i = 0; gbc.anchor = gbc.NORTHWEST; gbc.fill = gbc.BOTH; gbc.weightx = 1; gbc.gridx = 0; gbc.weighty = 1; gbc.gridy = i; gbl.setConstraints(chartPanel, gbc); mainpanel.add(chartPanel); // System.out.println("add"); setVisible(true); setSize(new Dimension(400, 300)); // chartPanel.setPopupMenu(buildPopupMenu()); chartPanel.setMouseZoomable(true); chartPanel.setHorizontalAxisTrace(true); chartPanel.setVerticalAxisTrace(true); chartPanel.setHorizontalZoom(true); chartPanel.setOpaque(true); chartPanel.setBackground(new Color(0, 0, 0)); this.getContentPane().add(mainpanel, BorderLayout.CENTER); this.setSize(600, 400); this.toFront(); this.show(); }
/** * The only constructor of the review dialog, which initialises the dates, sets the outer layout, * runs the analyser, creates rows for the results, and displays the window. * * @param main A link to the parent component. * @param config A link to the configuration object. */ ReviewDialog(Main main, Config config) { super(main, "Review & Save"); this.main = main; this.config = config; // layout date components GridBagLayout gbl = new GridBagLayout(); setLayout(gbl); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.insets = new Insets(0, 0, 5, 0); gbc.ipadx = 10; gbc.gridx = 0; gbc.gridy = 0; gbl.setConstraints(yearLabel, gbc); gbc.gridx = 1; gbl.setConstraints(yearCB, gbc); gbc.gridx = 0; gbc.gridy = 1; gbl.setConstraints(weekLabel, gbc); gbc.gridx = 1; gbl.setConstraints(weekCB, gbc); gbc.gridx = 0; gbc.gridy = 2; gbl.setConstraints(fromLabel, gbc); gbc.weightx = 1; gbc.gridx = 1; gbl.setConstraints(fromDate, gbc); gbc.insets = new Insets(0, 0, 0, 0); gbc.weightx = 0; gbc.gridx = 0; gbc.gridy = 3; gbl.setConstraints(toLabel, gbc); gbc.weightx = 1; gbc.gridx = 1; gbl.setConstraints(toDate, gbc); gbc.gridx = 0; gbc.gridy = 4; gbc.gridwidth = 2; gbc.insets = new Insets(10, 5, 10, 5); gbc.weighty = 1; JScrollPane scrollReviewPanel = new JScrollPane(reviewPanel); gbl.setConstraints(scrollReviewPanel, gbc); gbc.insets = new Insets(0, 0, 0, 0); gbc.gridy = 5; gbc.weighty = 0; gbl.setConstraints(saveToFileButton, gbc); gbc.gridy = 6; gbl.setConstraints(copyToClipboardButton, gbc); add(yearLabel); add(yearCB); add(weekLabel); add(weekCB); add(fromLabel); add(fromDate); add(toLabel); add(toDate); add(scrollReviewPanel); add(saveToFileButton); add(copyToClipboardButton); // layout results updateYearWeekDates(); setVisible(true); setLocation(main.getLocation()); }
public void setup() { setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); title = new JLabel(SHTML + TITLE + elem.title + EHTML); gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.WEST; gbc.gridy = 4; gbc.gridx = 0; gbc.gridwidth = 2; gbc.gridheight = 1; gbc.weighty = 1.0; add(title, gbc); donor = new JLabel(SHTML + DONOR + elem.donor + EHTML); gbc.gridy = 5; add(donor, gbc); subDate = new JLabel(SHTML + SUB_DATE + elem.subDate.toString() + EHTML); gbc.gridy = 6; add(subDate, gbc); objDate = new JLabel(SHTML + OBJ_DATE + elem.objDate.toString() + EHTML); gbc.gridy = 7; add(objDate, gbc); medium = new JLabel(SHTML + MEDIUM + elem.medium + EHTML); gbc.gridy = 8; add(medium, gbc); accNum = new JLabel(SHTML + ACC_NUM + elem.accNum + EHTML); gbc.gridy = 9; add(accNum, gbc); desc = new JLabel(SHTML + DESC + EHTML); // gbc.anchor = GridBagConstraints.PAGE_START; gbc.insets = new Insets(0, 50, 0, 0); gbc.gridy = 4; gbc.gridx = 2; add(desc, gbc); descView = new JTextArea(); descView.setLineWrap(true); descView.setWrapStyleWord(true); descView.setEditable(false); descView.setText(elem.desc); descView.setFont(new Font("Times New Roman", Font.PLAIN, 13)); JScrollPane scrollPane = new JScrollPane(descView); scrollPane.setPreferredSize(new Dimension(225, 100)); // scrollPane.setBorder(null); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); descView.setCaretPosition(0); gbc.gridy = 5; gbc.gridheight = 4; gbc.gridx = 2; add(scrollPane, gbc); gbc.insets = null; gbc.gridy = 0; gbc.gridx = 0; gbc.gridwidth = 4; gbc.gridheight = 4; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(0, 0, 10, 0); vpan = new V3DPanel(elem, provider); vpan.setPreferredSize(new Dimension(500, 300)); setBackground(BACKGROUND); add(vpan, gbc); validate(); }
/** Constructor (create and layout page) */ public SOAPMonitorPage(String host_name) { host = host_name; // Set up default filter (show all messages) filter = new SOAPMonitorFilter(); // Use borders to help improve appearance etched_border = new EtchedBorder(); // Build top portion of split (list panel) model = new SOAPMonitorTableModel(); table = new JTable(model); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setRowSelectionInterval(0, 0); table.setPreferredScrollableViewportSize(new Dimension(600, 96)); table.getSelectionModel().addListSelectionListener(this); scroll = new JScrollPane(table); remove_button = new JButton("Remove"); remove_button.addActionListener(this); remove_button.setEnabled(false); remove_all_button = new JButton("Remove All"); remove_all_button.addActionListener(this); filter_button = new JButton("Filter ..."); filter_button.addActionListener(this); list_buttons = new JPanel(); list_buttons.setLayout(new FlowLayout()); list_buttons.add(remove_button); list_buttons.add(remove_all_button); list_buttons.add(filter_button); list_panel = new JPanel(); list_panel.setLayout(new BorderLayout()); list_panel.add(scroll, BorderLayout.CENTER); list_panel.add(list_buttons, BorderLayout.SOUTH); list_panel.setBorder(empty_border); // Build bottom portion of split (message details) details_time = new JLabel("Time: ", SwingConstants.RIGHT); details_target = new JLabel("Target Service: ", SwingConstants.RIGHT); details_status = new JLabel("Status: ", SwingConstants.RIGHT); details_time_value = new JLabel(); details_target_value = new JLabel(); details_status_value = new JLabel(); Dimension preferred_size = details_time.getPreferredSize(); preferred_size.width = 1; details_time.setPreferredSize(preferred_size); details_target.setPreferredSize(preferred_size); details_status.setPreferredSize(preferred_size); details_time_value.setPreferredSize(preferred_size); details_target_value.setPreferredSize(preferred_size); details_status_value.setPreferredSize(preferred_size); details_header = new JPanel(); details_header_layout = new GridBagLayout(); details_header.setLayout(details_header_layout); details_header_constraints = new GridBagConstraints(); details_header_constraints.fill = GridBagConstraints.BOTH; details_header_constraints.weightx = 0.5; details_header_layout.setConstraints(details_time, details_header_constraints); details_header.add(details_time); details_header_layout.setConstraints(details_time_value, details_header_constraints); details_header.add(details_time_value); details_header_layout.setConstraints(details_target, details_header_constraints); details_header.add(details_target); details_header_constraints.weightx = 1.0; details_header_layout.setConstraints(details_target_value, details_header_constraints); details_header.add(details_target_value); details_header_constraints.weightx = .5; details_header_layout.setConstraints(details_status, details_header_constraints); details_header.add(details_status); details_header_layout.setConstraints(details_status_value, details_header_constraints); details_header.add(details_status_value); details_header.setBorder(etched_border); request_label = new JLabel("SOAP Request", SwingConstants.CENTER); request_text = new SOAPMonitorTextArea(); request_text.setEditable(false); request_scroll = new JScrollPane(request_text); request_panel = new JPanel(); request_panel.setLayout(new BorderLayout()); request_panel.add(request_label, BorderLayout.NORTH); request_panel.add(request_scroll, BorderLayout.CENTER); response_label = new JLabel("SOAP Response", SwingConstants.CENTER); response_text = new SOAPMonitorTextArea(); response_text.setEditable(false); response_scroll = new JScrollPane(response_text); response_panel = new JPanel(); response_panel.setLayout(new BorderLayout()); response_panel.add(response_label, BorderLayout.NORTH); response_panel.add(response_scroll, BorderLayout.CENTER); details_soap = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); details_soap.setTopComponent(request_panel); details_soap.setRightComponent(response_panel); details_soap.setResizeWeight(.5); details_panel = new JPanel(); layout_button = new JButton("Switch Layout"); layout_button.addActionListener(this); reflow_xml = new JCheckBox("Reflow XML text"); reflow_xml.addActionListener(this); details_buttons = new JPanel(); details_buttons.setLayout(new FlowLayout()); details_buttons.add(reflow_xml); details_buttons.add(layout_button); details_panel.setLayout(new BorderLayout()); details_panel.add(details_header, BorderLayout.NORTH); details_panel.add(details_soap, BorderLayout.CENTER); details_panel.add(details_buttons, BorderLayout.SOUTH); details_panel.setBorder(empty_border); // Add the two parts to the age split pane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT); split.setTopComponent(list_panel); split.setRightComponent(details_panel); // Build status area start_button = new JButton("Start"); start_button.addActionListener(this); stop_button = new JButton("Stop"); stop_button.addActionListener(this); status_buttons = new JPanel(); status_buttons.setLayout(new FlowLayout()); status_buttons.add(start_button); status_buttons.add(stop_button); status_text = new JLabel(); status_text.setBorder(new BevelBorder(BevelBorder.LOWERED)); status_text_panel = new JPanel(); status_text_panel.setLayout(new BorderLayout()); status_text_panel.add(status_text, BorderLayout.CENTER); status_text_panel.setBorder(empty_border); status_area = new JPanel(); status_area.setLayout(new BorderLayout()); status_area.add(status_buttons, BorderLayout.WEST); status_area.add(status_text_panel, BorderLayout.CENTER); status_area.setBorder(etched_border); // Add the split and status area to page setLayout(new BorderLayout()); add(split, BorderLayout.CENTER); add(status_area, BorderLayout.SOUTH); }