Project

General

Profile

« Previous | Next » 

Revision a0f770fe

Added by Andreas Müller over 1 year ago

cleanup

View differences:

eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditor.java
66 66
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
67 67
import eu.etaxonomy.taxeditor.bulkeditor.input.GroupEditorInput;
68 68
import eu.etaxonomy.taxeditor.bulkeditor.input.MediaEditorInput;
69
import eu.etaxonomy.taxeditor.bulkeditor.input.NameEditorInput;
70 69
import eu.etaxonomy.taxeditor.bulkeditor.input.TaxonEditorInput;
71 70
import eu.etaxonomy.taxeditor.editor.IBulkEditor;
72 71
import eu.etaxonomy.taxeditor.editor.ITaxonEditor;
......
111 110
    private BulkEditorQuery lastQuery = null;
112 111

  
113 112
    private BulkEditorComposite bulkEditorComposite;
114
    
113

  
115 114
    private Set<AbstractPostOperation> operations = new HashSet<>();
116 115

  
117 116
    @Inject
......
147 146
            String operationlabel = entry.getLabel();
148 147
            try {
149 148
                entry.addContext(IOperationHistory.GLOBAL_UNDO_CONTEXT);
150
                
149

  
151 150
                status = entry.execute(new NullProgressMonitor(), uiInfoAdapter);
152 151
            } catch (ExecutionException e) {
153 152
                MessagingUtils.operationDialog(AbstractUtility.class, e, TaxeditorStorePlugin.PLUGIN_ID, operationlabel, null);
......
178 177
        if (lastQuery != null){
179 178
            bulkEditorComposite.performSearch(lastQuery, selection);
180 179
        }
181
       
180

  
182 181
    }
183 182

  
184 183

  
......
186 185
		return new StructuredSelection(this.bulkEditorComposite.getLastSelectedObject());
187 186
	}
188 187

  
189
	@Focus
188
	@Override
189
    @Focus
190 190
	public void setFocus() {
191 191
        //make sure to bind again if maybe in another view the conversation was unbound
192 192
        if(conversation!=null && !conversation.isBound()){
......
241 241
        return bulkEditorComposite.getCellSelection();
242 242
    }
243 243

  
244
    @Override
244 245
    public void setSelection(IStructuredSelection selection){
245 246
        bulkEditorComposite.setSelection(selection);
246 247
    }
......
333 334
            }else if (element instanceof Media && input instanceof MediaEditorInput){
334 335
            	getEditorInput().addSaveCandidate((Media)element);
335 336
                input.replaceInModel((Media)element);
336
            }else if (element instanceof Media ) {            	
337
            }else if (element instanceof Media ) {
337 338
                IStructuredSelection sel = getSelection();
338 339
                Object firstElement = sel.getFirstElement();
339 340
                if (firstElement instanceof TaxonBase){
......
344 345
                    SpecimenOrObservationBase changedSpecimen = (SpecimenOrObservationBase)sel.getFirstElement();
345 346
                    getEditorInput().addSaveCandidate(changedSpecimen);
346 347
                    input.replaceInModel(changedSpecimen);
347
                } 
348
                }
348 349
            }else if(element instanceof Group){
349 350
                 Group oldGroup = ((GroupEditorInput)input).getEntityFromModel((Group)element);
350 351
                 ((GroupEditorInput)input).getSaveUserCandidates().addAll(oldGroup.getMembers());
......
375 376
                	getEditorInput().addSaveCandidate(taxon);
376 377
                	input.replaceInModel(taxon);
377 378
                }
378
                
379

  
379 380
            }
380 381
            else{
381 382
                getEditorInput().addSaveCandidate((CdmBase)element);
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/session/ICdmEntitySession.java
1
/**
2
 * Copyright (C) 2007 EDIT
3
 * European Distributed Institute of Taxonomy
4
 * http://www.e-taxonomy.eu
5
 *
6
 * The contents of this file are subject to the Mozilla Public License Version 1.1
7
 * See LICENSE.TXT at the top of this package for the full license terms.
8
 */
1 9
package eu.etaxonomy.taxeditor.session;
2 10

  
3 11
import java.util.Collection;
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java
242 242
        	        partService.activate(part, true);
243 243
        	        return;
244 244
        	    }
245

  
246 245
            }
247 246
        }
248 247
        if (alreadyOpenInOtherClassification != null){
......
276 275
    public static void showMedia(EModelService modelService, EPartService partService) {
277 276
        String partIdFactualData = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_MEDIA_E4_MEDIAVIEWPARTE4;
278 277
        showPart(partIdFactualData, modelService, partService);
279

  
280 278
    }
281 279

  
282 280
    public static void showFacts(EModelService modelService, EPartService partService) {
283 281
        String partIdFactualData = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DESCRIPTIVE_E4_FACTUALDATAPARTE4;
284 282
        showPart(partIdFactualData, modelService, partService);
285

  
286 283
    }
287 284

  
288 285
    public static Collection<MPart> checkForChanges(UUID taxonUUID, EPartService partService ){
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/e4/TaxonEditorInputE4.java
126 126
        }
127 127
        init(taxonNode);
128 128
        setInitiallySelectedTaxonBase(getTaxon());
129

  
130 129
    }
131 130

  
132 131
    private void initForTaxonBase(UUID taxonBaseUuid) {
......
171 170
        }
172 171
    }
173 172

  
174

  
175 173
    private void initForParentTaxonNode(UUID parentNodeUuid){
176 174
    	this.getCdmEntitySession().bind();
177 175
        TaxonName name = PreferencesUtil.getPreferredNomenclaturalCode().getNewTaxonNameInstance(null);
......
258 256

  
259 257
    public static TaxonEditorInputE4 NewInstance(UUID taxonNodeUuid) {
260 258
        return new TaxonEditorInputE4(taxonNodeUuid, CdmType.TAXON_NODE);
261

  
262 259
    }
263 260

  
264 261
    public static TaxonEditorInputE4 NewInstanceFromTaxonBase(UUID taxonBaseUuid){
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/TaxonNameEditorE4.java
104 104
 * @author pplitzner
105 105
 * @date Aug 24, 2017
106 106
 */
107
public class TaxonNameEditorE4 implements IConversationEnabled, IDirtyMarkable, IPartContentHasDetails,
108
        IPartContentHasSupplementalData, IPartContentHasMedia, IPartContentHasFactualData, IPartChangeListener,
109
        ISelectionListener, ISecuredEditor, IE4SavablePart, ITaxonEditor, IDropTargetableE4 {
107
public class TaxonNameEditorE4
108
        implements IConversationEnabled, IDirtyMarkable, IPartContentHasDetails,
109
            IPartContentHasSupplementalData, IPartContentHasMedia, IPartContentHasFactualData, IPartChangeListener,
110
            ISelectionListener, ISecuredEditor, IE4SavablePart, ITaxonEditor, IDropTargetableE4 {
110 111

  
111 112
    private Taxon taxon;
112 113

  
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/FactualDataPartE4.java
122 122

  
123 123
    @Override
124 124
    public void selectionChanged_internal(Object selection, MPart activePart, MPart thisPart) {
125
        if(activePart==thisPart){
125
        if(activePart == thisPart){
126 126
            return;
127 127
        }
128 128

  
129 129
        Object partObject = createPartObject(activePart);
130 130

  
131
        if ((partObject instanceof DetailsPartE4 && !(selection instanceof TaxonName))|| partObject instanceof SupplementalDataPartE4
132
                || partObject instanceof MediaViewPartE4 || partObject instanceof ConceptViewPartE4 || ((partObject instanceof AbstractCdmEditorPartE4) &&(((AbstractCdmEditorPartE4)partObject).getViewer().getInput() instanceof DescriptionElementBase))) {
131
        if ( (partObject instanceof DetailsPartE4 && !(selection instanceof TaxonName))
132
              || partObject instanceof SupplementalDataPartE4
133
              || partObject instanceof MediaViewPartE4
134
              || partObject instanceof ConceptViewPartE4
135
              || ((partObject instanceof AbstractCdmEditorPartE4) &&(((AbstractCdmEditorPartE4)partObject).getViewer().getInput() instanceof DescriptionElementBase))) {
133 136
            // do not show empty page as these views are also used to edit the
134 137
            // description selected in this view
135 138
            return;
......
220 223
            	StructuredSelection selection = new StructuredSelection(object);
221 224
            	viewer.setSelection(selection, true);
222 225
            }
223
            
226

  
224 227
        }
225 228

  
226 229

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java
349 349
            return mockCdmEntitySessionManager;
350 350
        }
351 351
    }
352
    public static  ICdmEntitySessionManager getCurrentSessionManager() {
352
    public static ICdmEntitySessionManager getCurrentSessionManager() {
353 353
        return getCurrentSessionManager(false);
354 354
    }
355 355

  
356 356
    public static  ICdmEntitySessionManager getCurrentSessionManager(boolean connecting) {
357
        if (getDefault(connecting) != null) {
358
            return getDefault(connecting).getSessionManager();
357
        CdmStore cdmStore = getDefault(connecting);
358
        if (cdmStore != null) {
359
            return cdmStore.getSessionManager();
359 360
        }
360 361
        return null;
361 362
    }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/AbstractCdmEditorPartE4.java
69 69
	private static final Logger logger = LogManager.getLogger(AbstractCdmEditorPartE4.class);
70 70

  
71 71
	private DelaySelection delaySelection = null;
72

  
72 73
    /**
73 74
     * This is the monitor for the DelaySelection runnable.
74 75
     * If it is <code>true</code> then it is currently delaying a selection.
......
146 147
            @Optional@Named(IServiceConstants.ACTIVE_SELECTION)Object selection,
147 148
            @Optional@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
148 149
            MPart thisPart, UISynchronize sync, EPartService partService){
150

  
149 151
        //multiple selections are not supported
150
        if(activePart!=null
151
                && thisPart!=null
152
        if(activePart != null
153
                && thisPart != null
152 154
                && !activePart.equals(thisPart)
153 155
                && selection instanceof IStructuredSelection
154 156
                && ((IStructuredSelection) selection).size()>1){
155 157
            showEmptyPage();
156 158
            return;
157 159
        }
160

  
158 161
        // no active editor found
159
        if(activePart==thisPart && WorkbenchUtility.getActiveEditorPart(partService)==null && showEmptyIfNoActiveEditor()){
162
        if(activePart == thisPart && WorkbenchUtility.getActiveEditorPart(partService) == null && showEmptyIfNoActiveEditor()){
160 163
            showEmptyPage();
161 164
            return;
162 165
        }
166

  
163 167
        if (viewer != null && viewer.getControl()!= null && viewer.getInput() != null && !viewer.getControl().isDisposed()){
164 168
           try{
165 169
               viewer.getControl().setEnabled(isEnabled);
......
168 172
           }
169 173
        }
170 174

  
171
        if((previousSelection!=null && selection!=null)
172
               && (activePart != null &&  selectionProvidingPart != null && activePart.equals(selectionProvidingPart))
173
               && (previousSelection==selection
175
        //same as previous selection? => return
176
        if((previousSelection != null && selection != null)
177
               && (activePart != null && selectionProvidingPart != null
178
                   && activePart.equals(selectionProvidingPart))
179
               && (previousSelection == selection
174 180
                    || previousSelection.equals(selection)
175 181
                    || new StructuredSelection(selection).equals(previousSelection))
176 182
                ) {
177 183
            return;
178 184
        }
179
        if(delaySelection==null){
185
        if(delaySelection == null){
180 186
            delaySelection = new DelaySelection(selection, activePart, thisPart);
181 187
        }else{
182 188
            delaySelection.setSelection(selection);
......
306 312
                }
307 313
            }
308 314
        }
309

  
310 315
    }
311 316

  
312 317
    protected Object createPartObject(MPart activePart) {
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/MockConversationEnabled.java
16 16
/**
17 17
 * @author cmathew
18 18
 * @date 15 Jun 2015
19
 *
20 19
 */
21 20
public class MockConversationEnabled implements IConversationEnabled {
22 21

  
23
    /* (non-Javadoc)
24
     * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
25
     */
26 22
    @Override
27 23
    public void update(CdmDataChangeMap arg0) {
28 24
        // TODO Auto-generated method stub
29 25

  
30 26
    }
31 27

  
32
    /* (non-Javadoc)
33
     * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
34
     */
35 28
    @Override
36 29
    public ConversationHolder getConversationHolder() {
37 30
        return new ConversationHolderMock();
38 31
    }
39

  
40
}
32
}

Also available in: Unified diff