All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.tidalwave.semantic.importexport.action.ImportRepositoryAction Maven / Gradle / Ivy

There is a newer version: 1.0.30
Show newest version
/*******************************************************************************
 *
 * blueMarine - open source photo workflow
 * =======================================
 *
 * Copyright (C) 2003-2010 by Fabrizio Giudici
 * Project home page: http://bluemarine.tidalwave.it
 *
 *******************************************************************************
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 *******************************************************************************
 *
 * $Id: ImportRepositoryAction.java,v 213fe927a495 2010/01/01 00:36:29 fabrizio $
 *
 ******************************************************************************/
package it.tidalwave.semantic.importexport.action;

import javax.annotation.Nonnull;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import org.jdesktop.beansbinding.BindingGroup;
import it.tidalwave.util.logging.Logger;
import it.tidalwave.openide.DialogRunner;
import it.tidalwave.semantic.importexport.ImportSourceSelectionPanel;
import it.tidalwave.semantic.importexport.ByteCountProgressPanel;
import it.tidalwave.semantic.importexport.ImportSourceSelectionController;

/*******************************************************************************
 *
 * @author  Fabrizio Giudici
 * @version $Id: ImportRepositoryAction.java,v 213fe927a495 2010/01/01 00:36:29 fabrizio $
 *
 ******************************************************************************/
public final class ImportRepositoryAction implements ActionListener
  {
    private final static String CLASS = ImportRepositoryAction.class.getName();
    private final static Logger logger = Logger.getLogger(CLASS);

    public void actionPerformed (@Nonnull final ActionEvent event)
      {
        final ImportSourceSelectionPanel panel = new ImportSourceSelectionPanel();

        if (DialogRunner.runOkCancelModalDialog(panel, "Select the source to import data from"))
          {
            try
              {
                final ImportSourceSelectionController controller = panel.getController();
                final ByteCountProgressPanel progressPanel = new ByteCountProgressPanel();
                final BindingGroup bindings = progressPanel.bind(controller, controller.PROP_PROGRESSCOUNT, controller.PROP_SIZE);

                DialogRunner.runTaskDialog(progressPanel, "Loading",  new DialogRunner.Task()
                  {
                    public void run()
                      throws Exception
                      {
                        try
                          {
                            controller.doImport();
                          }
                        finally
                          {
                            bindings.unbind(); // FIXME: must it be the EDT?
                          }
                      }
                  });
              }
            catch (Throwable e)
              {
                logger.severe("While importing: %s", e.toString());
                logger.throwing(CLASS, "doImport()", e);
                DialogRunner.showError("Error", e.toString());
              }
          }
      }
  }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy