KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ui > mapping > StreamMergerDelegate


1 /*******************************************************************************
2  * Copyright (c) 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.team.internal.ui.mapping;
12
13 import org.eclipse.compare.CompareUI;
14 import org.eclipse.compare.IStreamMerger;
15 import org.eclipse.core.resources.IStorage;
16 import org.eclipse.core.runtime.CoreException;
17 import org.eclipse.core.runtime.content.IContentType;
18 import org.eclipse.team.core.mapping.IStorageMerger;
19 import org.eclipse.team.internal.core.mapping.DelegatingStorageMerger;
20 import org.eclipse.team.internal.core.mapping.IStreamMergerDelegate;
21 import org.eclipse.team.internal.ui.TeamUIPlugin;
22
23 public class StreamMergerDelegate implements IStreamMergerDelegate {
24
25     public static void start() {
26         DelegatingStorageMerger.setMergerDelegate(new StreamMergerDelegate());
27     }
28     
29     public IStorageMerger findMerger(IStorage target) {
30         try {
31             IContentType type = DelegatingStorageMerger.getContentType(target);
32             if (type != null) {
33                 IStreamMerger merger = CompareUI.createStreamMerger(type);
34                 if (merger != null)
35                     return new StorageStreamMerger(merger);
36             }
37         } catch (CoreException e) {
38             TeamUIPlugin.log(e);
39         }
40         IStreamMerger merger = CompareUI.createStreamMerger(DelegatingStorageMerger.getExtension(target.getName()));
41         if (merger != null)
42             return new StorageStreamMerger(merger);
43         return null;
44     }
45
46 }
47
Popular Tags