Examples of SwingWorker


Examples of org.fcrepo.client.SwingWorker

    @Override
    public RepositoryInfo describeRepository() {
        String METHOD_NAME = "describeRepository";
        HashMap PARMS = new HashMap();
        // Run the method in a SwingWorker thread
        SwingWorker worker = new SwingWorker(PARMS) {

            @Override
            public Object construct() {

                // call wrapped method
                return m_instance.describeRepository();

            }
        };
        worker.start();
        // The following code will run in the (safe)
        // Swing event dispatcher thread.
        int ms = 0;
        Dimension d = Administrator.PROGRESS.getSize();
        // Devise verbage based on method name
        ArrayList words = new ArrayList();
        StringBuffer word = new StringBuffer();
        boolean lastWasCaps = true;
        for (int i = 0; i < METHOD_NAME.length(); i++) {
            char c = METHOD_NAME.charAt(i);
            if (c >= 'A' && c <= 'Z') {
                // char is caps
                if (!lastWasCaps) {
                    // new word
                    words.add(word.toString());
                    word = new StringBuffer();
                }
                word.append(c);
                lastWasCaps = true;
            } else {
                // char is lowercase
                word.append(c);
                lastWasCaps = false;
            }
        }
        words.add(word.toString());
        StringBuffer buf = new StringBuffer();
        for (int i = 0; i < words.size(); i++) {
            String lcWord = ((String) words.get(i)).toLowerCase();
            if (i == 0) {
                String firstChar = lcWord.substring(0, 1).toUpperCase();
                char lastChar = lcWord.charAt(lcWord.length() - 1);
                String middle = lcWord.substring(1, lcWord.length() - 1);
                buf.append(firstChar);
                buf.append(middle);
                buf.append(lastChar);
                buf.append(" ");
            } else {
                buf.append(lcWord + " ");
            }
        }
        Administrator.PROGRESS.setString(buf.toString() + ". . .");
        while (!worker.done) {
            try {
                Administrator.PROGRESS.setValue(ms);
                Administrator.PROGRESS
                        .paintImmediately(0,
                                          0,
                                          (int) d.getWidth() - 1,
                                          (int) d.getHeight() - 1);
                Thread.sleep(100);
                ms = ms + 100;
                if (ms >= 2000) ms = 200;
            } catch (InterruptedException ie) {
            }
        }
        Administrator.PROGRESS.setValue(2000);
        Administrator.PROGRESS.paintImmediately(0,
                                                0,
                                                (int) d.getWidth() - 1,
                                                (int) d.getHeight() - 1);
        try {
            Thread.sleep(100);
        } catch (InterruptedException ie) {
        }
        Administrator.PROGRESS.setValue(0);
        Administrator.PROGRESS.setString("");

        // Otherwise, get the value from the
        // worker (returning it if applicable)
        return (RepositoryInfo) worker.get();
    }
View Full Code Here

Examples of org.jdesktop.swingworker.SwingWorker

    private void stopWorker(AsyncTreeNode node) {
       
        // Check to see if there is an active worker for the give node. Since
        // this is always called on the AWT Event Thread, we do not need to
        // separately synchronize around the Map of workers.
        SwingWorker worker = workerMap.get(node);
        if (worker != null) {
            worker.cancel(true);
            workerMap.remove(node);
            updateCursor();
        }
    }
View Full Code Here

Examples of org.jdesktop.swingworker.SwingWorker

            mouseListeners.remove(listener);
        }
    }

    public void notifyMouseMotionListeners(final MouseEvent e) {
        SwingWorker worker = new SwingWorker<String, Object>() {

            @Override
            public String doInBackground() {
                if (mouseMotionListeners != null) {
                    e.setSource(this);
                    ListIterator<MouseMotionListener> iter = mouseMotionListeners.listIterator();
                    while (iter.hasNext()) {
                        MouseMotionListener listener = iter.next();

                        switch (e.getID()) {
                            case MouseEvent.MOUSE_MOVED:
                                listener.mouseMoved(e);
                                break;
                            case MouseEvent.MOUSE_DRAGGED:
                                listener.mouseDragged(e);
                                break;
                            default:
                                break;
                        }
                    }
                    iter = null;
                }
                return null;
            }
        };
        worker.execute();
        try {
            worker.get();
        } catch (Exception ie) {
        }
    }
View Full Code Here

Examples of org.jpedal.utils.SwingWorker

        /** if running terminate first */
    thumbnails.terminateDrawing();

    commonValues.setProcessing(true);

    SwingWorker worker = new SwingWorker() {
      public Object construct() {

        try {

          currentGUI.updateStatusMessage(Messages.getMessage("PdfViewerDecoding.page"));

          if (img != null)
            addImage(img);

          PdfPageData page_data = decode_pdf.getPdfPageData();
         
          if (img != null)
            page_data.setMediaBox(new float[]{0,0,img.getWidth(),img.getHeight()});

          page_data.checkSizeSet(1);
          currentGUI.resetRotationBox();

          /**
           * make sure screen fits display nicely
           */
          if ((resizePanel) && (thumbnails.isShownOnscreen()))
            currentGUI.zoom(false);

          if (Thread.interrupted())
            throw new InterruptedException();
         
          currentGUI.setPageNumber();
         
          currentGUI.setViewerTitle(null); // restore title
         
        } catch (Exception e) {
          currentGUI.setViewerTitle(null); //restore title
         
        }

        currentGUI.setStatusProgress(100);

        //reanable user changing scaling
        currentGUI.resetComboBoxes(true);
       
        //ensure drawn
        decode_pdf.repaint();

        openingTransferedFile=false;
       
        return null;
      }
    };

    worker.start();
  }
View Full Code Here

Examples of org.openquark.util.ui.SwingWorker

        config.setMonitor(monitor);
       
        final String carName = CarBuilder.makeCarNameFromSourceWorkspaceDeclName(workspaceManager.getInitialWorkspaceDeclarationName());
       
        // Set up a SwingWorker to run the export process in a separate thread.
        SwingWorker worker = new SwingWorker() {
            public Object construct() {
                try {
                    CarBuilder.buildCar(config, outputDirectory, carName, options);
                   
                    // Display a status message.
                    SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                            String statusMessage = GemCutterMessages.getString("SM_CarExported", carName);
                            statusMessageManager.displayMessage(GemCutter.this, statusMessage, StatusMessageDisplayer.MessageType.TRANSIENT, true);
                        }
                    });
                   
                } catch (final IOException e) {
                    // Inform the user.
                    SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                            showActionFailureDialog(getResourceString("ExportWorkspaceToCarFailedDialogTitle"), getResourceString("ExportWorkspaceToCarFailedDialogMessage"), e);
                        }
                    });
                }
                return null;
            }
        };
       
        // Start the CarBuilder worker and then launch the progress monitor (which is modal and would block the UI until
        // either the progress reaches 100% or the monitor is canceled)
        worker.start();
        monitor.showDialog();
        // there is no interesting value to get from the worker, but a call to get() effectively does a join
        // on the worker thread
        worker.get();
    }
View Full Code Here

Examples of org.owasp.webscarab.util.swing.SwingWorker

                final File dir = jfc.getSelectedFile();
                if (FileSystemStore.isExistingSession(dir)) {
                    JOptionPane.showMessageDialog(null, new String[] {dir + " already contains a session ", }, "Error", JOptionPane.ERROR_MESSAGE);
                    return;
                } else {
                    new SwingWorker() {
                        public Object construct() {
                            try {
                                closeSession();
                                TempDir.recursiveCopy(_tempDir, dir);
                                TempDir.recursiveDelete(_tempDir);
View Full Code Here

Examples of org.rioproject.tools.ui.util.SwingWorker

        });

        /* Increase instance behavior */
        increaseService.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                SwingWorker worker = new SwingWorker() {
                    public Object construct() {
                        try {
                            int planned = sElem.getPlanned();
                            opMgr.increment(sElem, true, null);
                            planned++;
                            sElem.setPlanned(planned);
                            String value = Integer.toString(planned);
                            ServiceAttributeTableItem tableItem =
                                    new ServiceAttributeTableItem();
                            tableItem.attributeDescription = new JLabel(value);
                            DefaultTableModel tableModel =
                                    (DefaultTableModel)serviceAttributeTable.getModel();
                            tableModel.setValueAt(tableItem,
                                                  2,   /*row*/
                                                  1)/*column*/
                            setInstanceTableLabel(sElem,
                                                  initializeInstanceTable(
                                                          opMgr.getServiceBeanInstances(sElem)));
                        } catch (Exception e) {
                            Util.showError(e, parent, "Unable to increase instance count");
                        }

                        return null;
                        }
                    };
                    worker.start();
            }
        });
        /* Decrease instance behavior */
        decreaseService.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
View Full Code Here

Examples of viewer.common.SwingWorker

    */

    public void createTimelineWindow( final int view_ID )
    {
        if ( slog_ins != null && view_ID >= 0 ) {
            SwingWorker create_timeline_worker = new SwingWorker() {
                public Object construct()
                {
                    timeline_frame = new TimelineFrame( slog_ins, view_ID );
                    return null// returned value is not needed
                }
                public void finished()
                {
                    timeline_frame.pack();
                    TopWindow.layoutIdealLocations();
                    timeline_frame.setVisible( true );
                    timeline_frame.init();
                }
            };
            create_timeline_worker.start();
        }
    }
View Full Code Here

Examples of viewer.common.SwingWorker

        return url;
    }

    private void createSummaryDialog()
    {
        SwingWorker           create_statline_worker;

        root_dialog = (Dialog) SwingUtilities.windowForComponent( this );
        create_statline_worker = new SwingWorker() {
            public Object construct()
            {
                summary_dialog = summarizable.createSummary( root_dialog,
                                                             timebox );
                return null// returned value is not needed
            }
            public void finished()
            {
                summary_dialog.pack();
                if ( Parameters.AUTO_WINDOWS_LOCATION ) {
                    Rectangle bounds = root_dialog.getBounds();
                    summary_dialog.setLocation( bounds.x + bounds.width/2,
                                                bounds.y + bounds.height/2 );
                }
                summary_dialog.setVisible( true );
                summary_dialog.init();
            }
        };
        create_statline_worker.start();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.