Revision e9a587e7
Added by Patrick Plitzner over 8 years ago
- added configurator settings to taxon deletion dialog
.gitattributes | ||
---|---|---|
1410 | 1410 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/EnumComboElement.java -text |
1411 | 1411 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/TermComboElement.java -text |
1412 | 1412 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/DefaultLanguageDialog.java -text |
1413 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/DeleteConfiguratorDialog.java -text |
|
1414 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/DeleteTaxonConfiguratorDialog.java -text |
|
1413 | 1415 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/LoginDialog.java -text |
1414 | 1416 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/UriDialog.java -text |
1415 | 1417 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/AbstractFilteredCdmEnumSelectionDialog.java -text |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/DeleteHandler.java | ||
---|---|---|
17 | 17 |
import org.eclipse.core.commands.AbstractHandler; |
18 | 18 |
import org.eclipse.core.commands.ExecutionEvent; |
19 | 19 |
import org.eclipse.core.commands.ExecutionException; |
20 |
import org.eclipse.core.commands.IHandler; |
|
21 | 20 |
import org.eclipse.core.commands.common.NotDefinedException; |
22 | 21 |
import org.eclipse.jface.dialogs.MessageDialog; |
23 | 22 |
import org.eclipse.jface.viewers.TreeSelection; |
... | ... | |
34 | 33 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
35 | 34 |
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode; |
36 | 35 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
37 |
import eu.etaxonomy.cdm.persistence.dao.hibernate.taxon.TaxonNodeDaoHibernateImpl; |
|
38 | 36 |
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput; |
37 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
|
39 | 38 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
40 | 39 |
import eu.etaxonomy.taxeditor.navigation.NavigationUtil; |
41 | 40 |
import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigator; |
42 | 41 |
import eu.etaxonomy.taxeditor.navigation.navigator.operation.DeleteOperation; |
43 | 42 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
43 |
import eu.etaxonomy.taxeditor.ui.dialog.DeleteConfiguratorDialog; |
|
44 |
import eu.etaxonomy.taxeditor.ui.dialog.DeleteTaxonConfiguratorDialog; |
|
44 | 45 |
|
45 | 46 |
/** |
46 | 47 |
* <p>DeleteTreeNodeHandler class.</p> |
... | ... | |
49 | 50 |
* @created 06.04.2009 |
50 | 51 |
* @version 1.0 |
51 | 52 |
*/ |
52 |
public class DeleteHandler extends AbstractHandler implements IHandler{
|
|
53 |
public class DeleteHandler extends AbstractHandler{ |
|
53 | 54 |
|
54 | 55 |
protected IWorkbenchPage activePage; |
55 | 56 |
protected TaxonNavigator taxonNavigator; |
... | ... | |
64 | 65 |
|
65 | 66 |
TreeSelection selection = (TreeSelection) HandlerUtil.getCurrentSelection(event); |
66 | 67 |
|
67 |
String plural = selection.size() > 1 ? "s" : ""; |
|
68 |
// Prompt user for confirmation |
|
69 |
|
|
70 |
|
|
71 |
|
|
72 | 68 |
Iterator selectionIterator = selection.iterator(); |
73 | 69 |
Set<ITaxonTreeNode> treeNodes = new HashSet<ITaxonTreeNode>(); |
74 | 70 |
|
... | ... | |
85 | 81 |
} |
86 | 82 |
} |
87 | 83 |
AbstractPostOperation operation = null; |
84 |
TaxonDeletionConfigurator config = new TaxonDeletionConfigurator(); |
|
88 | 85 |
if (treeNodes.size() == 1 ){ |
89 | 86 |
try { |
90 |
|
|
87 |
|
|
91 | 88 |
ITaxonTreeNode treeNode = treeNodes.iterator().next(); |
92 | 89 |
ITaxonTreeNode taxonNode =treeNode; |
93 | 90 |
TaxonNodeDeletionConfigurator configNodes = new TaxonNodeDeletionConfigurator(); |
94 |
TaxonDeletionConfigurator config = new TaxonDeletionConfigurator(); |
|
95 | 91 |
if (taxonNode instanceof Classification && taxonNode.hasChildNodes()){ |
96 |
if(! MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the classification? The tree has children, they will be deleted, too.")){
|
|
92 |
if(!DeleteTaxonConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the classification? The tree has children, they will be deleted, too.")){
|
|
97 | 93 |
return null; |
98 | 94 |
} |
99 | 95 |
} else if (taxonNode instanceof Classification && !taxonNode.hasChildNodes()){ |
100 |
if(! MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the classification?")){
|
|
96 |
if(!DeleteTaxonConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the classification?")){
|
|
101 | 97 |
return null; |
102 | 98 |
} |
103 | 99 |
} else { |
100 |
|
|
104 | 101 |
if (taxonNode.hasChildNodes()){ |
105 |
MessageDialog dialog = new MessageDialog(HandlerUtil.getActiveShell(event), "Confirm Deletion", null, |
|
106 |
"Do you really want to delete the selected node? It has childnodes, they will be deleted, too.", MessageDialog.WARNING, new String[] { "Delete all children", |
|
107 |
"Move children to parent node", "Skip" }, 0); |
|
102 |
DeleteConfiguratorDialog dialog = new DeleteTaxonConfiguratorDialog( |
|
103 |
config, |
|
104 |
HandlerUtil.getActiveShell(event), |
|
105 |
"Confirm Deletion", |
|
106 |
null, |
|
107 |
"Do you really want to delete the selected node? It has childnodes, they will be deleted, too.", |
|
108 |
MessageDialog.WARNING, new String[] { "Delete all children", |
|
109 |
"Move children to parent node", "Skip" }, 0); |
|
108 | 110 |
int result = dialog.open(); |
109 |
|
|
111 |
|
|
110 | 112 |
if (result == 0){ |
111 | 113 |
//delete all children |
112 | 114 |
configNodes.setChildHandling(ChildHandling.DELETE); |
... | ... | |
118 | 120 |
} else if (result == 2){ |
119 | 121 |
//skip |
120 | 122 |
return null; |
121 |
|
|
123 |
|
|
122 | 124 |
} |
123 | 125 |
}else{ |
124 |
if(! MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the selected node?")){
|
|
126 |
if(!DeleteTaxonConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the selected node?")){
|
|
125 | 127 |
return null; |
126 | 128 |
} |
127 | 129 |
} |
128 | 130 |
} |
129 |
|
|
131 |
|
|
130 | 132 |
if (allEditorsClosed){ |
131 | 133 |
/*if(! MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the selected nodes?")){ |
132 | 134 |
return null; |
... | ... | |
134 | 136 |
operation = new DeleteOperation( |
135 | 137 |
event.getCommand().getName(), NavigationUtil.getUndoContext(), |
136 | 138 |
taxonNode, config, taxonNavigator, taxonNavigator); |
137 |
|
|
138 |
NavigationUtil.executeOperation(operation);
|
|
139 |
|
|
140 |
AbstractUtility.executeOperation(operation);
|
|
139 | 141 |
//} |
140 | 142 |
} |
141 |
|
|
142 |
|
|
143 |
|
|
143 |
|
|
144 |
|
|
145 |
|
|
144 | 146 |
} catch (NotDefinedException e) { |
145 | 147 |
MessagingUtils.warn(getClass(), "Command name not set"); |
146 | 148 |
} |
147 | 149 |
} else{ |
148 | 150 |
try{ |
149 |
if(! MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the selected nodes?")){
|
|
151 |
if(!DeleteTaxonConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the selected nodes?")){
|
|
150 | 152 |
return null; |
151 | 153 |
} |
152 | 154 |
if (allEditorsClosed){ |
153 | 155 |
operation = new DeleteOperation( |
154 | 156 |
event.getCommand().getName(), NavigationUtil.getUndoContext(), |
155 | 157 |
treeNodes, new TaxonDeletionConfigurator(), taxonNavigator, taxonNavigator); |
156 |
|
|
157 |
NavigationUtil.executeOperation(operation);
|
|
158 |
|
|
159 |
AbstractUtility.executeOperation(operation);
|
|
158 | 160 |
} |
159 | 161 |
}catch (NotDefinedException e) { |
160 | 162 |
MessagingUtils.warn(getClass(), "Command name not set"); |
... | ... | |
168 | 170 |
for (IEditorReference ref : activePage.getEditorReferences()) { |
169 | 171 |
try { |
170 | 172 |
String treeIndex = ((ITreeNode)taxonNode).treeIndex(); |
171 |
|
|
172 |
|
|
173 |
|
|
174 |
|
|
173 | 175 |
IEditorInput input = ref.getEditorInput(); |
174 | 176 |
if (input instanceof TaxonEditorInput) { |
175 | 177 |
TaxonNode node = ((TaxonEditorInput) input).getTaxonNode(); |
... | ... | |
177 | 179 |
if( ((ITreeNode) node).treeIndex().startsWith(treeIndex)){ |
178 | 180 |
//if (taxonNode.equals(node)) { |
179 | 181 |
result &= activePage.closeEditor(ref.getEditor(false), true); |
180 |
|
|
182 |
|
|
181 | 183 |
} |
182 | 184 |
} |
183 | 185 |
} catch (PartInitException e) { |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/DeleteConfiguratorDialog.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2015 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
package eu.etaxonomy.taxeditor.ui.dialog; |
|
11 |
|
|
12 |
import org.eclipse.jface.dialogs.IDialogConstants; |
|
13 |
import org.eclipse.jface.dialogs.MessageDialog; |
|
14 |
import org.eclipse.swt.graphics.Image; |
|
15 |
import org.eclipse.swt.widgets.Composite; |
|
16 |
import org.eclipse.swt.widgets.Control; |
|
17 |
import org.eclipse.swt.widgets.Listener; |
|
18 |
import org.eclipse.swt.widgets.Shell; |
|
19 |
|
|
20 |
import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase; |
|
21 |
|
|
22 |
/** |
|
23 |
* Abstract subclass of MessageDialog providing the functionality to configure |
|
24 |
* a {@link DeleteConfiguratorBase} |
|
25 |
* @author pplitzner |
|
26 |
* @date Jan 28, 2015 |
|
27 |
* |
|
28 |
*/ |
|
29 |
public abstract class DeleteConfiguratorDialog extends MessageDialog implements Listener{ |
|
30 |
|
|
31 |
public DeleteConfiguratorDialog(Shell parentShell, String dialogTitle, |
|
32 |
Image dialogTitleImage, String dialogMessage, int dialogImageType, String[] dialogButtonLabels, int defaultIndex) { |
|
33 |
super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels, defaultIndex); |
|
34 |
} |
|
35 |
|
|
36 |
/* (non-Javadoc) |
|
37 |
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) |
|
38 |
*/ |
|
39 |
@Override |
|
40 |
protected Control createDialogArea(Composite parent) { |
|
41 |
Composite composite = (Composite) super.createDialogArea(parent); |
|
42 |
|
|
43 |
createCheckBoxes(composite); |
|
44 |
|
|
45 |
return composite; |
|
46 |
} |
|
47 |
|
|
48 |
protected abstract void createCheckBoxes(Composite parent); |
|
49 |
|
|
50 |
/** |
|
51 |
* @param kind |
|
52 |
* @return |
|
53 |
*/ |
|
54 |
static String[] getButtonLabels(int kind) { |
|
55 |
String[] dialogButtonLabels; |
|
56 |
switch (kind) { |
|
57 |
case ERROR: |
|
58 |
case INFORMATION: |
|
59 |
case WARNING: { |
|
60 |
dialogButtonLabels = new String[] { IDialogConstants.OK_LABEL }; |
|
61 |
break; |
|
62 |
} |
|
63 |
case CONFIRM: { |
|
64 |
dialogButtonLabels = new String[] { IDialogConstants.OK_LABEL, |
|
65 |
IDialogConstants.CANCEL_LABEL }; |
|
66 |
break; |
|
67 |
} |
|
68 |
case QUESTION: { |
|
69 |
dialogButtonLabels = new String[] { IDialogConstants.YES_LABEL, |
|
70 |
IDialogConstants.NO_LABEL }; |
|
71 |
break; |
|
72 |
} |
|
73 |
case QUESTION_WITH_CANCEL: { |
|
74 |
dialogButtonLabels = new String[] { IDialogConstants.YES_LABEL, |
|
75 |
IDialogConstants.NO_LABEL, |
|
76 |
IDialogConstants.CANCEL_LABEL }; |
|
77 |
break; |
|
78 |
} |
|
79 |
default: { |
|
80 |
throw new IllegalArgumentException( |
|
81 |
"Illegal value for kind in MessageDialog.open()"); //$NON-NLS-1$ |
|
82 |
} |
|
83 |
} |
|
84 |
return dialogButtonLabels; |
|
85 |
} |
|
86 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/DeleteTaxonConfiguratorDialog.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2015 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
package eu.etaxonomy.taxeditor.ui.dialog; |
|
11 |
|
|
12 |
import org.apache.log4j.Logger; |
|
13 |
import org.eclipse.swt.SWT; |
|
14 |
import org.eclipse.swt.graphics.Image; |
|
15 |
import org.eclipse.swt.widgets.Button; |
|
16 |
import org.eclipse.swt.widgets.Composite; |
|
17 |
import org.eclipse.swt.widgets.Event; |
|
18 |
import org.eclipse.swt.widgets.Shell; |
|
19 |
|
|
20 |
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator; |
|
21 |
|
|
22 |
/** |
|
23 |
* @author pplitzner |
|
24 |
* @date Jan 28, 2015 |
|
25 |
* |
|
26 |
*/ |
|
27 |
public class DeleteTaxonConfiguratorDialog extends DeleteConfiguratorDialog { |
|
28 |
|
|
29 |
@SuppressWarnings("unused") |
|
30 |
private final Logger logger = Logger.getLogger(DeleteTaxonConfiguratorDialog.class); |
|
31 |
|
|
32 |
private final TaxonDeletionConfigurator configurator; |
|
33 |
private Button btnDeleteName; |
|
34 |
|
|
35 |
/** |
|
36 |
* @param configurator |
|
37 |
* @param parentShell |
|
38 |
* @param dialogTitle |
|
39 |
* @param dialogTitleImage |
|
40 |
* @param dialogMessage |
|
41 |
* @param dialogImageType |
|
42 |
* @param dialogButtonLabels |
|
43 |
* @param defaultIndex |
|
44 |
*/ |
|
45 |
public DeleteTaxonConfiguratorDialog(TaxonDeletionConfigurator configurator, Shell parentShell, String dialogTitle, |
|
46 |
Image dialogTitleImage, String dialogMessage,int dialogImageType, String[] dialogButtonLabels, int defaultIndex) { |
|
47 |
super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels, defaultIndex); |
|
48 |
this.configurator = configurator; |
|
49 |
} |
|
50 |
|
|
51 |
/* (non-Javadoc) |
|
52 |
* @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event) |
|
53 |
*/ |
|
54 |
@Override |
|
55 |
public void handleEvent(Event event) { |
|
56 |
if(event.widget==btnDeleteName){ |
|
57 |
configurator.setDeleteNameIfPossible(btnDeleteName.getSelection()); |
|
58 |
} |
|
59 |
} |
|
60 |
|
|
61 |
/* (non-Javadoc) |
|
62 |
* @see eu.etaxonomy.taxeditor.ui.dialog.DeleteConfiguratorDialog#createCheckBoxes() |
|
63 |
*/ |
|
64 |
@Override |
|
65 |
protected void createCheckBoxes(Composite parent) { |
|
66 |
btnDeleteName = new Button(parent, SWT.CHECK); |
|
67 |
btnDeleteName.setText("Delete taxon name if possible"); |
|
68 |
btnDeleteName.addListener(SWT.Selection, this); |
|
69 |
btnDeleteName.setSelection(configurator.isDeleteNameIfPossible()); |
|
70 |
} |
|
71 |
|
|
72 |
public static boolean openConfirmWithConfigurator(TaxonDeletionConfigurator configurator, Shell parent, String title, String message) { |
|
73 |
DeleteTaxonConfiguratorDialog dialog = new DeleteTaxonConfiguratorDialog(configurator, parent, title, getDefaultImage(), message, QUESTION, getButtonLabels(QUESTION), 0); |
|
74 |
return dialog.open() == 0; |
|
75 |
} |
|
76 |
|
|
77 |
} |
Also available in: Unified diff