List of usage examples for java.lang Thread setName
public final synchronized void setName(String name)
From source file:ECallCenter21.java
private void applyVergunning() { applyVergunningButton.setEnabled(false); vergunning.setActivationCode(activationCodeField.getText()); vergunning.setVergunningCode(vergunningCodeField.getText()); vergunning.saveVergunning();//from www.ja v a 2 s. co m vergunning.setVergunningOrderInProgress(false); executeVergunning(); if (vergunning.isValid()) { performanceMeter.setCallPerHourScale(0, (vergunning.getCallsPerHour() / 100), (vergunning.getCallsPerHour() / 1000)); movePerformanceMeter(0, true); if ((prefPhoneLinesSlider.getMaximum() == 0) || (prefPhoneLinesSlider.getMaximum() > vergunning.getPhoneLines())) { prefPhoneLinesSlider.setMaximum(vergunning.getPhoneLines()); prefPhoneLinesSlider.setValue(vergunning.getPhoneLines()); } else { prefPhoneLinesSlider.setMaximum(vergunning.getPhoneLines()); prefPhoneLinesSlider.setValue(Integer.parseInt(configurationCallCenter.getPrefPhoneLines())); } Thread validLicenseAppliedThread = new Thread(allThreadsGroup, new Runnable() { @Override public void run() { showStatus("Congratulations and thank you for choosing " + Vergunning.BRAND + " " + Vergunning.PRODUCT + ".", true, true); applyVergunningButton.setEnabled(false); requestVergunningButton.setEnabled(false); try { Thread.sleep(1000); } catch (InterruptedException ex) { } tabPane.setSelectedIndex(0); try { Thread.sleep(2000); } catch (InterruptedException ex) { } setImagePanelVisible(false); setPowerOn(true); } }); validLicenseAppliedThread.setName("validLicenseAppliedThread"); validLicenseAppliedThread.setDaemon(runThreadsAsDaemons); validLicenseAppliedThread.start(); } else { prefPhoneLinesSlider.setMaximum(Integer.parseInt(configurationCallCenter.getPrefPhoneLines())); prefPhoneLinesSlider.setValue(Integer.parseInt(configurationCallCenter.getPrefPhoneLines())); Thread invalidLicenseAppliedThread = new Thread(allThreadsGroup, new Runnable() { @Override public void run() { applyVergunningButton.setEnabled(false); requestVergunningButton.setEnabled(false); //licenseCodeField.setEnabled(false); vergunningCodeField.setEditable(false); vergunningCodeField.setForeground(Color.red); if (vergunning.getVergunningInvalidReason().length() == 0) { showStatus("License Code is Invalid due to Internet Connectivity", true, true); } else { showStatus("License Code is Invalid due to " + vergunning.getVergunningInvalidReason() + ". " + vergunning.getVergunningInvalidAdvise(), true, true); } try { Thread.sleep(5000); } catch (InterruptedException ex) { } //licenseCodeField.setEnabled(true); vergunningCodeField.setEditable(true); vergunningCodeField.setForeground(Color.black); licenseCodePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "License Code", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP, new java.awt.Font("STHeiti", 0, 10))); // NOI18N } }); invalidLicenseAppliedThread.setName("invalidLicenseAppliedThread"); invalidLicenseAppliedThread.setDaemon(runThreadsAsDaemons); invalidLicenseAppliedThread.start(); } }
From source file:ECallCenter21.java
/** * *///from ww w. jav a2 s .co m public void register() // Will also set reregisters { isRegistering = true; Thread registerThread = new Thread(allThreadsGroup, new Runnable() { @Override @SuppressWarnings("static-access") public void run() { boundMode = "Inbound"; callCenterIsOutBound = false; runCampaignToggleButton.setEnabled(false); stopCampaignButton.setEnabled(false); campaignComboBox.setEnabled(false); registerToggleButton.setEnabled(true); registerToggleButton.setSelected(true); autoSpeedToggleButton.setSelected(false); // We dont need auto speed and system-load checking in inbound test mode muteAudioToggleButton.setEnabled(false); humanResponseSimulatorToggleButton.setEnabled(false); // Registration showStatus("Sending registration requests to PBX...", true, true); serviceLoopProgressBar.setValue(0); serviceLoopProgressBar.setEnabled(true); registerCounter = 0; registerToggleButton.setSelected(true); while (registerCounter < outboundSoftPhonesAvailable) // Starts looping through the user-range { Thread registerInnerThread = new Thread(allThreadsGroup, new Runnable() { @Override @SuppressWarnings({ "static-access", "empty-statement" }) public void run() { String[] status = new String[2]; SoftPhone thisSoftPhoneInstance = (SoftPhone) threadArray[registerCounter]; // Get the reference to the SoftPhone object in the loop status = thisSoftPhoneInstance.userInput(REGISTERBUTTON, "1", "", ""); // 1 ringResponseDelay, 2 BusyPercentage, 3 EndDelay if (status[0].equals("1")) { showStatus("Registration Error: " + status[1], true, true); } } }); registerInnerThread.setName("registerInnerThread"); registerInnerThread.setDaemon(runThreadsAsDaemons); registerInnerThread.start(); try { Thread.sleep(registrationBurstDelay); } catch (InterruptedException ex) { } phoneStatsTable.setValueAt(registerCounter + 1, 1, 1); // ProcessingInstance serviceLoopProgressBar.setValue(registerCounter); registerCounter++; } serviceLoopProgressBar.setEnabled(false); serviceLoopProgressBar.setValue(0); // Wait for delayed registerResponses from PBX int lastRegisteredActiveCount = 0; showStatus("Receiving delayed PBX registration responses...", true, true); while (lastRegisteredActiveCount != registeredActiveCount) // This codeblock waits until no more PBX registries are detected in time before doing another last (extra) register round { lastRegisteredActiveCount = registeredActiveCount; try { Thread.sleep(1000); } catch (InterruptedException ex) { } } // Extra registrations serviceLoopProgressBar.setValue(0); serviceLoopProgressBar.setEnabled(true); registerCounter = 0; showStatus("Sending extra registration requests to PBX...", true, true); while ((registeredActiveCount < outboundSoftPhonesAvailable) && (registerCounter < outboundSoftPhonesAvailable)) // Starts looping through the user-range { Thread registerInnerThread = new Thread(allThreadsGroup, new Runnable() { @Override @SuppressWarnings({ "static-access", "empty-statement" }) public void run() { SoftPhone thisSoftPhoneInstance = (SoftPhone) threadArray[registerCounter]; // Get the reference to the SoftPhone object in the loop if (thisSoftPhoneInstance .getLoginState() == thisSoftPhoneInstance.LOGINSTATE_UNREGISTERED) { String[] status = new String[2]; status = thisSoftPhoneInstance.userInput(REGISTERBUTTON, "1", "", ""); // 1 ringResponseDelay, 2 BusyPercentage, 3 EndDelay if (status[0].equals("1")) { showStatus("Registration Error: " + status[1], true, true); } } } }); registerInnerThread.setName("registerInnerThread"); registerInnerThread.setDaemon(runThreadsAsDaemons); registerInnerThread.start(); try { Thread.sleep(Math.round(registrationBurstDelay / 4)); } catch (InterruptedException ex) { } phoneStatsTable.setValueAt(registerCounter + 1, 1, 1); // ProcessingInstance serviceLoopProgressBar.setValue(registerCounter); registerCounter++; } serviceLoopProgressBar.setEnabled(false); serviceLoopProgressBar.setValue(0); lastRegisteredActiveCount = 0; showStatus("Receiving extra PBX registration responses...", true, true); while (lastRegisteredActiveCount != registeredActiveCount) // This codeblock waits until no more PBX registries are detected in time before doing another last (extra) register round { lastRegisteredActiveCount = registeredActiveCount; try { Thread.sleep(1000); } catch (InterruptedException ex) { } } // Final registrations serviceLoopProgressBar.setValue(0); serviceLoopProgressBar.setEnabled(true); registerCounter = 0; showStatus("Sending final registration requests to PBX...", true, true); while ((registeredActiveCount < outboundSoftPhonesAvailable) && (registerCounter < outboundSoftPhonesAvailable)) // Starts looping through the user-range { Thread registerInnerThread = new Thread(allThreadsGroup, new Runnable() { @Override @SuppressWarnings({ "static-access", "empty-statement" }) public void run() { SoftPhone thisSoftPhoneInstance = (SoftPhone) threadArray[registerCounter]; // Get the reference to the SoftPhone object in the loop if (thisSoftPhoneInstance .getLoginState() == thisSoftPhoneInstance.LOGINSTATE_UNREGISTERED) { String[] status = new String[2]; status = thisSoftPhoneInstance.userInput(REGISTERBUTTON, "1", "", ""); // 1 ringResponseDelay, 2 BusyPercentage, 3 EndDelay if (status[0].equals("1")) { showStatus("Registration Error: " + status[1], true, true); } } } }); registerInnerThread.setName("registerInnerThread"); registerInnerThread.setDaemon(runThreadsAsDaemons); registerInnerThread.start(); try { Thread.sleep(Math.round(registrationBurstDelay / 8)); } catch (InterruptedException ex) { } phoneStatsTable.setValueAt(registerCounter + 1, 1, 1); // ProcessingInstance serviceLoopProgressBar.setValue(registerCounter); registerCounter++; } serviceLoopProgressBar.setEnabled(false); serviceLoopProgressBar.setValue(0); lastRegisteredActiveCount = 0; showStatus("Receiving final PBX registration responses...", true, true); while (lastRegisteredActiveCount != registeredActiveCount) // This codeblock waits until no more PBX registries are detected in time before doing another last (extra) register round { lastRegisteredActiveCount = registeredActiveCount; try { Thread.sleep(1000); } catch (InterruptedException ex) { } } // Setting the Human Answer Simulator Settings humanResponseSimulator("1"); if (callCenterIsNetManaged) { netManagerInboundServerToggleButton.setEnabled(callCenterIsNetManaged); netManagerInboundServerToggleButton.setSelected(callCenterIsNetManaged); enableInboundNetManagerServer(true); } serviceLoopProgressBar.setValue(0); serviceLoopProgressBar.setEnabled(false); registerToggleButton.setForeground(Color.BLUE); phoneStatsTable.setValueAt("-", 1, 1); // ProcessingInstance // reRegistering = false; muteAudioToggleButton.setEnabled(true); humanResponseSimulatorToggleButton.setEnabled(true); setAutoSpeed(false); // // Setup the infrequent SystemStats Timer // updateSystemStatsTimer.cancel(); updateSystemStatsTimer.purge(); // showStatus("updateSystemStatsTimer Canceled!", true, true); // updateSystemStatsTimer = new Timer(); updateSystemStatsTimer.scheduleAtFixedRate(new UpdateSystemStatsTimer(eCallCenterGUI), (long)(0), updateSystemStatsTimerSlowInterval); // showStatus("updateSystemStatsTimer Scheduled immediate at " + Math.round(updateSystemStatsTimerSlowInterval / 1000) + " Sec Interval", true, true); // Setup the infrequent ReRegister to Proxy timer reRegisterTimer = new Timer(); reRegisterTimer.scheduleAtFixedRate(new ReRegisterTimer(eCallCenterGUI), (SoftPhone.getRegisterLoginTimeout() * 1000L), (SoftPhone.getRegisterLoginTimeout() * 1000L)); // milliSec showStatus( "reRegisterTimer Scheduled " + SoftPhone.getRegisterLoginTimeout() + " Sec postponed at " + SoftPhone.getRegisterLoginTimeout() + " Sec Interval", true, true); isRegistering = false; } }); registerThread.setName("registerThread"); registerThread.setDaemon(runThreadsAsDaemons); registerThread.start(); }
From source file:ECallCenter21.java
private void tabPaneMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tabPaneMouseClicked if (tabPane.getSelectedIndex() == 8) { if (brandLabel.getForeground().getRGB() == aboutPanel.getBackground().getRGB()) { Thread aboutFadeThread = new Thread(new Runnable() { @Override/*from w w w .j a v a2 s .c om*/ @SuppressWarnings({ "static-access" }) public void run() { Color textColor = aboutPanel.getBackground(); while (brandLabel.getForeground().getGreen() < 255) { textColor = new Color(textColor.getRed() + 1, textColor.getGreen() + 1, textColor.getBlue() + 1); brandLabel.setForeground(textColor); brandDescriptionLabel.setForeground(textColor); productLabel.setForeground(textColor); productDescriptionLabel.setForeground(textColor); copyrightLabel.setForeground(textColor); try { Thread.sleep(10); } catch (InterruptedException ex) { } } } }); aboutFadeThread.setName("aboutFadeThread"); aboutFadeThread.setDaemon(runThreadsAsDaemons); aboutFadeThread.start(); } } }
From source file:ECallCenter21.java
/** * * @param onParam//from ww w . java2 s .co m */ public void setPowerOn(final boolean onParam) { while (!defaultConstructorIsReady) { try { Thread.sleep(100); } catch (InterruptedException ex) { } } Thread outboundPowerToggleButtonActionPerformedThread9 = new Thread(allThreadsGroup, new Runnable() { @Override @SuppressWarnings("static-access") public void run() { String[] status = new String[2]; if ((onParam) && (vergunning.isValid())) { // myClickOnSoundTool.play(); setImagePanelVisible(false); // smoothCheckBox.setSelected(false); String varUsername; callCenterStatus = POWERINGON; powerToggleButton.setSelected(true); powerToggleButton.setForeground(Color.BLUE); showStatus("PowerOn " + Vergunning.PRODUCT + "...", true, true); /* true = logToApplic, true = logToFile */ try { Thread.sleep(1000); } catch (InterruptedException ex) { } eCallCenterGUI.destinationTextArea.setEnabled(true); String clientIP = configurationCallCenter.getClientIP(); if (VoipStormTools.isLong(configurationCallCenter.getUsername())) { usernameStart = Long.parseLong(configurationCallCenter.getUsername()); } else { usernameStart = 0L; } prefixToegang = prefixField.getText(); suffixToegang = suffixField.getText(); outboundSoftPhonesAvailable = softphonesQuantity; serviceLoopProgressBar.setMaximum(outboundSoftPhonesAvailable - 1); threadArray = new Thread[outboundSoftPhonesAvailable + 1]; // Now that we know how many instances are required, we can reinstantiate the phonesTable. // Set the preferred number of columns and calculate the rowcount final int phonesTableRowsNeeded = Math .round(outboundSoftPhonesAvailable / phonesPoolTablePreferredColumns); PhonesPoolTableModel tableModel = new PhonesPoolTableModel(); phonesPoolTable.setModel(tableModel); // [rows][cols] so rows is an array of columns // Originally DefaultTableModel phonesPoolTableCellRenderer = new PhonesPoolTableCellRenderer(); for (int columnCounter = 0; columnCounter < phonesPoolTablePreferredColumns; columnCounter++) { phonesPoolTableColumn = phonesPoolTable.getColumnModel().getColumn(columnCounter); phonesPoolTableColumn.setCellRenderer(phonesPoolTableCellRenderer); phonesPoolTable.getColumnModel().getColumn(columnCounter).setResizable(false); phonesPoolTable.getColumnModel().getColumn(columnCounter) .setMinWidth(PHONESPOOLTABLECOLUMNWIDTH); phonesPoolTable.getColumnModel().getColumn(columnCounter) .setMaxWidth(PHONESPOOLTABLECOLUMNWIDTH); phonesPoolTable.getColumnModel().getColumn(columnCounter) .setPreferredWidth(PHONESPOOLTABLECOLUMNWIDTH); } phonesPoolTable.setRowHeight(PHONESPOOLTABLECOLUMNHEIGHT); phonesPoolTable.setForeground(new java.awt.Color(102, 102, 102)); phonesPoolTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF); phonesPoolTable.setAutoscrolls(false); phonesPoolTable.setDoubleBuffered(true); phonesPoolTable.setFocusTraversalKeysEnabled(false); phonesPoolTable.setFocusable(false); phonesPoolTable.setRequestFocusEnabled(false); phonesPoolTable.setSelectionBackground(new java.awt.Color(204, 204, 204)); phonesPoolTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); phonesPoolTable.setRowSelectionAllowed(false); phonesPoolTable.setColumnSelectionAllowed(false); phonesPoolTable.getTableHeader().setResizingAllowed(false); phonesPoolTable.getTableHeader().setReorderingAllowed(false); phonesPoolTable.setShowGrid(false); outboundInstanceCounter = 0; powerCounter = 0; serviceLoopProgressBar.setEnabled(true); showStatus("Powering SoftPhones...", true, true); /* true = logToApplic, true = logToFile */ while (powerCounter < outboundSoftPhonesAvailable) { try { configurationSoftPhone = (Configuration) configurationCallCenter.clone(); } catch (CloneNotSupportedException ex) { showStatus(ex.getMessage(), true, true); } // if ((VoipStormTools.isLong(configurationCallCenter.getUsername())) && (configurationSoftPhone.getPublicIP().length() == 0)) // { // varUsername = Long.toString(usernameStart + (long)powerCounter); // configurationSoftPhone.setUsername(varUsername); // configurationSoftPhone.setToegang(prefixToegang + varUsername + suffixToegang); // } // else // or single account to remote PBX (budgetphone) // { configurationSoftPhone.setUsername(configurationCallCenter.getUsername()); configurationSoftPhone.setToegang(configurationCallCenter.getToegang()); // } // if (configurationSoftPhone.getPublicIP().length() == 0) // multiple accounts to local proxy // { // varUsername = Long.toString(usernameStart + (long)powerCounter); // configurationSoftPhone.setUsername(varUsername); // configurationSoftPhone.setToegang(prefixToegang + varUsername + suffixToegang); // } // else // or single account to remote PBX (budgetphone) // { // configurationSoftPhone.setUsername(configurationCallCenter.getUsername()); // configurationSoftPhone.setToegang(configurationCallCenter.getToegang()); // } // SoftPhone instance try { threadArray[powerCounter] = new SoftPhone(eCallCenterGUI, powerCounter, debugging, configurationSoftPhone); } catch (CloneNotSupportedException error) { showStatus("Error: threadArray[powerCounter] = new SoftPhone(..)" + error.getMessage(), true, true); /* true = logToApplic, true = logToFile */ } threadArray[powerCounter].setName("SoftPhone" + threadArray[powerCounter]); threadArray[powerCounter].setDaemon(runThreadsAsDaemons); // Starts the SoftPhone object as a thread threadArray[powerCounter].setPriority(5); // Starts the SoftPhone object as a thread threadArray[powerCounter].start(); // Starts the SoftPhone object as a thread // New included start lsteners all in one go status[0] = ""; status[1] = ""; SoftPhone thisSoftPhoneInstance = (SoftPhone) threadArray[powerCounter]; thisSoftPhoneInstance.autoEndCall = true; // Make sure the calls end after streaming the media status = thisSoftPhoneInstance .startListener(eCallCenterGUI.configurationSoftPhone.getClientPort()); if (status[0].equals("1")) { showStatus("startListener Error: " + status[1], true, true); } else { if (powerCounter < (outboundSoftPhonesAvailable - 1)) // get rid of the last empty line if else construction { eCallCenterGUI.destinationTextArea .append("sip:" + clientIP + ":" + status[1] + lineTerminator); } else { eCallCenterGUI.destinationTextArea.append("sip:" + clientIP + ":" + status[1]); } } phoneStatsTable.setValueAt((outboundInstanceCounter + 1), 0, 1); phoneStatsTable.setValueAt((powerCounter + 1), 1, 1); outboundInstanceCounter++; powerCounter++; serviceLoopProgressBar.setValue(powerCounter); try { Thread.sleep(ultraShortMessagePeriod); } catch (InterruptedException ex) { } } serviceLoopProgressBar.setValue(0); serviceLoopProgressBar.setEnabled(false); phoneStatsTable.setValueAt("-", 1, 1); // ProcessingInstance serviceLoopProgressBar.setValue(0); serviceLoopProgressBar.setEnabled(false); // // Sets Mute // powerCounter = 0; // serviceLoopProgressBar.setEnabled(true); // showStatus("Mute Audio SoftPhones...", true, true); /* true = logToApplic, true = logToFile */ // while (powerCounter < outboundSoftPhonesAvailable) // Starts looping through the user-range // { // SoftPhone thisSoftPhoneInstance = (SoftPhone) threadArray[powerCounter]; // status = thisSoftPhoneInstance.userInput(MUTEAUDIOBUTTON, "1", "", ""); // if (status[0].equals("1")) { showStatus("Mute Audio Error: " + status[1], true, true); /* true = logToApplic, true = logToFile */ } // phoneStatsTable.setValueAt(powerCounter + 1, 1, 1); // try { Thread.sleep(ultraShortMessagePeriod); } catch (InterruptedException ex) { } // serviceLoopProgressBar.setValue(powerCounter); // powerCounter++; // } // phoneStatsTable.setValueAt("-", 1, 1); // serviceLoopProgressBar.setValue(0); serviceLoopProgressBar.setEnabled(false); // callRatioChartData.setValue("Slack", 0); callRatioChartData.setValue("Busy", 0); callRatioChartData.setValue("Success", 0); graphInnerPanel.setVisible(true); chartPanel.setVisible(true); if (outboundSoftPhonesAvailable > 0) // Successfully started our SoftPhone pool { showStatus(Vergunning.PRODUCT + " Ready", true, true); powerToggleButton.setForeground(Color.blue); callButton.setEnabled(true); endButton.setEnabled(true); autoSpeedToggleButton.setEnabled(true); campaignProgressBar.setEnabled(true); muteAudioToggleButton.setEnabled(true); muteAudioToggleButton.setSelected(true); muteAudioToggleButton.setForeground(Color.blue); registerToggleButton.setEnabled(true); humanResponseSimulatorToggleButton.setEnabled(true); debugToggleButton.setEnabled(true); vergunningTypeList.setEnabled(false); vergunningDateChooserPanel.setEnabled(false); vergunningPeriodList.setEnabled(false); String[] openCampaigns = dbClient.getOpenCampaigns(); if ((openCampaigns != null) && (openCampaigns.length > 0)) { campaignComboBox.setModel(new javax.swing.DefaultComboBoxModel(openCampaigns)); campaignComboBox.setEnabled(true); } else { campaignComboBox.setEnabled(false); runCampaignToggleButton.setEnabled(false); runCampaignToggleButton.setEnabled(false); } } callCenterStatus = POWEREDON; } else { // myClickOffSoundTool.play(); powerCounter = outboundInstanceCounter; showStatus("Powering Off " + Vergunning.PRODUCT, true, true); while (powerCounter > 0) // Starts looping through the user-range { powerCounter--; Thread powerOffThread = new Thread(allThreadsGroup, new Runnable() { @Override @SuppressWarnings("static-access") public void run() { SoftPhone thisSoftPhoneInstance = (SoftPhone) threadArray[powerCounter]; // Get the reference to the SoftPhone object in the loop thisSoftPhoneInstance.pleaseStop(); String[] status = new String[2]; status = thisSoftPhoneInstance.userInput(LINE1BUTTON, "1", "0", ""); if (status[0].equals("1")) { showStatus("Power Error: " + status[1], true, true); } } }); powerOffThread.setName("powerOffThread"); powerOffThread.setDaemon(runThreadsAsDaemons); powerOffThread.start(); outboundInstanceCounter--; phoneStatsTable.setValueAt(outboundInstanceCounter + outboundInstanceCounter, 0, 1); // Instance phoneStatsTable.setValueAt(powerCounter + outboundInstanceCounter, 0, 1); // Processing serviceLoopProgressBar.setValue(powerCounter); try { Thread.sleep(smoothMovementPeriod); } catch (InterruptedException ex) { } } powerToggleButton.setForeground(Color.black); registerToggleButton.setSelected(false); registerToggleButton.setForeground(Color.black); registerToggleButton.setEnabled(false); humanResponseSimulatorToggleButton.setSelected(false); humanResponseSimulatorToggleButton.setForeground(Color.black); humanResponseSimulatorToggleButton.setEnabled(false); muteAudioToggleButton.setSelected(false); muteAudioToggleButton.setForeground(Color.black); muteAudioToggleButton.setEnabled(false); debugToggleButton.setSelected(false); debugToggleButton.setForeground(Color.black); debugToggleButton.setEnabled(false); callButton.setEnabled(false); endButton.setEnabled(false); autoSpeedToggleButton.setEnabled(false); vergunningTypeList.setEnabled(true); vergunningDateChooserPanel.setEnabled(true); // licensePeriodList.setEnabled(true); showStatus(Vergunning.PRODUCT + " Powered Off", true, true); phoneStatsTable.setValueAt("-", 1, 1); // Processing callCenterStatus = POWEREDOFF; if (!vergunning.isValid()) { showStatus("Please select \"License Type\" and see \"License Details\"...", false, false); tabPane.setSelectedIndex(6); // setImagePanelVisible(true); } try { Thread.sleep(mediumMessagePeriod); } catch (InterruptedException ex) { } setImagePanelVisible(true); } return; } }); outboundPowerToggleButtonActionPerformedThread9.setName("outboundPowerToggleButtonActionPerformedThread9"); outboundPowerToggleButtonActionPerformedThread9.setDaemon(runThreadsAsDaemons); outboundPowerToggleButtonActionPerformedThread9.start(); }
From source file:ECallCenter21.java
/** * *//*from w w w .jav a 2 s . c o m*/ public void blinkNetManagerToggleButton() { Thread blinkNetManagerToggleButtonThread = new Thread(allThreadsGroup, new Runnable() { @Override @SuppressWarnings({ "static-access", "empty-statement" }) public void run() { if (netManagerInboundServerToggleButton.isSelected()) { netManagerInboundServerToggleButton.setForeground(Color.GREEN); powerToggleButton.setForeground(Color.GREEN); try { Thread.sleep(smoothMovementPeriod); } catch (InterruptedException ex) { } netManagerInboundServerToggleButton.setForeground(Color.BLUE); powerToggleButton.setForeground(Color.BLUE); } else if (netManagerOutboundServerToggleButton.isSelected()) { netManagerOutboundServerToggleButton.setForeground(Color.GREEN); powerToggleButton.setForeground(Color.GREEN); try { Thread.sleep(smoothMovementPeriod); } catch (InterruptedException ex) { } netManagerOutboundServerToggleButton.setForeground(Color.BLUE); powerToggleButton.setForeground(Color.BLUE); } } }); blinkNetManagerToggleButtonThread.setName("blinkNetManagerToggleButtonThread"); blinkNetManagerToggleButtonThread.setDaemon(runThreadsAsDaemons); blinkNetManagerToggleButtonThread.start(); }
From source file:ECallCenter21.java
synchronized void moveVMUsageMeter(final int toParam, boolean smoothParam) { if ((smoothParam) && (!moveVMUSageMeterIsLocked)) { moveVMUSageMeterIsLocked = true; Thread moveVMUsageMeterThread = new Thread(allThreadsGroup, new Runnable() { @Override/*from w w w .ja v a 2 s . c o m*/ @SuppressWarnings("empty-statement") public void run() { if (performanceMeter != null) { double from = performanceMeter.getVMUsageNeedle().doubleValue(); double counter = from; double to = toParam; if (from < to) { for (counter = from; counter < to; counter++) { performanceMeter.setVMUsageNeedle(counter); try { Thread.sleep(5); } catch (InterruptedException ex) { } } } else { for (counter = from; counter > to; counter--) { performanceMeter.setVMUsageNeedle(counter); try { Thread.sleep(5); } catch (InterruptedException ex) { } } } } moveVMUSageMeterIsLocked = false; } }); moveVMUsageMeterThread.setName("moveVMUsageMeterThread"); moveVMUsageMeterThread.setDaemon(runThreadsAsDaemons); moveVMUsageMeterThread.setPriority(5); moveVMUsageMeterThread.start(); } else { if (performanceMeter != null) { performanceMeter.setVMUsageNeedle(toParam); } } }
From source file:ECallCenter21.java
/** * * @param toParam//from w w w . ja v a2s.c om * @param smoothParam */ synchronized protected void movePerformanceMeter(final double toParam, boolean smoothParam) { if ((smoothParam) && (!performanceMeterIsLocked)) { performanceMeterIsLocked = true; Thread movePerformanceMeterThread = new Thread(allThreadsGroup, new Runnable() { @Override @SuppressWarnings("empty-statement") public void run() { if (performanceMeter != null) { double from = performanceMeter.getCallPerHourNeedle().doubleValue(); double counter = from; double to = toParam; if (from < to) { for (counter = from; counter < to; counter += 1) { performanceMeter.setCallPerHourNeedle(counter); try { Thread.sleep(3); } catch (InterruptedException ex) { } } } else { for (counter = from; counter > to; counter -= 1) { performanceMeter.setCallPerHourNeedle(counter); try { Thread.sleep(3); } catch (InterruptedException ex) { } } } } performanceMeterIsLocked = false; } }); movePerformanceMeterThread.setName("movePerformanceMeterThread"); movePerformanceMeterThread.setDaemon(runThreadsAsDaemons); movePerformanceMeterThread.setPriority(5); movePerformanceMeterThread.start(); } else { if (performanceMeter != null) { performanceMeter.setCallPerHourNeedle(toParam); } } }
From source file:org.energy_home.jemma.javagal.layers.business.implementations.ApsManager.java
/** * Processes the APS indication message trying to dispatch it to the right * destination. The {@link GalController} maintains a collection of * registered callbacks' listeners. This method verifies if a match exists * on that collection for the callback's filter, i.e. looks if one or more * destination(s) for that APS message is present. If it exists, sends the * APS message to all found destinations. * /* w w w. j ava 2 s . co m*/ * @param message * the indication APSMessageEvent to process. */ public void APSMessageIndication(final APSMessageEvent message) { Thread thr = new Thread() { @Override public void run() { if (gal.getPropertiesManager().getDebugEnabled()) { logger.info("Aps Message Indication in process..."); } for (CallbackEntry ce : gal.getCallbacks()) { APSMessageListener apml = ce.getDestination(); Callback callback = ce.getCallback(); Filter filter = callback.getFilter(); if (filter.getLevelSpecification().getLevel().get(0).equals(Level.APS_LEVEL)) { if (filter.getMessageSpecification().size() > 0) { boolean messageSpecificationFound = false; for (MessageSpecification ms : filter.getMessageSpecification()) { if (ms.getAPSClusterIdentifier() == null) { messageSpecificationFound = true; // If match we can stop the search loop. break; } else if (ms.getAPSClusterIdentifier() == message.getClusterID()) { messageSpecificationFound = true; // If match we can stop the search loop. break; } } if (!messageSpecificationFound) { // If no Messaging Specification was found, // then this callback doesn't match and we // can jump to check the next one. continue; } } // Address Specification check. If there are at // least one address specification in the filter, // then we proceed to find a match, else if no // address specification is present we assume that // the check pass. if (filter.getAddressSpecification().size() > 0) { boolean addressingSpecificationFound = false; for (AddressSpecification as : filter.getAddressSpecification()) { // Source Address (Address Specification) Address assa = as.getNWKSourceAddress(); int asnsa = 0xFFFF; // If null, then we assume that all address // match for this filter, and so we leave // the initial value of 0xFFFF. if (assa != null) { asnsa = assa.getNetworkAddress(); } short assep = -1; if (as.getAPSSourceEndpoint() != null) assep = as.getAPSSourceEndpoint(); // Pass if the callback has a broadcast // Source Address if (asnsa != 0xFFFF) { // Source Address long msam = message.getSourceAddressMode().longValue(); Address msa = message.getSourceAddress(); if (msam == 0x01) { // Network address, NO source end // point int msna0x01 = msa.getNetworkAddress(); // Pass if the message has a // broadcast Source Address if (msna0x01 != 0xFFFF) { // Don't pass if they differs, // so we go ahead on the next // iteration in the for cycle if (asnsa != msna0x01) { continue; } } } else if (msam == 0x02) { // Network address, AND source end // point present. int msna0x02 = msa.getNetworkAddress(); short msep = message.getSourceEndpoint(); // Pass if the message has a // broadcast Source Address. if (msna0x02 != 0xFFFF) { // Don't pass if they differs, // so we go ahead on the // next iteration in for cycle. if (asnsa != msna0x02) { // Don't pass if they // differs, so we go ahead // on the next iteration in // the for cycle. continue; } else if (msep != 0xFF) { if (msep != assep) { // Don't pass if they // differs, so we go // ahead on the next // iteration in the for // cycle. continue; } } } } else if (msam == 0x03) { logger.info("AIA"); // ASK No ieee address defined in // the AddressSpecification // object. We do nothing since we // can't compare the values. } } // If reached this point, then a matching // Source Address is found for the current // AddressSpecification. So we can proceed // to check the Destination End Point. // Destination End Point (Address // Specification) if (as.getAPSDestinationEndpoint() == null) { addressingSpecificationFound = true; break; } else { short asdep = as.getAPSDestinationEndpoint(); // Pass if the callback has a broadcast // Destination End Point if (asdep != 0xFF) { long dam = message.getDestinationAddressMode(); // 0x00 and 0x01 Destination End // Point // not present if (dam > 0x01) { short mdep = message.getDestinationEndpoint(); // Pass if the message has a // broadcast Destination End // Point if (mdep != 0xFF) { // Don't pass if they // differs, // so we go ahead on the // next // iteration in the for // cycle if (asdep != mdep) { continue; } } } } } // If reached this point, then a matching // Destination End Point is also found for // the current AddressSpecification. This // means that a matching Addressing // Specification is found. We can stop here // the loop since one match it's enough. addressingSpecificationFound = true; break; } if (!addressingSpecificationFound) { // If no Addressing Specification was found, // then this callback doesn't match and we // can jump to check the next one. continue; } } // If this point is reached, then a matching // callback is found. Notify the message to its // destination. apml.notifyAPSMessage(message); // Add it to the list of already notified // destinations. } } } }; thr.setName("Thread APSMessageIndication(final APSMessageEvent message)"); thr.start(); }
From source file:ECallCenter21.java
synchronized void moveCallSpeedSlider(final int toParam, boolean smoothParam) // When going faster, this routine does not move to "toParam" but instead to a little less than current slider value { if ((smoothParam) && (!moveCallSpeedSliderIsLocked)) { moveCallSpeedSliderIsLocked = true; Thread moveCallSpeedSliderThread = new Thread(allThreadsGroup, new Runnable() { @Override//from ww w.j av a2 s. c o m @SuppressWarnings("empty-statement") public void run() { if (callSpeedSlider != null) { int from = callSpeedSlider.getValue(); int counter = from; int to = toParam; int step = Math.round((callSpeedSlider.getMaximum() - callSpeedSlider.getMinimum()) / 100); int get = (callSpeedSlider.getValue() - callSpeedSlider.getMinimum()); int max = (callSpeedSlider.getMaximum() - callSpeedSlider.getMinimum()); int perdecimal = (get / (max / 10)) + 2; if (from < to) // Sliding down to longer intervals { for (counter = from; counter < to; counter += step) { callSpeedSlider.setValue(counter); try { Thread.sleep(5); } catch (InterruptedException ex) { } } } else { // for (counter = from; counter > (from - (step * 5)); counter -= step ) { callSpeedSlider.setValue(counter); try { Thread.sleep(100); } catch (InterruptedException ex) { } } for (counter = from; counter > (from - (step * perdecimal)); counter -= step) { callSpeedSlider.setValue(counter); try { Thread.sleep(100); } catch (InterruptedException ex) { } } } } moveCallSpeedSliderIsLocked = false; } }); moveCallSpeedSliderThread.setName("moveCallSpeedSliderThread"); moveCallSpeedSliderThread.setDaemon(runThreadsAsDaemons); moveCallSpeedSliderThread.setPriority(5); moveCallSpeedSliderThread.start(); } else { if (callSpeedSlider != null) { callSpeedSlider.setValue(toParam); } } }
From source file:ECallCenter21.java
private void resizeWindowButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resizeWindowButtonActionPerformed Thread resizeWindowThread = new Thread(new Runnable() { @Override// w w w. jav a2 s . com @SuppressWarnings({ "static-access" }) public void run() { if (getSize().getHeight() == getMinimumSize().getHeight()) { colorMaskPanel.setVisible(false); int dimWidth = (int) getMaximumSize().getWidth(); int dimHeight = (int) getMinimumSize().getHeight(); double step = 70; while (dimHeight < (int) getMaximumSize().getHeight()) { setSize(dimWidth, dimHeight); try { Thread.sleep(2); } catch (InterruptedException ex) { } dimHeight += step; step = (step * 0.65) + 1; } setSize(getMaximumSize()); colorMaskPanel.setVisible(true); resizeWindowButton.setText(icons.getResizeUpChar()); resizeWindowButton.setToolTipText("Hide Controls"); } else { colorMaskPanel.setVisible(false); int dimWidth = (int) getMaximumSize().getWidth(); int dimHeight = (int) getMaximumSize().getHeight(); double step = 70; while (dimHeight > (int) getMinimumSize().getHeight()) { setSize(dimWidth, dimHeight); try { Thread.sleep(2); } catch (InterruptedException ex) { } dimHeight -= step; step = (step * 0.65) + 1; } setSize(getMinimumSize()); colorMaskPanel.setVisible(true); resizeWindowButton.setText(icons.getResizeDownChar()); resizeWindowButton.setToolTipText("Show Controls"); } } }); resizeWindowThread.setName("resizeWindowThread"); resizeWindowThread.setDaemon(runThreadsAsDaemons); resizeWindowThread.start(); }