Revision bc330e88
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/NavigationUtil.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.taxeditor.navigation; |
11 | 11 |
|
12 |
import java.util.Collection; |
|
12 | 13 |
import java.util.HashMap; |
13 | 14 |
import java.util.HashSet; |
14 | 15 |
import java.util.Map; |
... | ... | |
20 | 21 |
import org.eclipse.core.commands.common.NotDefinedException; |
21 | 22 |
import org.eclipse.core.commands.operations.IUndoContext; |
22 | 23 |
import org.eclipse.core.commands.operations.UndoContext; |
24 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
25 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
|
23 | 26 |
import org.eclipse.jface.wizard.WizardDialog; |
24 | 27 |
import org.eclipse.swt.widgets.Shell; |
25 |
import org.eclipse.ui.IEditorReference; |
|
26 | 28 |
import org.eclipse.ui.IWorkbenchWindow; |
27 | 29 |
import org.eclipse.ui.PartInitException; |
28 | 30 |
import org.eclipse.ui.PlatformUI; |
... | ... | |
43 | 45 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
44 | 46 |
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache; |
45 | 47 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
46 |
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
|
|
48 |
import eu.etaxonomy.taxeditor.editor.e4.TaxonEditorInputE4;
|
|
47 | 49 |
import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin; |
50 |
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4; |
|
48 | 51 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
49 | 52 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
50 | 53 |
import eu.etaxonomy.taxeditor.navigation.internal.TaxeditorNavigationPlugin; |
... | ... | |
233 | 236 |
* @param taxonNode a {@link eu.etaxonomy.cdm.model.taxon.TaxonNode} object. |
234 | 237 |
* @return a boolean. |
235 | 238 |
*/ |
236 |
public static boolean isDirty(TaxonNode taxonNode){ |
|
237 |
|
|
238 |
for (IEditorReference reference : getActivePage().getEditorReferences()) { |
|
239 |
|
|
240 |
try { |
|
241 |
if (reference.getEditorInput() instanceof TaxonEditorInput) { |
|
242 |
TaxonEditorInput editorInput = (TaxonEditorInput) reference.getEditorInput(); |
|
243 |
if(editorInput.getTaxonNode().equals(taxonNode) && reference.isDirty()){ |
|
244 |
return true; |
|
245 |
} |
|
246 |
} |
|
247 |
} catch (PartInitException e) { |
|
248 |
MessagingUtils.error(NavigationUtil.class, e.getMessage(), e); |
|
249 |
throw new RuntimeException(e); |
|
250 |
} |
|
251 |
|
|
252 |
} |
|
239 |
public static boolean isDirty(TaxonNode taxonNode, EPartService partService){ |
|
240 |
|
|
241 |
Collection<MPart> dirtyParts = partService.getDirtyParts(); |
|
242 |
for (MPart part : dirtyParts) { |
|
243 |
if(part.getObject() instanceof TaxonNameEditorE4){ |
|
244 |
TaxonEditorInputE4 input = ((TaxonNameEditorE4) part.getObject()).getEditorInput(); |
|
245 |
if(input.getTaxonNode().equals(taxonNode)){ |
|
246 |
return true; |
|
247 |
} |
|
248 |
} |
|
249 |
} |
|
253 | 250 |
return false; |
254 | 251 |
} |
255 | 252 |
|
Also available in: Unified diff
ref #6925 Refactor NavigationUtil.isDirty()