1 11 package org.eclipse.team.internal.ui.synchronize; 12 13 import org.eclipse.jface.viewers.Viewer; 14 import org.eclipse.swt.SWT; 15 import org.eclipse.swt.graphics.Color; 16 import org.eclipse.swt.layout.GridData; 17 import org.eclipse.swt.layout.GridLayout; 18 import org.eclipse.swt.widgets.Composite; 19 import org.eclipse.swt.widgets.Control; 20 import org.eclipse.team.internal.ui.TeamUIPlugin; 21 import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; 22 import org.eclipse.ui.forms.HyperlinkGroup; 23 import org.eclipse.ui.forms.widgets.FormToolkit; 24 import org.eclipse.ui.part.PageBook; 25 26 32 public class ChangesSection extends Composite { 33 34 private AbstractSynchronizePage page; 35 private ISynchronizePageConfiguration configuration; 36 private FormToolkit forms; 37 38 43 private PageBook changesSectionContainer; 44 45 49 private Viewer changesViewer; 50 51 57 public ChangesSection(Composite parent, AbstractSynchronizePage page, ISynchronizePageConfiguration configuration) { 58 super(parent, SWT.NONE); 59 this.page = page; 60 this.configuration = configuration; 61 62 GridLayout layout = new GridLayout(); 63 layout.marginHeight = 0; 64 layout.marginWidth = 0; 65 setLayout(layout); 66 GridData data = new GridData(GridData.FILL_BOTH); 67 data.grabExcessVerticalSpace = true; 68 setLayoutData(data); 69 70 forms = new FormToolkit(parent.getDisplay()); 71 forms.setBackground(getBackgroundColor()); 72 HyperlinkGroup group = forms.getHyperlinkGroup(); 73 group.setBackground(getBackgroundColor()); 74 75 changesSectionContainer = new PageBook(this, SWT.NONE); 76 data = new GridData(GridData.FILL_BOTH); 77 data.grabExcessHorizontalSpace = true; 78 data.grabExcessVerticalSpace = true; 79 changesSectionContainer.setLayoutData(data); 80 } 81 82 protected Color getBackgroundColor() { 83 return getShell().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND); 84 } 85 86 public PageBook getContainer() { 87 return changesSectionContainer; 88 } 89 90 protected ISynchronizePageConfiguration getConfiguration() { 91 return configuration; 92 } 93 94 protected FormToolkit getForms() { 95 return forms; 96 } 97 98 protected AbstractSynchronizePage getPage() { 99 return page; 100 } 101 102 105 public void dispose() { 106 super.dispose(); 107 forms.dispose(); 108 } 109 110 public void setViewer(Viewer viewer) { 111 this.changesViewer = viewer; 112 initializeChangesViewer(); 113 } 114 115 protected void initializeChangesViewer() { 116 TeamUIPlugin.getStandardDisplay().asyncExec(new Runnable () { 117 public void run() { 118 Control control = ChangesSection.this.getChangesViewer().getControl(); 119 if (!getContainer().isDisposed() && !control.isDisposed()) { 120 getContainer().showPage(control); 121 } 122 } 123 }); 124 } 125 126 public Viewer getChangesViewer() { 127 return changesViewer; 128 } 129 130 protected boolean isThreeWay() { 131 return ISynchronizePageConfiguration.THREE_WAY.equals(getConfiguration().getComparisonType()); 132 } 133 } 134 | Popular Tags |