org.eclipse.swt.widgets.Scale#addSelectionListener ( )源码实例Demo

下面列出了org.eclipse.swt.widgets.Scale#addSelectionListener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: nebula   文件: NavigationPageScaleRenderer.java
@Override
protected void createUI(Composite parent) {
	GridLayout layout = new GridLayout(1, false);
	layout.marginWidth = 0;
	layout.marginHeight = 0;
	this.setLayout(layout);

	pageScale = new Scale(parent, SWT.READ_ONLY);
	pageScale.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

	pageScale.addSelectionListener(this);
}
 
源代码2 项目: spotbugs   文件: ReportConfigurationTab.java
private void createRankGroup(Composite parent) {
    Composite prioGroup = new Composite(parent, SWT.NONE);
    prioGroup.setLayout(new GridLayout(2, false));

    Label minRankLabel = new Label(prioGroup, SWT.NONE);
    minRankLabel.setText(getMessage("property.minRank") + System.getProperty("line.separator")
            + getMessage("property.minRank.line2"));
    minRankLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));

    minRankSlider = new Scale(prioGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
    minRankSlider.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false));
    minRankSlider.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            int rank = minRankSlider.getSelection();
            getCurrentProps().getFilterSettings().setMinRank(rank);
            updateRankValueLabel();
        }
    });
    minRankSlider.setMinimum(BugRanker.VISIBLE_RANK_MIN);
    minRankSlider.setMaximum(BugRanker.VISIBLE_RANK_MAX);
    minRankSlider.setSelection(getCurrentProps().getFilterSettings().getMinRank());
    minRankSlider.setIncrement(1);
    minRankSlider.setPageIncrement(5);
    Label dummyLabel = new Label(prioGroup, SWT.NONE);
    dummyLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));

    rankValueLabel = new Label(prioGroup, SWT.NONE);
    rankValueLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false));
    updateRankValueLabel();
}
 
源代码3 项目: slr-toolkit   文件: LegendPageBar.java
/**
 * Create the composite.
 * @param parent
 * @param style
 */
public LegendPageBar(Composite parent, int style) {
	super(parent, style);
	setLayout(new GridLayout(2, false));
	
	lblLegend = new Label(this, SWT.NONE);
	lblLegend.setText("Legend ");
	
	btnEnableLegend = new Button(this, SWT.CHECK);
	btnEnableLegend.setText("Enable Legend");
	
	Label lblBackgroundColor = new Label(this, SWT.NONE);
	GridData gd_lblBackgroundColor = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
	gd_lblBackgroundColor.widthHint = 150;
	lblBackgroundColor.setLayoutData(gd_lblBackgroundColor);
	lblBackgroundColor.setText("Background Color");
	
	labelColorShow = new Label(this, SWT.BORDER);
	GridData gd_labelColorShow = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
	gd_labelColorShow.widthHint = 100;
	labelColorShow.setLayoutData(gd_labelColorShow);
	labelColorShow.setText(" ");
	labelColorShow.setBackground(PageSupport.getColor(parent, 0));
	labelColorShow.addMouseListener(this);
	
	Label lblOutline = new Label(this, SWT.NONE);
	lblOutline.setText("Outline Style");
	
	comboOutline = new Combo(this, SWT.READ_ONLY);
	comboOutline.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
	comboOutline.add("None");
	comboOutline.add("Dashed");
	comboOutline.add("Dash Dotted");
	comboOutline.add("Dotted");
	comboOutline.add("Solid");
	comboOutline.select(0);
	
	lblMaxPercent = new Label(this, SWT.NONE);
	lblMaxPercent.setText("Max. Percent");
	
	scale = new Scale(this, SWT.NONE);
	scale.setIncrement(2);
	GridData gd_scale = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
	gd_scale.widthHint = 309;
	scale.setLayoutData(gd_scale);
	scale.setPageIncrement(2);
	scale.setMaximum(50);
	scale.setSelection(10);
	scale.addSelectionListener(this);
	
	Label lblPosition = new Label(this, SWT.NONE);
	lblPosition.setText("Position");
	
	comboPosition = new Combo(this, SWT.READ_ONLY);
	comboPosition.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
	comboPosition.add("Right");
	comboPosition.add("Left");
	comboPosition.add("Below");
	comboPosition.add("Top");
	comboPosition.select(0);		

	loadSettings();
}
 
源代码4 项目: slr-toolkit   文件: LegendPagePie.java
/**
 * Create the composite.
 * @param parent
 * @param style
 */
public LegendPagePie(Composite parent, int style) {
	super(parent, style);
	setLayout(new GridLayout(2, false));
	
	lblLegend = new Label(this, SWT.NONE);
	lblLegend.setText("Legend");
	
	btnEnableLegend = new Button(this, SWT.CHECK);
	btnEnableLegend.setText("Enable Legend");
	
	Label lblBackgroundColor = new Label(this, SWT.NONE);
	GridData gd_lblBackgroundColor = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
	gd_lblBackgroundColor.widthHint = 150;
	lblBackgroundColor.setLayoutData(gd_lblBackgroundColor);
	lblBackgroundColor.setText("Background Color");
	
	labelColorShow = new Label(this, SWT.BORDER);
	GridData gd_labelColorShow = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
	gd_labelColorShow.widthHint = 100;
	labelColorShow.setLayoutData(gd_labelColorShow);
	labelColorShow.setText(" ");
	labelColorShow.setBackground(PageSupport.getColor(parent, 0));
	labelColorShow.addMouseListener(this);
	
	Label lblOutline = new Label(this, SWT.NONE);
	lblOutline.setText("Outline Style");
	
	comboOutline = new Combo(this, SWT.READ_ONLY);
	comboOutline.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
	comboOutline.add("None");
	comboOutline.add("Dashed");
	comboOutline.add("Dash Dotted");
	comboOutline.add("Dotted");
	comboOutline.add("Solid");
	comboOutline.select(0);
	
	lblMaxPercent = new Label(this, SWT.NONE);
	lblMaxPercent.setText("Max. Percent");
	
	scale = new Scale(this, SWT.NONE);
	scale.setIncrement(2);
	GridData gd_scale = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
	gd_scale.widthHint = 309;
	scale.setLayoutData(gd_scale);
	scale.setPageIncrement(2);
	scale.setMaximum(50);
	scale.setSelection(10);
	scale.addSelectionListener(this);
	
	Label lblPosition = new Label(this, SWT.NONE);
	lblPosition.setText("Position");
	
	comboPosition = new Combo(this, SWT.READ_ONLY);
	comboPosition.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
	comboPosition.add("Right");
	comboPosition.add("Left");
	comboPosition.add("Below");
	comboPosition.add("Top");
	comboPosition.select(0);		
	
	

	loadSettings();
}
 
/**
 * Create the controls that compose the console test.
 * 
 */
protected void createControls(IHierarchicalJaretTableModel hierarchicalModel) {
    GridLayout gl = new GridLayout();
    gl.numColumns = 1;
    _shell.setLayout(gl);

    GridData gd = new GridData(GridData.FILL_BOTH);

    _jt = new JaretTable(_shell, SWT.V_SCROLL | SWT.H_SCROLL);
    _jt.setLayoutData(gd);

    IHierarchicalJaretTableModel hmodel = hierarchicalModel;

    if (hierarchicalModel == null) {

        ITableNode root = new DummyTableNode("tn1", "tn1", "Root", "This the root node");
        ITableNode r1 = new DummyTableNode("tn11", "tn12", "1", "Child 1 of the root");
        ITableNode r2 = new DummyTableNode("tn12", "tn12", "2", "Child 2 of the root");
        ITableNode r3 = new DummyTableNode("tn13", "tn13", "3", "Child 3 of the root");
        root.addNode(r1);
        root.addNode(r2);
        root.addNode(r3);

        r1.addNode(new DummyTableNode("tn111", "tn111", "1", "A second level child"));
        r1.addNode(new DummyTableNode("tn112", "tn112", "2", "Another second level child"));

        ITableNode n1 = new DummyTableNode("tn131", "tn131", "1", "A second level child");
        r3.addNode(n1);
        ITableNode n2 = new DummyTableNode("tn132", "tn132", "2", "Another second level child");
        r3.addNode(n2);

        n1.addNode(new DummyTableNode("tn1311", "tn1311", "1", "A third level child"));
        n1.addNode(new DummyTableNode("tn1312", "tn1312", "2", "Another third level child"));

        DefaultHierarchicalTableModel dhmodel = new DefaultHierarchicalTableModel(root);
        hmodel = dhmodel;

        if (SUPPORT_DND) {
            // init the simple drag and drop handling
            initDND(_jt, _shell);
        }
    }

    _jt.setTableModel(hmodel);
    StdHierarchicalTableModel model = (StdHierarchicalTableModel) _jt.getTableModel();
    IColumn hcol = new HierarchyColumn();
    // create and setup hierarchy renderer
    final TableHierarchyRenderer hierarchyRenderer = new TableHierarchyRenderer();
    hierarchyRenderer.setLabelProvider(new LabelProvider());
    hierarchyRenderer.setDrawIcons(true);
    hierarchyRenderer.setDrawLabels(true);
    _jt.registerCellRenderer(hcol, hierarchyRenderer);
    model.addColumn(hcol);

    model.addColumn(new PropCol("b1", "column 1", "B1"));
    model.addColumn(new PropCol("t1", "column 2", "T1"));
    model.addColumn(new PropCol("t2", "column 3", "T2"));
    model.addColumn(new PropCol("t3", "column 4", "T3"));

    JaretTableActionFactory af = new JaretTableActionFactory();

    MenuManager mm = new MenuManager();
    mm.add(af.createStdAction(_jt, JaretTableActionFactory.ACTION_CONFIGURECOLUMNS));
    _jt.setHeaderContextMenu(mm.createContextMenu(_jt));

    MenuManager rm = new MenuManager();
    rm.add(af.createStdAction(_jt, JaretTableActionFactory.ACTION_OPTROWHEIGHT));
    rm.add(af.createStdAction(_jt, JaretTableActionFactory.ACTION_OPTALLROWHEIGHTS));
    _jt.setRowContextMenu(rm.createContextMenu(_jt));

    TableControlPanel ctrlPanel = new TableControlPanel(_shell, SWT.NULL, _jt);

    Label l = new Label(_shell, SWT.NONE);
    l.setText("Level width:");
    final Scale levelWidthScale = new Scale(_shell, SWT.HORIZONTAL);
    levelWidthScale.setMaximum(40);
    levelWidthScale.setMinimum(0);
    levelWidthScale.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent ev) {
            int val = levelWidthScale.getSelection();
            hierarchyRenderer.setLevelWidth(val);
            _jt.redraw();
        }
    });

}
 
源代码6 项目: tmxeditor8   文件: TableHierarchicalExample.java
/**
 * Create the controls that compose the console test.
 * 
 */
protected void createControls(IHierarchicalJaretTableModel hierarchicalModel) {
    GridLayout gl = new GridLayout();
    gl.numColumns = 1;
    _shell.setLayout(gl);

    GridData gd = new GridData(GridData.FILL_BOTH);

    _jt = new JaretTable(_shell, SWT.V_SCROLL | SWT.H_SCROLL);
    _jt.setLayoutData(gd);

    IHierarchicalJaretTableModel hmodel = hierarchicalModel;

    if (hierarchicalModel == null) {

        ITableNode root = new DummyTableNode("tn1", "tn1", "Root", "This the root node");
        ITableNode r1 = new DummyTableNode("tn11", "tn12", "1", "Child 1 of the root");
        ITableNode r2 = new DummyTableNode("tn12", "tn12", "2", "Child 2 of the root");
        ITableNode r3 = new DummyTableNode("tn13", "tn13", "3", "Child 3 of the root");
        root.addNode(r1);
        root.addNode(r2);
        root.addNode(r3);

        r1.addNode(new DummyTableNode("tn111", "tn111", "1", "A second level child"));
        r1.addNode(new DummyTableNode("tn112", "tn112", "2", "Another second level child"));

        ITableNode n1 = new DummyTableNode("tn131", "tn131", "1", "A second level child");
        r3.addNode(n1);
        ITableNode n2 = new DummyTableNode("tn132", "tn132", "2", "Another second level child");
        r3.addNode(n2);

        n1.addNode(new DummyTableNode("tn1311", "tn1311", "1", "A third level child"));
        n1.addNode(new DummyTableNode("tn1312", "tn1312", "2", "Another third level child"));

        DefaultHierarchicalTableModel dhmodel = new DefaultHierarchicalTableModel(root);
        hmodel = dhmodel;

        if (SUPPORT_DND) {
            // init the simple drag and drop handling
            initDND(_jt, _shell);
        }
    }

    _jt.setTableModel(hmodel);
    StdHierarchicalTableModel model = (StdHierarchicalTableModel) _jt.getTableModel();
    IColumn hcol = new HierarchyColumn();
    // create and setup hierarchy renderer
    final TableHierarchyRenderer hierarchyRenderer = new TableHierarchyRenderer();
    hierarchyRenderer.setLabelProvider(new LabelProvider());
    hierarchyRenderer.setDrawIcons(true);
    hierarchyRenderer.setDrawLabels(true);
    _jt.registerCellRenderer(hcol, hierarchyRenderer);
    model.addColumn(hcol);

    model.addColumn(new PropCol("b1", "column 1", "B1"));
    model.addColumn(new PropCol("t1", "column 2", "T1"));
    model.addColumn(new PropCol("t2", "column 3", "T2"));
    model.addColumn(new PropCol("t3", "column 4", "T3"));

    JaretTableActionFactory af = new JaretTableActionFactory();

    MenuManager mm = new MenuManager();
    mm.add(af.createStdAction(_jt, JaretTableActionFactory.ACTION_CONFIGURECOLUMNS));
    _jt.setHeaderContextMenu(mm.createContextMenu(_jt));

    MenuManager rm = new MenuManager();
    rm.add(af.createStdAction(_jt, JaretTableActionFactory.ACTION_OPTROWHEIGHT));
    rm.add(af.createStdAction(_jt, JaretTableActionFactory.ACTION_OPTALLROWHEIGHTS));
    _jt.setRowContextMenu(rm.createContextMenu(_jt));

    TableControlPanel ctrlPanel = new TableControlPanel(_shell, SWT.NULL, _jt);

    Label l = new Label(_shell, SWT.NONE);
    l.setText("Level width:");
    final Scale levelWidthScale = new Scale(_shell, SWT.HORIZONTAL);
    levelWidthScale.setMaximum(40);
    levelWidthScale.setMinimum(0);
    levelWidthScale.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent ev) {
            int val = levelWidthScale.getSelection();
            hierarchyRenderer.setLevelWidth(val);
            _jt.redraw();
        }
    });

}
 
源代码7 项目: olca-app   文件: Controls.java
public static void onSelect(Scale scale, Consumer<SelectionEvent> consumer) {
	scale.addSelectionListener(selectionListener(consumer));
}