/* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * See LICENSE.txt included in this distribution for the specific * language governing permissions and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at LICENSE.txt. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. */ package org.opensolaris.opengrok.management.client; import java.awt.Dimension; import java.awt.Toolkit; import java.util.Date; /** * * @author Jan S Berg */ @SuppressWarnings("PMD.SingularField") public class NotificationsFrame extends javax.swing.JFrame { private static final long serialVersionUID = -7314367696755820002L; private final java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyy-MM-dd' 'HH:mm:ss.SSS"); /** Creates new form NotificationsFrame */ public NotificationsFrame(String notifications, long startime, long endtime) { initComponents(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension mySize = getPreferredSize(); setLocation(screenSize.width / 2 - (mySize.width / 2), screenSize.height / 2 - (mySize.height / 2)); jTextArea1.setText(notifications); endTimelabel.setText(formatTimestamp(endtime)); startTimeLabel.setText(formatTimestamp(startime)); } private String formatTimestamp(long timestamp) { return formatter.format(new Date(timestamp)); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { notificationsPane = new javax.swing.JScrollPane(); jTextArea1 = new javax.swing.JTextArea(); closeButton = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); startTimeLabel = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); endTimelabel = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("OpenGrok Notifications"); jTextArea1.setColumns(20); jTextArea1.setEditable(false); jTextArea1.setRows(5); notificationsPane.setViewportView(jTextArea1); closeButton.setText("Close"); closeButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { closeButtonActionPerformed(evt); } }); jLabel1.setText("Files changed:"); jLabel2.setText("Last Index Start:"); startTimeLabel.setText("no time"); jLabel4.setText("Last Index End:"); endTimelabel.setText("no time"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(notificationsPane, javax.swing.GroupLayout.DEFAULT_SIZE, 424, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel2) .addComponent(jLabel4)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(startTimeLabel) .addComponent(endTimelabel))) .addComponent(jLabel1) .addComponent(closeButton, javax.swing.GroupLayout.Alignment.TRAILING)) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(startTimeLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel4) .addComponent(endTimelabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(notificationsPane, javax.swing.GroupLayout.DEFAULT_SIZE, 237, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(closeButton) .addContainerGap()) ); pack(); }// //GEN-END:initComponents @SuppressWarnings("unused") private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeButtonActionPerformed this.dispose(); }//GEN-LAST:event_closeButtonActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new NotificationsFrame("",0,0).setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton closeButton; private javax.swing.JLabel endTimelabel; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel4; private javax.swing.JTextArea jTextArea1; private javax.swing.JScrollPane notificationsPane; private javax.swing.JLabel startTimeLabel; // End of variables declaration//GEN-END:variables }