blob: 7baef2ac8078f11279d5ffb7094292721231b00b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.team.internal.ui.synchronize;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.internal.ui.widgets.FormSection;
import org.eclipse.team.ui.controls.IControlFactory;
import org.eclipse.team.ui.synchronize.*;
public class ChangesSection extends FormSection {
private TeamSubscriberParticipant participant;
private Composite parent;
private ParticipantComposite participantComposite;
private ISynchronizeView view;
private Viewer changesViewer;
private ISyncSetChangedListener changedListener = new ISyncSetChangedListener() {
public void syncSetChanged(ISyncInfoSetChangeEvent event) {
calculateDescription();
}
};
private TeamSubscriberParticipantPage page;
public ChangesSection(Composite parent, TeamSubscriberParticipantPage page) {
this.page = page;
this.participant = page.getParticipant();
this.parent = parent;
this.view = page.getSynchronizeView();
setCollapsable(true);
setCollapsed(false);
setDescription("");
calculateDescription();
}
/*
* (non-Javadoc)
* @see org.eclipse.team.internal.ui.widgets.FormSection#getHeaderText()
*/
public String getHeaderText() {
return "Changes";
}
/*
* (non-Javadoc)
* @see org.eclipse.team.internal.ui.widgets.FormSection#createClient(org.eclipse.swt.widgets.Composite,
* org.eclipse.team.internal.ui.widgets.FormWidgetFactory)
*/
public Composite createClient(Composite parent, IControlFactory factory) {
Composite clientComposite = factory.createComposite(parent);
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
clientComposite.setLayout(layout);
changesViewer = page.createChangesViewer(clientComposite);
participant.getInput().registerListeners(changedListener);
return clientComposite;
}
protected void reflow() {
super.reflow();
if(parent != null && !parent.isDisposed()) {
parent.setRedraw(false);
parent.getParent().setRedraw(false);
parent.layout(true);
parent.getParent().layout(true);
parent.setRedraw(true);
parent.getParent().setRedraw(true);
}
}
private void calculateDescription() {
if(participant.getInput().getFilteredSyncSet().size() == 0) {
TeamUIPlugin.getStandardDisplay().asyncExec(new Runnable() {
public void run() {
setDescription(getEmptyChangesText());
}
});
} else {
String description = getDescription();
if(description != null) {
TeamUIPlugin.getStandardDisplay().asyncExec(new Runnable() {
public void run() {
setDescription("");
}
});
}
}
}
private String getEmptyChangesText() {
ITeamSubscriberSyncInfoSets input = participant.getInput();
int changesInWorkspace = input.getSubscriberSyncSet().size();
int changesInWorkingSet = input.getWorkingSetSyncSet().size();
int changesInFilter = input.getFilteredSyncSet().size();
if(changesInFilter == 0 && changesInWorkingSet != 0) {
return "The current mode '" + Utils.modeToString(participant.getMode()) + "' doesn't contain any changes. Switch to another mode.";
} else if(changesInFilter == 0 && changesInWorkingSet == 0 && changesInWorkspace != 0) {
return "The current working set '" + Utils.workingSetToString(participant.getWorkingSet(), 50) + "' is hiding changes in your workspace. Remove working set.";
} else {
return "No changes in workspace";
}
}
public Viewer getChangesViewer() {
return changesViewer;
}
/* (non-Javadoc)
* @see org.eclipse.team.internal.ui.widgets.FormSection#dispose()
*/
public void dispose() {
super.dispose();
participant.getInput().deregisterListeners(changedListener);
}
}
|