Revision e11c0cff
Added by Patrick Plitzner over 8 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/datasource/handler/ChangeConnectionHandler.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 | 3 |
* Copyright (C) 2007 EDIT |
4 |
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy |
|
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
... | ... | |
22 | 22 |
import eu.etaxonomy.taxeditor.view.datasource.CdmMetaDataAwareDataSourceContainer; |
23 | 23 |
|
24 | 24 |
/** |
25 |
* <p>ChangeConnectionHandler class.</p> |
|
26 |
* |
|
27 | 25 |
* @author n.hoffmann |
28 | 26 |
* @created 15.04.2009 |
29 | 27 |
* @version 1.0 |
30 | 28 |
*/ |
31 | 29 |
public class ChangeConnectionHandler extends AbstractHandler { |
32 | 30 |
|
33 |
/* (non-Javadoc) |
|
34 |
* @see eu.etaxonomy.taxeditor.store.datasource.handler.AbstractDataSourceHandler#specificExecute(org.eclipse.core.commands.ExecutionEvent) |
|
35 |
*/ |
|
36 | 31 |
/** {@inheritDoc} */ |
37 |
public Object execute(ExecutionEvent event) { |
|
32 |
@Override |
|
33 |
public Object execute(ExecutionEvent event) { |
|
38 | 34 |
ISelection selection = HandlerUtil.getCurrentSelection(event); |
39 |
|
|
35 |
|
|
40 | 36 |
if(selection != null && selection instanceof IStructuredSelection){ |
41 | 37 |
CdmMetaDataAwareDataSourceContainer container = (CdmMetaDataAwareDataSourceContainer) ((IStructuredSelection) selection).getFirstElement(); |
42 |
|
|
38 |
|
|
43 | 39 |
if(CdmStore.isConnecting()){ |
44 | 40 |
MessagingUtils.warningDialog("Already connecting", this, "You are currently connecting to a different datasource already."); |
45 | 41 |
return null; |
46 | 42 |
} |
47 |
|
|
43 |
|
|
48 | 44 |
try { |
49 | 45 |
container.getCdmSource().checkConnection(); |
50 | 46 |
boolean confirmed = MessagingUtils.confirmDialog("Confirm Datasource Connection", "Do you really want to connect to this datasource?\n\n" |
51 | 47 |
+ container.getCdmSource().getName()); |
52 |
|
|
48 |
|
|
53 | 49 |
if(confirmed){ |
54 | 50 |
CdmDataSourceRepository.changeDataSource(container.getCdmSource()); |
55 | 51 |
} |
... | ... | |
59 | 55 |
"Please also make sure that you are connected to the network when trying to connect to a remote datasource."); |
60 | 56 |
MessagingUtils.warn(getClass(), e); |
61 | 57 |
return null; |
62 |
}
|
|
58 |
} |
|
63 | 59 |
} |
64 |
|
|
60 |
|
|
65 | 61 |
return null; |
66 | 62 |
} |
67 | 63 |
} |
Also available in: Unified diff
Trim code