// $Id$
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
-*
+*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
import eu.etaxonomy.taxeditor.view.datasource.CdmMetaDataAwareDataSourceContainer;
/**
- * <p>ChangeConnectionHandler class.</p>
- *
* @author n.hoffmann
* @created 15.04.2009
* @version 1.0
*/
public class ChangeConnectionHandler extends AbstractHandler {
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.store.datasource.handler.AbstractDataSourceHandler#specificExecute(org.eclipse.core.commands.ExecutionEvent)
- */
/** {@inheritDoc} */
- public Object execute(ExecutionEvent event) {
+ @Override
+ public Object execute(ExecutionEvent event) {
ISelection selection = HandlerUtil.getCurrentSelection(event);
-
+
if(selection != null && selection instanceof IStructuredSelection){
CdmMetaDataAwareDataSourceContainer container = (CdmMetaDataAwareDataSourceContainer) ((IStructuredSelection) selection).getFirstElement();
-
+
if(CdmStore.isConnecting()){
MessagingUtils.warningDialog("Already connecting", this, "You are currently connecting to a different datasource already.");
return null;
}
-
+
try {
container.getCdmSource().checkConnection();
boolean confirmed = MessagingUtils.confirmDialog("Confirm Datasource Connection", "Do you really want to connect to this datasource?\n\n"
+ container.getCdmSource().getName());
-
+
if(confirmed){
CdmDataSourceRepository.changeDataSource(container.getCdmSource());
}
"Please also make sure that you are connected to the network when trying to connect to a remote datasource.");
MessagingUtils.warn(getClass(), e);
return null;
- }
+ }
}
-
+
return null;
}
}