Package es.iiia.sgi.controls

Source Code of es.iiia.sgi.controls.PossibleResultsBox

package es.iiia.sgi.controls;

import org.eclipse.jface.action.ControlContribution;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Spinner;
import org.eclipse.ui.PlatformUI;

import es.iiia.sgi.editors.RenderingEditor;

public class PossibleResultsBox extends ControlContribution {

  Spinner text;
  int selection = 10;
 
  public PossibleResultsBox(String id) {
    super(id);
  }

  @Override
  protected Control createControl(Composite parent) {
    text = new Spinner(parent, SWT.BORDER | SWT.FLAT);
    text.setToolTipText("Possible results");
    text.setTextLimit(3);
    text.setSize(25, 15);
    text.setDigits(0);
    text.setIncrement(1);
    text.setMaximum(10000000);
    text.setMinimum(0);
    text.setSelection(selection);
   
    text.addModifyListener(new ModifyListener() {
      public void modifyText(ModifyEvent e) {
        RenderingEditor editor = ((RenderingEditor) PlatformUI
            .getWorkbench().getActiveWorkbenchWindow()
            .getActivePage().getActiveEditor());
        editor.setPossibleResults(text.getSelection());       
        selection = text.getSelection();
      }
     
    });
   
    Font font = new Font(parent.getDisplay(), "Arial", 11, SWT.NORMAL);
    text.setFont(font);   
    text.pack();
    return text;
  }
 

}
TOP

Related Classes of es.iiia.sgi.controls.PossibleResultsBox

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.