List of usage examples for java.awt EventQueue invokeLater
public static void invokeLater(Runnable runnable)
From source file:org.zaproxy.zap.extension.importurls.ExtensionImportUrls.java
public String importUrlFile(File file) { if (file == null) { return ""; }// w w w.j av a2 s . c o m BufferedReader in = null; try { if (View.isInitialised()) { // Switch to the output panel, if in GUI mode View.getSingleton().getOutputPanel().setTabFocus(); } in = new BufferedReader(new FileReader(file)); HttpSender sender = new HttpSender(Model.getSingleton().getOptionsParam().getConnectionParam(), true, HttpSender.MANUAL_REQUEST_INITIATOR); String line; StringBuilder outputLine; while ((line = in.readLine()) != null) { if (!line.startsWith("#") && line.trim().length() > 0) { if (!line.startsWith("http")) { // ZAP exports urls to a file in which each line starts with the HTTP Method // (verb) // followed by a tab, so makes sense to cope with it. // Otherwise assume complete URLs starting with http(s) scheme. int tabIdx = line.indexOf("\t"); if (tabIdx > -1) { line = line.substring(line.indexOf("\t")).trim(); } } outputLine = new StringBuilder(); try { outputLine.append("GET").append("\t").append(line).append("\t"); HttpMessage msg = new HttpMessage(new URI(line, false)); sender.sendAndReceive(msg, true); persistMessage(msg); outputLine.append(msg.getResponseHeader().getStatusCode()); } catch (Exception e) { outputLine.append(e.getMessage()); } outputLine.append("\n"); if (View.isInitialised()) { final String str = outputLine.toString(); EventQueue.invokeLater(new Runnable() { @Override public void run() { View.getSingleton().getOutputPanel().append(str); } }); } } } } catch (Exception e) { log.error(e.getMessage(), e); } finally { if (in != null) { try { in.close(); } catch (IOException e) { // Ignore } } } return null; }
From source file:com.willwinder.universalgcodesender.uielements.macros.MacroActionPanel.java
private void customGcodeButtonActionPerformed(int macroIndex) { Macro macro = backend.getSettings().getMacro(macroIndex); EventQueue.invokeLater(new Runnable() { @Override// ww w.ja v a 2s .c o m public void run() { try { MacroHelper.executeCustomGcode(macro.getGcode(), backend); } catch (Exception ex) { GUIHelpers.displayErrorDialog(ex.getMessage()); } } }); }
From source file:org.zaproxy.zap.extension.importurls.ExtensionImportUrls.java
private static void persistMessage(final HttpMessage message) { // Add the message to the history panel and sites tree final HistoryReference historyRef; try {/* w w w . j a v a2 s. co m*/ historyRef = new HistoryReference(Model.getSingleton().getSession(), HistoryReference.TYPE_ZAP_USER, message); } catch (Exception e) { log.warn(e.getMessage(), e); return; } final ExtensionHistory extHistory = (ExtensionHistory) Control.getSingleton().getExtensionLoader() .getExtension(ExtensionHistory.NAME); if (extHistory != null) { EventQueue.invokeLater(new Runnable() { @Override public void run() { extHistory.addHistory(historyRef); Model.getSingleton().getSession().getSiteTree().addPath(historyRef, message); } }); } }
From source file:org.eclipse.titanium.graph.gui.windows.GraphEditor.java
/** * We have to dispose the windows shown on our Editor *//*from www.ja v a 2 s . c o m*/ @Override public void dispose() { super.dispose(); EventQueue.invokeLater(new Runnable() { @Override public void run() { if (window != null) { window.dispose(); } } }); Display.getDefault().asyncExec(new Runnable() { @Override public void run() { if (wndFind != null) { wndFind.close(); } } }); final IWorkbenchWindow wind = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (wind == null) { return; } final IEditorReference[] editors = wind.getActivePage().findEditors(null, GraphEditor.ID, IWorkbenchPage.MATCH_ID); if (editors != null && editors.length == 0 && satView != null) { satView.setEditor(null); satView.clear(); } for (final AbstractHandler hnd : handlers) { hnd.dispose(); } }
From source file:me.paddingdun.gen.code.gui.view.dbtable.TableView.java
/** * 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.// w w w . j a v a 2 s. c o m */ // <editor-fold defaultstate="collapsed" desc="Generated // Code">//GEN-BEGIN:initComponents private void initComponents() { setIconifiable(true); setMaximizable(true); setResizable(true); setTitle("?/"); fileChooser = new javax.swing.JFileChooser(); p = new javax.swing.JSplitPane(); p0t = new javax.swing.JPanel(); pt = new javax.swing.JSplitPane(); ptt = new javax.swing.JScrollPane(); ptb = new javax.swing.JScrollPane(); ptba = new javax.swing.JPanel(); pb = new javax.swing.JSplitPane(); p0b = new javax.swing.JPanel(); pbt = new javax.swing.JScrollPane(); pbb = new javax.swing.JScrollPane(); pbba = new javax.swing.JPanel(); p.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); pt.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); pb.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); p.setTopComponent(p0t); p.setBottomComponent(p0b); p0t.setLayout(new BorderLayout()); p0t.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "?", TitledBorder.LEFT, TitledBorder.DEFAULT_POSITION, null, Color.BLACK)); p0t.add(pt, BorderLayout.CENTER); p0t.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { p.setDividerLocation(p.getHeight() - 40); EventQueue.invokeLater(new Runnable() { @Override public void run() { pt.setDividerLocation(0.38); EventQueue.invokeLater(new Runnable() { @Override public void run() { pb.setDividerLocation(1.0d); } }); } }); } }); p0b.setLayout(new BorderLayout()); p0b.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "", TitledBorder.LEFT, TitledBorder.DEFAULT_POSITION, null, Color.BLACK)); p0b.add(pb, BorderLayout.CENTER); p0b.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { p.setDividerLocation(30); EventQueue.invokeLater(new Runnable() { @Override public void run() { pt.setDividerLocation(1.0d); EventQueue.invokeLater(new Runnable() { @Override public void run() { pb.setDividerLocation(0.38); } }); } }); } }); pt.setTopComponent(ptt); pt.setBottomComponent(ptb); ptb.setViewportView(ptba); ptb.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); pb.setTopComponent(pbt); pb.setBottomComponent(pbb); pbb.setViewportView(pbba); pbb.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); tableColumnTable = new javax.swing.JTable() { public void editingStopped(ChangeEvent e) { TableCellEditor editor = this.getCellEditor(); if (editor != null) { Object value = editor.getCellEditorValue(); setTableColumnValue(value); } // System.out.println(MessageFormat.format("c:{0}-r:{1}", // this.getSelectedColumn(), this.getSelectedRow())); super.editingStopped(e); } }; // ColumnModel?false; // table.setAutoCreateColumnsFromModel(false); ptt.setViewportView(tableColumnTable); /** * add by 2016422 ; */ listColumnTable = new javax.swing.JTable() { public void editingStopped(ChangeEvent e) { TableCellEditor editor = this.getCellEditor(); if (editor != null) { Object value = editor.getCellEditorValue(); setListColumnValue(value); } // System.out.println(MessageFormat.format("c:{0}-r:{1}", // this.getSelectedColumn(), this.getSelectedRow())); super.editingStopped(e); } }; listColumnTable.getTableHeader().addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { } }); pbt.setViewportView(listColumnTable); jLabel1 = new javax.swing.JLabel(); basePackageName = new javax.swing.JTextField(); btnGen = new javax.swing.JButton(); btnListColumnOk = new javax.swing.JButton(); btnTableColumnOk = new javax.swing.JButton(); jLabel2 = new javax.swing.JLabel(); jcombo_sqlMapMarkUse = new javax.swing.JComboBox<Option<Integer>>(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); jLabel8 = new javax.swing.JLabel(); jLabel9 = new javax.swing.JLabel(); jLabel10 = new javax.swing.JLabel(); jLabel11 = new javax.swing.JLabel(); jLabel12 = new javax.swing.JLabel(); jLabel13 = new javax.swing.JLabel(); jLabel14 = new javax.swing.JLabel(); jLabel15 = new javax.swing.JLabel(); jLabel16 = new javax.swing.JLabel(); columnTitle = new javax.swing.JTextField(); listTitle = new javax.swing.JTextField(); jcombo_showGsonAnnotation = new javax.swing.JComboBox<Option<Boolean>>(); jcombo_queryRenderShow = new javax.swing.JComboBox<Option<Boolean>>(); jcombo_listRenderShow = new javax.swing.JComboBox<Option<Boolean>>(); jcombo_editRenderShow = new javax.swing.JComboBox<Option<Boolean>>(); jcombo_queryRenderWay = new javax.swing.JComboBox<Option<Integer>>(); jcombo_listRenderWay = new javax.swing.JComboBox<Option<Integer>>(); jcombo_editRenderWay = new javax.swing.JComboBox<Option<Integer>>(); saveMethodPrefix = new javax.swing.JTextField(); updateMethodPrefix = new javax.swing.JTextField(); getMethodPrefix = new javax.swing.JTextField(); deleteMethodPrefix = new javax.swing.JTextField(); queryMethodPrefix = new javax.swing.JTextField(); queryPagingMethodPrefix = new javax.swing.JTextField(); queryColumnJson = new javax.swing.JTextArea(1, 10); javax.swing.JScrollPane cqpc = new javax.swing.JScrollPane(queryColumnJson); // customQueryProperty.setAutoscrolls(true); editValueGenWayJson = new javax.swing.JTextArea(1, 10); javax.swing.JScrollPane cevfw = new javax.swing.JScrollPane(editValueGenWayJson); // editValidateJson = new javax.swing.JTextArea(1, 10); // javax.swing.JScrollPane evj = new javax.swing.JScrollPane(editValidateJson); editValidateEasyuiString = new javax.swing.JTextArea(1, 10); javax.swing.JScrollPane evj = new javax.swing.JScrollPane(editValidateEasyuiString); jLabel1.setText("??"); btnGen.setText("?"); btnTableColumnOk.setText("Ok"); btnListColumnOk.setText("Ok"); jLabel2.setText("SQL??"); // sqlMapMarkUse.setModel(null); jLabel3.setText("??"); jLabel4.setText("?"); jLabel5.setText("??"); jLabel6.setText("?"); jLabel7.setText("?"); jLabel8.setText("?"); jLabel9.setText("?gosn"); jLabel10.setText("?"); jLabel11.setText("?"); jLabel12.setText("?"); jLabel13.setText("?"); jLabel14.setText("?"); jLabel15.setText("?"); jLabel16.setText(""); TableLayout tableLayout_ptba = new TableLayout(); double border = 2; // 0 1 2 3 4 5 6 tableLayout_ptba.setColumn(new double[] { border, 50, 50, 80, -1, 50, 70, border }); tableLayout_ptba.setRow(new double[] { border, 30, 30, 30, 130, 130, 130, border }); ptba.setLayout(tableLayout_ptba); queryRenderShow.addElement(CollectionHelper.option("", Boolean.TRUE)); queryRenderShow.addElement(CollectionHelper.option("?", Boolean.FALSE)); jcombo_queryRenderShow.setModel(queryRenderShow); listRenderShow.addElement(CollectionHelper.option("", Boolean.TRUE)); listRenderShow.addElement(CollectionHelper.option("?", Boolean.FALSE)); jcombo_listRenderShow.setModel(listRenderShow); editRenderShow.addElement(CollectionHelper.option("", Boolean.TRUE)); editRenderShow.addElement(CollectionHelper.option("?", Boolean.FALSE)); jcombo_editRenderShow.setModel(editRenderShow); CollectionHelper.renderWayOption(queryRenderWay, "query"); jcombo_queryRenderWay.setModel(queryRenderWay); CollectionHelper.renderWayOption(listRenderWay, "list"); jcombo_listRenderWay.setModel(listRenderWay); CollectionHelper.renderWayOption(editRenderWay, "edit"); jcombo_editRenderWay.setModel(editRenderWay); jcombo_editRenderWay.addItemListener(new ItemListener() { @SuppressWarnings("unchecked") @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { //?? Option<Integer> o = (Option<Integer>) e.getItem(); String s = EditValueGenWayHelper.toEditValueShowWayJson(o.getValue()); editRenderWayJson.setText(s); } } }); int row = 1; ptba.add(new JLabel(""), MessageFormat.format("1,{0},2,{0}", row)); ptba.add(columnTitle, MessageFormat.format("3,{0},4,{0}", row)); ptba.add(btnTableColumnOk, MessageFormat.format("6,{0}", row)); row++; ptba.add(jLabel14, MessageFormat.format("1,{0},2,{0}", row)); ptba.add(jcombo_editRenderShow, MessageFormat.format("3,{0},4,{0}", row)); ptba.add(btnListColumnOk, MessageFormat.format("6,{0}", row)); row++; ptba.add(jLabel15, MessageFormat.format("1,{0},2,{0}", row)); ptba.add(jcombo_editRenderWay, MessageFormat.format("3,{0},4,{0}", row)); row++; ptba.add(new JLabel("?"), MessageFormat.format("1,{0},2,{0}", row)); editRenderWayJson = new javax.swing.JTextArea(1, 10); editRenderWayJson.setLineWrap(true); editRenderWayJson.setWrapStyleWord(true); javax.swing.JScrollPane erwjj = new javax.swing.JScrollPane(editRenderWayJson); ptba.add(erwjj, MessageFormat.format("3,{0},6,{0}", row)); row++; JLabel j1 = new JLabel("?"); j1.setToolTipText("<html>\n" + "<table border=\"1\">\n" + "<tr>\n" + " <th>?</th>\n" + " <th>??</th>\n" + "</tr>\n" + "<tr>\n" + " <td>new</td>\n" + " <td>?,\"input\":, \"time\":??, \"nothing\":??</td>\n" + "</tr>\n" + "</table>\n" + "</html>"); ptba.add(j1, MessageFormat.format("1,{0},2,{0}", row)); ptba.add(cevfw, MessageFormat.format("3,{0},6,{0}", row)); row++; ptba.add(new JLabel("JS?"), MessageFormat.format("1,{0},2,{0}", row)); ptba.add(evj, MessageFormat.format("3,{0},6,{0}", row)); // showGsonAnnotation.setModel(null); btnGen.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnGenActionPerformed(evt); } }); btnListColumnOk.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnListColumnOkActionPerformed(evt); } }); btnTableColumnOk.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnTableColumnOkActionPerformed(evt); } }); TableLayout tableLayout_pbba = new TableLayout(); // double border = 2; //0 1 2 3 4 5 6 tableLayout_pbba.setColumn(new double[] { border, 50, 50, 80, -1, 50, 70, border }); tableLayout_pbba.setRow(new double[] { border, 30, 30, 30, 30, 30, 130, border }); pbba.setLayout(tableLayout_pbba); row = 1; pbba.add(jLabel16, MessageFormat.format("1,{0},2,{0}", row)); pbba.add(listTitle, MessageFormat.format("3,{0},4,{0}", row)); pbba.add(btnListColumnOk, MessageFormat.format("6,{0}", row)); row++; pbba.add(jLabel12, MessageFormat.format("1,{0},2,{0}", row)); pbba.add(jcombo_listRenderShow, MessageFormat.format("3,{0},4,{0}", row)); row++; pbba.add(jLabel13, MessageFormat.format("1,{0},2,{0}", row)); pbba.add(jcombo_listRenderWay, MessageFormat.format("3,{0},4,{0}", row)); row++; pbba.add(jLabel10, MessageFormat.format("1,{0},2,{0}", row, row)); pbba.add(jcombo_queryRenderShow, MessageFormat.format("3,{0},4,{0}", row)); row++; pbba.add(jLabel11, MessageFormat.format("1,{0},2,{0}", row)); pbba.add(jcombo_queryRenderWay, MessageFormat.format("3,{0},4,{0}", row)); row++; pbba.add(new JLabel(""), MessageFormat.format("1,{0},2,{0}", row)); pbba.add(cqpc, MessageFormat.format("3,{0},6,{0}", row)); // TableLayout tableLayout_pba = new TableLayout(); //// double border = 2; //0 1 2 3 4 5 6 // tableLayout_pba.setColumn(new double[]{border, 50, 50, 80, -1, 50, // 70, border}); // tableLayout_pba.setRow(new double[]{border,30, 30, 30, 30, 30, 30, // 30, 30, 30, 30, border}); // pba.setLayout(tableLayout_pba); // // pba.add(jLabel1, "1,1,2,1"); // pba.add(basePackageName, "3,1,5,1"); // pba.add(btnGen, "6,1"); // // pba.add(jLabel2, "1,2,2,2"); // pba.add(jcombo_sqlMapMarkUse, "3,2,4,2"); // // pba.add(jLabel9, "1,3,2,3"); // pba.add(jcombo_showGsonAnnotation, "3,3,4,3"); // // pba.add(jLabel3, "1,4,2,4"); // pba.add(saveMethodPrefix, "3,4,4,4"); // // pba.add(jLabel4, "1,5,2,5"); // pba.add(updateMethodPrefix, "3,5,4,5"); // // pba.add(jLabel5, "1,6,2,6"); // pba.add(getMethodPrefix, "3,6,4,6"); // // pba.add(jLabel6, "1,7,2,7"); // pba.add(deleteMethodPrefix, "3,7,4,7"); // // pba.add(jLabel7, "1,8,2,8"); // pba.add(queryMethodPrefix, "3,8,4,8"); // // pba.add(jLabel8, "1,9,2,9"); // pba.add(queryPagingMethodPrefix, "3,9,4,9"); sqlMapMarkUse.addElement(CollectionHelper.option("??", 1)); sqlMapMarkUse.addElement(CollectionHelper.option("??", 2)); jcombo_sqlMapMarkUse.setModel(sqlMapMarkUse); showGsonAnnotation.addElement(CollectionHelper.option("", Boolean.TRUE)); showGsonAnnotation.addElement(CollectionHelper.option("?", Boolean.FALSE)); jcombo_showGsonAnnotation.setModel(showGsonAnnotation); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(p, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 470, Short.MAX_VALUE)); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent( p, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 446, Short.MAX_VALUE)); this.addComponentListener(new java.awt.event.ComponentAdapter() { public void componentShown(java.awt.event.ComponentEvent evt) { afterShow(evt); } }); pack(); }
From source file:org.parosproxy.paros.view.SiteMapPanel.java
public void expandRoot() { TreeNode root = (TreeNode) treeSite.getModel().getRoot(); if (rootTreePath == null || root != rootTreePath.getPathComponent(0)) { rootTreePath = new TreePath(root); }//from w w w . ja v a2s.c o m if (EventQueue.isDispatchThread()) { getTreeSite().expandPath(rootTreePath); return; } try { EventQueue.invokeLater(new Runnable() { public void run() { getTreeSite().expandPath(rootTreePath); } }); } catch (Exception e) { log.warn(e.getMessage(), e); } }
From source file:gov.sandia.umf.platform.ui.jobs.RunPanel.java
public RunPanel() { root = new NodeBase(); model = new DefaultTreeModel(root); tree = new JTree(model); tree.setRootVisible(false);// ww w .j a v a 2 s . c o m tree.setShowsRootHandles(true); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); tree.setCellRenderer(new DefaultTreeCellRenderer() { @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); NodeBase node = (NodeBase) value; Icon icon = node.getIcon(expanded); // A node knows whether it should hold other nodes or not, so don't pass leaf to it. if (icon == null) { if (leaf) icon = getDefaultLeafIcon(); else if (expanded) icon = getDefaultOpenIcon(); else icon = getDefaultClosedIcon(); } setIcon(icon); return this; } }); tree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { NodeBase newNode = (NodeBase) tree.getLastSelectedPathComponent(); if (newNode == null) return; if (newNode == displayNode) return; if (displayThread != null) synchronized (displayText) { displayThread.stop = true; } displayNode = newNode; if (displayNode instanceof NodeFile) viewFile(); else if (displayNode instanceof NodeJob) viewJob(); } }); tree.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { int keycode = e.getKeyCode(); if (keycode == KeyEvent.VK_DELETE || keycode == KeyEvent.VK_BACK_SPACE) { delete(); } } }); tree.addTreeWillExpandListener(new TreeWillExpandListener() { public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException { TreePath path = event.getPath(); // TODO: can this ever be null? Object o = path.getLastPathComponent(); if (o instanceof NodeJob) ((NodeJob) o).build(tree); } public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException { } }); tree.addTreeExpansionListener(new TreeExpansionListener() { public void treeExpanded(TreeExpansionEvent event) { Rectangle node = tree.getPathBounds(event.getPath()); Rectangle visible = treePane.getViewport().getViewRect(); visible.height -= node.y - visible.y; visible.y = node.y; tree.repaint(visible); } public void treeCollapsed(TreeExpansionEvent event) { Rectangle node = tree.getPathBounds(event.getPath()); Rectangle visible = treePane.getViewport().getViewRect(); visible.height -= node.y - visible.y; visible.y = node.y; tree.repaint(visible); } }); Thread refreshThread = new Thread() { public void run() { try { // Initial load synchronized (running) { for (MNode n : AppData.runs) running.add(0, new NodeJob(n)); // This should be efficient on a doubly-linked list. for (NodeJob job : running) root.add(job); } EventQueue.invokeLater(new Runnable() { public void run() { model.nodeStructureChanged(root); if (model.getChildCount(root) > 0) tree.setSelectionRow(0); } }); // Periodic refresh to show status of running jobs int shortCycles = 100; // Force full scan on first cycle. while (true) { NodeBase d = displayNode; // Make local copy (atomic action) to prevent it changing from under us if (d instanceof NodeJob) ((NodeJob) d).monitorProgress(RunPanel.this); if (shortCycles++ < 20) { Thread.sleep(1000); continue; } shortCycles = 0; synchronized (running) { Iterator<NodeJob> i = running.iterator(); while (i.hasNext()) { NodeJob job = i.next(); if (job != d) job.monitorProgress(RunPanel.this); if (job.complete >= 1) i.remove(); } } } } catch (InterruptedException e) { } } }; refreshThread.setDaemon(true); refreshThread.start(); displayText = new JTextArea(); displayText.setEditable(false); final JCheckBox chkFixedWidth = new JCheckBox("Fixed-Width Font"); chkFixedWidth.setFocusable(false); chkFixedWidth.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int size = displayText.getFont().getSize(); if (chkFixedWidth.isSelected()) { displayText.setFont(new Font(Font.MONOSPACED, Font.PLAIN, size)); } else { displayText.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, size)); } } }); displayPane.setViewportView(displayText); ActionListener graphListener = new ActionListener() { public void actionPerformed(ActionEvent e) { if (displayNode instanceof NodeFile) { NodeFile nf = (NodeFile) displayNode; if (nf.type == NodeFile.Type.Output || nf.type == NodeFile.Type.Result) { String graphType = e.getActionCommand(); if (displayPane.getViewport().getView() instanceof ChartPanel && displayGraph.equals(graphType)) { viewFile(); displayGraph = ""; } else { if (graphType.equals("Graph")) { Plot plot = new Plot(nf.path.getAbsolutePath()); if (!plot.columns.isEmpty()) displayPane.setViewportView(plot.createGraphPanel()); } else // Raster { Raster raster = new Raster(nf.path.getAbsolutePath(), displayPane.getHeight()); displayPane.setViewportView(raster.createGraphPanel()); } displayGraph = graphType; } } } } }; buttonGraph = new JButton("Graph", ImageUtil.getImage("analysis.gif")); buttonGraph.setFocusable(false); buttonGraph.addActionListener(graphListener); buttonGraph.setActionCommand("Graph"); buttonRaster = new JButton("Raster", ImageUtil.getImage("prnplot.gif")); buttonRaster.setFocusable(false); buttonRaster.addActionListener(graphListener); buttonRaster.setActionCommand("Raster"); Lay.BLtg(this, "C", Lay.SPL(Lay.BL("C", treePane = Lay.sp(tree)), Lay.BL("N", Lay.FL(chkFixedWidth, Lay.FL(buttonGraph, buttonRaster), "hgap=50"), "C", displayPane), "divpixel=250")); setFocusCycleRoot(true); }
From source file:net.technicpack.launcher.ui.components.discover.DiscoverInfoPanel.java
protected void triggerLoadListener() { final ActionListener deferredListener = loadListener; if (deferredListener != null) { EventQueue.invokeLater(new Runnable() { @Override// ww w . j a va2 s . c o m public void run() { deferredListener.actionPerformed(new ActionEvent(this, 0, "loaded")); } }); loadListener = null; } }
From source file:phex.gui.tabs.search.SearchListTableModel.java
@EventTopicSubscriber(topic = PhexEventTopics.Search_Update) public void onSearchUpdateEvent(String topic, final ContainerEvent event) { if (searchContainer != event.getContainer()) { return;//from ww w. j ava 2 s. c om } EventQueue.invokeLater(new Runnable() { public void run() { int position = event.getPosition(); if (event.getType() == ContainerEvent.Type.ADDED) { fireTableChanged(new TableModelEvent(SearchListTableModel.this, position, position, TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT)); } else if (event.getType() == ContainerEvent.Type.REMOVED) { fireTableChanged(new TableModelEvent(SearchListTableModel.this, position, position, TableModelEvent.ALL_COLUMNS, TableModelEvent.DELETE)); } } }); }
From source file:org.opendatakit.appengine.updater.UpdaterWindow.java
/** * Launch the application./*from w w w . j a v a 2 s .c o m*/ */ public static void main(String[] args) { translations = ResourceBundle.getBundle(TranslatedStrings.class.getCanonicalName(), Locale.getDefault()); Options options = addOptions(); // get location of this jar String reflectedJarPath = UpdaterWindow.class.getProtectionDomain().getCodeSource().getLocation().getFile(); // remove %20 substitutions. reflectedJarPath = reflectedJarPath.replace("%20", " "); File myJar = new File(reflectedJarPath, Preferences.JAR_NAME); System.out.println("CodeSource Location: " + myJar.getAbsolutePath()); File cleanJarPath = null; if (myJar.exists()) { try { cleanJarPath = myJar.getCanonicalFile(); } catch (Throwable t) { t.printStackTrace(); } } if (cleanJarPath == null) { // try finding this within our working directory String dir = System.getProperty("user.dir"); if (dir != null) { File myWD = new File(dir); if (myWD.exists()) { myJar = new File(myWD, Preferences.JAR_NAME); System.out.println("user.dir path: " + myJar.getAbsolutePath()); if (myJar.exists()) { try { cleanJarPath = myJar.getCanonicalFile(); } catch (Throwable t) { t.printStackTrace(); } } } } } if (cleanJarPath != null) { myJarDir = cleanJarPath.getParentFile(); System.out.println(fmt(TranslatedStrings.DIR_RUNNABLE_JAR, myJarDir.getAbsolutePath())); } else { myJarDir = null; } CommandLineParser parser = new DefaultParser(); final CommandLine cmdArgs; try { cmdArgs = parser.parse(options, args); } catch (ParseException e1) { System.out.println(fmt(TranslatedStrings.LAUNCH_FAILED, e1.getMessage())); showHelp(options); System.exit(1); return; } if (cmdArgs.hasOption(ArgumentNameConstants.HELP)) { showHelp(options); System.exit(0); return; } if (cmdArgs.hasOption(ArgumentNameConstants.VERSION)) { showVersion(); System.exit(0); return; } if (myJarDir == null && !cmdArgs.hasOption(ArgumentNameConstants.INSTALL_ROOT)) { System.out.println(fmt(TranslatedStrings.INSTALL_ROOT_REQUIRED, Preferences.JAR_NAME, ArgumentNameConstants.INSTALL_ROOT)); showHelp(options); System.exit(1); return; } // required for all operations if (cmdArgs.hasOption(ArgumentNameConstants.NO_UI) && !cmdArgs.hasOption(ArgumentNameConstants.EMAIL)) { System.out.println(fmt(TranslatedStrings.ARG_IS_REQUIRED, ArgumentNameConstants.EMAIL)); showHelp(options); System.exit(1); return; } // update appEngine with the local configuration if (cmdArgs.hasOption(ArgumentNameConstants.UPLOAD)) { if (cmdArgs.hasOption(ArgumentNameConstants.CLEAR)) { System.out.println(fmt(TranslatedStrings.CONFLICTING_ARGS_CMD, ArgumentNameConstants.UPLOAD, ArgumentNameConstants.CLEAR)); } if (cmdArgs.hasOption(ArgumentNameConstants.ROLLBACK)) { System.out.println(fmt(TranslatedStrings.CONFLICTING_ARGS_CMD, ArgumentNameConstants.UPLOAD, ArgumentNameConstants.ROLLBACK)); } if (!cmdArgs.hasOption(ArgumentNameConstants.EMAIL)) { System.out.println(fmt(TranslatedStrings.ARG_IS_REQUIRED_CMD, ArgumentNameConstants.EMAIL)); } showHelp(options); System.exit(1); return; } // rollback any stuck outstanding configuration transaction on appEngine infrastructure if (cmdArgs.hasOption(ArgumentNameConstants.ROLLBACK)) { if (cmdArgs.hasOption(ArgumentNameConstants.CLEAR)) { System.out.println(fmt(TranslatedStrings.CONFLICTING_ARGS_CMD, ArgumentNameConstants.ROLLBACK, ArgumentNameConstants.CLEAR)); } if (cmdArgs.hasOption(ArgumentNameConstants.UPLOAD)) { System.out.println(fmt(TranslatedStrings.CONFLICTING_ARGS_CMD, ArgumentNameConstants.ROLLBACK, ArgumentNameConstants.UPLOAD)); } if (!cmdArgs.hasOption(ArgumentNameConstants.EMAIL)) { System.out.println(fmt(TranslatedStrings.ARG_IS_REQUIRED_CMD, ArgumentNameConstants.EMAIL)); } showHelp(options); System.exit(1); return; } if (cmdArgs.hasOption(ArgumentNameConstants.CLEAR)) { if (cmdArgs.hasOption(ArgumentNameConstants.ROLLBACK)) { System.out.println(fmt(TranslatedStrings.CONFLICTING_ARGS_CMD, ArgumentNameConstants.CLEAR, ArgumentNameConstants.ROLLBACK)); } if (cmdArgs.hasOption(ArgumentNameConstants.UPLOAD)) { System.out.println(fmt(TranslatedStrings.CONFLICTING_ARGS_CMD, ArgumentNameConstants.CLEAR, ArgumentNameConstants.UPLOAD)); } showHelp(options); System.exit(1); return; } if (!cmdArgs.hasOption(ArgumentNameConstants.NO_UI)) { EventQueue.invokeLater(new Runnable() { public void run() { try { // Set System L&F UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); UpdaterWindow window = new UpdaterWindow(cmdArgs); window.frame.setTitle(fmt(TranslatedStrings.AGG_INSTALLER_VERSION, Preferences.VERSION)); ImageIcon icon = new ImageIcon( UpdaterWindow.class.getClassLoader().getResource("odkupdater.png")); window.frame.setIconImage(icon.getImage()); window.frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } else { try { UpdaterCLI aggregateInstallerCLI = new UpdaterCLI(cmdArgs); aggregateInstallerCLI.run(); } catch (Exception e) { e.printStackTrace(); } } }