List of usage examples for javax.swing.event ChangeListener ChangeListener
ChangeListener
From source file:tk.tomby.tedit.core.Workspace.java
/** * Creates a new WorkSpace object.//from w w w. java2s .c o m */ public Workspace() { super(); setLayout(new BorderLayout()); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); MessageManager.addMessageListener(MessageManager.BUFFER_GROUP_NAME, new IMessageListener<BufferMessage>() { public void receiveMessage(BufferMessage message) { Workspace.this.receiveMessage(message); } }); MessageManager.addMessageListener(MessageManager.PREFERENCE_GROUP_NAME, new IMessageListener<PreferenceMessage>() { public void receiveMessage(PreferenceMessage message) { Workspace.this.receiveMessage(message); } }); bufferPane = new JTabbedPane(); bufferPane.setMinimumSize(new Dimension(600, 400)); bufferPane.setPreferredSize(new Dimension(800, 600)); bufferPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); bottomPort = createDockingPort(0, 80); rightPort = createDockingPort(80, 0); leftPort = createDockingPort(80, 0); splitPaneRight = createSplitPane(JSplitPane.HORIZONTAL_SPLIT, bufferPane, rightPort); splitPaneLeft = createSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPort, splitPaneRight); splitPaneBottom = createSplitPane(JSplitPane.VERTICAL_SPLIT, splitPaneLeft, bottomPort); bufferPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { MessageManager .sendMessage(new WorkspaceMessage(evt.getSource(), bufferPane.getSelectedComponent())); } }); bufferPane.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { if (evt.getClickCount() == 2) { splitPaneLeft.setDividerLocation(0.0d); splitPaneBottom.setDividerLocation(1.0d); splitPaneRight.setDividerLocation(1.0d); } } }); DropTarget dropTarget = new DropTarget(bufferPane, new DropTargetAdapter() { public void drop(DropTargetDropEvent dtde) { if (log.isDebugEnabled()) { log.debug("drop start"); } try { if (log.isDebugEnabled()) { log.debug(dtde.getSource()); } Transferable tr = dtde.getTransferable(); DataFlavor[] flavors = tr.getTransferDataFlavors(); for (int i = 0; i < flavors.length; i++) { DataFlavor flavor = flavors[i]; if (log.isDebugEnabled()) { log.debug("mime-type:" + flavor.getMimeType()); } if (flavor.isMimeTypeEqual("text/plain")) { final Object obj = tr.getTransferData(flavor); if (log.isDebugEnabled()) { log.debug(obj); } if (obj instanceof String) { TaskManager.execute(new Runnable() { public void run() { BufferFactory factory = new BufferFactory(); IBuffer buffer = factory.createBuffer(); buffer.open((String) obj); addBuffer(buffer); } }); } dtde.dropComplete(true); return; } } } catch (UnsupportedFlavorException e) { log.warn(e.getMessage(), e); } catch (IOException e) { log.warn(e.getMessage(), e); } dtde.rejectDrop(); if (log.isDebugEnabled()) { log.debug("drop end"); } } }); bufferPane.setDropTarget(dropTarget); this.add(BorderLayout.CENTER, splitPaneBottom); }
From source file:uk.ac.ebi.demo.picr.swing.PICRBLASTDemo.java
public PICRBLASTDemo() { //set general layout setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); add(Box.createVerticalStrut(5)); //create components JPanel row1 = new JPanel(); row1.setLayout(new BoxLayout(row1, BoxLayout.X_AXIS)); row1.add(Box.createHorizontalStrut(5)); row1.setBorder(BorderFactory.createTitledBorder("")); row1.add(new JLabel("Fragment:")); row1.add(Box.createHorizontalStrut(10)); final JTextArea sequenceArea = new JTextArea(5, 40); sequenceArea.setMaximumSize(sequenceArea.getPreferredSize()); row1.add(Box.createHorizontalStrut(10)); row1.add(sequenceArea);/*www . j a v a 2s .c om*/ row1.add(Box.createHorizontalGlue()); JPanel row2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); row2.setBorder(BorderFactory.createTitledBorder("Target Databases")); final JList databaseList = new JList(); JScrollPane listScroller = new JScrollPane(databaseList); listScroller.setMaximumSize(new Dimension(100, 10)); JButton loadDBButton = new JButton("Load Databases"); row2.add(listScroller); row2.add(loadDBButton); JPanel row3 = new JPanel(new FlowLayout(FlowLayout.LEFT)); JCheckBox onlyActiveCheckBox = new JCheckBox("Only Active"); onlyActiveCheckBox.setSelected(true); row3.add(new JLabel("Options: ")); row3.add(onlyActiveCheckBox); add(row1); add(row2); add(row3); final String[] columns = new String[] { "Database", "Accession", "Version", "Taxon ID" }; final JTable dataTable = new JTable(new Object[0][0], columns); dataTable.setShowGrid(true); add(new JScrollPane(dataTable)); JPanel buttonPanel = new JPanel(); JButton mapAccessionButton = new JButton("Generate Mapping!"); buttonPanel.add(mapAccessionButton); add(buttonPanel); //create listeners! //update boolean flag in communication class onlyActiveCheckBox.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { client.setOnlyActive(((JCheckBox) e.getSource()).isSelected()); } }); //performs mapping call and updates interface with results mapAccessionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { if (!"".equals(sequenceArea.getText())) { //TODO filters and database are hardcoded here. They should be added to the input panel at a later revision. java.util.List<UPEntry> entries = client.performBlastMapping(sequenceArea.getText(), databaseList.getSelectedValues(), "90", "", "IDENTITY", "UniprotKB", "", false, new BlastParameter()); //compute size of array if (entries != null) { int size = 0; for (UPEntry entry : entries) { for (CrossReference xref : entry.getIdenticalCrossReferences()) { size++; } for (CrossReference xref : entry.getLogicalCrossReferences()) { size++; } } if (size > 0) { final Object[][] data = new Object[size][4]; int i = 0; for (UPEntry entry : entries) { for (CrossReference xref : entry.getIdenticalCrossReferences()) { data[i][0] = xref.getDatabaseName(); data[i][1] = xref.getAccession(); data[i][2] = xref.getAccessionVersion(); data[i][3] = xref.getTaxonId(); i++; } for (CrossReference xref : entry.getLogicalCrossReferences()) { data[i][0] = xref.getDatabaseName(); data[i][1] = xref.getAccession(); data[i][2] = xref.getAccessionVersion(); data[i][3] = xref.getTaxonId(); i++; } } //refresh DefaultTableModel dataModel = new DefaultTableModel(); dataModel.setDataVector(data, columns); dataTable.setModel(dataModel); System.out.println("update done"); } else { JOptionPane.showMessageDialog(null, "No Mappind data found."); } } else { JOptionPane.showMessageDialog(null, "No Mappind data found."); } } else { JOptionPane.showMessageDialog(null, "You must enter a valid FASTA sequence to map."); } } catch (SOAPFaultException soapEx) { JOptionPane.showMessageDialog(null, "A SOAP Error occurred."); soapEx.printStackTrace(); } } }); //loads list of mapping databases from communication class loadDBButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { java.util.List<String> databases = client.loadDatabases(); if (databases != null && databases.size() > 0) { databaseList.setListData(databases.toArray()); System.out.println("database refresh done"); } else { JOptionPane.showMessageDialog(null, "No Databases Loaded!."); } } catch (SOAPFaultException soapEx) { JOptionPane.showMessageDialog(null, "A SOAP Error occurred."); soapEx.printStackTrace(); } } }); }
From source file:uk.ac.ucl.chem.ccs.clinicalgui.DisplayJobPanel.java
private void initGUI() { if (ajo == null) { try {// w ww. ja v a 2 s . c o m setPreferredSize(new Dimension(400, 300)); } catch (Exception e) { e.printStackTrace(); } //JLabel l = new JLabel("No simulation running"); //this.add(l); //this.setEnabled(false); return; } System.out.println("I am not null: drawing the display job panel"); try { TableLayout thisLayout = new TableLayout(new double[][] { { TableLayout.FILL }, { TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.FILL, TableLayout.FILL } }); thisLayout.setHGap(5); thisLayout.setVGap(5); this.setLayout(thisLayout); { jPanel1 = new JPanel(); TableLayout jPanel1Layout = new TableLayout(new double[][] { { TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.PREFERRED, TableLayout.PREFERRED }, { TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL } }); jPanel1Layout.setHGap(5); jPanel1Layout.setVGap(5); jPanel1.setLayout(jPanel1Layout); jPanel1.setLayout(jPanel1Layout); jPanel1.setBorder(BorderFactory.createEtchedBorder()); this.add(jPanel1, "0, 0, 0, 2"); jPanel1.setPreferredSize(new java.awt.Dimension(630, 305)); jPanel1.setSize(630, 305); { dtails = new JPanel(); GridLayout dtailsLayout = new GridLayout(1, 1); dtailsLayout.setColumns(1); dtailsLayout.setHgap(5); dtailsLayout.setVgap(5); dtails.setBorder(BorderFactory.createTitledBorder("Job Details")); jPanel1.add(dtails, "0, 0, 2, 4"); dtails.setLayout(dtailsLayout); { jobDetailsSP = new JScrollPane(); dtails.add(jobDetailsSP); { jPanel3 = new JPanel(); TableLayout jPanel3Layout = new TableLayout( new double[][] { { TableLayout.PREFERRED, TableLayout.FILL }, { TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL } }); jPanel3Layout.setHGap(5); jPanel3Layout.setVGap(5); jPanel3.setLayout(jPanel3Layout); jobDetailsSP.setViewportView(jPanel3); jPanel3.setBackground(new java.awt.Color(156, 199, 219)); { jLabel2 = new JLabel(); jPanel3.add(jLabel2, "0, 0"); jLabel2.setText("Job Start Time"); } { jLabel3 = new JLabel(); jPanel3.add(jLabel3, "0, 1"); jLabel3.setText("Resource ID"); } { jLabel4 = new JLabel(); jPanel3.add(jLabel4, "0, 2"); jLabel4.setText("Job Type"); } { jLabel5 = new JLabel(); jPanel3.add(jLabel5, "0, 3"); jLabel5.setText("Status"); } { jLabel6 = new JLabel(); jPanel3.add(jLabel6, "0, 4"); jLabel6.setText("Machine"); } { jLabel7 = new JLabel(); jPanel3.add(jLabel7, "0, 5"); jLabel7.setText("CPUs Requested"); } { jLabel8 = new JLabel(); jPanel3.add(jLabel8, "0, 6"); jLabel8.setText("Configuration File"); } { jLabel9 = new JLabel(); jPanel3.add(jLabel9, "0, 7"); jLabel9.setText("Job Arguments"); } { jLabel10 = new JLabel(); jPanel3.add(jLabel10, "0, 8"); jLabel10.setText("Job Stdout"); } { jLabel11 = new JLabel(); jPanel3.add(jLabel11, "0, 9"); jLabel11.setText("Job Stderr"); } { jLabel12 = new JLabel(); jPanel3.add(jLabel12, "0, 10"); jLabel12.setText("Job Stdin"); } { jLabel13 = new JLabel(); jPanel3.add(jLabel13, "0, 11"); jLabel13.setText("Resource Endpoint"); } { jobName = new JTextField(); jPanel3.add(jobName, "1, 0"); jobName.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 1, false)); jobName.setOpaque(true); jobName.setBackground(new java.awt.Color(255, 255, 255)); jobName.setEditable(false); } { resourceID = new JTextField(); jPanel3.add(resourceID, "1, 1"); resourceID.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 1, false)); resourceID.setOpaque(true); resourceID.setBackground(new java.awt.Color(255, 255, 255)); resourceID.setEditable(false); } { jobType = new JTextField(); jPanel3.add(jobType, "1, 2"); jobType.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 1, false)); jobType.setBackground(new java.awt.Color(255, 255, 255)); jobType.setOpaque(true); jobType.setEditable(false); } { jobStatus = new JLabel(); jPanel3.add(jobStatus, "1, 3"); jobStatus.setOpaque(true); jobStatus.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 1, false)); jobStatus.setBackground(new java.awt.Color(255, 255, 255)); } { rm = new JTextField(); jPanel3.add(rm, "1, 4"); rm.setBackground(new java.awt.Color(255, 255, 255)); rm.setOpaque(true); rm.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 1, false)); rm.setEditable(false); } { jobCpus = new JTextField(); jPanel3.add(jobCpus, "1, 5"); jobCpus.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 1, false)); jobCpus.setOpaque(true); jobCpus.setBackground(new java.awt.Color(255, 255, 255)); jobCpus.setEditable(false); } { jobConf = new JTextField(); jPanel3.add(jobConf, "1, 6"); jobConf.setBackground(new java.awt.Color(255, 255, 255)); jobConf.setOpaque(true); jobConf.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 1, false)); jobConf.setEditable(false); } { jobArgs = new JTextField(); jPanel3.add(jobArgs, "1, 7"); jobArgs.setBackground(new java.awt.Color(255, 255, 255)); jobArgs.setOpaque(true); jobArgs.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 1, false)); jobArgs.setEditable(false); } { jobSdtout = new JTextField(); jPanel3.add(jobSdtout, "1, 8"); jobSdtout.setBackground(new java.awt.Color(255, 255, 255)); jobSdtout.setOpaque(true); jobSdtout.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 1, false)); jobSdtout.setEditable(false); } { jobStderr = new JTextField(); jPanel3.add(jobStderr, "1, 9"); jobStderr.setBackground(new java.awt.Color(255, 255, 255)); jobStderr.setOpaque(true); jobStderr.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 1, false)); jobStderr.setEditable(false); } { jobStdin = new JTextField(); jPanel3.add(jobStdin, "1, 10"); jobStdin.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 1, false)); jobStdin.setBackground(new java.awt.Color(255, 255, 255)); jobStdin.setOpaque(true); jobStdin.setEditable(false); } { jobEPR = new JTextField(); jPanel3.add(jobEPR, "1, 11"); jobEPR.setOpaque(true); jobEPR.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 1, false)); jobEPR.setBackground(new java.awt.Color(255, 255, 255)); jobEPR.setEditable(false); } } } } { controls = new JPanel(); TableLayout controlsLayout = new TableLayout(new double[][] { { TableLayout.FILL }, { TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL } }); controlsLayout.setHGap(5); controlsLayout.setVGap(5); controls.setLayout(controlsLayout); controls.setBorder(BorderFactory.createTitledBorder("Operations")); jPanel1.add(controls, "3, 0, 4, 2"); { updateStatus = new JButton(); controls.add(updateStatus, "0, 0"); updateStatus.setText("Update Job Status"); updateStatus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (updateStatus.getText().equals("Start Job")) { StartCall sc = new StartCall(ajo, ClinicalGuiClient.prop .getProperty("uk.ac.ucl.chem.ccs.aheclient.myproxy-lifetime"), ClinicalGuiClient.prop .getProperty("uk.ac.ucl.chem.ccs.aheclient.myproxy-port"), ClinicalGuiClient.prop .getProperty("uk.ac.ucl.chem.ccs.aheclient.myproxy-dn"), ClinicalGuiClient.prop .getProperty("uk.ac.ucl.chem.ccs.aheclient.myproxy-server"), ClinicalGuiClient.prop .getProperty("uk.ac.ucl.chem.ccs.aheclient.myproxy-pw"), ClinicalGuiClient.prop .getProperty("uk.ac.ucl.chem.ccs.aheclient.myproxy-un")); ajo = sc.makeCall(); updatePanel(); } else { pollJobState(); } } }); } { teminateJob = new JButton(); controls.add(teminateJob, "0, 1"); teminateJob.setText("Terminate Job"); teminateJob.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { TerminateSimCall tsc = new TerminateSimCall(ajo.getEndPoint()); DisplayJobPanel.this.setCursor(new Cursor(Cursor.WAIT_CURSOR)); boolean tcsstatus = tsc.makeCall(); DisplayJobPanel.this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); if (tcsstatus) { ajo.setState(AHEJobObject.GRIDSAM_TERMINATING); updateState(); } else { ErrorMessage em = new ErrorMessage(DisplayJobPanel.this, "Error terminating job. Check log for details"); ; } } }); } { vizButton = new JButton(); controls.add(vizButton, "0, 2"); vizButton.setText("Visualize"); vizButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String h = "localhost"; int p = 65250; int w = 1024 * 1024; VizSteererWindow vs = new VizSteererWindow(h, p, w, (JFrame) DisplayJobPanel.this.getTopLevelAncestor()); } }); } { deleteFiles = new JCheckBox(); controls.add(deleteFiles, "0, 3"); deleteFiles.setText("Delete staged files when destroying job"); deleteFiles.setFont(new java.awt.Font("Sansserif", 0, 11)); deleteFiles.setSelected(true); } } { polling = new JPanel(); GridBagLayout pollingLayout = new GridBagLayout(); pollingLayout.rowWeights = new double[] { 0.1, 0.1, 0.1, 0.1 }; pollingLayout.rowHeights = new int[] { 7, 7, 7, 7 }; pollingLayout.columnWeights = new double[] { 0.0, 0.1 }; pollingLayout.columnWidths = new int[] { 109, 7 }; polling.setBorder(BorderFactory.createTitledBorder("Status Polling")); jPanel1.add(polling, "3, 3, 4, 4"); polling.setLayout(pollingLayout); { jLabel1 = new JLabel(); polling.add(jLabel1, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel1.setText("Set the polling interval "); jLabel1.setFont(new java.awt.Font("Sansserif", 0, 11)); } { jSlider1 = new JSlider(); polling.add(jSlider1, new GridBagConstraints(0, 1, 2, 2, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); jSlider1.setMaximum(60); jSlider1.setValue(0); //jSlider1.setMinorTickSpacing(1); //jSlider1.createStandardLabels(5); Hashtable lab = new Hashtable(); lab.put(new Integer(0), new JLabel("0")); lab.put(new Integer(20), new JLabel("10")); lab.put(new Integer(40), new JLabel("20")); lab.put(new Integer(60), new JLabel("30")); jSlider1.setLabelTable(lab); jSlider1.setPaintTicks(true); jSlider1.setPaintLabels(true); jSlider1.setSnapToTicks(false); jSlider1.setMajorTickSpacing(2); jSlider1.setFont(new java.awt.Font("Sansserif", 0, 11)); jSlider1.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (jSlider1.getValue() != 0) { Integer i = new Integer(jSlider1.getValue()); time1.setText(Float.toString(i.floatValue() / 2)); if (pollingButton.getText().equals("Stop Polling")) { pollTimer.stop(); pollTimer.setInitialDelay(jSlider1.getValue() * 30000); pollTimer.setDelay(jSlider1.getValue() * 30000); pollTimer.start(); } } else { if (pollingButton.getText().equals("Stop Polling")) { pollTimer.stop(); pollingButton.setText("Start Polling"); } time1.setText("0.0"); } } }); } { pollingButton = new JButton(); polling.add(pollingButton, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.SOUTHEAST, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 0), 0, 0)); pollingButton.setText("Start Polling"); pollingButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (jSlider1.getValue() > 0) { if (pollingButton.getText().equals("Start Polling")) { pollTimer = new Timer(jSlider1.getValue() * 30000, new ActionListener() { public void actionPerformed(ActionEvent evt) { pollJobState(); } }); pollTimer.setInitialDelay(1); pollTimer.start(); pollingButton.setText("Stop Polling"); } else { pollTimer.stop(); pollingButton.setText("Start Polling"); } } } }); } { time = new JLabel(); polling.add(time, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 0), 0, 0)); time.setBackground(new java.awt.Color(255, 255, 255)); time.setText("Every"); } { jLabel14 = new JLabel(); polling.add(jLabel14, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel14.setText("mins"); } { time1 = new JLabel(); polling.add(time1, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 0), 0, 0)); time1.setText("0.0"); ; } } } { jPanel2 = new JPanel(); GridLayout jPanel2Layout = new GridLayout(1, 1); jPanel2Layout.setColumns(1); jPanel2Layout.setHgap(5); jPanel2Layout.setVgap(5); jPanel2.setLayout(jPanel2Layout); TitledBorder title2; title2 = BorderFactory.createTitledBorder("Job Output"); jPanel2.setBorder(title2); this.add(jPanel2, "0, 3, 0, 4"); jPanel2.setPreferredSize(new java.awt.Dimension(630, 254)); { jTabbedPane1 = new JTabbedPane(); jPanel2.add(jTabbedPane1); { gridsamStatus = new JPanel(); GridLayout gridsamStatusLayout = new GridLayout(1, 1); gridsamStatusLayout.setColumns(1); gridsamStatusLayout.setHgap(5); gridsamStatusLayout.setVgap(5); gridsamStatus.setLayout(gridsamStatusLayout); jTabbedPane1.addTab("AHE Job Status", null, gridsamStatus, null); { jScrollPane1 = new JScrollPane(); gridsamStatus.add(jScrollPane1); { gridsamStatusResults = new JTextArea(); jScrollPane1.setViewportView(gridsamStatusResults); gridsamStatusResults.setFont(new java.awt.Font("Monospaced", 0, 12)); } } } { stagedFiles = new JPanel(); TableLayout stagedFilesLayout = new TableLayout(new double[][] { { TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.PREFERRED, TableLayout.PREFERRED }, { TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.PREFERRED } }); stagedFilesLayout.setHGap(5); stagedFilesLayout.setVGap(5); stagedFiles.setLayout(stagedFilesLayout); jTabbedPane1.addTab("Staged Files", null, stagedFiles, null); { filesScrollPane = new JScrollPane(); stagedFiles.add(filesScrollPane, "0, 0, 5, 4"); { outputFilesTable = new JTable(); int col1 = 0, col2 = 0; int fsize = outputFilesTable.getFont().getSize() - 5; Object data[][] = new Object[ajo.getOutfiles().size() + ajo.getInfiles().size()][3]; int i = 0; if (ajo.getOutfiles() != null) { Iterator it = ajo.getOutfiles().iterator(); while (it.hasNext()) { JobFileElement je = (JobFileElement) it.next(); data[i][0] = new Boolean(true); data[i][1] = je.getName(); if (je.getName().length() > col1) { col1 = je.getName().length(); } String url = Tools.getUrlNoUP(je.getRemotepath()); data[i][2] = url; if (url.length() > col2) { col2 = url.length(); } i++; } } if (ajo.getInfiles() != null) { Iterator it = ajo.getInfiles().iterator(); while (it.hasNext()) { JobFileElement je = (JobFileElement) it.next(); data[i][0] = new Boolean(false); data[i][1] = je.getName(); if (je.getName().length() > col1) { col1 = je.getName().length(); } String url = Tools.getUrlNoUP(je.getRemotepath()); data[i][2] = url; if (url.length() > col2) { col2 = url.length(); } i++; } } String colNames[] = { "Download", "File Name", "File Location" }; TableModel outputFilesTableModel = new MyTableModel(data, colNames); outputFilesTable.setIntercellSpacing(new Dimension(3, 3)); outputFilesTable.setModel(outputFilesTableModel); outputFilesTable.getColumnModel().getColumn(0).setPreferredWidth(70); outputFilesTable.getColumnModel().getColumn(1).setPreferredWidth(col1 * fsize); outputFilesTable.getColumnModel().getColumn(2).setPreferredWidth(col2 * fsize); outputFilesTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); filesScrollPane.setViewportView(outputFilesTable); this.addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent e) { if (outputFilesTable.getWidth() < filesScrollPane.getWidth()) { outputFilesTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); } else { outputFilesTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); } } }); } } { downloadButton = new JButton(); stagedFiles.add(downloadButton, "5, 5"); downloadButton.setText("Download"); downloadButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { int outFileSize = ajo.getOutfiles().size(); for (int row = 0; row < outputFilesTable.getRowCount(); row++) { if (((Boolean) outputFilesTable.getValueAt(row, 0)) .booleanValue() == true) { if (row < outFileSize) { JobFileElement je = (JobFileElement) ajo.getOutfiles() .elementAt(row); if (fileLocation != null) { je.setLocalpath(Tools.checkURL(fileLocation) + je.getName()); } downloadFiles.add(je); } else { JobFileElement je = (JobFileElement) ajo.getInfiles() .elementAt(row - outFileSize); if (fileLocation != null) { je.setLocalpath(Tools.checkURL(fileLocation) + je.getName()); } downloadFiles.add(je); } } } StageFilesIn task = new StageFilesIn( ClinicalGuiClient.prop .getProperty("uk.ac.ucl.chem.ccs.aheclient.ahedavserver"), ClinicalGuiClient.prop .getProperty("uk.ac.ucl.chem.ccs.aheclient.ahedavuser"), ClinicalGuiClient.prop .getProperty("uk.ac.ucl.chem.ccs.aheclient.ahedavpasswd")); task.init(downloadFiles); ProgressMonitor progressMonitor = new ProgressMonitor(DisplayJobPanel.this, "Downloading Files", null, 0, task.getLength()); //progressMonitor.setMillisToDecideToPopup(1); progressMonitor.setMillisToPopup(100); //jProgressBar1.setMaximum(task.getLength()); //jProgressBar1.setValue(0); while (task.filesToStage()) { if (task.stageNext()) { progressMonitor.setProgress(task.getCurrent()); } else { cat.error(task.getError()); } } } }); } { changeLocationButton = new JButton(); stagedFiles.add(changeLocationButton, "4, 5"); changeLocationButton.setText("Local Dir"); changeLocationButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { JFileChooser fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = fc.showOpenDialog(DisplayJobPanel.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); fileLocation = file.getAbsolutePath(); //System.out.println(fileLocation); } } }); } } { if (ajo.getReGSWSEPR() != null) { regSteering = new JPanel(); TableLayout steerLayout = new TableLayout( new double[][] { { TableLayout.FILL }, { TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL } }); regSteering.setLayout(steerLayout); steeredApp = true; jTabbedPane1.addTab("ReG Steering", null, regSteering, null); { JLabel look = new JLabel("Steering address"); steerERP = new JTextField(); steer = new JButton("Start Steerer"); steer.setEnabled(false); steer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { vs = new VizSteererWindow(h, p, w, DisplayJobPanel.this.getTopLevelAncestor()); } }); regSteering.add(look, "0,1"); regSteering.add(steerERP, "0,2"); regSteering.add(steer, "0,3"); } } } } } updatePanel(); this.setPreferredSize(new java.awt.Dimension(630, 605)); this.setSize(630, 605); this.setOpaque(false); } catch (Exception e) { e.printStackTrace(); } }
From source file:uk.nhs.cfh.dsp.srth.desktop.modules.simulator.viewcomponent.DataGenerationPanel.java
/** * Inits the components.// ww w .j ava 2 s.c o m */ public synchronized void initComponents() { while (activeFrame == null) { if (applicationService != null && applicationService.getFrameView() != null) { activeFrame = applicationService.getFrameView().getActiveFrame(); } } JPanel runPanel = new JPanel(); runPanel.setLayout(new BoxLayout(runPanel, BoxLayout.LINE_AXIS)); runPanel.setBorder(BorderFactory.createEmptyBorder(paddingSize, paddingSize, paddingSize, paddingSize)); JXLabel label = new JXLabel(); label.setLineWrap(true); label.setText( "<html>This panel allows the creation of clinically plausible data based on a query specification. " + "Please note that you <b>must</b> always specify a data generation source. " + "The rest of the parameters can be left in their default state. When you've configured the parameters " + "click the 'Generate data' button.</html>"); runPanel.add(label); runPanel.add(new JSeparator(SwingConstants.VERTICAL)); runPanel.add(Box.createHorizontalStrut(paddingSize)); JideButton runButton = new JideButton(new GenerateDataAction(applicationService, queryService, dataGenerationEngine, propertyChangeTrackerService)); runButton.setButtonStyle(ButtonStyle.HYPERLINK_STYLE); runPanel.add(runButton); runButton.setIcon(new ImageIcon(DataGenerationPanel.class.getResource("resources/linuxconf.png"))); runPanel.add(Box.createHorizontalStrut(paddingSize)); // create radio buttons for choosing source JRadioButton queryButton = new JRadioButton("Active Query"); queryButton.setSelected(true); queryButton.addActionListener(this); queryButton.setActionCommand("activeQuery"); JRadioButton fileButton = new JRadioButton("File"); fileButton.addActionListener(this); fileButton.setActionCommand("file"); JRadioButton folderButton = new JRadioButton("Folder"); folderButton.addActionListener(this); folderButton.setActionCommand("folder"); ButtonGroup bg = new ButtonGroup(); bg.add(queryButton); bg.add(fileButton); bg.add(folderButton); JPanel buttonsPanel = new JPanel(); buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.LINE_AXIS)); // buttonsPanel.add(new JLabel("Select data generation source")); buttonsPanel.setBorder(BorderFactory.createTitledBorder("Select data generation source")); buttonsPanel.add(Box.createHorizontalStrut(paddingSize)); buttonsPanel.add(queryButton); buttonsPanel.add(Box.createHorizontalStrut(paddingSize)); buttonsPanel.add(fileButton); buttonsPanel.add(Box.createHorizontalStrut(paddingSize)); buttonsPanel.add(folderButton); locationField = new JTextField(100); JButton loadQueryButton = new JButton("Browse"); loadQueryButton.addActionListener(this); loadQueryButton.setActionCommand("load"); locationPanel = new JPanel(); locationPanel.setLayout(new BoxLayout(locationPanel, BoxLayout.LINE_AXIS)); locationPanel.add(new JLabel("Load file from")); locationPanel.add(Box.createHorizontalStrut(paddingSize)); locationPanel.add(locationField); locationPanel.add(Box.createHorizontalStrut(paddingSize)); locationPanel.add(loadQueryButton); JPanel lhsPanel = new JPanel(new GridLayout(0, 2)); JPanel rhsPanel = new JPanel(new GridLayout(0, 2)); lhsPanel.add(new JLabel("Max number of patients to generate")); SpinnerNumberModel model = new SpinnerNumberModel(initialPatientsNumber, 1, 1000000, 1); ptNumberSpinner = new JSpinner(model); ptNumberSpinner.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent event) { // get value currently selected in spinner and set in engine dataGenerationEngine.setMaxPatientNumber(Long.parseLong(ptNumberSpinner.getValue().toString())); // Object value = ptNumberSpinner.getValue(); // if(value instanceof Double) // { // Double d = (Double) ptNumberSpinner.getValue(); // dataGenerationEngine.setMaxPatientNumber(d.longValue()); // } // else // { // dataGenerationEngine.setMaxPatientNumber(Long.parseLong(ptNumberSpinner.getValue().toString())); // } logger.debug("ptNumberSpinner.getValue().getClass() = " + ptNumberSpinner.getValue().getClass()); logger.debug("Max pt number in engine set to : " + dataGenerationEngine.getMaxPatientNumber()); } }); lhsPanel.add(ptNumberSpinner); lhsPanel.add(new JLabel("Min age of patients to generate")); SpinnerNumberModel ageModel = new SpinnerNumberModel(initialMinimumAge, 1, 120, 1); minAgeSpinner = new JSpinner(ageModel); minAgeSpinner.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { // set min pt age to current value dataGenerationEngine.setMinPatientAgeInYears(Integer.parseInt(minAgeSpinner.getValue().toString())); logger.debug("Value of engine.getMinPatientAgeInYears() : " + dataGenerationEngine.getMinPatientAgeInYears()); } }); lhsPanel.add(minAgeSpinner); lhsPanel.add(new JLabel("Data generation strategy")); generationStrategyBox = new JComboBox(DataGenerationEngine.DataGenerationStrategy.values()); generationStrategyBox.setSelectedItem(DataGenerationEngine.DataGenerationStrategy.ADD_IF_NOT_EXISTS); generationStrategyBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dataGenerationEngine.setDataGenerationStrategy( (DataGenerationEngine.DataGenerationStrategy) generationStrategyBox.getSelectedItem()); } }); lhsPanel.add(generationStrategyBox); includeExcludedTermsBox = new JCheckBox(new AbstractAction("Include Excluded terms in data") { public void actionPerformed(ActionEvent arg0) { dataGenerationEngine.setIncludeExcludedTerms(includeExcludedTermsBox.isSelected()); logger.debug("dataGenerationEngine.isIncludeExcludedTerms() = " + dataGenerationEngine.isIncludeExcludedTerms()); } }); rhsPanel.add(includeExcludedTermsBox); randomiseNumericalValuesBox = new JCheckBox(new AbstractAction("Randomise Numerical values in data") { public void actionPerformed(ActionEvent arg0) { dataGenerationEngine.setRandomiseNumericalValues(randomiseNumericalValuesBox.isSelected()); logger.debug("dataGenerationEngine.isRandomiseNumericalValues() = " + dataGenerationEngine.isRandomiseNumericalValues()); } }); rhsPanel.add(randomiseNumericalValuesBox); refineQualifiersCheckBox = new JCheckBox(new AbstractAction("Refine Qualifiers in expression") { public void actionPerformed(ActionEvent e) { dataGenerationEngine.setRefineQualifiers(refineQualifiersCheckBox.isSelected()); logger.debug( "dataGenerationEngine.isRefineQualifiers() = " + dataGenerationEngine.isRefineQualifiers()); } }); rhsPanel.add(refineQualifiersCheckBox); includePreCoordinatedDataCheckBox = new JCheckBox( new AbstractAction("Include pre-coordinated expressions") { public void actionPerformed(ActionEvent e) { dataGenerationEngine .setIncludePrecoordinatedData(includePreCoordinatedDataCheckBox.isSelected()); logger.debug("dataGenerationEngine.isIncludePrecoordinatedData() = " + dataGenerationEngine.isIncludePrecoordinatedData()); } }); rhsPanel.add(includePreCoordinatedDataCheckBox); rhsPanel.add(new JLabel(" ")); /* * create panel for parametrising engine */ JPanel parametrisationPanel = new JPanel(); parametrisationPanel.setLayout(new GridLayout(0, 2)); parametrisationPanel.setBorder(BorderFactory.createTitledBorder("Engine Parameters")); // add panels to parametrisation panel parametrisationPanel.add(lhsPanel); parametrisationPanel.add(rhsPanel); JPanel topPanel = new JPanel(); topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.LINE_AXIS)); topPanel.add(runPanel); topPanel.add(new JSeparator(SwingConstants.VERTICAL)); topPanel.add(buttonsPanel); // add all panels to this component setLayout(new BorderLayout()); add(topPanel, BorderLayout.NORTH); add(parametrisationPanel, BorderLayout.CENTER); // initialise values populateFields(dataGenerationEngine); }
From source file:view.AppearanceSettingsDialog.java
/** * Creates new form NewJDialog/*ww w . ja va 2 s . com*/ * * @param parent * @param modal * @param signatureSettings */ public AppearanceSettingsDialog(java.awt.Frame parent, boolean modal, CCSignatureSettings signatureSettings) { super(parent, modal); initComponents(); this.signatureSettings = signatureSettings; updateText(); // Pastas conforme o SO ArrayList<String> dirs = new ArrayList<>(); if (SystemUtils.IS_OS_WINDOWS) { dirs.add(System.getenv("windir") + File.separator + "fonts"); } else if (SystemUtils.IS_OS_LINUX) { dirs.add("/usr/share/fonts/truetype/"); dirs.add("/usr/X11R6/lib/X11/fonts/"); } else if (SystemUtils.IS_OS_MAC_OSX) { dirs.add("/Library/Fonts"); dirs.add("/System/Library/Fonts"); } dirs.add("extrafonts"); // Hashmap com fonts hmFonts = getAllFonts(dirs); ArrayList<com.itextpdf.text.Font> alFonts = new ArrayList<>(hmFonts.keySet()); Collections.sort(alFonts, new Comparator<com.itextpdf.text.Font>() { @Override public int compare(com.itextpdf.text.Font f1, com.itextpdf.text.Font f2) { return f1.getFamilyname().compareToIgnoreCase(f2.getFamilyname()); } }); DefaultComboBoxModel dcbm = new DefaultComboBoxModel(); for (com.itextpdf.text.Font font : alFonts) { dcbm.addElement(font.getFamilyname()); } cbFontType.setModel(dcbm); String fontLocation = signatureSettings.getAppearance().getFontLocation(); boolean italic = signatureSettings.getAppearance().isItalic(); boolean bold = signatureSettings.getAppearance().isBold(); boolean showName = signatureSettings.getAppearance().isShowName(); boolean showLocation = signatureSettings.getAppearance().isShowLocation(); boolean showReason = signatureSettings.getAppearance().isShowReason(); boolean showDate = signatureSettings.getAppearance().isShowDate(); int align = signatureSettings.getAppearance().getAlign(); switch (align) { case 0: cbAlign.setSelectedIndex(0); break; case 1: cbAlign.setSelectedIndex(1); break; case 2: cbAlign.setSelectedIndex(2); break; default: cbAlign.setSelectedIndex(0); } previewPanel1.setReason(signatureSettings.getReason()); previewPanel1.setShowDate(showDate); if (signatureSettings.getCcAlias() != null) { previewPanel1.setAliasName(signatureSettings.getCcAlias().getName()); } else { previewPanel1.setAliasName(Bundle.getBundle().getString("name")); } if (!signatureSettings.getLocation().isEmpty()) { previewPanel1.setLocation(signatureSettings.getLocation()); cbShowLocation.setSelected(showLocation); previewPanel1.setShowLocation(showLocation); } else { cbShowLocation.setEnabled(false); cbShowLocation.setSelected(false); } cbShowName.setSelected(showName); previewPanel1.setShowName(showName); if (!signatureSettings.getReason().isEmpty()) { previewPanel1.setReason(signatureSettings.getReason()); cbShowReason.setSelected(showReason); previewPanel1.setShowReason(showReason); } else { cbShowReason.setEnabled(false); cbShowReason.setSelected(false); } previewPanel1.setText(signatureSettings.getText()); previewPanel1.setAlign(align); colorChooser.setPreviewPanel(new JPanel()); Color color = signatureSettings.getAppearance().getFontColor(); colorChooser.setColor(color); lblSampleText.setForeground(color); cbShowReason.setSelected(showReason); cbShowLocation.setSelected(showLocation); cbShowDateTime.setSelected(showDate); ColorSelectionModel model = colorChooser.getSelectionModel(); ChangeListener changeListener = new ChangeListener() { @Override public void stateChanged(ChangeEvent changeEvent) { Color newForegroundColor = colorChooser.getColor(); lblSampleText.setForeground(newForegroundColor); } }; model.addChangeListener(changeListener); if (fontLocation.contains("aCCinaPDF" + File.separator + "extrafonts")) { try { Font newFont = Font.createFont(Font.TRUETYPE_FONT, new File(fontLocation)); Font font = null; if (italic && bold) { font = newFont.deriveFont(Font.ITALIC + Font.BOLD, 36); } else if (italic && !bold) { font = newFont.deriveFont(Font.ITALIC, 36); } else if (!italic && bold) { font = newFont.deriveFont(Font.BOLD, 36); } else { font = newFont.deriveFont(Font.PLAIN, 36); } lblSampleText.setFont(font); } catch (FontFormatException | IOException ex) { } } else { if (italic && bold) { lblSampleText.setFont(new Font(fontLocation, Font.ITALIC + Font.BOLD, 36)); } else if (italic && !bold) { lblSampleText.setFont(new Font(fontLocation, Font.ITALIC, 36)); } else if (!italic && bold) { lblSampleText.setFont(new Font(fontLocation, Font.BOLD, 36)); } else { lblSampleText.setFont(new Font(fontLocation, Font.PLAIN, 36)); } } cbBold.setSelected(bold); cbItalic.setSelected(italic); updateSettings(fontLocation, bold, italic); previewPanel1.repaint(); }