~berthold-daum/zora/trunk

« back to all changes in this revision

Viewing changes to com.bdaum.zoom.core/src/com/bdaum/zoom/core/internal/CoreActivator.java

  • Committer: bdaum
  • Date: 2015-12-26 10:21:51 UTC
  • Revision ID: berthold.daum@bdaum.de-20151226102151-44f1j5113167thb9
VersionĀ 2.4.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
import java.util.Date;
42
42
import java.util.HashMap;
43
43
import java.util.HashSet;
 
44
import java.util.Iterator;
44
45
import java.util.LinkedList;
45
46
import java.util.List;
46
47
import java.util.Map;
198
199
 
199
200
        private HighresImageLoader highresImageLoader;
200
201
 
 
202
        private ServiceReference<IGeoService> geoServiceRef;
 
203
 
201
204
        /*
202
205
         * (non-Javadoc)
203
206
         *
267
270
                                fileWatchManager.dispose();
268
271
                        if (dbfactoryRef != null)
269
272
                                getBundle().getBundleContext().ungetService(dbfactoryRef);
 
273
                        if (geoServiceRef != null)
 
274
                                context.ungetService(geoServiceRef);
270
275
                        if (imageCache != null) {
271
276
                                imageCache.dispose();
272
277
                                imageCache = null;
1033
1038
                                                                OperationHistoryEvent event) {
1034
1039
                                                        if (event.getEventType() == OperationHistoryEvent.OPERATION_REMOVED
1035
1040
                                                                        && event.getOperation() instanceof HistoryItem) {
1036
 
                                                                List<HistoryItem> set = dbManager.getTrash(
1037
 
                                                                                HistoryItem.class, ((HistoryItem) event
1038
 
                                                                                                .getOperation()).getOpId());
1039
 
                                                                if (!set.isEmpty())
1040
 
                                                                        getDbManager().deleteAllTrash(set);
 
1041
                                                                getDbManager().deleteAllTrash(
 
1042
                                                                                dbManager.getTrash(HistoryItem.class,
 
1043
                                                                                                ((HistoryItem) event
 
1044
                                                                                                                .getOperation())
 
1045
                                                                                                                .getOpId()));
1041
1046
                                                        }
1042
1047
                                                }
1043
1048
                                        });
1383
1388
                        return;
1384
1389
                URI uri = member.toURI();
1385
1390
                List<AssetImpl> assets = dbManager.obtainAssetsForFile(uri);
1386
 
                if (assets == null || assets.isEmpty()) {
 
1391
                Iterator<AssetImpl> ait = assets.iterator();
 
1392
                if (!ait.hasNext()) {
1387
1393
                        List<Trash> t = dbManager.obtainTrashForFile(uri);
1388
1394
                        if (t == null || t.isEmpty()) {
1389
1395
                                List<Ghost_typeImpl> ghosts = dbManager
1394
1400
                        return;
1395
1401
                }
1396
1402
                long xmpdate = Long.MIN_VALUE;
1397
 
                String filename = member.getName();
1398
 
                int p = filename.lastIndexOf('.');
1399
 
                if (p >= 0)
1400
 
                        filename = filename.substring(0, p);
1401
1403
                if (xmpMap != null) {
 
1404
                        String filename = member.getName();
 
1405
                        int p = filename.lastIndexOf('.');
 
1406
                        if (p >= 0)
 
1407
                                filename = filename.substring(0, p);
1402
1408
                        File sidecar = xmpMap.get(filename);
1403
1409
                        if (sidecar != null)
1404
1410
                                xmpdate = sidecar.lastModified();
1405
1411
                }
1406
1412
                long lastmod = -1;
1407
1413
                AssetImpl asset = null;
1408
 
                if (!assets.isEmpty()) {
1409
 
                        asset = assets.get(0);
 
1414
                if (ait.hasNext()) {
 
1415
                        asset = ait.next();
1410
1416
                        Date lastModification = asset.getLastModification();
1411
1417
                        if (lastModification != null)
1412
1418
                                lastmod = lastModification.getTime();
1426
1432
                }
1427
1433
                if (activeRecipeDetectors != null) {
1428
1434
                        if (lastmod < 0) {
1429
 
                                if (asset == null && !assets.isEmpty())
1430
 
                                        asset = assets.get(0);
 
1435
                                ait = assets.iterator();
 
1436
                                if (asset == null && ait.hasNext())
 
1437
                                        asset = ait.next();
1431
1438
                                if (asset != null) {
1432
1439
                                        Date lastModification = asset.getLastModification();
1433
1440
                                        if (lastModification != null)
1453
1460
                return highresImageLoader;
1454
1461
        }
1455
1462
 
 
1463
        public IGeoService getGeoService() {
 
1464
                BundleContext bundleContext = getBundle().getBundleContext();
 
1465
                geoServiceRef = bundleContext.getServiceReference(IGeoService.class);
 
1466
                if (geoServiceRef != null)
 
1467
                        return bundleContext.getService(geoServiceRef);
 
1468
                return null;
 
1469
        }
 
1470
 
1456
1471
}