Package org.springframework.richclient.application.statusbar

Examples of org.springframework.richclient.application.statusbar.StatusBar


                settings.getNumberOfDays(), settings.getTimeslotsPerDay()));
        if (ret != JOptionPane.OK_OPTION)
            return;

        ApplicationWindow aw = getApplicationWindow();
        final StatusBar bar = aw.getStatusBar();
        ProgressMonitor pm = bar.getProgressMonitor();

        JFileChooser fc = new JFileChooser();
        fc.setDialogTitle(tr.get(ID + ".fileDialog"));
        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int res = fc.showOpenDialog(aw.getControl());
        if (res != JFileChooser.APPROVE_OPTION) {
            bar.setMessage(tr.get(ID + ".noFileSelected"));
            return;
        }

        file = fc.getSelectedFile();
        if (!file.isDirectory()) {
            int resultOP = JOptionPane.showConfirmDialog(null, tr.get(ID + ".confirmation.message"),
                    tr.get(ID + ".confirmation.title"), JOptionPane.OK_CANCEL_OPTION);
            if (resultOP != JOptionPane.OK_OPTION) {
                return;
            }
        }
        pm.taskStarted(tr.get(ID + ".startTask"), 100);
        MySwingWorker sw = new MySwingWorker(ID) {

            @Override
            protected void myconstruct() throws Exception {
                bar.getProgressMonitor().worked(10);

                ImportBTXml importer = new ImportBTXml(dataPool, file);
                importer.setDataPoolSettings(settings);
                importer.doWork();
                bar.getProgressMonitor().worked(90);
            }

            @Override
            protected void done() {
                openAllViews();
                bar.getProgressMonitor().worked(100);
                super.done();
            }
        };

        sw.execute();
View Full Code Here


    protected void doOnce() {
        checkIfDataIsAlreadyAvailable();
        closeAllViews();

        ApplicationWindow aw = getApplicationWindow();
        final StatusBar bar = aw.getStatusBar();
        final ProgressMonitor pm = bar.getProgressMonitor();

        JFileChooser fc = new JFileChooser();
        fc.setDialogTitle(tr.get(ID + ".fileDialog"));
        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int res = fc.showOpenDialog(aw.getControl());
        if (res != JFileChooser.APPROVE_OPTION) {
            bar.setMessage(tr.get(ID + ".noFileSelected"));
            return;
        }
        file = fc.getSelectedFile();
        if (!file.isDirectory()) {
            int resultOP = JOptionPane.showConfirmDialog(null, tr.get(ID + ".confirmation.message"),
                    tr.get(ID + ".confirmation.title"), JOptionPane.OK_CANCEL_OPTION);
            if (resultOP != JOptionPane.OK_OPTION) {
                return;
            }
        }
        pm.taskStarted(tr.get(ID + ".startTask"), 100);

        MySwingWorker sw = new MySwingWorker(ID) {

            @Override
            protected void myconstruct() throws Exception {
                bar.getProgressMonitor().worked(10);
                ImportWinQD importer = new ImportWinQD(dataPool, settings, file);

                bar.getProgressMonitor().worked(20);
                importer.doWork();
                bar.getProgressMonitor().worked(80);
            }

            @Override
            protected void done() {
                bar.getProgressMonitor().worked(90);
                openAllViews();
                bar.getProgressMonitor().worked(100);
                super.done();
            }
        };

        sw.execute();
View Full Code Here

        if (ret != JOptionPane.OK_OPTION)
            return;

        track2allData.changeSettings();
        ApplicationWindow aw = getApplicationWindow();
        final StatusBar bar = aw.getStatusBar();

        try {
            if (download) {
                // see MySwingWorker.construct -> it could be that site is not accessible
                // -> then the ui should not freeze
            } else {
                JFileChooser fc = new JFileChooser();
                fc.setDialogTitle(tr.get(ID + ".fileDialog"));
                int resultFC = fc.showOpenDialog(aw.getControl());
                if (resultFC != JFileChooser.APPROVE_OPTION) {
                    bar.setMessage(tr.get(ID + ".noFileSelected"));
                    return;
                }
                file = fc.getSelectedFile();
                if (!file.getName().endsWith(".tim")) {
                    int resultOP = JOptionPane.showConfirmDialog(null, tr.get(ID + ".confirmation.message"),
                            tr.get(ID + ".confirmation.title"), JOptionPane.OK_CANCEL_OPTION);
                    if (resultOP != JOptionPane.OK_OPTION) {
                        return;
                    }
                }
                reader = new FileReader(file);
            }
        } catch (Exception ex) {
            String errorMsg = "Cannot read file! " + ex.getLocalizedMessage();
            logger.fatal(errorMsg, ex);
            bar.setErrorMessage(errorMsg);
            return;
        }

        bar.getProgressMonitor().taskStarted(tr.get(ID + ".startTask"), 100);       
        MySwingWorker sw = new MySwingWorker(ID) {

            @Override
            protected void myconstruct() throws Exception {
                if (download) {
                    String str = "http://timefinder.sourceforge.net/files/comp-2007-2-09.tim";
                    bar.setMessage(tr.get("downloadFrom", str));
                    // why does decompressing not work?? -> first line == null !?
                    // reader = new InputStreamReader(new ZipInputStream(
                    //          new UrlResource("http://timefinder.sourceforge.net/files/comp-2007-2-09.zip").getInputStream()));
                    reader = new InputStreamReader(new UrlResource(str).getInputStream());
                    bar.setMessage("");
                }

                track2allData.setSource(reader);
                track2allData.setStatusBar(new StatusBarBridge(bar));
                track2allData.doWork();
                bar.getProgressMonitor().worked(90);
            }

            @Override
            protected void done() {
                openAllViews();
                bar.getProgressMonitor().worked(100);
                super.done();
            }
        };

        sw.execute();
View Full Code Here

        checkIfDataIsAlreadyAvailable();
        closeAllViews();
        //days==5; 14 timeslots per day
        JOptionPane.showMessageDialog(null, tr.get(ID + ".question", 5, 9));

        StatusBar bar = getApplicationWindow().getStatusBar();
        try {
            int resultDownload = JOptionPane.showConfirmDialog(null, tr.get(ID + ".downloadQuestion"),
                    tr.get(ID + ".downloadQuestion"), JOptionPane.YES_NO_OPTION);
            if (resultDownload == JOptionPane.YES_OPTION) {
            } else {
                JFileChooser fc = new JFileChooser();
                fc.setDialogTitle(tr.get(ID + ".fileDialog"));
                int res = fc.showOpenDialog(getApplicationWindow().getControl());
                if (res != JFileChooser.APPROVE_OPTION) {
                    bar.setMessage(tr.get(ID + ".noFileSelected"));
                    return;
                }

                file = fc.getSelectedFile();

                if (!file.getName().endsWith(".j1")) {
                    int resultOP = JOptionPane.showConfirmDialog(null, tr.get(ID + ".confirmation.message"),
                            tr.get(ID + ".confirmation.title"), JOptionPane.OK_CANCEL_OPTION);
                    if (resultOP != JOptionPane.OK_OPTION) {
                        return;
                    }
                }
                istream = new FileInputStream(file);
            }
        } catch (Exception ex) {
            String errorMsg = "Cannot read file! " + ex.getLocalizedMessage();
            logger.fatal(errorMsg, ex);
            bar.setErrorMessage(errorMsg);
            return;
        }

        MySwingWorker sw = new MySwingWorker(ID) {

            @Override
            protected void myconstruct() throws Exception {
                StatusBar bar = getApplicationWindow().getStatusBar();
                ProgressMonitor pm = bar.getProgressMonitor();

                int resultDownload = JOptionPane.showConfirmDialog(null, tr.get(ID + ".downloadQuestion"),
                        tr.get(ID + ".downloadQuestion"), JOptionPane.YES_NO_OPTION);
                if (resultDownload == JOptionPane.YES_OPTION) {
                    String str = "http://peat_hal.users.sourceforge.net/sessions_catalog.j1";
                    bar.setMessage(tr.get("downloadFrom", str));
                    istream = new UrlResource(str).getInputStream();
                    pm.worked(5);
                    bar.setMessage("");
                }

                pm.taskStarted(tr.get(ID + ".startTask"), -1);
                pm.worked(10);
View Full Code Here

    protected void doOnce() {
        checkIfDataIsAlreadyAvailable();
        closeAllViews();

        ApplicationWindow aw = getApplicationWindow();
        final StatusBar bar = aw.getStatusBar();
        final ProgressMonitor pm = bar.getProgressMonitor();

        JFileChooser fc = new JFileChooser();
        fc.setDialogTitle(tr.get(ID + ".fileDialog"));
        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int res = fc.showOpenDialog(aw.getControl());
        if (res != JFileChooser.APPROVE_OPTION) {
            bar.setMessage(tr.get(ID + ".noFileSelected"));
            return;
        }
        file = fc.getSelectedFile();
        if (!file.isDirectory()) {
            int resultOP = JOptionPane.showConfirmDialog(null, tr.get(ID + ".confirmation.message"),
                    tr.get(ID + ".confirmation.title"), JOptionPane.OK_CANCEL_OPTION);
            if (resultOP != JOptionPane.OK_OPTION) {
                return;
            }
        }
        pm.taskStarted(tr.get(ID + ".startTask"), 100);
        MySwingWorker sw = new MySwingWorker(ID) {

            @Override
            protected void myconstruct() throws Exception {
                bar.getProgressMonitor().worked(10);
                ImportText importer = new ImportText(dataPool, settings, file);

                bar.getProgressMonitor().worked(20);
                importer.doWork();
                bar.getProgressMonitor().worked(80);
            }

            @Override
            protected void done() {
                bar.getProgressMonitor().worked(90);
                openAllViews();
                bar.getProgressMonitor().worked(100);
                super.done();
            }
        };

        sw.execute();
View Full Code Here

     * @see Application#close()
     */
    @Override
    protected void doOnce() {
        ApplicationWindow aw = getApplicationWindow();
        final StatusBar bar = aw.getStatusBar();
        ProgressMonitor pm = bar.getProgressMonitor();

        JFileChooser fc = new JFileChooser();
        fc.setDialogTitle(tr.get(ID + ".fileDialog"));
        int res = fc.showSaveDialog(aw.getControl());
        if (res != JFileChooser.APPROVE_OPTION) {
            bar.setMessage(tr.get(ID + ".noFileSelected"));
            return;
        }
        final File f = fc.getSelectedFile();

        pm.taskStarted(tr.get(ID + ".startTask"), -1);

        MySwingWorker sw = new MySwingWorker(ID) {

            @Override
            protected void myconstruct() throws Exception {
                bar.getProgressMonitor().worked(10);
                XmlExport exporter = new XmlExport(dataPool,
                        settings, new FileOutputStream(f.getAbsoluteFile()));

                exporter.doWork();
                bar.getProgressMonitor().worked(100);
            }
        };

        sw.execute();
    }
View Full Code Here

        ViewDescriptorRegistry viewDescriptorRegistry = (ViewDescriptorRegistry) ApplicationServicesLocator.services().getService(ViewDescriptorRegistry.class);

        final DualEventDescriptor view = (DualEventDescriptor) viewDescriptorRegistry.getViewDescriptor("dualEventView");
        final List<DualEvent> eventsList = view.getDualEvents();
        final Dao<Event> dao = view.getDao();
        final StatusBar bar = getApplicationWindow().getStatusBar();

        bar.getProgressMonitor().taskStarted(tr.get(ID + ".startTask"), 100);
        MySwingWorker sw = new MySwingWorker(ID) {

            @Override
            protected void myconstruct() throws Exception {
                double delta = 90.0 / dao.getAll().size();
                double counter = 1;
                for (Event a : dao.getAll()) {
                    bar.getProgressMonitor().worked((int) counter);
                    counter += delta;
                    if (!firstEvent(a))
                        continue;

                    for (Event b : dao.getAll()) {
                        if (a == b || !firstEvent(b))
                            continue;

                        eventsList.add(new DualEvent(a, b));
                    }
                }
                logger.info("Read dual events:" + eventsList.size());
            }

            private boolean firstEvent(Event ev) {
                DifferentDayConstraint constr = ev.getConstraint(DifferentDayConstraint.class);
                if (constr != null) {
                    // only one event of the event group
                    if (constr.getEvents().size() > 0
                            && ev == constr.getEvents().iterator().next())
                        return true;
                }
                return false;
            }

            @Override
            protected void done() {
                bar.getProgressMonitor().worked(95);
                view.createShowViewCommand(getApplicationWindow()).execute();
                super.done();
            }
        };
View Full Code Here

    protected void doOnce() {
        checkIfDataIsAlreadyAvailable();
        closeAllViews();

        ApplicationWindow aw = getApplicationWindow();
        final StatusBar bar = aw.getStatusBar();
        final ProgressMonitor pm = bar.getProgressMonitor();

        JFileChooser fc = new JFileChooser();
        fc.setDialogTitle(tr.get(ID + ".fileDialog"));
        int res = fc.showOpenDialog(aw.getControl());
        if (res != JFileChooser.APPROVE_OPTION) {
            bar.setMessage(tr.get(ID + ".noFileSelected"));
            return;
        }
        file = fc.getSelectedFile();
        if (!file.getName().endsWith(".xml")) {
            int resultOP = JOptionPane.showConfirmDialog(null, tr.get(ID + ".confirmation.message"),
                    tr.get(ID + ".confirmation.title"), JOptionPane.OK_CANCEL_OPTION);
            if (resultOP != JOptionPane.OK_OPTION) {
                return;
            }
        }
        pm.taskStarted(tr.get(ID + ".startTask"), 100);
        MySwingWorker sw = new MySwingWorker(ID) {

            @Override
            protected void myconstruct() throws Exception {
                bar.getProgressMonitor().worked(10);

                XmlImport importer = new XmlImport(dataPool, settings,
                        new FileInputStream(file.getAbsolutePath()));

                // TODO NOW
//                importer.setStatusBar(bar);

                importer.doWork();
                bar.getProgressMonitor().worked(90);
            }

            @Override
            protected void done() {
                bar.getProgressMonitor().worked(90);
                openAllViews();
                bar.getProgressMonitor().worked(100);
                super.done();
            }
        };

        sw.execute();
View Full Code Here

        }

        @Override
        protected void done() {
            // all of the following code will be called on the Event Dispatching Thread
            StatusBar bar = getApplicationWindow().getStatusBar();
            if (bar.getProgressMonitor().isCanceled()) {
                bar.setErrorMessage(tr.get(ID + ".canceled"));
            } else {
                if (getException() != null)
                    bar.setErrorMessage(tr.get(ID + ".exception") + ": "
                            + getException().getLocalizedMessage());
                else if (getException() != null && getException().getCause() != null)
                    bar.setErrorMessage(tr.get(ID + ".exception") + ": "
                            + getException().getCause().getLocalizedMessage());
                else
                    bar.setMessage(tr.get(ID + ".finished"));
            }
            bar.getProgressMonitor().done();
            setFinished(true);
        }
View Full Code Here

            if (dataProvider.supportsBaseCriteria())
            {
                dataProvider.setBaseCriteria(getBaseCriteria());
            }

            StatusBar statusBar = Application.instance().getActiveWindow().getStatusBar();
            statusBar.getProgressMonitor().taskStarted(
                    RcpSupport.getMessage("statusBar", "loadTable", RcpSupport.LABEL),
                    StatusBarProgressMonitor.UNKNOWN);
            //            getFilterForm().getCommitCommand().setEnabled(false);
            //            getRefreshCommand().setEnabled(false);
View Full Code Here

TOP

Related Classes of org.springframework.richclient.application.statusbar.StatusBar

Copyright © 2018 www.massapicom. 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.