diff options
Diffstat (limited to 'bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/ResourceMappingSelectionArea.java')
-rw-r--r-- | bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/ResourceMappingSelectionArea.java | 238 |
1 files changed, 119 insertions, 119 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/ResourceMappingSelectionArea.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/ResourceMappingSelectionArea.java index 9085ea2c2..7b0f31291 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/ResourceMappingSelectionArea.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/ResourceMappingSelectionArea.java @@ -37,64 +37,64 @@ import org.eclipse.ui.model.BaseWorkbenchContentProvider; public class ResourceMappingSelectionArea extends DialogArea { /** - * Property constant used to indicate that the selected mapping has changed. - * The object associated with the property is a <code>ResourceMapping</code>. - */ - public static final String SELECTED_MAPPING = "SelectedMapping"; //$NON-NLS-1$ - - /** - * Property constant used to indicate that the checked mappings have changed. - * The object associated with the property is a <code>ResourceMapping[]</code> - * (i.e. an array of mappings). - */ - public static final String CHECKED_MAPPINGS = "CheckedMappings"; //$NON-NLS-1$ - - private ResourceMapping[] mappings; - private TableViewer viewer; - private ResourceMapping[] checkedMappings; - private ResourceMapping selectedMapping; - private String description; + * Property constant used to indicate that the selected mapping has changed. + * The object associated with the property is a <code>ResourceMapping</code>. + */ + public static final String SELECTED_MAPPING = "SelectedMapping"; //$NON-NLS-1$ + + /** + * Property constant used to indicate that the checked mappings have changed. + * The object associated with the property is a <code>ResourceMapping[]</code> + * (i.e. an array of mappings). + */ + public static final String CHECKED_MAPPINGS = "CheckedMappings"; //$NON-NLS-1$ + + private ResourceMapping[] mappings; + private TableViewer viewer; + private ResourceMapping[] checkedMappings; + private ResourceMapping selectedMapping; + private String description; private boolean supportsChecking; private boolean supportsSelection; - public ResourceMappingSelectionArea(ResourceMapping[] mappings, boolean supportSelection, boolean supportChecking) { - this.mappings = mappings; - this.supportsChecking = supportChecking; - this.supportsSelection = supportSelection; - } + public ResourceMappingSelectionArea(ResourceMapping[] mappings, boolean supportSelection, boolean supportChecking) { + this.mappings = mappings; + this.supportsChecking = supportChecking; + this.supportsSelection = supportSelection; + } - @Override + @Override public void createArea(Composite parent) { - Composite composite = createComposite(parent, 1, true); - GridLayout layout = new GridLayout(1, false); - layout.marginHeight = 0; - layout.marginWidth = 0; - layout.verticalSpacing = 0; - layout.horizontalSpacing = 0; - composite.setLayout(layout); - - if (description != null) - createWrappingLabel(composite, description, 1); - - createViewer(composite); - GridData data = new GridData(GridData.FILL_BOTH); - data.heightHint = 100; - data.widthHint = 300; - viewer.getControl().setLayoutData(data); - viewer.setContentProvider(new BaseWorkbenchContentProvider()); - viewer.setLabelProvider(new ResourceMappingLabelProvider()); - viewer.setInput(new AdaptableList(mappings)); - if (isSupportsSelection()) { - viewer.addSelectionChangedListener(event -> { - ResourceMapping oldSelection = selectedMapping; - selectedMapping = internalGetSelectedMapping(); - if (oldSelection != selectedMapping) - firePropertyChangeChange(SELECTED_MAPPING, oldSelection, selectedMapping); + Composite composite = createComposite(parent, 1, true); + GridLayout layout = new GridLayout(1, false); + layout.marginHeight = 0; + layout.marginWidth = 0; + layout.verticalSpacing = 0; + layout.horizontalSpacing = 0; + composite.setLayout(layout); + + if (description != null) + createWrappingLabel(composite, description, 1); + + createViewer(composite); + GridData data = new GridData(GridData.FILL_BOTH); + data.heightHint = 100; + data.widthHint = 300; + viewer.getControl().setLayoutData(data); + viewer.setContentProvider(new BaseWorkbenchContentProvider()); + viewer.setLabelProvider(new ResourceMappingLabelProvider()); + viewer.setInput(new AdaptableList(mappings)); + if (isSupportsSelection()) { + viewer.addSelectionChangedListener(event -> { + ResourceMapping oldSelection = selectedMapping; + selectedMapping = internalGetSelectedMapping(); + if (oldSelection != selectedMapping) + firePropertyChangeChange(SELECTED_MAPPING, oldSelection, selectedMapping); }); - } - if (isSupportsChecking()) - initializeCheckboxViewer(composite); - } + } + if (isSupportsChecking()) + initializeCheckboxViewer(composite); + } private void initializeCheckboxViewer(Composite composite) { final CheckboxTableViewer checkboxViewer = getCheckboxTableViewer(); @@ -105,29 +105,29 @@ public class ResourceMappingSelectionArea extends DialogArea { firePropertyChangeChange(CHECKED_MAPPINGS, oldMappings, checkedMappings); }); checkboxViewer.setCheckedElements(mappings); - checkedMappings = mappings; + checkedMappings = mappings; - Composite buttons = createEmbeddedButtonComposite(composite); + Composite buttons = createEmbeddedButtonComposite(composite); - Button selectAll = new Button(buttons, SWT.PUSH); - selectAll.setText(TeamUIMessages.ResourceMappingSelectionArea_0); - selectAll.setLayoutData(new GridData(GridData.FILL_BOTH)); - selectAll.addSelectionListener(new SelectionAdapter() { - @Override + Button selectAll = new Button(buttons, SWT.PUSH); + selectAll.setText(TeamUIMessages.ResourceMappingSelectionArea_0); + selectAll.setLayoutData(new GridData(GridData.FILL_BOTH)); + selectAll.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { - checkboxViewer.setAllChecked(true); - } - }); - - Button deselectAll = new Button(buttons, SWT.PUSH); - deselectAll.setText(TeamUIMessages.ResourceMappingSelectionArea_1); - deselectAll.setLayoutData(new GridData(GridData.FILL_BOTH)); - deselectAll.addSelectionListener(new SelectionAdapter() { - @Override + checkboxViewer.setAllChecked(true); + } + }); + + Button deselectAll = new Button(buttons, SWT.PUSH); + deselectAll.setText(TeamUIMessages.ResourceMappingSelectionArea_1); + deselectAll.setLayoutData(new GridData(GridData.FILL_BOTH)); + deselectAll.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { - checkboxViewer.setAllChecked(false); - } - }); + checkboxViewer.setAllChecked(false); + } + }); } private void createViewer(Composite composite) { @@ -144,54 +144,54 @@ public class ResourceMappingSelectionArea extends DialogArea { return style; } - /* private */ ResourceMapping[] internalGetCheckedMappings() { - Object[] checked = getCheckboxTableViewer().getCheckedElements(); - ResourceMapping[] mappings = new ResourceMapping[checked.length]; - for (int i = 0; i < checked.length; i++) { - Object object = checked[i]; - mappings[i] = (ResourceMapping)object; - } - return mappings; - } - - private Composite createEmbeddedButtonComposite(Composite composite) { - GridData data; - Composite buttons = new Composite(composite, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; // this is incremented by createButton - layout.makeColumnsEqualWidth = true; - layout.marginWidth = 0; - buttons.setLayout(layout); - data = new GridData(GridData.HORIZONTAL_ALIGN_END - | GridData.VERTICAL_ALIGN_CENTER); - buttons.setLayoutData(data); - return buttons; - } - - /* private */ ResourceMapping internalGetSelectedMapping() { - ISelection selection = viewer.getSelection(); - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection) selection; - Object firstElement = ss.getFirstElement(); - if (firstElement instanceof ResourceMapping) - return (ResourceMapping)firstElement; - } - return null; - } - - public void setDescription(String description) { - this.description = description; - } - public ResourceMapping[] getCheckedMappings() { - return checkedMappings; - } - public ResourceMapping getSelectedMapping() { - return selectedMapping; - } - - private CheckboxTableViewer getCheckboxTableViewer() { - return (CheckboxTableViewer)viewer; - } + /* private */ ResourceMapping[] internalGetCheckedMappings() { + Object[] checked = getCheckboxTableViewer().getCheckedElements(); + ResourceMapping[] mappings = new ResourceMapping[checked.length]; + for (int i = 0; i < checked.length; i++) { + Object object = checked[i]; + mappings[i] = (ResourceMapping)object; + } + return mappings; + } + + private Composite createEmbeddedButtonComposite(Composite composite) { + GridData data; + Composite buttons = new Composite(composite, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; // this is incremented by createButton + layout.makeColumnsEqualWidth = true; + layout.marginWidth = 0; + buttons.setLayout(layout); + data = new GridData(GridData.HORIZONTAL_ALIGN_END + | GridData.VERTICAL_ALIGN_CENTER); + buttons.setLayoutData(data); + return buttons; + } + + /* private */ ResourceMapping internalGetSelectedMapping() { + ISelection selection = viewer.getSelection(); + if (selection instanceof IStructuredSelection) { + IStructuredSelection ss = (IStructuredSelection) selection; + Object firstElement = ss.getFirstElement(); + if (firstElement instanceof ResourceMapping) + return (ResourceMapping)firstElement; + } + return null; + } + + public void setDescription(String description) { + this.description = description; + } + public ResourceMapping[] getCheckedMappings() { + return checkedMappings; + } + public ResourceMapping getSelectedMapping() { + return selectedMapping; + } + + private CheckboxTableViewer getCheckboxTableViewer() { + return (CheckboxTableViewer)viewer; + } public boolean isSupportsChecking() { return supportsChecking; |