public ConfTableViewer()

in org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/ConfTableViewer.java [61:158]


    public ConfTableViewer(Composite parent, int style) {
        super(parent, style);
        GridLayout layout = new GridLayout(2, false);
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        setLayout(layout);

        selectAll = new Button(this, SWT.CHECK);
        selectAll.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
        selectAll.setText("Select every configuration");
        selectAll.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                boolean enabled = !selectAll.getSelection();
                confTableViewer.getTable().setEnabled(enabled);
                updateAllNoneEnableButtons(enabled);
                updateUpDownEnableButtons(enabled);
                confTableUpdated();
            }
        });

        confTableViewer = CheckboxTableViewer.newCheckList(this, SWT.BORDER | SWT.H_SCROLL
                | SWT.V_SCROLL);
        confTableViewer.getTable().setHeaderVisible(true);
        confTableViewer.getTable().setLayoutData(
            new GridData(GridData.FILL, GridData.FILL, true, true));
        TableColumn col1 = new TableColumn(confTableViewer.getTable(), SWT.NONE);
        col1.setText("Name");
        // CheckStyle:MagicNumber| OFF
        col1.setWidth(100);
        TableColumn col2 = new TableColumn(confTableViewer.getTable(), SWT.NONE);
        col2.setText("Description");
        col2.setWidth(300);
        // CheckStyle:MagicNumber| ON
        confTableViewer.setColumnProperties(new String[] {"Name", "Description"});
        confTableViewer.getTable().setLayoutData(
            new GridData(GridData.FILL, GridData.FILL, true, true));
        confTableViewer.setContentProvider(ArrayContentProvider.getInstance());
        confTableViewer.setLabelProvider(new ConfigurationLabelProvider());
        confTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
            public void selectionChanged(SelectionChangedEvent event) {
                updateUpDownEnableButtons(true);
                updateAllNoneEnableButtons(true);
                confTableUpdated();
            }
        });

        Composite upDownButtons = new Composite(this, SWT.NONE);
        upDownButtons.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, true));
        upDownButtons.setLayout(new GridLayout());

        all = new Button(upDownButtons, SWT.PUSH);
        all.setText("All");
        all.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
        all.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                confTableViewer.setCheckedElements(orderedConfigurations);
                updateAllNoneEnableButtons(true);
            }
        });

        none = new Button(upDownButtons, SWT.PUSH);
        none.setText("None");
        none.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
        none.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                confTableViewer.setCheckedElements(new Configuration[0]);
                updateAllNoneEnableButtons(true);
            }
        });

        up = new Button(upDownButtons, SWT.PUSH);
        up.setText("Up");
        up.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
        up.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                int i = getSelectedConfigurationIndex();
                Configuration c = orderedConfigurations[i];
                orderedConfigurations[i] = orderedConfigurations[i - 1];
                orderedConfigurations[i - 1] = c;
                confTableViewer.refresh();
                updateUpDownEnableButtons(true);
            }
        });

        down = new Button(upDownButtons, SWT.PUSH);
        down.setText("Down");
        down.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
        down.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                int i = getSelectedConfigurationIndex();
                Configuration c = orderedConfigurations[i];
                orderedConfigurations[i] = orderedConfigurations[i + 1];
                orderedConfigurations[i + 1] = c;
                confTableViewer.refresh();
                updateUpDownEnableButtons(true);
            }
        });
    }