Example usage for java.lang CloneNotSupportedException getMessage

List of usage examples for java.lang CloneNotSupportedException getMessage

Introduction

In this page you can find the example usage for java.lang CloneNotSupportedException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:edu.caltech.ipac.firefly.server.util.ipactable.DataGroupReader.java

public static DataGroup read(File inf, boolean isFixedLength, boolean readAsString, boolean saveFormattedData,
        String... onlyColumns) throws IOException {

    TableDef tableMeta = IpacTableUtil.getMetaInfo(inf);
    List<DataGroup.Attribute> attributes = tableMeta.getAttributes();
    List<DataType> cols = tableMeta.getCols();

    if (readAsString) {
        for (DataType dt : cols) {
            dt.setDataType(String.class);
        }/*from  w  w  w.  j  av  a 2  s  .co  m*/
    }

    DataGroup headers = new DataGroup(null, cols);
    DataGroup data = null;
    boolean isSelectedColumns = onlyColumns != null && onlyColumns.length > 0;

    if (isSelectedColumns) {
        List<DataType> selCols = new ArrayList<DataType>();
        for (String c : onlyColumns) {
            DataType dt = headers.getDataDefintion(c);
            if (dt != null) {
                try {
                    selCols.add((DataType) dt.clone());
                } catch (CloneNotSupportedException e) {
                } // shouldn't happen
            }
        }
        data = new DataGroup(null, selCols);
    } else {
        data = headers;
    }

    data.setAttributes(attributes);

    String line = null;
    int lineNum = 0;

    BufferedReader reader = new BufferedReader(new FileReader(inf), IpacTableUtil.FILE_IO_BUFFER_SIZE);
    try {
        line = reader.readLine();
        lineNum++;
        while (line != null) {
            DataObject row = IpacTableUtil.parseRow(headers, line, isFixedLength, saveFormattedData);
            if (row != null) {
                if (isSelectedColumns) {
                    DataObject arow = new DataObject(data);
                    for (DataType dt : data.getDataDefinitions()) {
                        arow.setDataElement(dt, row.getDataElement(dt.getKeyName()));
                    }
                    data.add(arow);
                } else {
                    data.add(row);
                }
            }
            line = reader.readLine();
            lineNum++;
        }
    } catch (Exception e) {
        String msg = e.getMessage() + "<br>on line " + lineNum + ": " + line;
        if (msg.length() > 128)
            msg = msg.substring(0, 128) + "...";
        logger.error(e, "on line " + lineNum + ": " + line);
        throw new IOException(msg);
    } finally {
        reader.close();
    }

    if (!saveFormattedData) {
        data.shrinkToFitData();
    }
    return data;
}

From source file:com.dattack.naming.AbstractContext.java

@Override
public Object lookup(final Name name) throws NamingException {

    ensureContextNotClosed();//  w  ww .j  ava  2 s  . c om

    /*
     * Extract from Context Javadoc: If name is empty, returns a new instance of this context (which represents the
     * same naming context as this context, but its environment may be modified independently and it may be accessed
     * concurrently).
     */
    if (name.isEmpty()) {
        try {
            return this.clone();
        } catch (final CloneNotSupportedException e) {
            // this shouldn't happen, since we are Cloneable
            throw (NamingException) new OperationNotSupportedException(e.getMessage()).initCause(e);
        }
    }

    if (name.size() > 1) {
        if (subContexts.containsKey(name.getPrefix(1))) {
            return subContexts.get(name.getPrefix(1)).lookup(name.getSuffix(1));
        }
        throw new NamingException(
                String.format("Invalid subcontext '%s' in context '%s'", name.getPrefix(1).toString(),
                        StringUtils.isBlank(getNameInNamespace()) ? "/" : getNameInNamespace()));
    }

    Object result = null; // not found
    if (objectTable.containsKey(name)) {
        result = objectTable.get(name);
    } else if (subContexts.containsKey(name)) {
        result = subContexts.get(name);
    } else if (env.containsKey(name.toString())) {
        result = env.get(name.toString());
    }

    return result;
}

From source file:org.grails.orm.hibernate.HibernateDatastore.java

private void addTenantForSchemaInternal(String schemaName) {
    if (multiTenantMode != MultiTenancySettings.MultiTenancyMode.SCHEMA) {
        throw new ConfigurationException(
                "The method [addTenantForSchema] can only be called with multi-tenancy mode SCHEMA. Current mode is: "
                        + multiTenantMode);
    }//  w  w  w.  j a  va  2s.  co  m
    HibernateConnectionSourceFactory factory = (HibernateConnectionSourceFactory) connectionSources
            .getFactory();
    HibernateConnectionSource defaultConnectionSource = (HibernateConnectionSource) connectionSources
            .getDefaultConnectionSource();
    HibernateConnectionSourceSettings tenantSettings;
    try {
        tenantSettings = connectionSources.getDefaultConnectionSource().getSettings().clone();
    } catch (CloneNotSupportedException e) {
        throw new ConfigurationException("Couldn't clone default Hibernate settings! " + e.getMessage(), e);
    }
    tenantSettings.getHibernate().put("default_schema", schemaName);

    String dbCreate = tenantSettings.getDataSource().getDbCreate();

    SchemaAutoTooling schemaAutoTooling = dbCreate != null ? SchemaAutoTooling.interpret(dbCreate) : null;
    if (schemaAutoTooling != null && schemaAutoTooling != SchemaAutoTooling.VALIDATE
            && schemaAutoTooling != SchemaAutoTooling.NONE) {

        Connection connection = null;
        try {
            connection = defaultConnectionSource.getDataSource().getConnection();
            try {
                schemaHandler.useSchema(connection, schemaName);
            } catch (Exception e) {
                // schema doesn't exist
                schemaHandler.createSchema(connection, schemaName);
            }
        } catch (SQLException e) {
            throw new DatastoreConfigurationException(
                    String.format("Failed to create schema for name [%s]", schemaName));
        } finally {
            if (connection != null) {
                try {
                    connection.close();
                } catch (SQLException e) {
                    //ignore
                }
            }
        }
    }

    DataSource dataSource = defaultConnectionSource.getDataSource();
    dataSource = new MultiTenantDataSource(dataSource, schemaName);
    DefaultConnectionSource<DataSource, DataSourceSettings> dataSourceConnectionSource = new DefaultConnectionSource<>(
            schemaName, dataSource, tenantSettings.getDataSource());
    ConnectionSource<SessionFactory, HibernateConnectionSourceSettings> connectionSource = factory
            .create(schemaName, dataSourceConnectionSource, tenantSettings);
    SingletonConnectionSources<SessionFactory, HibernateConnectionSourceSettings> singletonConnectionSources = new SingletonConnectionSources<>(
            connectionSource, connectionSources.getBaseConfiguration());
    HibernateDatastore childDatastore = new HibernateDatastore(singletonConnectionSources,
            (HibernateMappingContext) mappingContext, eventPublisher) {
        @Override
        protected HibernateGormEnhancer initialize() {
            return null;
        }
    };
    datastoresByConnectionSource.put(connectionSource.getName(), childDatastore);
}

From source file:com.lineage.server.templates.L1Npc.java

@Override
public L1Npc clone() {
    try {//from  w w  w .j a  v  a2 s  .c  om
        return (L1Npc) (super.clone());
    } catch (final CloneNotSupportedException e) {
        throw (new InternalError(e.getMessage()));
    }
}

From source file:net.sf.ehcache.CacheManager.java

/**
 * Adds a {@link Ehcache} based on the defaultCache with the given name.
 * <p/>//from   w w w.ja v a 2s  .c om
 * Memory and Disk stores will be configured for it and it will be added
 * to the map of caches.
 * <p/>
 * Also notifies the CacheManagerEventListener after the cache was initialised and added.
 * <p/>
 * It will be created with the defaultCache attributes specified in ehcache.xml
 *
 * @param cacheName the name for the cache
 * @throws ObjectExistsException if the cache already exists
 * @throws CacheException        if there was an error creating the cache.
 */
public synchronized void addCache(String cacheName)
        throws IllegalStateException, ObjectExistsException, CacheException {
    checkStatus();

    //NPE guard
    if (cacheName == null || cacheName.length() == 0) {
        return;
    }

    if (ehcaches.get(cacheName) != null) {
        throw new ObjectExistsException("Cache " + cacheName + " already exists");
    }
    Ehcache cache = null;
    try {
        cache = (Ehcache) defaultCache.clone();
    } catch (CloneNotSupportedException e) {
        throw new CacheException("Failure adding cache. Initial cause was " + e.getMessage(), e);
    }
    if (cache != null) {
        cache.setName(cacheName);
    }
    addCache(cache);
}

From source file:com.gdo.stencils.plug.PStcl.java

/**
 * Returns a cloned stencil (which is never in cursor).
 * /*from w w  w .  jav  a2  s.c om*/
 * @param stclContext
 *            the stencil context.
 * @param key
 *            the plug key.
 * @return the cloned stencil.
 */
public PStcl clone(StclContext stclContext, PSlot<StclContext, PStcl> slot, IKey key) {
    try {
        return getReleasedStencil(stclContext).clone(stclContext, slot, key, self());
    } catch (CloneNotSupportedException e) {
        return nullPStencil(stclContext, Result.error(e.getMessage()));
    }
}

From source file:eu.eidas.auth.engine.EIDASSAMLEngine.java

/**
* Resign authentication request ( for validation purpose).
* @return the resigned request/*from   w  w w  .  j  a v  a2  s  .  co m*/
* @throws EIDASSAMLEngineException the EIDASSAML engine exception
*/
public EIDASAuthnRequest resignEIDASAuthnRequest(final EIDASAuthnRequest request, boolean changeProtocol)
        throws EIDASSAMLEngineException {
    LOG.trace("Generate SAMLAuthnRequest.");

    EIDASAuthnRequest authRequest = null;
    AuthnRequest authnRequestAux = null;

    try {
        authRequest = (EIDASAuthnRequest) request.clone();
    } catch (CloneNotSupportedException e) {
        LOG.debug(SAML_EXCHANGE, "BUSINESS EXCEPTION : Clone not supported in resignEIDASAuthnRequest {}", e);
        LOG.info(SAML_EXCHANGE, "BUSINESS EXCEPTION : Clone not supported in resignEIDASAuthnRequest {}",
                e.getMessage());
    }

    byte[] tokenSaml = request.getTokenSaml();

    try {
        authnRequestAux = (AuthnRequest) unmarshall(tokenSaml);
        if (SAMLEngineUtils.isEidasFormat(request)) {
            authnRequestAux.setProtocolBinding(null);
        } else if (authnRequestAux.getProtocolBinding() == null || changeProtocol) {
            authnRequestAux.setProtocolBinding(getProtocolBinding(authRequest.getBinding()));
        }
    } catch (SAMLEngineException e) {
        LOG.info(SAML_EXCHANGE, "BUSINESS EXCEPTION : resignEIDASAuthnRequest {}", e.getMessage());
        LOG.debug(SAML_EXCHANGE, "BUSINESS EXCEPTION : resignEIDASAuthnRequest {}", e);
    }

    try {
        authRequest.setTokenSaml(
                super.signAndMarshall(authnRequestAux, getExtensionProcessor().getFormat().getName()));
    } catch (SAMLEngineException e) {
        LOG.info(SAML_EXCHANGE, "BUSINESS EXCEPTION : resignEIDASAuthnRequest : Sign and Marshall.{}",
                e.getMessage());
        LOG.debug(SAML_EXCHANGE, "BUSINESS EXCEPTION : resignEIDASAuthnRequest : Sign and Marshall.{}", e);
        throw new EIDASSAMLEngineException(EIDASErrors.INTERNAL_ERROR.errorCode(),
                EIDASErrors.INTERNAL_ERROR.errorMessage(), e);
    }
    return authRequest;
}

From source file:ECallCenter21.java

/**
 *
 * @param onParam/*  w w w . ja  v  a2s .c  om*/
 */
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:lasige.steeldb.jdbc.BFTRowSet.java

/**
 * Returns a new <code>RowSet</code> object backed by the same data as
 * that of this <code>CachedRowSetImpl</code> object and sharing a set of cursors
 * with it. This allows cursors to interate over a shared set of rows, providing
 * multiple views of the underlying data.
 *
 * @return a <code>RowSet</code> object that is a copy of this <code>CachedRowSetImpl</code>
 * object and shares a set of cursors with it
 * @throws SQLException if an error occurs or cloning is
 *                         not supported
 * @see javax.sql.RowSetEvent/*  w w  w . ja  v  a 2  s. c o m*/
 * @see javax.sql.RowSetListener
 */
public RowSet createShared() throws SQLException {
    RowSet clone;
    try {
        clone = (RowSet) clone();
    } catch (CloneNotSupportedException ex) {
        throw new SQLException(ex.getMessage());
    }
    return clone;
}

From source file:ECallCenter21.java

/**
 *
 * @param campaignIdParam//from   w w w.  j a v  a 2  s  .c  om
 */
public void runCampaign(int campaignIdParam) {
    callCenterStatus = LOADCAMPAIGN;
    runCampaignToggleButton.removeActionListener(runCampaignToggleButton.getActionListeners()[0]);
    final int campaignId = campaignIdParam;
    Thread outboundCallButtonActionPerformedThread7 = new Thread(allThreadsGroup, new Runnable() {
        @Override
        @SuppressWarnings({ "static-access", "static-access", "static-access", "static-access", "static-access",
                "static-access", "static-access" })
        public void run() {
            String[] status = new String[2];
            //              Prepare the Campaign Run loading the data objects
            campaignStopRequested = false;
            campaign = dbClient.loadCampaignFromOrderId(campaignId);

            order = dbClient.selectCustomerOrder(campaign.getOrderId());
            lastMessageDuration = order.getMessageDuration();

            // Load the Campaign Destinations
            destinationArray = dbClient.selectAllOpenCampaignDestinations(campaignId);

            // Get the saved campaignStat record
            int onAC = campaignStat.getOnAC();
            int idleAC = campaignStat.getIdleAC();
            campaignStat = dbClient.selectCampaignStat(campaignId);
            campaignStat.setOnAC(onAC);
            campaignStat.setIdleAC(idleAC);
            campaignStat.resetActiveCounts();
            try {
                lastTimeDashboardCampaignStat = (CampaignStat) campaignStat.clone();
            } catch (CloneNotSupportedException ex) {
                /* Nonsens in this case*/ } // Make sure there is no difference between this and lastCampaignStat (prevent dashboard going wild on first run)
            if (campaignStat.getConnectingTT() == 0) {
                campaign.setCalendarRegisteredStart(Calendar.getInstance(nlLocale));
                dbClient.updateCampaign(campaign);
            } // First run setting starttime

            soundFileToStream = order.getMessageFilename();
            toegangField.setText(usernameField.getText());
            //                durationCallsEpochTime = 0;
            outboundCallsInProgress = true;
            callCenterIsOutBound = true;
            campaignProgressBar.setEnabled(true);
            runCampaignToggleButton.setEnabled(true);
            stopCampaignButton.setEnabled(true);
            campaignProgressBar.setValue(0);

            callRatioChartData.setValue("Connecting", 0);
            callRatioChartData.setValue("Trying", 0);
            callRatioChartData.setValue("Busy", 0);
            callRatioChartData.setValue("Success", 0);
            graphInnerPanel.setVisible(true);
            chartPanel.setVisible(true);

            turnoverStatsTable.setValueAt(0, 0, 2);
            turnoverStatsTable.setValueAt(0, 1, 2);
            turnoverStatsTable.setValueAt(0, 2, 2);

            // Scheduled Start
            campaignLabel.setText("Campaign " + campaign.getId());
            if (campaign.getCalendarScheduledStart().getTimeInMillis() != 0) {
                campaignTable.setValueAt(String.format("%04d",
                        campaign.getCalendarScheduledStart().get(Calendar.YEAR)) + "-"
                        + String.format("%02d", campaign.getCalendarScheduledStart().get(Calendar.MONTH) + 1)
                        + "-"
                        + String.format("%02d", campaign.getCalendarScheduledStart().get(Calendar.DAY_OF_MONTH))
                        + " "
                        + String.format("%02d", campaign.getCalendarScheduledStart().get(Calendar.HOUR_OF_DAY))
                        + ":" + String.format("%02d", campaign.getCalendarScheduledStart().get(Calendar.MINUTE))
                        + ":"
                        + String.format("%02d", campaign.getCalendarScheduledStart().get(Calendar.SECOND)), 0,
                        1);
            }
            // Scheduled End
            if (campaign.getCalendarScheduledEnd().getTimeInMillis() != 0) {
                campaignTable.setValueAt(String.format("%04d",
                        campaign.getCalendarScheduledEnd().get(Calendar.YEAR)) + "-"
                        + String.format("%02d", campaign.getCalendarScheduledEnd().get(Calendar.MONTH) + 1)
                        + "-"
                        + String.format("%02d", campaign.getCalendarScheduledEnd().get(Calendar.DAY_OF_MONTH))
                        + " "
                        + String.format("%02d", campaign.getCalendarScheduledEnd().get(Calendar.HOUR_OF_DAY))
                        + ":" + String.format("%02d", campaign.getCalendarScheduledEnd().get(Calendar.MINUTE))
                        + ":" + String.format("%02d", campaign.getCalendarScheduledEnd().get(Calendar.SECOND)),
                        1, 1);
            }
            // Expect Start
            if (campaign.getCalendarExpectedStart().getTimeInMillis() != 0) {
                campaignTable.setValueAt(String.format("%04d",
                        campaign.getCalendarExpectedStart().get(Calendar.YEAR)) + "-"
                        + String.format("%02d", campaign.getCalendarExpectedStart().get(Calendar.MONTH) + 1)
                        + "-"
                        + String.format("%02d", campaign.getCalendarExpectedStart().get(Calendar.DAY_OF_MONTH))
                        + " "
                        + String.format("%02d", campaign.getCalendarExpectedStart().get(Calendar.HOUR_OF_DAY))
                        + ":" + String.format("%02d", campaign.getCalendarExpectedStart().get(Calendar.MINUTE))
                        + ":" + String.format("%02d", campaign.getCalendarExpectedStart().get(Calendar.SECOND)),
                        2, 1);
            }
            // Expect End
            if (campaign.getCalendarExpectedEnd().getTimeInMillis() != 0) {
                campaignTable.setValueAt(
                        String.format("%04d", campaign.getCalendarExpectedEnd().get(Calendar.YEAR)) + "-"
                                + String.format("%02d",
                                        campaign.getCalendarExpectedEnd().get(Calendar.MONTH) + 1)
                                + "-"
                                + String.format(
                                        "%02d", campaign.getCalendarExpectedEnd().get(Calendar.DAY_OF_MONTH))
                                + " "
                                + String.format("%02d",
                                        campaign.getCalendarExpectedEnd().get(Calendar.HOUR_OF_DAY))
                                + ":"
                                + String.format("%02d", campaign.getCalendarExpectedEnd().get(Calendar.MINUTE))
                                + ":"
                                + String.format("%02d", campaign.getCalendarExpectedEnd().get(Calendar.SECOND)),
                        3, 1);
            }
            // Registered Start
            if (campaign.getCalendarRegisteredStart().getTimeInMillis() != 0) {
                campaignTable
                        .setValueAt(
                                String.format("%04d", campaign.getCalendarRegisteredStart().get(Calendar.YEAR))
                                        + "-"
                                        + String.format("%02d",
                                                campaign.getCalendarRegisteredStart().get(Calendar.MONTH) + 1)
                                        + "-"
                                        + String.format("%02d",
                                                campaign.getCalendarRegisteredStart()
                                                        .get(Calendar.DAY_OF_MONTH))
                                        + " "
                                        + String.format("%02d",
                                                campaign.getCalendarRegisteredStart().get(Calendar.HOUR_OF_DAY))
                                        + ":"
                                        + String.format("%02d",
                                                campaign.getCalendarRegisteredStart().get(Calendar.MINUTE))
                                        + ":"
                                        + String.format("%02d",
                                                campaign.getCalendarRegisteredStart().get(Calendar.SECOND)),
                                4, 1);
            }
            // Registered End
            if (campaign.getCalendarRegisteredEnd().getTimeInMillis() != 0) {
                campaignTable.setValueAt(String.format("%04d",
                        campaign.getCalendarRegisteredEnd().get(Calendar.YEAR)) + "-"
                        + String.format("%02d", campaign.getCalendarRegisteredEnd().get(Calendar.MONTH) + 1)
                        + "-"
                        + String.format("%02d", campaign.getCalendarRegisteredEnd().get(Calendar.DAY_OF_MONTH))
                        + " "
                        + String.format("%02d", campaign.getCalendarRegisteredEnd().get(Calendar.HOUR_OF_DAY))
                        + ":" + String.format("%02d", campaign.getCalendarRegisteredEnd().get(Calendar.MINUTE))
                        + ":" + String.format("%02d", campaign.getCalendarRegisteredEnd().get(Calendar.SECOND)),
                        5, 1);
            }
            // The rest
            campaignTable.setValueAt("-", 6, 1); // Time Tot
            campaignTable.setValueAt("-", 7, 1); // Time Elap
            campaignTable.setValueAt("-", 8, 1); // Time End
            campaignTable.setValueAt("-", 9, 1); // Throughput Calls

            // Set the static proxy config

            status = new String[2];
            username = configurationCallCenter.getUsername();
            //                toegang         = prefixField.getText() + configurationCallCenter.getToegang() + suffixField.getText(); // User for Asterisk
            toegang = configurationCallCenter.getToegang();
            filename = "file:" + soundFileToStream;

            String text = destinationTextArea.getText();

            // ==============================================================================================================================

            // Sets the Order Object and after that displays the OrderMembers in the orderTable and turnover info
            orderLabel.setText("Order " + order.getOrderId());
            orderTable.setValueAt(order.getRecipientsCategory(), 0, 1);
            //                orderTable.setValueAt(order.getTimeWindowCategory(), 1, 1);
            orderTable.setValueAt(
                    order.getTimeWindow0() + " " + order.getTimeWindow1() + " " + order.getTimeWindow2(), 1, 1);
            orderTable.setValueAt(order.getTargetTransactionQuantity(), 2, 1);
            orderTable.setValueAt(order.getTargetTransactionQuantity(), 2, 1);
            orderTable.setValueAt(order.getMessageDuration() + " Sec", 3, 1);
            orderTable.setValueAt(order.getMessageRatePerSecond() + " / Sec", 4, 1);
            orderTable.setValueAt(order.getMessageRate(), 5, 1);
            orderTable.setValueAt(order.getSubTotal(), 6, 1);
            turnoverStatsTable
                    .setValueAt((float) (order.getTargetTransactionQuantity() * order.getMessageRate()), 2, 2); // Total Turnover

            // Make sure the outboundBurstRateSlider adapts to the message length in relation to the Call / Message Duration when message is longer than 10 seconds
            if (Math.round(order.getMessageDuration() * 100) < (eCallCenterGUI.callSpeedSlider.getMinimum())) // Soundfile results below minimum
            {
                eCallCenterGUI.callSpeedSlider.setMaximum(eCallCenterGUI.callSpeedSlider.getMinimum());
            } else {
                eCallCenterGUI.callSpeedSlider.setMaximum(order.getMessageDuration() * 50);
                eCallCenterGUI.callSpeedSlider
                        .setMajorTickSpacing(Math.round((eCallCenterGUI.callSpeedSlider.getMaximum()
                                - eCallCenterGUI.callSpeedSlider.getMinimum()) / 10));
                eCallCenterGUI.callSpeedSlider.setPaintLabels(true);
            }
            callSpeedInterval = Math.round(eCallCenterGUI.callSpeedSlider.getMaximum() / 2);
            callSpeedSlider.setValue(callSpeedInterval);

            //                campaignProgressBar.setMaximum(order.getTargetTransactionQuantity()-1);
            campaignProgressBar.setMaximum(dbClient.getNumberOfAllOpenCampaignDestinations(campaign.getId()));

            // This is where the Campaign Re-run loop start
            campaignRerunForLoop: for (int campaignReRunCounter = 1; campaignReRunCounter <= campaignReRunLimit; campaignReRunCounter++) {
                campaignReRunStage = campaignReRunCounter;
                destinationArray = dbClient.selectAllOpenCampaignDestinations(campaignId);

                try {
                    configurationSoftPhone = (Configuration) configurationCallCenter.clone();
                } // clone the config
                catch (CloneNotSupportedException ex) {
                    showStatus(ex.getMessage(), true, true);
                }

                configurationSoftPhone.setUsername(username);
                configurationSoftPhone.setToegang(toegang);

                // ==============================================================================================================================

                destinationsCounter = 0;
                runCampaignCounter = 0;

                // Call Queuer
                // This is where the Call Loop start
                campaignRunForLoop: for (Destination destinationElement : destinationArray) {
                    // TimeWindow Protector
                    if (callCenterIsNetManaged) {
                        //                            if (!TimeWindow.getCurrentTimeWindow().equals(order.getTimeWindowCategory()))

                        boolean legalTimeWindow = false;
                        for (int orderTimewindow : order.getTimewindowIndexArray()) {
                            if (timeTool.getCurrentTimeWindowIndex() == orderTimewindow) {
                                legalTimeWindow = true;
                            }
                        }

                        if (!legalTimeWindow) {
                            showStatus(
                                    "Self Destructing: " + Vergunning.PRODUCT + " running outside TimeWindow !",
                                    true, true);
                            try {
                                Thread.sleep(5000);
                            } catch (InterruptedException ex) {
                            }
                            System.exit(0);
                        }
                    }

                    if (campaignStopRequested) {
                        runCampaignToggleButton.addActionListener(new java.awt.event.ActionListener() {
                            @Override
                            public void actionPerformed(java.awt.event.ActionEvent evt) {
                                runCampaignToggleButtonActionPerformed(evt);
                            }
                        });
                        runCampaignToggleButton.setSelected(false);
                        showStatus("Campaign " + campaign.getId() + " Stopped by user.", true, true);
                        runCampaignToggleButton.setText("");
                        runCampaignToggleButton.setForeground(Color.BLACK);
                        callCenterStatus = STOPPED;

                        campaignProgressBar.setValue(0);
                        campaignProgressBar.setEnabled(false);
                        outboundCallsInProgress = false;
                        phoneStatsTable.setValueAt("-", 1, 1); // ProcessingInstance

                        // Campaign is ready updating open campaignlist
                        String[] openCampaigns = dbClient.getOpenCampaigns();
                        if ((openCampaigns != null) && (openCampaigns.length > 0)) {
                            if (!callCenterIsNetManaged) {
                                campaignComboBox.setModel(new javax.swing.DefaultComboBoxModel(openCampaigns));
                                campaignComboBox.setEnabled(true);
                            }
                        } else {
                            campaignComboBox.setEnabled(false);
                            runCampaignToggleButton.setEnabled(false);
                            stopCampaignButton.setEnabled(false);
                        }
                        return;
                    }

                    destinationElement.resetTimestamps();
                    dbClient.updateDestination(destinationElement); // Makes sure progresstimestamps are reset  on e.g. second campaign round
                    if (runCampaignCounter == outboundSoftPhonesAvailable) {
                        runCampaignCounter = 0;
                    } // This actually makes the loop roundrobin connecting the end with the beginning

                    // Overheat Protector
                    while (
                    //                                (
                    //                                    (order.getTimeWindowCategory().equals(TimeWindow.getDAYTIME_DECRIPTION())) &&
                    //                                    (currentTimeCalendar.get(Calendar.HOUR_OF_DAY)  == TimeWindow.getDAYTIMEENDHOUR()) &&
                    //                                    (currentTimeCalendar.get(Calendar.MINUTE)       == TimeWindow.getDAYTIMEENDMINUTE())
                    //                                )                                                                                           ||
                    //                                (
                    //                                    (order.getTimeWindowCategory().equals(TimeWindow.getEVENING_DECRIPTION())) &&
                    //                                    (currentTimeCalendar.get(Calendar.HOUR_OF_DAY)  == TimeWindow.getEVENINGENDHOUR()) &&
                    //                                    (currentTimeCalendar.get(Calendar.MINUTE)       == TimeWindow.getEVENINGENDMINUTE())
                    //                                )                                                                                           ||

                    ((currentTimeCalendar.get(Calendar.HOUR_OF_DAY) == timeTool.getCurrentTimeWindow()
                            .getEndHour())
                            && (currentTimeCalendar.get(Calendar.MINUTE) == timeTool.getCurrentTimeWindow()
                                    .getEndMinute()))
                            ||

                            (vmUsage >= vmUsagePauseThreashold) || (memFree <= memFreeThreshold)
                            || (heapMemFree <= heapMemFreeThreshold)
                            || (campaignStat.getConnectingAC() >= connectingTallyLimit)
                            || (campaignStat.getCallingAC() >= callingTallyLimit)
                            || (campaignStat.getTalkingAC() >= establishedTallyLimit)
                            || (!runCampaignToggleButton.isSelected()) || (!powerToggleButton.isSelected())) {
                        callCenterStatus = PAUSING;
                        showStatus("Campaign: " + campaign.getId() + " Run: " + campaignReRunCounter + "-"
                                + campaignReRunLimit + " Pausing...", false, false);
                        runCampaignToggleButton.setText("? ?");
                        runCampaignToggleButton.setForeground(Color.ORANGE);
                        if (vmUsage >= vmUsagePauseThreashold) {
                            eCallCenterGUI.vmUsageThresholdLabel.setForeground(Color.RED);
                            eCallCenterGUI.vmUsagePauseValue.setForeground(Color.RED);
                            eCallCenterGUI.vmUsageThresholdSlider.setForeground(Color.RED);
                        } else {
                            eCallCenterGUI.vmUsageThresholdLabel.setForeground(Color.BLACK);
                            eCallCenterGUI.vmUsagePauseValue.setForeground(Color.BLACK);
                            eCallCenterGUI.vmUsageThresholdSlider.setForeground(Color.BLACK);
                        }
                        if (memFree <= memFreeThreshold) {
                            eCallCenterGUI.memFreeThresholdLabel.setForeground(Color.RED);
                            eCallCenterGUI.memFreeThresholdValue.setForeground(Color.RED);
                            eCallCenterGUI.memFreeThresholdSlider.setForeground(Color.RED);
                        } else {
                            eCallCenterGUI.memFreeThresholdLabel.setForeground(Color.BLACK);
                            eCallCenterGUI.memFreeThresholdValue.setForeground(Color.BLACK);
                            eCallCenterGUI.memFreeThresholdSlider.setForeground(Color.BLACK);
                        }
                        if (heapMemFree <= heapMemFreeThreshold) {
                            eCallCenterGUI.heapMemFreeThresholdLabel.setForeground(Color.RED);
                            eCallCenterGUI.heapMemFreeThresholdValue.setForeground(Color.RED);
                            eCallCenterGUI.heapMemFreeThresholdSlider.setForeground(Color.RED);
                        } else {
                            eCallCenterGUI.heapMemFreeThresholdLabel.setForeground(Color.BLACK);
                            eCallCenterGUI.heapMemFreeThresholdValue.setForeground(Color.BLACK);
                            eCallCenterGUI.heapMemFreeThresholdSlider.setForeground(Color.BLACK);
                        }
                        if (campaignStat.getConnectingAC() >= connectingTallyLimit) {
                            eCallCenterGUI.connectingTallyLimitLabel.setForeground(Color.RED);
                            eCallCenterGUI.connectingTallyLimitValue.setForeground(Color.RED);
                            eCallCenterGUI.connectingTallyLimitSlider.setForeground(Color.RED);
                        } else {
                            eCallCenterGUI.connectingTallyLimitLabel.setForeground(Color.BLACK);
                            eCallCenterGUI.connectingTallyLimitValue.setForeground(Color.BLACK);
                            eCallCenterGUI.connectingTallyLimitSlider.setForeground(Color.BLACK);
                        }
                        if (campaignStat.getCallingAC() >= callingTallyLimit) {
                            eCallCenterGUI.callingTallyLimitLabel.setForeground(Color.RED);
                            eCallCenterGUI.callingTallyLimitValue.setForeground(Color.RED);
                            eCallCenterGUI.callingTallyLimitSlider.setForeground(Color.RED);
                        } else {
                            eCallCenterGUI.callingTallyLimitLabel.setForeground(Color.BLACK);
                            eCallCenterGUI.callingTallyLimitValue.setForeground(Color.BLACK);
                            eCallCenterGUI.callingTallyLimitSlider.setForeground(Color.BLACK);
                        }
                        if (campaignStat.getTalkingAC() >= establishedTallyLimit) {
                            eCallCenterGUI.establishedTallyLimitLabel.setForeground(Color.RED);
                            eCallCenterGUI.establishedTallyLimitValue.setForeground(Color.RED);
                            eCallCenterGUI.establishedTallyLimitSlider.setForeground(Color.RED);
                        } else {
                            eCallCenterGUI.establishedTallyLimitLabel.setForeground(Color.BLACK);
                            eCallCenterGUI.establishedTallyLimitValue.setForeground(Color.BLACK);
                            eCallCenterGUI.establishedTallyLimitSlider.setForeground(Color.BLACK);
                        }
                        try {
                            Thread.sleep(outboundBurstDelay);
                        } catch (InterruptedException ex) {
                        }
                    }

                    if (destinationElement.getDestinationCount() > vergunning.getMaxCalls()) {
                        break;
                    }
                    //                        if ((order.getTargetTransactionQuantity() / 100) != 0) {campaignProgressPercentage = Math.round(destinationElement.getDestinationCount() / (order.getTargetTransactionQuantity() / 100));}
                    if ((order.getTargetTransactionQuantity() / 100) != 0) {
                        campaignProgressPercentage = Math
                                .round(destinationsCounter / (order.getTargetTransactionQuantity() / 100));
                    }
                    showStatus(
                            "Campaign: " + Integer.toString(campaign.getId()) + " Run: "
                                    + Integer.toString(campaignReRunCounter) + "-"
                                    + Integer.toString(campaignReRunLimit) + " " + icons.getTalkChar()
                                    + destinationElement.getDestination() + " ("
                                    + Integer.toString(campaignProgressPercentage) + "%) ["
                                    + Integer.toString(destinationElement.getDestinationCount()) + "-"
                                    + Integer.toString(order.getTargetTransactionQuantity()) + "]",
                            false, false);

                    //                    float cumTurnoverPrecise = destinationsCounter * order.getMessageRate();
                    float cumTurnoverPrecise = campaignStat.getCallingTT() * order.getMessageRate();
                    float cumTurnoverRounded = (float) (Math.round(cumTurnoverPrecise * 100.0) / 100.0);
                    turnoverStatsTable.setValueAt(cumTurnoverRounded, 1, 2); // Cummulative Turnover

                    //                        campaignProgressBar.setValue(destinationElement.getDestinationCount());
                    //                        campaignProgressBar.setValue(destinationsCounter);
                    campaignProgressBar.setValue(campaignStat.getCallingTT());
                    runCampaignToggleButton.setText("");
                    runCampaignToggleButton.setForeground(Color.GREEN);
                    callCenterStatus = RUNNING;
                    eCallCenterGUI.vmUsageThresholdLabel.setForeground(Color.BLACK);
                    eCallCenterGUI.vmUsagePauseValue.setForeground(Color.BLACK);
                    eCallCenterGUI.vmUsageThresholdSlider.setForeground(Color.BLACK);
                    eCallCenterGUI.memFreeThresholdLabel.setForeground(Color.BLACK);
                    eCallCenterGUI.memFreeThresholdValue.setForeground(Color.BLACK);
                    eCallCenterGUI.memFreeThresholdSlider.setForeground(Color.BLACK);
                    eCallCenterGUI.heapMemFreeThresholdLabel.setForeground(Color.BLACK);
                    eCallCenterGUI.heapMemFreeThresholdValue.setForeground(Color.BLACK);
                    eCallCenterGUI.heapMemFreeThresholdSlider.setForeground(Color.BLACK);
                    eCallCenterGUI.connectingTallyLimitLabel.setForeground(Color.BLACK);
                    eCallCenterGUI.connectingTallyLimitValue.setForeground(Color.BLACK);
                    eCallCenterGUI.connectingTallyLimitSlider.setForeground(Color.BLACK);
                    eCallCenterGUI.callingTallyLimitLabel.setForeground(Color.BLACK);
                    eCallCenterGUI.callingTallyLimitValue.setForeground(Color.BLACK);
                    eCallCenterGUI.callingTallyLimitSlider.setForeground(Color.BLACK);
                    eCallCenterGUI.establishedTallyLimitLabel.setForeground(Color.BLACK);
                    eCallCenterGUI.establishedTallyLimitValue.setForeground(Color.BLACK);
                    eCallCenterGUI.establishedTallyLimitSlider.setForeground(Color.BLACK);

                    //                        outboundSoftPhoneInstance = (SoftPhone) threadArray[runCampaignCounter];
                    // -- Make PhoneCall
                    if ((destinationElement.getDestination().length() != 0) && (destinationElement
                            .getDestination().length() <= vergunning.getDestinationDigits())) // If destination / phonenumber is larger than 0 bytes
                    {
                        try // If destination / phonenumber is larger than 0 bytes
                        {
                            final Destination callDestination = (Destination) destinationElement.clone();
                            Thread campaignCallThread = new Thread(allThreadsGroup, new Runnable() {

                                @Override
                                public void run() {
                                    SoftPhone thisSoftPhone = (SoftPhone) threadArray[runCampaignCounter]; // work from a copy softphone reference as the call loop carries on
                                    int callMode = 0;
                                    if (scanCheckBox.isSelected()) {
                                        callMode = SCANNING;
                                    } else {
                                        callMode = CALLING;
                                    }
                                    thisSoftPhone.setDestination(callDestination); // Load the phonenumber into the softphone instance before calling

                                    String[] status2 = new String[2];
                                    status2[0] = "0";
                                    status2[1] = "";
                                    status2 = thisSoftPhone.userInput(CALLBUTTON,
                                            callDestination.getDestination(), filename,
                                            Integer.toString(callMode));
                                    if (status2[0].equals("1")) {
                                        // Starting Instant SelfHealing Mechanism (I know it's not a mechanism, but it sounds so much better than automation)
                                        if (thisSoftPhone.getSipState() != thisSoftPhone.SIPSTATE_IDLE) {
                                            showStatus(icons.getIdleChar() + " " + thisSoftPhone.getInstanceId()
                                                    + " Unexpected Sipstatus: "
                                                    + thisSoftPhone.SIPSTATE_DESCRIPTION[thisSoftPhone
                                                            .getSipState()]
                                                    + "...", true, true);
                                            if (thisSoftPhone.getSipState() > thisSoftPhone.SIPSTATE_IDLE) {
                                                String[] status3 = new String[2];
                                                status3[0] = "";
                                                status3[1] = "";
                                                status3 = thisSoftPhone.stopListener();
                                                if (status3[0].equals("0")) {
                                                    showStatus(icons.getIdleChar() + " "
                                                            + thisSoftPhone.getInstanceId()
                                                            + " Listener Stopped Successfully to Sipstate: "
                                                            + thisSoftPhone.SIPSTATE_DESCRIPTION[thisSoftPhone
                                                                    .getSipState()],
                                                            true, true);
                                                } else {
                                                    showStatus(icons.getIdleChar() + " "
                                                            + thisSoftPhone.getInstanceId()
                                                            + " Listener Stopped Unsuccessfully to Sipstate: "
                                                            + thisSoftPhone.SIPSTATE_DESCRIPTION[thisSoftPhone
                                                                    .getSipState()],
                                                            true, true);
                                                }
                                            }
                                            if (thisSoftPhone.getSipState() < thisSoftPhone.SIPSTATE_IDLE) {
                                                String[] status4 = new String[2];
                                                status4[0] = "";
                                                status4[1] = "";
                                                status4 = thisSoftPhone.startListener(
                                                        thisSoftPhone.getConfiguration().getClientPort());
                                                if (status4[0].equals("0")) {
                                                    showStatus(icons.getIdleChar() + " "
                                                            + thisSoftPhone.getInstanceId()
                                                            + " Listener Started Successfully to Sipstate: "
                                                            + thisSoftPhone.SIPSTATE_DESCRIPTION[thisSoftPhone
                                                                    .getSipState()],
                                                            true, true);
                                                    thisSoftPhone.userInput(CALLBUTTON,
                                                            callDestination.getDestination(), filename,
                                                            Integer.toString(callMode));
                                                } else {
                                                    showStatus(icons.getIdleChar() + " "
                                                            + thisSoftPhone.getInstanceId()
                                                            + " Listener Started Unsuccessfully to Sipstate: "
                                                            + thisSoftPhone.SIPSTATE_DESCRIPTION[thisSoftPhone
                                                                    .getSipState()],
                                                            true, true);
                                                }
                                            }
                                        } else // The softphone is okay, so make the call
                                        {
                                            thisSoftPhone.userInput(CALLBUTTON,
                                                    callDestination.getDestination(), filename,
                                                    Integer.toString(callMode));
                                        }
                                    }
                                }
                            });
                            campaignCallThread.setName("campaignCallThread");
                            campaignCallThread.setDaemon(runThreadsAsDaemons);
                            campaignCallThread.start();
                        } catch (CloneNotSupportedException ex) {
                        }
                    }

                    // -- End of Valid Destinstion Call Routine

                    phoneStatsTable.setValueAt(runCampaignCounter + 1, 1, 1); // ProcessingInstance
                    try {
                        Thread.sleep(outboundBurstDelay);
                    } catch (InterruptedException ex) {
                    }
                    destinationsCounter++;
                    runCampaignCounter++;
                } // CampaignRun Loop

                // Wait until all phone become available again or 1 minute has passed
                callCenterStatus = RERUNBREAK;
                int reRunBreakCounter = 60;
                while ((campaignStat.getIdleAC() < outboundSoftPhonesAvailable) && (reRunBreakCounter > 0)
                        && (!campaignStopRequested)) {
                    showStatus(
                            "Campaign: " + campaign.getId() + " ReRun: " + campaignReRunCounter
                                    + " Break, Waiting Max: " + reRunBreakCounter + " seconds...",
                            false, false);
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException ex) {
                    }
                    reRunBreakCounter--;
                }
            } // CampaignReRuns Loop

            runCampaignToggleButton.addActionListener(new java.awt.event.ActionListener() {
                @Override
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    runCampaignToggleButtonActionPerformed(evt);
                }
            });
            runCampaignToggleButton.setSelected(false);
            showStatus("Campaign Completed...", true, true);
            runCampaignToggleButton.setText("");
            runCampaignToggleButton.setForeground(Color.BLACK);

            campaignProgressBar.setValue(0);
            campaignProgressBar.setEnabled(false);
            outboundCallsInProgress = false;
            phoneStatsTable.setValueAt("-", 1, 1); // ProcessingInstance

            // Writing Completion of campaign to database
            campaign.setCalendarRegisteredEnd(Calendar.getInstance(nlLocale));
            dbClient.updateCampaign(campaign);
            campaignTable.setValueAt(
                    String.format("%04d", campaign.getCalendarRegisteredEnd().get(Calendar.YEAR)) + "-"
                            + String.format("%02d", campaign.getCalendarRegisteredEnd().get(Calendar.MONTH) + 1)
                            + "-"
                            + String.format(
                                    "%02d", campaign.getCalendarRegisteredEnd().get(Calendar.DAY_OF_MONTH))
                            + " "
                            + String.format("%02d",
                                    campaign.getCalendarRegisteredEnd().get(Calendar.HOUR_OF_DAY))
                            + ":"
                            + String.format("%02d", campaign.getCalendarRegisteredEnd().get(Calendar.MINUTE))
                            + ":"
                            + String.format("%02d", campaign.getCalendarRegisteredEnd().get(Calendar.SECOND)),
                    5, 1);

            // Campaign is ready updating open campaignlist
            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);
                stopCampaignButton.setEnabled(false);
            }

            if (autoPowerOff) {
                System.exit(0);
            }
            return;
        }
    });
    outboundCallButtonActionPerformedThread7.setName("outboundCallButtonActionPerformedThread7");
    outboundCallButtonActionPerformedThread7.setDaemon(runThreadsAsDaemons);
    outboundCallButtonActionPerformedThread7.start();
}