List of usage examples for javax.swing SwingWorker execute
public final void execute()
From source file:edu.ku.brc.specify.tasks.subpane.lm.LifeMapperPane.java
/** * Creates the UI./*from ww w . j a v a 2 s .c o m*/ */ @SuppressWarnings("unchecked") protected void createUI() { currentSize = getCurrentSizeSquare(); searchText = createTextField(25); searchSciNameBtn = createI18NButton("LM_SEARCH"); list = new JList(listModel); imgDisplay = new ImageDisplay(IMG_WIDTH, IMG_HEIGHT, false, true); imgDisplay.setChangeListener(this); wwPanel = new WorldWindPanel(false); wwPanel.setPreferredSize(new Dimension(currentSize, currentSize)); wwPanel.setZoomInMeters(600000.0); imgDisplay.setDoShowText(false); searchMyDataBtn = createI18NButton("LM_SRCH_SP_DATA"); myDataTF = UIHelper.createTextField(); CellConstraints cc = new CellConstraints(); PanelBuilder pb1 = new PanelBuilder(new FormLayout("p,2px,f:p:g,2px,p", "p")); pb1.add(createI18NFormLabel("LM_SRCH_COL"), cc.xy(1, 1)); pb1.add(searchText, cc.xy(3, 1)); pb1.add(searchSciNameBtn, cc.xy(5, 1)); PanelBuilder myPB = new PanelBuilder(new FormLayout("f:p:g,p", "p,2px,p,2px,p")); mySepComp = myPB.addSeparator(getResourceString("LM_MYDATA_TITLE"), cc.xyw(1, 1, 2)); myPB.add(myDataTF, cc.xyw(1, 3, 2)); myPB.add(searchMyDataBtn, cc.xy(2, 5)); PanelBuilder pb2 = new PanelBuilder(new FormLayout("MAX(p;300px),2px,f:p:g", "f:p:g,20px,p")); pb2.add(createScrollPane(list), cc.xy(1, 1)); pb2.add(myPB.getPanel(), cc.xy(1, 3)); PanelBuilder pb3 = new PanelBuilder(new FormLayout("f:p:g,p,f:p:g", "f:p:g,p,4px,p,f:p:g")); pb3.add(createI18NLabel("LM_WRLD_OVRVW", SwingConstants.CENTER), cc.xy(2, 2)); pb3.add(imgDisplay, cc.xy(2, 4)); PanelBuilder pb4 = new PanelBuilder(new FormLayout("f:p:g,p,f:p:g", "f:p:g,p,4px,p,f:p:g")); pb4.add(createI18NLabel("LM_INTRACT_VW", SwingConstants.CENTER), cc.xy(2, 2)); pb4.add(wwPanel, cc.xy(2, 4)); PanelBuilder pb5 = new PanelBuilder(new FormLayout("f:p:g", "f:p:g,p,f:p:g")); pb5.add(pb3.getPanel(), cc.xy(1, 1)); pb5.add(pb4.getPanel(), cc.xy(1, 3)); PanelBuilder pb = new PanelBuilder(new FormLayout("p,8px,f:p:g", "p,8px,f:p:g"), this); pb.add(pb1.getPanel(), cc.xyw(1, 1, 3)); pb.add(pb2.getPanel(), cc.xy(1, 3)); pb.add(pb5.getPanel(), cc.xy(3, 3)); updateMyDataUIState(false); searchText.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { searchSciNameBtn.doClick(); } } }); myDataTF.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { searchMyDataBtn.doClick(); } } }); list.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (list.getSelectedIndex() == -1) { wwPanel.reset(); imgDisplay.setImage(blueMarble); } else { SwingWorker<Boolean, Boolean> worker = new SwingWorker<Boolean, Boolean>() { @Override protected Boolean doInBackground() throws Exception { if (doResetWWPanel) { wwPanel.reset(); } doSearchOccur(); return null; } @Override protected void done() { imgDisplay.repaint(); } }; worker.execute(); } } } }); searchMyDataBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { doSearchSpecifyData(myDataTF.getText().trim()); } }); } }); searchSciNameBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doSearchGenusSpecies(); } }); blueMarbleListener = new BufferedImageFetcherIFace() { @Override public void imageFetched(BufferedImage image) { blueMarble = image; imgDisplay.setImage(blueMarble); } @Override public void error() { blueMarbleTries++; if (blueMarbleTries < 5) { blueMarbleRetry(); } } }; blueMarbleURL = BG_URL + String.format("WIDTH=%d&HEIGHT=%d", IMG_WIDTH, IMG_HEIGHT); pointsMapImageListener = new BufferedImageFetcherIFace() { @Override public void imageFetched(final BufferedImage image) { if (renderImage == null) { renderImage = new BufferedImage(IMG_WIDTH, IMG_HEIGHT, BufferedImage.TYPE_INT_ARGB); } Graphics2D g2d = renderImage.createGraphics(); if (g2d != null) { g2d.fillRect(0, 0, IMG_WIDTH, IMG_HEIGHT); if (blueMarble != null) { g2d.drawImage(blueMarble, 0, 0, null); } if (image != null) { g2d.drawImage(image, 0, 0, null); } g2d.dispose(); imgDisplay.setImage(renderImage); } } @Override public void error() { } }; blueMarbleRetry(); }
From source file:com.dfki.av.sudplan.vis.VisualizationPanel.java
/** * Adds a KML file to the world wind model. * * @param file the {@link File}/*from w w w.ja va 2s . co m*/ * @throws IllegalArgumentException if file == null * @throws Exception */ public void addKMLLayer(File file) throws Exception { if (file == null) { String msg = "file == null"; log.error(msg); throw new IllegalArgumentException(msg); } final File kmlFile = file; SwingWorker workerThread = new SwingWorker() { @Override protected Object doInBackground() throws Exception { KMLRoot kmlRoot = KMLRoot.createAndParse(kmlFile); KMLAbstractFeature rootFeature = kmlRoot.getFeature(); String layerName = "KML Layer"; if (rootFeature != null && !WWUtil.isEmpty(rootFeature.getName())) { layerName = rootFeature.getName(); } else if (kmlFile instanceof File) { layerName = kmlFile.getName(); } kmlRoot.setField(AVKey.DISPLAY_NAME, layerName); KMLController kmlController = new KMLController(kmlRoot); // Adds a new layer containing the KMLRoot to the end of the WorldWindow's layer list. This // retrieves the layer name from the KMLRoot's DISPLAY_NAME field. RenderableLayer layer = new RenderableLayer(); layer.setName((String) kmlRoot.getField(AVKey.DISPLAY_NAME)); layer.addRenderable(kmlController); ApplicationTemplate.insertBeforePlacenames(wwd, layer); return null; } }; workerThread.execute(); }
From source file:com.u2apple.rt.ui.RecognitionToolJFrame.java
private void detailButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_detailButtonActionPerformed String vid = vidTextField.getText(); String model = modelTextField.getText(); int limit = (int) queryLimitSpinner.getValue(); boolean isAll = allCheckBox.isSelected(); if (StringUtils.isBlank(vid)) { JOptionPane.showMessageDialog(jPanel13, "Vid should not be blank."); } else if (StringUtils.isBlank(model)) { JOptionPane.showMessageDialog(jPanel13, "Model should not be blank."); } else {//w w w . jav a 2 s.c om SwingWorker<List<AndroidDevice>, Void> deviceWorker = new DeviceWorker(vid, model, limit, isAll, this.deviceDetailTable); deviceWorker.execute(); } }
From source file:com.mirth.connect.client.ui.NotificationDialog.java
private void loadNotifications() { // Get user preferences Set<String> preferenceNames = new HashSet<String>(); preferenceNames.add("firstlogin"); preferenceNames.add("checkForNotifications"); preferenceNames.add("showNotificationPopup"); preferenceNames.add("archivedNotifications"); try {/*from w w w.j a va 2s. c om*/ userPreferences = parent.mirthClient.getUserPreferences(parent.getCurrentUser(parent).getId(), preferenceNames); } catch (ClientException e) { } String archivedNotificationString = userPreferences.getProperty("archivedNotifications"); if (archivedNotificationString != null) { archivedNotifications = ObjectXMLSerializer.getInstance().deserialize(archivedNotificationString, Set.class); } showNotificationPopup = userPreferences.getProperty("showNotificationPopup"); checkForNotifications = userPreferences.getProperty("checkForNotifications"); // Build UI initComponents(); // Pull notifications final String workingId = parent.startWorking("Loading notifications..."); SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { List<Notification> notifications = new ArrayList<Notification>(); public Void doInBackground() { try { notifications = ConnectServiceUtil.getNotifications(PlatformUI.SERVER_ID, PlatformUI.SERVER_VERSION, LoadedExtensions.getInstance().getExtensionVersions(), PlatformUI.HTTPS_PROTOCOLS, PlatformUI.HTTPS_CIPHER_SUITES); } catch (Exception e) { PlatformUI.MIRTH_FRAME.alertError(PlatformUI.MIRTH_FRAME, "Failed to retrieve notifications. Please try again later."); } return null; } public void done() { notificationModel.setData(notifications); for (Notification notification : notifications) { if (archivedNotifications.contains(notification.getId())) { notificationModel.setArchived(true, notifications.indexOf(notification)); } else { unarchivedCount++; } } updateUnarchivedCountLabel(); list.setModel(notificationModel); list.setSelectedIndex(0); parent.stopWorking(workingId); } }; worker.execute(); }
From source file:edu.ku.brc.specify.dbsupport.cleanuptools.AgentCleanupProcessor.java
/** * @param fii//from w w w . j av a 2 s .co m */ private void doMergeOfAgents(final FindItemInfo fii) { prgDlg.setProcess(0, 100); System.out.println(String.format("%d : %s - %d", fii.getId(), fii.getValue(), fii.getCount())); SwingWorker<Object, Object> worker = new SwingWorker<Object, Object>() { @Override protected Object doInBackground() throws Exception { try { doProcessMerge(fii); } catch (Exception ex) { ex.printStackTrace(); } return null; } @Override protected void done() { if (hasMoreAgents()) { nextAgent(); } else { doComplete(); } } }; worker.execute(); }
From source file:com.xilinx.kintex7.MainScreen.java
private JPanel testPanelItems() { JPanel panel1 = new JPanel(); JPanel panel = new JPanel(); panel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); panel.add(new JLabel("Data Path-0:")); t1_o1 = new JCheckBox("Loopback"); if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV) t1_o1.setToolTipText("This loops back software generated traffic at DMA user interface"); else if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) t1_o1.setToolTipText("This loops back software generated raw Ethernet frames at 10G PHY"); t1_o1.setSelected(true);/* w w w . jav a 2 s . c o m*/ t1_o1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) { t1_o1.setSelected(true); return; } if (t1_o1.isSelected()) { // disable others test1_option = DriverInfo.ENABLE_LOOPBACK; t1_o2.setSelected(false); t1_o3.setSelected(false); } else { if (!t1_o2.isSelected() && !t1_o3.isSelected()) { test1_option = DriverInfo.CHECKER; t1_o2.setSelected(true); } } } }); //b1.setSelected(true); t1_o2 = new JCheckBox("HW Checker"); if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV) t1_o2.setToolTipText( "This enables Checker in hardware at DMA user interface verifying traffic generated by software"); t1_o2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (t1_o2.isSelected()) { // disable others test1_option = DriverInfo.CHECKER; t1_o1.setSelected(false); if (t1_o3.isSelected()) test1_option = DriverInfo.CHECKER_GEN; } else { if (t1_o3.isSelected()) test1_option = DriverInfo.GENERATOR; else { test1_option = DriverInfo.ENABLE_LOOPBACK; t1_o1.setSelected(true); } } } }); t1_o3 = new JCheckBox("HW Generator"); if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV) t1_o3.setToolTipText("This enables traffic generator in hardware at the DMA user interface"); t1_o3.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (t1_o3.isSelected()) { // disable others test1_option = DriverInfo.GENERATOR; t1_o1.setSelected(false); //t1_o2.setSelected(false); if (t1_o2.isSelected()) test1_option = DriverInfo.CHECKER_GEN; } else { if (t1_o2.isSelected()) test1_option = DriverInfo.CHECKER; else { test1_option = DriverInfo.ENABLE_LOOPBACK; t1_o1.setSelected(true); } } } }); //b3.setEnabled(false); JPanel ip = new JPanel(); ip.setLayout(new BoxLayout(ip, BoxLayout.PAGE_AXIS)); ip.add(t1_o1); ip.add(t1_o2); ip.add(t1_o3); panel.add(ip); panel.add(new JLabel("Packet Size (bytes):")); t1_psize = new JTextField("32768", 5); panel.add(t1_psize); startTest = new JButton("Start"); startTest.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { //Check for led status and start the test if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) { if (lstats.ddrCalib == LED_OFF && (lstats.phy0 == LED_ON && lstats.phy1 == LED_ON)) { JOptionPane.showMessageDialog(null, "DDR3 is not calibrated. Test cannot be started", "Error", JOptionPane.ERROR_MESSAGE); return; } else if (lstats.ddrCalib == LED_OFF && (lstats.phy0 == LED_OFF || lstats.phy1 == LED_OFF)) { JOptionPane.showMessageDialog(null, "DDR3 is not calibrated and 10G-PHY link is down. Test cannot be started", "Error", JOptionPane.ERROR_MESSAGE); return; } else if (lstats.ddrCalib == LED_ON && (lstats.phy0 == LED_OFF || lstats.phy1 == LED_OFF)) { JOptionPane.showMessageDialog(null, "10G-PHY link is down. Test cannot be started", "Error", JOptionPane.ERROR_MESSAGE); return; } } if (startTest.getText().equals("Start")) { int psize = 0; dataMismatch0 = errcnt0 = false; try { psize = Integer.parseInt(t1_psize.getText()); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Only Natural numbers are allowed", "Error", JOptionPane.ERROR_MESSAGE); return; } if (psize < minpkt0 || psize > maxpkt0) { JOptionPane.showMessageDialog(null, "Packet size must be within " + minpkt0 + " to " + maxpkt0 + " bytes", "Error", JOptionPane.ERROR_MESSAGE); return; } di.startTest(0, test1_option, psize); // disable components t1_o1.setEnabled(false); t1_o2.setEnabled(false); t1_o3.setEnabled(false); t1_psize.setEnabled(false); startTest.setText("Stop"); testStarted = true; updateLog("[Test Started for Data Path-0]", logStatus); } else if (startTest.getText().equals("Stop")) { startTest.setEnabled(false); SwingWorker worker = new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { try { stopTest1(); } catch (Exception e) { e.printStackTrace(); } return null; } }; worker.execute(); } } }); panel.add(startTest); if ((mode == LandingPage.APPLICATION_MODE) || (mode == LandingPage.APPLICATION_MODE_P2P)) { t1_o1.setSelected(false); t1_o2.setSelected(false); t1_o3.setSelected(false); t1_o1.setEnabled(false); t1_o2.setEnabled(false); t1_o3.setEnabled(false); t1_psize.setEnabled(false); t1_psize.setText(""); startTest.setEnabled(false); } panel1.add(panel); return panel1; }
From source file:com.xilinx.kintex7.MainScreen.java
private JPanel testPanelItems1() { JPanel panel = new JPanel(); panel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); /*panel.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("Test Parameters-1"), BorderFactory.createEmptyBorder()));*/ float w = (float) ((float) width * 0.4); //panel.setPreferredSize(new Dimension((int)w, 100)); panel.add(new JLabel("Data Path-1:")); t2_o1 = new JCheckBox("Loopback"); if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV) t2_o1.setToolTipText("This loops back software generated traffic at DMA user interface"); else if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) t2_o1.setToolTipText("This loops back software generated raw Ethernet frames at 10G PHY"); t2_o1.setSelected(true);// ww w .j ava2s . c om t2_o1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) { t2_o1.setSelected(true); return; } if (t2_o1.isSelected()) { // disable others test2_option = DriverInfo.ENABLE_LOOPBACK; t2_o2.setSelected(false); t2_o3.setSelected(false); } else { if (!t2_o2.isSelected() && !t2_o3.isSelected()) { test2_option = DriverInfo.CHECKER; t2_o2.setSelected(true); } } } }); //b1.setSelected(true); t2_o2 = new JCheckBox("HW Checker"); if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV) t2_o2.setToolTipText( "This enables Checker in hardware at DMA user interface verifying traffic generated by software"); t2_o2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (t2_o2.isSelected()) { // disable others test2_option = DriverInfo.CHECKER; t2_o1.setSelected(false); //t2_o3.setSelected(false); if (t2_o3.isSelected()) test2_option = DriverInfo.CHECKER_GEN; } else { if (t2_o3.isSelected()) test2_option = DriverInfo.GENERATOR; else { test2_option = DriverInfo.ENABLE_LOOPBACK; t2_o1.setSelected(true); } } } }); //b2.setEnabled(false); t2_o3 = new JCheckBox("HW Generator"); if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV) t2_o3.setToolTipText("This enables traffic generator in hardware at the DMA user interface"); t2_o3.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (t2_o3.isSelected()) { // disable others test2_option = DriverInfo.GENERATOR; t2_o1.setSelected(false); //t2_o2.setSelected(false); if (t2_o2.isSelected()) test2_option = DriverInfo.CHECKER_GEN; } else { if (t2_o2.isSelected()) test2_option = DriverInfo.CHECKER; else { test2_option = DriverInfo.ENABLE_LOOPBACK; t2_o1.setSelected(true); } } } }); //b3.setEnabled(false); JPanel ip = new JPanel(); ip.setLayout(new BoxLayout(ip, BoxLayout.PAGE_AXIS)); ip.add(t2_o1); ip.add(t2_o2); ip.add(t2_o3); panel.add(ip); panel.add(new JLabel("Packet Size (bytes):")); t2_psize = new JTextField("32768", 5); panel.add(t2_psize); stest = new JButton("Start"); stest.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { //Check for led status and start the test if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) { if (lstats.ddrCalib == LED_OFF && (lstats.phy0 == LED_ON && lstats.phy1 == LED_ON)) { JOptionPane.showMessageDialog(null, "DDR3 is not calibrated. Test cannot be started", "Error", JOptionPane.ERROR_MESSAGE); return; } else if (lstats.ddrCalib == LED_OFF && (lstats.phy0 == LED_OFF || lstats.phy1 == LED_OFF)) { JOptionPane.showMessageDialog(null, "DDR3 is not calibrated and 10G-PHY link is down. Test cannot be started", "Error", JOptionPane.ERROR_MESSAGE); return; } else if (lstats.ddrCalib == LED_ON && (lstats.phy0 == LED_OFF || lstats.phy1 == LED_OFF)) { JOptionPane.showMessageDialog(null, "10G-PHY link is down. Test cannot be started", "Error", JOptionPane.ERROR_MESSAGE); return; } } if (stest.getText().equals("Start")) { int psize = 0; dataMismatch2 = errcnt1 = false; try { psize = Integer.parseInt(t2_psize.getText()); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Only Natural numbers are allowed", "Error", JOptionPane.ERROR_MESSAGE); return; } if (psize < minpkt1 || psize > maxpkt1) { JOptionPane.showMessageDialog(null, "Packet size must be within " + minpkt1 + " to " + maxpkt1 + " bytes", "Error", JOptionPane.ERROR_MESSAGE); return; } di.startTest(1, test2_option, psize); t2_o1.setEnabled(false); t2_o2.setEnabled(false); t2_o3.setEnabled(false); t2_psize.setEnabled(false); stest.setText("Stop"); testStarted1 = true; updateLog("[Test Started for Data Path-1]", logStatus); } else if (stest.getText().equals("Stop")) { // Disable button to avoid multiple clicks stest.setEnabled(false); SwingWorker worker = new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { try { stopTest2(); } catch (Exception e) { e.printStackTrace(); } return null; } }; worker.execute(); } } }); panel.add(stest); if ((mode == LandingPage.APPLICATION_MODE) || (mode == LandingPage.APPLICATION_MODE_P2P)) { t2_o1.setSelected(false); t2_o2.setSelected(false); t2_o3.setSelected(false); t2_o1.setEnabled(false); t2_o2.setEnabled(false); t2_o3.setEnabled(false); t2_psize.setEnabled(false); t2_psize.setText(""); stest.setEnabled(false); } return panel; }
From source file:com.mirth.connect.client.ui.SettingsPanelServer.java
public void doClearAllStats() { String result = JOptionPane.showInputDialog(this, "<html>This will reset all channel statistics (including lifetime statistics) for<br>all channels (including undeployed channels).<br><font size='1'><br></font>Type CLEAR and click the OK button to continue.</html>", "Clear All Statistics", JOptionPane.WARNING_MESSAGE); if (result != null) { if (!result.equals("CLEAR")) { getFrame().alertWarning(SettingsPanelServer.this, "You must type CLEAR to clear all statistics."); return; }/*w w w . j ava 2 s . c om*/ final String workingId = getFrame().startWorking("Clearing all statistics..."); SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { private Exception exception = null; public Void doInBackground() { try { getFrame().mirthClient.clearAllStatistics(); } catch (ClientException e) { exception = e; getFrame().alertThrowable(SettingsPanelServer.this, e); } return null; } public void done() { getFrame().stopWorking(workingId); if (exception == null) { getFrame().alertInformation(SettingsPanelServer.this, "All current and lifetime statistics have been cleared for all channels."); } } }; worker.execute(); } }
From source file:com.u2apple.tool.ui.MainFrame.java
private void detailButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_detailButtonActionPerformed String vid = vidTextField.getText(); String brand = conditionTextField.getText(); String model = modelTextField.getText(); int limit = (int) queryLimitSpinner.getValue(); boolean isAll = allCheckBox.isSelected(); if (StringUtils.isBlank(vid)) { JOptionPane.showMessageDialog(jPanel1, "Vid should not be blank."); } else if (model == null) { JOptionPane.showMessageDialog(jPanel1, "Model should not be blank."); } else {/*from w ww. jav a 2 s. co m*/ SwingWorker<List<AndroidDevice>, Void> deviceWorker = new DeviceWorker(vid, brand, model, limit, isAll, Profile.SOURCE, this.deviceDetailTable); deviceWorker.execute(); } }
From source file:biomine.bmvis2.crawling.CrawlSuggestionList.java
private void updateList() { final int myVersion = ++curVersion; SwingWorker<Void, Void> work = new SwingWorker<Void, Void>() { protected Void doInBackground() throws Exception { try { suggestionQuery.setQuery(query.getText()); suggestionQuery.updateResult(); } catch (final IOException e) { // TODO Auto-generated catch block e.printStackTrace();/*from w w w . j ava 2s . co m*/ SwingUtilities.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(CrawlSuggestionList.this, e.getMessage()); } }); return null; } // update list in event thread SwingUtilities.invokeLater(new Runnable() { public void run() { // this thread finished after new thread was started if (myVersion < curVersion) return; itemList.clear(); for (NodeType n : suggestionQuery.getResult()) { itemList.add(n); for (NodeItem ni : n.items) { nameMap.put(ni.getCode(), ni.getName()); itemList.add(ni); } } list.updateUI(); } }); return null; } }; work.execute(); }