KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ui > synchronize > SynchronizePageConfiguration


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.synchronize;
12
13 import java.util.HashMap JavaDoc;
14 import java.util.Map JavaDoc;
15
16 import org.eclipse.core.runtime.*;
17 import org.eclipse.jface.action.IMenuManager;
18 import org.eclipse.jface.operation.IRunnableContext;
19 import org.eclipse.jface.util.IPropertyChangeListener;
20 import org.eclipse.jface.util.PropertyChangeEvent;
21 import org.eclipse.jface.viewers.ILabelDecorator;
22 import org.eclipse.team.core.diff.IDiff;
23 import org.eclipse.team.core.diff.IThreeWayDiff;
24 import org.eclipse.team.core.mapping.IResourceDiff;
25 import org.eclipse.team.core.synchronize.SyncInfoSet;
26 import org.eclipse.team.internal.ui.TeamUIPlugin;
27 import org.eclipse.team.internal.ui.mapping.CommonViewerAdvisor;
28 import org.eclipse.team.ui.synchronize.*;
29 import org.eclipse.ui.IActionBars;
30 import org.eclipse.ui.actions.ActionContext;
31
32 /**
33  * Concrete implementation of the ISynchronizePageConfiguration. It
34  * extends SynchronizePageActionGroup in order to delegate action group
35  * operations.
36  *
37  * @since 3.0
38  */

39 public class SynchronizePageConfiguration extends SynchronizePageActionGroup implements ISynchronizePageConfiguration {
40
41     /**
42      * Property constant for the page's viewer input which is
43      * an instance of <code>ISynchronizeModelElement</code>.
44      * This property can be queried by clients but should not be
45      * set.
46      */

47     public static final String JavaDoc P_MODEL = TeamUIPlugin.ID + ".P_MODEL"; //$NON-NLS-1$
48

49     /**
50      * Property constant for the page's viewer advisor which is
51      * an instance of <code>StructuredViewerAdvisor</code>.
52      * The page's viewer can be obtained from the advisor.
53      * This property can be queried by clients but should not be
54      * set.
55      */

56     public static final String JavaDoc P_ADVISOR = TeamUIPlugin.ID + ".P_ADVISOR"; //$NON-NLS-1$
57

58     /**
59      * Property constant for the page's navigator
60      * an instance of <code>INavigable</code>.
61      * This property can be queried by clients and can be set. By default
62      * the advisors navigator will be used.
63      */

64     public static final String JavaDoc P_NAVIGATOR = TeamUIPlugin.ID + ".P_NAVIGATOR"; //$NON-NLS-1$
65

66     /**
67      * Property constant for the compare editor inputs navigator
68      * an instance of <code>INavigable</code>.
69      * This property can be queried by clients and can be set.
70      */

71     public static final String JavaDoc P_INPUT_NAVIGATOR = TeamUIPlugin.ID + ".P_INPUT_NAVIGATOR"; //$NON-NLS-1$
72

73     /**
74      * Property constant for the page's model manager which is
75      * an instance of <code>SynchronizeModelManager</code>.
76      * This property can be queried by clients but should not be
77      * set.
78      */

79     public static final String JavaDoc P_MODEL_MANAGER = TeamUIPlugin.ID + ".P_MODEL_MANAGER"; //$NON-NLS-1$
80

81     /**
82      * Property that gives access to a set the
83      * contains all out-of-sync resources for the participant
84      * in the selected working set.
85      */

86     public static final String JavaDoc P_WORKING_SET_SYNC_INFO_SET = TeamUIPlugin.ID + ".P_WORKING_SET_SYNC_INFO_SET"; //$NON-NLS-1$
87

88     /**
89      * Property that gives access to a set the
90      * contains all out-of-sync resources for the participant
91      * before any filtering (working set or modes) is applied.
92      */

93     public static final String JavaDoc P_PARTICIPANT_SYNC_INFO_SET = TeamUIPlugin.ID + ".P_PARTICIPANT_SYNC_INFO_SET"; //$NON-NLS-1$
94

95     /**
96      * The hidden configuration property that opens the current selection in the
97      * page. The registered <code>IAction</code> is invoked on a single or
98      * double click depending on the open strategy chosen by the user.
99      */

100     public static final String JavaDoc P_OPEN_ACTION = TeamUIPlugin.ID + ".P_OPEN_ACTION"; //$NON-NLS-1$
101

102     /**
103      * Property constant for the style of the view to be used by the page.
104      */

105     public static final String JavaDoc P_VIEWER_STYLE = TeamUIPlugin.ID + ".P_VIEWER_STYLE"; //$NON-NLS-1$
106

107     public static final int CHECKBOX = TreeViewerAdvisor.CHECKBOX;
108     
109     // State flags
110
private static final int UNINITIALIZED = 0;
111     private static final int INITIALIZED = 1;
112     private static final int DISPOSED = 2;
113     
114     private ISynchronizeParticipant participant;
115     private ISynchronizePageSite site;
116     private ListenerList propertyChangeListeners = new ListenerList(ListenerList.IDENTITY);
117     private ListenerList actionContributions = new ListenerList(ListenerList.IDENTITY);
118     private Map JavaDoc properties = new HashMap JavaDoc();
119     private int actionState = UNINITIALIZED;
120     private ISynchronizePage page;
121     private IRunnableContext context;
122     
123     /**
124      * Create a configuration for creating a page from the given participant.
125      * @param participant the participant whose page is being configured
126      */

127     public SynchronizePageConfiguration(ISynchronizeParticipant participant) {
128         this.participant = participant;
129         setProperty(P_CONTEXT_MENU, DEFAULT_CONTEXT_MENU);
130         setProperty(P_TOOLBAR_MENU, DEFAULT_TOOLBAR_MENU);
131         setProperty(P_VIEW_MENU, DEFAULT_VIEW_MENU);
132         setProperty(P_COMPARISON_TYPE, THREE_WAY);
133     }
134     
135     /* (non-Javadoc)
136      * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#getParticipant()
137      */

138     public ISynchronizeParticipant getParticipant() {
139         return participant;
140     }
141     
142     /* (non-Javadoc)
143      * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#getSite()
144      */

145     public ISynchronizePageSite getSite() {
146         return site;
147     }
148     
149     /**
150      * Set the site that is associated with the page that was
151      * configured using this configuration.
152      * @param site a synchronize page site
153      */

154     public void setSite(ISynchronizePageSite site) {
155         this.site = site;
156     }
157     
158     /* (non-Javadoc)
159      * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
160      */

161     public void addPropertyChangeListener(IPropertyChangeListener listener) {
162         synchronized(propertyChangeListeners) {
163             propertyChangeListeners.add(listener);
164         }
165     }
166     
167     /* (non-Javadoc)
168      * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#removePropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
169      */

170     public void removePropertyChangeListener(IPropertyChangeListener listener) {
171         synchronized(propertyChangeListeners) {
172             propertyChangeListeners.remove(listener);
173         }
174     }
175     
176     /* (non-Javadoc)
177      * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#setProperty(java.lang.String, java.lang.Object)
178      */

179     public void setProperty(String JavaDoc key, Object JavaDoc newValue) {
180         Object JavaDoc oldValue = properties.get(key);
181         if (page == null || page.aboutToChangeProperty(this, key, newValue)) {
182             properties.put(key, newValue);
183             if (oldValue == null || !oldValue.equals(newValue))
184                 firePropertyChange(key, oldValue, newValue);
185         }
186     }
187
188     /* (non-Javadoc)
189      * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#getProperty(java.lang.String)
190      */

191     public Object JavaDoc getProperty(String JavaDoc key) {
192         return properties.get(key);
193     }
194     
195     /* (non-Javadoc)
196      * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#addActionContribution(org.eclipse.team.ui.synchronize.IActionContribution)
197      */

198     public void addActionContribution(SynchronizePageActionGroup contribution) {
199         int currentActionState;
200         synchronized(actionContributions) {
201             // Determine the action state while locked so we handle the addition properly below
202
currentActionState = actionState;
203             if (currentActionState != DISPOSED)
204                 actionContributions.add(contribution);
205         }
206         if (currentActionState == INITIALIZED) {
207             // This is tricky because we are doing the initialize while not locked.
208
// It is possible that another thread is concurrently disposing the contributions
209
// but we can't lock while calling client code. We'll change for DISPOSE after
210
// we initialize and, if we are disposed, we dispose this one, just in case.
211
contribution.initialize(this);
212             if (actionState == DISPOSED) {
213                 contribution .dispose();
214             }
215         } else if (currentActionState == DISPOSED) {
216             contribution.dispose();
217         }
218     }
219     
220     /* (non-Javadoc)
221      * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#removeActionContribution(org.eclipse.team.ui.synchronize.IActionContribution)
222      */

223     public void removeActionContribution(SynchronizePageActionGroup contribution) {
224         synchronized(actionContributions) {
225             actionContributions.remove(contribution);
226         }
227     }
228     
229     private void firePropertyChange(String JavaDoc key, Object JavaDoc oldValue, Object JavaDoc newValue) {
230         Object JavaDoc[] listeners;
231         synchronized(propertyChangeListeners) {
232             listeners = propertyChangeListeners.getListeners();
233         }
234         final PropertyChangeEvent event = new PropertyChangeEvent(this, key, oldValue, newValue);
235         for (int i = 0; i < listeners.length; i++) {
236             final IPropertyChangeListener listener = (IPropertyChangeListener)listeners[i];
237             SafeRunner.run(new ISafeRunnable() {
238                 public void handleException(Throwable JavaDoc exception) {
239                     // Error is logged by platform
240
}
241                 public void run() throws Exception JavaDoc {
242                     listener.propertyChange(event);
243                 }
244             });
245         }
246     }
247     
248     /* (non-Javadoc)
249      * @see org.eclipse.team.ui.synchronize.IActionContribution#initialize(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration)
250      */

251     public void initialize(final ISynchronizePageConfiguration configuration) {
252         super.initialize(configuration);
253         // need to synchronize here to ensure that actions that are added concurrently also get initialized
254
final Object JavaDoc[] listeners;
255         synchronized(actionContributions) {
256             if (actionState != UNINITIALIZED) {
257                 // Initialization has already taken place so just return.
258
return;
259             }
260             actionState = INITIALIZED;
261             listeners = actionContributions.getListeners();
262         }
263         for (int i= 0; i < listeners.length; i++) {
264             final SynchronizePageActionGroup contribution = (SynchronizePageActionGroup)listeners[i];
265             SafeRunner.run(new ISafeRunnable() {
266                 public void handleException(Throwable JavaDoc exception) {
267                     // Logged by Platform
268
}
269                 public void run() throws Exception JavaDoc {
270                     contribution.initialize(configuration);
271                 }
272             });
273         }
274     }
275     
276     /* (non-Javadoc)
277      * @see org.eclipse.ui.actions.ActionGroup#setContext(org.eclipse.ui.actions.ActionContext)
278      */

279     public void setContext(final ActionContext context) {
280         super.setContext(context);
281         final Object JavaDoc[] listeners;
282         synchronized(actionContributions) {
283             listeners = actionContributions.getListeners();
284         }
285         for (int i= 0; i < listeners.length; i++) {
286             final SynchronizePageActionGroup contribution = (SynchronizePageActionGroup)listeners[i];
287             SafeRunner.run(new ISafeRunnable() {
288                 public void handleException(Throwable JavaDoc exception) {
289                     // Logged by Platform
290
}
291                 public void run() throws Exception JavaDoc {
292                     contribution.setContext(context);
293                 }
294             });
295         }
296     }
297     
298     /**
299      * Callback invoked from the advisor each time the context menu is
300      * about to be shown.
301      * @param manager the context menu manager
302      */

303     public void fillContextMenu(final IMenuManager manager) {
304         final Object JavaDoc[] listeners;
305         synchronized(actionContributions) {
306             listeners = actionContributions.getListeners();
307         }
308         for (int i= 0; i < listeners.length; i++) {
309             final SynchronizePageActionGroup contribution = (SynchronizePageActionGroup)listeners[i];
310             SafeRunner.run(new ISafeRunnable() {
311                 public void handleException(Throwable JavaDoc exception) {
312                     // Logged by Platform
313
}
314                 public void run() throws Exception JavaDoc {
315                     contribution.fillContextMenu(manager);
316                 }
317             });
318         }
319     }
320
321     /**
322      * Callback invoked from the page to fill the action bars.
323      * @param actionBars the action bars of the view
324      */

325     public void fillActionBars(final IActionBars actionBars) {
326         if (actionState == UNINITIALIZED) {
327             initialize(this);
328         }
329         final Object JavaDoc[] listeners;
330         synchronized(actionContributions) {
331             listeners = actionContributions.getListeners();
332         }
333         for (int i= 0; i < listeners.length; i++) {
334             final SynchronizePageActionGroup contribution = (SynchronizePageActionGroup)listeners[i];
335             SafeRunner.run(new ISafeRunnable() {
336                 public void handleException(Throwable JavaDoc exception) {
337                     // Logged by Platform
338
}
339                 public void run() throws Exception JavaDoc {
340                     contribution.fillActionBars(actionBars);
341                 }
342             });
343         }
344     }
345     
346     /* (non-Javadoc)
347      * @see org.eclipse.ui.actions.ActionGroup#updateActionBars()
348      */

349     public void updateActionBars() {
350         final Object JavaDoc[] listeners;
351         synchronized(actionContributions) {
352             listeners = actionContributions.getListeners();
353         }
354         for (int i= 0; i < listeners.length; i++) {
355             final SynchronizePageActionGroup contribution = (SynchronizePageActionGroup)listeners[i];
356             SafeRunner.run(new ISafeRunnable() {
357                 public void handleException(Throwable JavaDoc exception) {
358                     // Logged by Platform
359
}
360                 public void run() throws Exception JavaDoc {
361                     contribution.updateActionBars();
362                 }
363             });
364         }
365     }
366     
367     /* (non-Javadoc)
368      * @see org.eclipse.team.ui.synchronize.SynchronizePageActionGroup#modelChanged(org.eclipse.team.ui.synchronize.ISynchronizeModelElement)
369      */

370     public void modelChanged(final ISynchronizeModelElement root) {
371         final Object JavaDoc[] listeners;
372         synchronized(actionContributions) {
373             listeners = actionContributions.getListeners();
374         }
375         for (int i= 0; i < listeners.length; i++) {
376             final SynchronizePageActionGroup contribution = (SynchronizePageActionGroup)listeners[i];
377             SafeRunner.run(new ISafeRunnable() {
378                 public void handleException(Throwable JavaDoc exception) {
379                     // Logged by Platform
380
}
381                 public void run() throws Exception JavaDoc {
382                     contribution.modelChanged(root);
383                 }
384             });
385         }
386     }
387     
388     /* (non-Javadoc)
389      * @see org.eclipse.team.ui.synchronize.IActionContribution#dispose()
390      */

391     public void dispose() {
392         super.dispose();
393         final Object JavaDoc[] listeners;
394         synchronized(actionContributions) {
395             listeners = actionContributions.getListeners();
396             actionState = DISPOSED;
397         }
398         for (int i= 0; i < listeners.length; i++) {
399             final SynchronizePageActionGroup contribution = (SynchronizePageActionGroup)listeners[i];
400             SafeRunner.run(new ISafeRunnable() {
401                 public void handleException(Throwable JavaDoc exception) {
402                     // Logged by Platform
403
}
404                 public void run() throws Exception JavaDoc {
405                     contribution.dispose();
406                 }
407             });
408         }
409     }
410     
411     /* (non-Javadoc)
412      * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#setMenu(java.lang.String, java.lang.String[])
413      */

414     public void setMenuGroups(String JavaDoc menuPropertyId, String JavaDoc[] groups) {
415         setProperty(menuPropertyId, groups);
416     }
417     
418     /* (non-Javadoc)
419      * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#appendMenu(java.lang.String, java.lang.String)
420      */

421     public void addMenuGroup(String JavaDoc menuPropertyId, String JavaDoc groupId) {
422         String JavaDoc[] menuGroups = (String JavaDoc[])getProperty(menuPropertyId);
423         if (menuGroups == null) {
424             menuGroups = getDefault(menuPropertyId);
425         }
426         String JavaDoc[] newGroups = new String JavaDoc[menuGroups.length + 1];
427         System.arraycopy(menuGroups, 0, newGroups, 0, menuGroups.length);
428         newGroups[menuGroups.length] = groupId;
429         setProperty(menuPropertyId, newGroups);
430     }
431
432     /* (non-Javadoc)
433      * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#hasMenuGroup(java.lang.String, java.lang.String)
434      */

435     public boolean hasMenuGroup(String JavaDoc menuPropertyId, String JavaDoc groupId) {
436         String JavaDoc[] groups = (String JavaDoc[])getProperty(menuPropertyId);
437         if (groups == null) {
438             groups = getDefault(menuPropertyId);
439         }
440         for (int i = 0; i < groups.length; i++) {
441             String JavaDoc string = groups[i];
442             if (string.equals(groupId)) return true;
443         }
444         return false;
445     }
446     
447     protected String JavaDoc[] getDefault(String JavaDoc menuPropertyId) {
448         if (menuPropertyId.equals(P_CONTEXT_MENU)) {
449             return DEFAULT_CONTEXT_MENU;
450         } else if (menuPropertyId.equals(P_VIEW_MENU)) {
451             return DEFAULT_VIEW_MENU;
452         } else if (menuPropertyId.equals(P_TOOLBAR_MENU)) {
453             return DEFAULT_TOOLBAR_MENU;
454         } else {
455             return new String JavaDoc[0];
456         }
457     }
458     
459     /* (non-Javadoc)
460      * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#addLabelDecorator(org.eclipse.jface.viewers.ILabelDecorator)
461      */

462     public void addLabelDecorator(ILabelDecorator decorator) {
463         ILabelDecorator[] decorators = (ILabelDecorator[])getProperty(P_LABEL_DECORATORS);
464         if (decorators == null) {
465             decorators = new ILabelDecorator[0];
466         }
467         // Ensure we don't have it registered already
468
for (int i = 0; i < decorators.length; i++) {
469             ILabelDecorator d = decorators[i];
470             if (d == decorator) {
471                 return;
472             }
473         }
474         ILabelDecorator[] newDecorators = new ILabelDecorator[decorators.length + 1];
475         System.arraycopy(decorators, 0, newDecorators, 0, decorators.length);
476         newDecorators[decorators.length] = decorator;
477         setProperty(P_LABEL_DECORATORS, newDecorators);
478     }
479
480     /**
481      * @param group
482      * @return the group id
483      */

484     public String JavaDoc getGroupId(String JavaDoc group) {
485         String JavaDoc id = getParticipant().getId();
486         if (getParticipant().getSecondaryId() != null) {
487             id += "."; //$NON-NLS-1$
488
id += getParticipant().getSecondaryId();
489         }
490         return id + "." + group; //$NON-NLS-1$
491
}
492     
493     /* (non-Javadoc)
494      * @see org.eclipse.team.ui.synchronize.subscribers.ISubscriberPageConfiguration#getMode()
495      */

496     public int getMode() {
497         Object JavaDoc o = getProperty(P_MODE);
498         if (o instanceof Integer JavaDoc) {
499             return ((Integer JavaDoc)o).intValue();
500         }
501         return 0;
502     }
503
504     /* (non-Javadoc)
505      * @see org.eclipse.team.ui.synchronize.subscribers.ISubscriberPageConfiguration#setMode(int)
506      */

507     public void setMode(int mode) {
508         if (isModeSupported(mode))
509             setProperty(P_MODE, new Integer JavaDoc(mode));
510     }
511
512     public boolean isModeSupported(int mode) {
513         return (getSupportedModes() & mode) > 0;
514     }
515
516     public int getSupportedModes() {
517         Object JavaDoc o = getProperty(P_SUPPORTED_MODES);
518         if (o instanceof Integer JavaDoc) {
519             return ((Integer JavaDoc)o).intValue();
520         }
521         return 0;
522     }
523     
524     /* (non-Javadoc)
525      * @see org.eclipse.team.ui.synchronize.subscribers.ISubscriberPageConfiguration#setSupportedModes(int)
526      */

527     public void setSupportedModes(int modes) {
528         setProperty(P_SUPPORTED_MODES, new Integer JavaDoc(modes));
529     }
530     
531     /**
532      * @return Returns the page.
533      */

534     public ISynchronizePage getPage() {
535         return page;
536     }
537     /**
538      * @param page The page to set.
539      */

540     public void setPage(ISynchronizePage page) {
541         this.page = page;
542     }
543
544     /**
545      * @return the viewer style
546      */

547     public int getViewerStyle() {
548         Object JavaDoc o = getProperty(P_VIEWER_STYLE);
549         if (o instanceof Integer JavaDoc) {
550             return ((Integer JavaDoc)o).intValue();
551         }
552         return 0;
553     }
554
555     /**
556      * @param style
557      */

558     public void setViewerStyle(int style) {
559         setProperty(P_VIEWER_STYLE, new Integer JavaDoc(style));
560     }
561
562     /* (non-Javadoc)
563      * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#getSyncInfoSet()
564      */

565     public SyncInfoSet getSyncInfoSet() {
566         Object JavaDoc o = getProperty(P_SYNC_INFO_SET);
567         if (o instanceof SyncInfoSet) {
568             return (SyncInfoSet)o;
569         }
570         return null;
571     }
572
573     /* (non-Javadoc)
574      * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#getComparisonType()
575      */

576     public String JavaDoc getComparisonType() {
577         return (String JavaDoc)getProperty(P_COMPARISON_TYPE);
578     }
579
580     /* (non-Javadoc)
581      * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#setComparisonType(java.lang.String)
582      */

583     public void setComparisonType(String JavaDoc type) {
584         setProperty(P_COMPARISON_TYPE,type);
585     }
586
587     /* (non-Javadoc)
588      * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#setRunnableContext(org.eclipse.jface.operation.IRunnableContext)
589      */

590     public void setRunnableContext(IRunnableContext context) {
591         this.context = context;
592     }
593
594     /* (non-Javadoc)
595      * @see org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration#getRunnableContext()
596      */

597     public IRunnableContext getRunnableContext() {
598         return context;
599     }
600
601     public String JavaDoc getViewerId() {
602         String JavaDoc viewerId = (String JavaDoc)getProperty(P_VIEWER_ID);
603         if (viewerId != null)
604             return viewerId;
605         return CommonViewerAdvisor.TEAM_NAVIGATOR_CONTENT;
606     }
607     
608     /**
609      * Return whether the given node is visible in the page based
610      * on the mode in the configuration.
611      * @param node a diff node
612      * @return whether the given node is visible in the page
613      */

614     public boolean isVisible(IDiff node) {
615         if (getComparisonType() == ISynchronizePageConfiguration.THREE_WAY
616                 && node instanceof IThreeWayDiff) {
617             IThreeWayDiff twd = (IThreeWayDiff) node;
618             return includeDirection(twd.getDirection());
619         }
620         return getComparisonType() == ISynchronizePageConfiguration.TWO_WAY && node instanceof IResourceDiff;
621     }
622     
623     /**
624      * Return whether elements with the given direction should be included in
625      * the contents.
626      *
627      * @param direction
628      * the synchronization direction
629      * @return whether elements with the given synchronization kind should be
630      * included in the contents
631      */

632     public boolean includeDirection(int direction) {
633         int mode = getMode();
634         switch (mode) {
635         case ISynchronizePageConfiguration.BOTH_MODE:
636             return true;
637         case ISynchronizePageConfiguration.CONFLICTING_MODE:
638             return direction == IThreeWayDiff.CONFLICTING;
639         case ISynchronizePageConfiguration.INCOMING_MODE:
640             return direction == IThreeWayDiff.CONFLICTING || direction == IThreeWayDiff.INCOMING;
641         case ISynchronizePageConfiguration.OUTGOING_MODE:
642             return direction == IThreeWayDiff.CONFLICTING || direction == IThreeWayDiff.OUTGOING;
643         default:
644             break;
645         }
646         return true;
647     }
648     
649     public ILabelDecorator getLabelDecorator() {
650         ILabelDecorator[] decorators = (ILabelDecorator[])getProperty(ISynchronizePageConfiguration.P_LABEL_DECORATORS);
651         if (decorators == null) {
652             return null;
653         }
654         return new MultiLabelDecorator(decorators);
655     }
656 }
657
Popular Tags