Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 22d5099749c4bc7a74c060a5a44cc3918167409d (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
/*******************************************************************************
 * Copyright (c) 2006, 2018 IBM Corporation and others.
 * 
 * This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License 2.0
 * which is available at https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - Jeff Briggs, Henry Hughes, Ryan Morse
 *******************************************************************************/

package org.eclipse.linuxtools.internal.systemtap.graphing.ui.wizards.filter;

import org.eclipse.linuxtools.internal.systemtap.graphing.ui.Localization;
import org.eclipse.linuxtools.systemtap.graphing.core.filters.SortFilter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.forms.widgets.ColumnLayout;



public class SortFilterWizardPage extends FilterWizardPage {
    public SortFilterWizardPage() {
        super("selectFilterOptions"); //$NON-NLS-1$
        setTitle(Localization.getString("SortFilterWizardPage.CreateSortFilter")); //$NON-NLS-1$
    }

    @Override
    public void createControl(Composite parent) {
        super.createControl(parent);

        Composite comp = new Composite(parent, SWT.NULL);
        comp.setLayout(new FormLayout());
        FormData data1 = new FormData();
        data1.left = new FormAttachment(0, 0);
        data1.top = new FormAttachment(0, 0);
        data1.right = new FormAttachment(40, 0);
        data1.bottom = new FormAttachment(100, 0);

        Composite cmpFilterOpts = new Composite(comp, SWT.NONE);
        cmpFilterOpts.setLayoutData(data1);
        ColumnLayout colLayout = new ColumnLayout();
        colLayout.maxNumColumns = 1;
        cmpFilterOpts.setLayout(colLayout);

        //Column
        Label lblColumn = new Label(cmpFilterOpts, SWT.NONE);
        lblColumn.setText(Localization.getString("SortFilterWizardPage.Column")); //$NON-NLS-1$
        cboColumn = new Combo(cmpFilterOpts, SWT.DROP_DOWN | SWT.READ_ONLY);
        cboColumn.addSelectionListener(selectionListener);
        for(int i=0; i<wizard.series.length; i++) {
            cboColumn.add(wizard.series[i]);
        }

        new Label(cmpFilterOpts, SWT.NONE);    //Spacer

        //Style
        radAscending = new Button(cmpFilterOpts, SWT.RADIO);
        radAscending.setText(Localization.getString("SortFilterWizardPage.Ascending")); //$NON-NLS-1$
        radAscending.addSelectionListener(selectionListener);
        radAscending.setSelection(true);
        radDescending = new Button(cmpFilterOpts, SWT.RADIO);
        radDescending.setText(Localization.getString("SortFilterWizardPage.Descending")); //$NON-NLS-1$
        radDescending.addSelectionListener(selectionListener);

        cboColumn.select(0);
        createFilter();
        setControl(comp);
    }

    @Override
    public boolean canFlipToNextPage() {
        return false;
    }

    @Override
    protected void createFilter() {
        int selected = cboColumn.getSelectionIndex();
        int style = (radAscending.getSelection() ? SortFilter.ASCENDING : SortFilter.DESCENDING);
        filter = new SortFilter(selected, style);
    }

    @Override
    public void dispose() {
        if(null != cboColumn) {
            cboColumn.removeSelectionListener(selectionListener);
            cboColumn.dispose();
            cboColumn = null;
        }

        if(null != radAscending) {
            radAscending.removeSelectionListener(selectionListener);
            radAscending.dispose();
            radAscending = null;
        }

        if(null != radDescending) {
            radDescending.removeSelectionListener(selectionListener);
            radDescending.dispose();
            radDescending = null;
        }

        super.dispose();
    }

    private Combo cboColumn;
    private Button radAscending, radDescending;
}

Back to the top