Java 类javax.swing.SwingWorker.StateValue 实例源码

项目:OpenID-Attacker    文件:EvaluationGui.java   
private void performAttackButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_performAttackButtonActionPerformed
    String attackName = (String)attackComboBox.getSelectedItem();

    currentActionProgressBar.setIndeterminate(true);
    performAttackButton.setEnabled(false);
    currentActionLabel.setText("Performing " + attackName + " Attack...");
    enableAllButtons(false);
    showProgressBar(true);

    AttackWorker attackWorker = new AttackWorker(attackName, serviceProvider, EvaluationResultStore.getEvaluationResultStore().getLatestEvaluationResult());
    attackWorker.addPropertyChangeListener((PropertyChangeEvent evt1) -> {
        if (evt1.getPropertyName().equals("state")) {
            if ((StateValue) evt1.getNewValue() == DONE) {
                currentActionProgressBar.setIndeterminate(false);
                performAttackButton.setEnabled(true);
                currentActionLabel.setText("");
                enableAllButtons(true);
                setTrainined(true);
                showProgressBar(false);
            }
        }
    });

    attackWorker.execute();
}
项目:japura-gui    文件:SwingWorkerHandler.java   
@Override
public void propertyChange(PropertyChangeEvent evt) {
  if ("state".equals(evt.getPropertyName())) {
    if (evt.getNewValue().equals(StateValue.STARTED)) {
      handler.incWorkersCount();
      eventHook.apply();
      start();
    } else if (evt.getNewValue().equals(StateValue.DONE)) {
      handler.decWorkersCount();
      stop();
      eventHook.remove();
    }
  } else if ("progress".equals(evt.getPropertyName())) {
    handler.progress((Integer) evt.getNewValue());
  }
}
项目:svarog    文件:ChooseExperimentPanel.java   
@Override
public void propertyChange(PropertyChangeEvent evt) {

    if ((evt.getNewValue() instanceof StateValue)
            && ((StateValue) evt.getNewValue()) == StateValue.DONE) {
        executing = false;
        setEnabled(true);
        getCancelButton().setEnabled(false);
        getProgressBar().setIndeterminate(false);
    }
    else if (evt.getPropertyName().equals(FindEEGExperimentsWorker.WORKER_LOG_APPENDED_PROPERTY)) {
        logger.debug("Appending" + evt.getNewValue());
        getLogTextField().append((String) evt.getNewValue());
    }
    else if (evt.getPropertyName().equals(FindEEGExperimentsWorker.NEW_EXPERIMENTS_RECEIVED)) {
        List<ExperimentDescriptor> newExperiments = (List<ExperimentDescriptor>) evt.getNewValue();
        chooseExperimentTableModel.addExperiments(newExperiments);
    }
}
项目:mychart    文件:WorkerStateAdapter.java   
@Override
public void stateChange(SwingWorker<?, ?> source, StateValue oldState, StateValue newState) {
    switch (newState) {
    case STARTED:
        started(source);
        break;
    case PENDING:
        pending(source);
        break;
    case DONE:
        done(source);
        break;
    default:
        break;
    }
}
项目:LichtstrahlenSpiel    文件:NewGamePropertyDialog.java   
@Override
//Catch the property changes of the CreateRandomWorker
public void propertyChange(PropertyChangeEvent evt) {
    switch(evt.getPropertyName()) {
        case "state": {
            SwingWorker.StateValue state = (StateValue) evt.getNewValue();
            if(state == SwingWorker.StateValue.DONE) {
                progressMonitor.close();
            }
        }
        case "progress": {
            int progress = (Integer)evt.getNewValue();
            progressMonitor.setProgress(progress);
            break;
        }
    }
}
项目:doujindb    文件:PanelSearch.java   
@Override
public void actionPerformed(ActionEvent ae)
{
    if(m_Worker.isDone() || m_Worker.getState() == StateValue.PENDING)
    {
        // Prepare the Query to be run
        QueryConvention q = new QueryConvention();
        if(!textTagName.getText().equals(""))
            q.TagName = textTagName.getText();

        // Clean result
        while(m_TableModel.getRowCount()>0)
            m_TableModel.removeRow(0);

        // UI feedback
        m_ButtonSearch.setText("Cancel");
        m_ButtonSearch.setMnemonic('C');
        m_Tab.setIconAt(m_Index, Icon.window_loading);

        // Run the Worker
        m_Worker = new SearchConvention(q);
        m_Worker.execute();
    } else {
        m_Worker.cancel(true);
    }
}
项目:ChAsE    文件:ProgressDialog.java   
/**
 * Invoked when task's progress property changes.
 */
public void propertyChange(PropertyChangeEvent evt)
{
    String evtName = evt.getPropertyName();
    if ("state" == evtName)
    {
    }
    else if (evtName.startsWith(PROGRESS_PREFIX))
    {
        int progress = (Integer) evt.getNewValue();
        m_ProgressBar.setValue(progress);
        m_LabelActivity.setText(evtName.substring(PROGRESS_PREFIX.length()));
    }
    else if (evtName.startsWith("activity:"))
    {
        m_LabelActivity.setText(evtName.substring("activity:".length()));
    }
    else if (evtName.startsWith("cancel"))
    {
        m_ModalDialog.setVisible(false);
    }
    else if (evtName.startsWith("error"))
    {
        m_TextTaskOutput.setForeground(Color.red);
        m_TextTaskOutput.append(evtName.substring("error".length()));
    }
    else
    {
        m_TextTaskOutput.append(evtName+"\n");
        m_TextTaskOutput.setCaretPosition(m_TextTaskOutput.getDocument().getLength());
    }

    if (m_Task != null && m_Task.getState() == StateValue.DONE && !m_Task.isCancelled())
    {
        m_ModalDialog.setVisible(false);
    }
}
项目:ChAsE    文件:ProgressDialog.java   
public void actionPerformed(ActionEvent evt)
{
    if (evt.getActionCommand().equalsIgnoreCase("CANCEL"))
    {
        if (m_Task.getState() == StateValue.DONE) {
            m_ModalDialog.setVisible(false);
        } else {    
            m_Task.cancel(true);
        }
    }
}
项目:swingx    文件:XTableDemo.java   
/**
     * Callback for worker's state notification: cleanup if done.
     * @param state
     */
    public void setLoadState(StateValue state) {
        //<snip>Use SwingWorker to asynchronously load the data
        // remove progressbar if done loading
        if (state != StateValue.DONE) return;
        statusBarLeft.remove(progressBar);
        statusBarLeft.remove(actionStatus);
        revalidate();
        repaint();
//        </snip>
    }
项目:OpenID-Attacker    文件:EvaluationGui.java   
private void trainButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_trainButtonActionPerformed
    serviceProvider = new ServiceProvider(serviceProviderTextField.getText());

    EvaluationResult evaluationResult = new EvaluationResult(new Date(), serviceProviderTextField.getText());
    EvaluationResultStore evaluationResultStore = EvaluationResultStore.getEvaluationResultStore();
    evaluationResultStore.addEvaluationResult(evaluationResult);

    enableAllButtons(false);
    showProgressBar(true);

    TrainingWorker trainingWorker = new TrainingWorker(serviceProvider, currentActionProgressBar, evaluationResult);      

    trainingWorker.addPropertyChangeListener((PropertyChangeEvent evt1) -> {
        if (evt1.getPropertyName().equals("state")) {
            if ((StateValue) evt1.getNewValue() == DONE) {
                boolean cancelled = currentWorker.isCancelled();
                System.out.println("cancelled: " + cancelled);

                if (cancelled) {
                    try {
                        ((TrainingWorker)currentWorker).awaitActualCompletion();
                    } catch (InterruptedException ex) {
                        Logger.getLogger(EvaluationGui.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }

                enableAllButtons(true);
                setTrainined(!cancelled);
                showProgressBar(false);
            }
        }
        System.out.println(evt1.getPropertyName() + " from " + evt1.getOldValue() + " to " + evt1.getNewValue());
    });
    trainingWorker.execute();

    currentWorker = trainingWorker;
}
项目:LightsCameraAction    文件:PluginInterface.java   
private void addPropertyChangeListenersTest(SwingWorker worker) {
    worker.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(final PropertyChangeEvent event) {
            String eventName = event.getPropertyName();
            if(eventName == "state") {
                switch ((StateValue)event.getNewValue()) {
                    case STARTED:
                    case PENDING:
                        enableComponents(jPanelConfiguration, false);
                        enableComponents(jPanelTesting, false);
                        enableComponents(jPanelRun, false);
                        jButtonTestLights.setText("Cancel");
                        jButtonTestLights.setEnabled(true);
                        break;
                    case DONE:
                        jButtonTestLights.setText("Test Lights On/Off");
                        enableComponents(jPanelConfiguration, true);
                        enableComponents(jPanelTesting, true);
                        enableComponents(jPanelRun, true);
                        worker_ = null;
                        break;

                }
            }
        }
    });        
}
项目:mychart    文件:WorkerWaitListener.java   
@Override
public void stateChange(SwingWorker<?, ?> source, StateValue oldState, StateValue newState) {
    logger.trace("Mudança de estado do worker {} de {} para {}", source, oldState, newState);
    switch (newState) {
    case STARTED:
        showView();
        break;
    case DONE:
        hideView();
        break;
    default:
        break;
    }
}
项目:mychart    文件:WorkerDoneListener.java   
@Override
default void stateChange(SwingWorker<?, ?> source, StateValue oldState, StateValue newState) {
    AbstractWorker<?, ?> worker = (AbstractWorker<?, ?>) source;
    if (newState == StateValue.DONE && worker.isDoneWithSuccess()) {
        doneWithSuccess(worker);
    } else if (newState == StateValue.DONE) {
        doneWithError(worker, worker.getLastError());
    }
}
项目:doujindb    文件:PanelSearch.java   
@Override
public void actionPerformed(ActionEvent ae)
{
    if(m_Worker.isDone() || m_Worker.getState() == StateValue.PENDING)
    {
        // Prepare the Query to be run
        QueryArtist q = new QueryArtist();
        if(!textJapaneseName.getText().equals(""))
            q.JapaneseName = textJapaneseName.getText();
        if(!textTranslatedName.getText().equals(""))
            q.TranslatedName = textTranslatedName.getText();
        if(!textRomajiName.getText().equals(""))
            q.RomajiName = textRomajiName.getText();
        if(!textWeblink.getText().equals(""))
            q.Weblink = textWeblink.getText();

        // Clean result
        while(m_TableModel.getRowCount()>0)
            m_TableModel.removeRow(0);

        // UI feedback
        m_ButtonSearch.setText("Cancel");
        m_ButtonSearch.setMnemonic('C');
        m_Tab.setIconAt(m_Index, Icon.window_loading);

        // Run the Worker
        m_Worker = new SearchArtist(q);
        m_Worker.execute();
    } else {
        m_Worker.cancel(true);
    }
}
项目:doujindb    文件:PanelSearch.java   
@Override
public void actionPerformed(ActionEvent ae)
{
    if(m_Worker.isDone() || m_Worker.getState() == StateValue.PENDING)
    {
        // Prepare the Query to be run
        QueryCircle q = new QueryCircle();
        if(!textJapaneseName.getText().equals(""))
            q.JapaneseName = textJapaneseName.getText();
        if(!textTranslatedName.getText().equals(""))
            q.TranslatedName = textTranslatedName.getText();
        if(!textRomajiName.getText().equals(""))
            q.RomajiName = textRomajiName.getText();
        if(!textWeblink.getText().equals(""))
            q.Weblink = textWeblink.getText();

        // Clean result
        while(m_TableModel.getRowCount()>0)
            m_TableModel.removeRow(0);

        // UI feedback
        m_ButtonSearch.setText("Cancel");
        m_ButtonSearch.setMnemonic('C');
        m_Tab.setIconAt(m_Index, Icon.window_loading);

        // Run the Worker
        m_Worker = new SearchCircle(q);
        m_Worker.execute();
    } else {
        m_Worker.cancel(true);
    }
}
项目:doujindb    文件:PanelSearch.java   
@Override
public void actionPerformed(ActionEvent ae)
{
    if(m_Worker.isDone() || m_Worker.getState() == StateValue.PENDING)
    {
        // Prepare the Query to be run
        QueryContent q = new QueryContent();
        if(!textTagName.getText().equals(""))
            q.TagName = textTagName.getText();
        q.Namespace = (org.dyndns.doujindb.db.record.Content.Namespace) comboNamespace.getSelectedItem();

        // Clean result
        while(m_TableModel.getRowCount()>0)
            m_TableModel.removeRow(0);

        // UI feedback
        m_ButtonSearch.setText("Cancel");
        m_ButtonSearch.setMnemonic('C');
        m_Tab.setIconAt(m_Index, Icon.window_loading);

        // Run the Worker
        m_Worker = new SearchContent(q);
        m_Worker.execute();
    } else {
        m_Worker.cancel(true);
    }
}
项目:doujindb    文件:PanelSearch.java   
@Override
public void actionPerformed(ActionEvent ae)
{
    if(m_Worker.isDone() || m_Worker.getState() == StateValue.PENDING)
    {
        // Prepare the Query to be run
        QueryParody q = new QueryParody();
        if(!textJapaneseName.getText().equals(""))
            q.JapaneseName = textJapaneseName.getText();
        if(!textTranslatedName.getText().equals(""))
            q.TranslatedName = textTranslatedName.getText();
        if(!textRomajiName.getText().equals(""))
            q.RomajiName = textRomajiName.getText();
        if(!textWeblink.getText().equals(""))
            q.Weblink = textWeblink.getText();

        // Clean result
        while(m_TableModel.getRowCount()>0)
            m_TableModel.removeRow(0);

        // UI feedback
        m_ButtonSearch.setText("Cancel");
        m_ButtonSearch.setMnemonic('C');
        m_Tab.setIconAt(m_Index, Icon.window_loading);

        // Run the Worker
        m_Worker = new SearchParody(q);
        m_Worker.execute();
    } else {
        m_Worker.cancel(true);
    }
}
项目:ClassiCubeLauncher    文件:ServerListScreen.java   
private void joinSelectedServer() {
    LogUtil.getLogger().log(Level.INFO,
            "Fetching details for server: {0}", selectedServer.name);
    final String url = tServerURL.getText();
    final String trimmedInput = url.replaceAll("[\\r\\n\\s]", "");
    final ServerJoinInfo joinInfo = session.getDetailsFromUrl(trimmedInput);
    if (joinInfo == null) {
        ErrorScreen.show("Cannot connect to given server",
                "Unrecognized server URL. Make sure that you are using the correct link.", null);
    } else if (joinInfo.passNeeded) {
        getServerDetailsTask = session.getServerDetailsAsync(trimmedInput);
        getServerDetailsTask.addPropertyChangeListener(
                new PropertyChangeListener() {
                    @Override
                    public void propertyChange(final PropertyChangeEvent evt) {
                        if ("state".equals(evt.getPropertyName())) {
                            if (evt.getNewValue().equals(StateValue.DONE)) {
                                onServerDetailsDone();
                            }
                        }
                    }
                });
        progress.setVisible(true);
        if (Prefs.getKeepOpen()) {
            disableGui();
        }
        getServerDetailsTask.execute();
    } else {
        joinServer(joinInfo);
    }
}
项目:Local_Hough_Circle    文件:Hough_GUI.java   
void startTransform(){
    //Create and instance of the analysis class
    guiInput = new Hough_Circle();

    KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    manager.addKeyEventDispatcher(new MyDispatcher());

    //Add an action listener to the status to allow for GUI to be updated
    //Code modified from: http://www.javacreed.com/swing-worker-example/

    guiInput.addPropertyChangeListener((final PropertyChangeEvent event) -> {
        switch (event.getPropertyName()) {

            //If event has progress flag, update progress bar
            case "progress":
                barString = guiInput.getStatus();
                if(isGUI){
                    guiProgressBar.setIndeterminate(false);
                    guiProgressBar.setValue((Integer) event.getNewValue()); 
                    guiProgressBar.setString(barString);
                }
                break;

            //if event has state flag, it indicates thread completion status
            case "state":
                switch ((StateValue) event.getNewValue()) {

                    //If worker thread is done, then clear out progress indicators and set button to "OK"
                    case DONE:
                        IJ.showProgress(0);
                        if(isGUI){
                            guiProgressBar.setVisible(false);
                            guiOKButton.setText("OK");
                        }
                        analysisStarted = false;
                        IJ.showStatus("Analysis complete...");
                        break;

                    //If worker has just started, set progress to indetertminate, to let user know plugin is active
                    case STARTED:
                        if(isGUI){
                            guiProgressBar.setVisible(true);
                            guiProgressBar.setIndeterminate(true);
                            guiProgressBar.setString("Starting Transform...");
                        }
                        break;
                    case PENDING:
                        if(isGUI){
                            guiProgressBar.setVisible(true);
                            guiProgressBar.setIndeterminate(true);
                        }
                        break;
                }
                break;
        }
    });

    //Start the background transform by sending the GUI variables to the transform
    guiInput.setParameters(radiusMin, radiusMax, radiusInc, minCircles, maxCircles, thresholdRatio, resolution, ratio, searchBand, 
            searchRadius, reduce, local, houghSeries, showCircles, showID, showScores, results, isGUI);

    //Start the analysis on a separate thread so the GUI stays free.
    guiInput.execute();
}
项目:swingx    文件:XTableDemo.java   
public StateValue getLoadState() {
    return null;
}
项目:jpexs-decompiler    文件:LoadFromMemoryFrame.java   
private void selectProcess() {
    if (processing) {
        return;
    }

    selProcesses = list.getSelectedValuesList();
    if (!selProcesses.isEmpty()) {
        processing = true;
        tableRes.setEnabled(false);
        resTableModel.getDataVector().removeAllElements();
        resTableModel.fireTableDataChanged();
        foundIs = null;
        progress.setIndeterminate(true);
        progress.setString(translate("searching"));
        progress.setStringPainted(true);
        progress.setVisible(true);
        final SelectProcessWorker wrk = new SelectProcessWorker(selProcesses);
        wrk.addPropertyChangeListener((PropertyChangeEvent evt) -> {
            switch (evt.getPropertyName()) {
                case "progress":
                    progress.setIndeterminate(false);
                    progress.setStringPainted(false);
                    progress.setValue((Integer) evt.getNewValue());
                    break;
                case "state":
                    if (((StateValue) evt.getNewValue()) == StateValue.DONE) {
                        try {
                            foundIs = wrk.get();
                        } catch (InterruptedException | ExecutionException ex) {
                            Logger.getLogger(LoadFromMemoryFrame.class.getName()).log(Level.SEVERE, null, ex);
                        }
                        if (foundIs == null) {
                            addResultRow(null);
                        }
                        tableRes.setEnabled(foundIs != null);
                        progress.setVisible(false);
                        processing = false;
                    }
            }
        });
        wrk.execute();
    }
}
项目:mychart    文件:WorkerStateListener.java   
@Override
default void propertyChange(PropertyChangeEvent event) {
    if (StringUtils.equals(event.getPropertyName(), "state")) {
        stateChange((SwingWorker<?, ?>) event.getSource(), (StateValue) event.getOldValue(), (StateValue) event.getNewValue());
    }
}
项目:ClassiCubeLauncher    文件:ServerListScreen.java   
public ServerListScreen() {
    LogUtil.getLogger().log(Level.FINE, "ServerListScreen");

    // Make a pretty background
    final ImagePanel bgPanel = new ImagePanel(null, true);
    bgPanel.setGradient(true);
    this.setContentPane(bgPanel);
    bgPanel.setBorder(new EmptyBorder(8, 8, 8, 8));

    // init components and stuff
    this.initComponents();
    this.setIconImages(Resources.getWindowIcons());
    this.serverTableContainer.getViewport().setBackground(new Color(247, 247, 247));

    // hook up context menus
    CutCopyPasteAdapter.addToComponent(this.tSearch, true, true);
    CutCopyPasteAdapter.addToComponent(this.tServerURL, true, true);

    // set window title
    this.session = SessionManager.getSession();
    final String playerName = session.getAccount().playerName;
    if (session.getServiceType() == GameServiceType.ClassiCubeNetService) {
        setTitle(playerName + " @ ClassiCube.net - servers");
        bgPanel.setImage(Resources.getClassiCubeBackground());
        bgPanel.setGradientColor(Resources.ccGradient);
        serverTable.getColumnModel().getColumn(4).setHeaderValue("Software");
    } else {
        setTitle(playerName + " @ Minecraft.net - servers");
        bgPanel.setImage(Resources.getMinecraftNetBackground());
        bgPanel.setGradientColor(Resources.mcGradient);
    }

    // prepare to auto-adjust table columns (when the data arrives)
    serverTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    tableColumnAdjuster = new TableColumnAdjuster(serverTable);

    // configure table sorting and selection
    serverTable.setAutoCreateRowSorter(true);
    serverTable.setCellSelectionEnabled(false);
    serverTable.setRowSelectionAllowed(true);

    // set table shortcuts
    setHandlers();

    // center the form on screen (initially)
    setLocationRelativeTo(null);

    getRootPane().setDefaultButton(this.bConnect);

    // start fetching the server list
    tSearch.setPlaceholder("Loading server list...");
    tSearch.setEnabled(false);

    getServerListTask = session.getServerListAsync();
    getServerListTask.addPropertyChangeListener(
            new PropertyChangeListener() {
                @Override
                public void propertyChange(final PropertyChangeEvent evt) {
                    if ("state".equals(evt.getPropertyName())) {
                        if (evt.getNewValue().equals(StateValue.DONE)) {
                            onServerListDone();
                        }
                    }
                }
            });
    getServerListTask.execute();
}
项目:mychart    文件:WorkerStateListener.java   
/**
 * Método invocado quando o estado do <em>worker</em> é alterado.
 * 
 * @param source
 *            a instância de {@link SwingWorker} que originou o evento
 * @param oldState
 *            o estado anterior
 * @param newState
 *            o novo estado
 */
void stateChange(SwingWorker<?, ?> source, StateValue oldState, StateValue newState);
项目:wichtel    文件:Worker.java   
StateValue getState();