Java Code Examples for org.eclipse.swt.widgets.Composite#getDisplay()

The following examples show how to use org.eclipse.swt.widgets.Composite#getDisplay() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ViewStatisticsClassification.java    From arx with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new instance.
 *
 * @param parent
 * @param controller
 * @param part
 */
public ViewStatisticsClassification(final Composite parent,
                                    final Controller controller,
                                    final ModelPart part) {

    super(parent, controller, part, null, false);
    this.manager = new AnalysisManager(parent.getDisplay());
    this.isOutput = part != ModelPart.INPUT;
    this.rocCurves = new HashMap<>();
    this.originalRocCurves = new HashMap<>();
    this.zerorRocCurves = new HashMap<>();
    
    controller.addListener(ModelPart.CLASSIFICATION_CONFIGURATION, this);
    controller.addListener(ModelPart.DATA_TYPE, this);
    controller.addListener(ModelPart.SELECTED_ATTRIBUTE, this);
    controller.addListener(ModelPart.SELECTED_CLASS_VALUE, this);
}
 
Example 2
Source File: RenameRefactoringPopup.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected void createContent(Composite parent) {
	Display display = parent.getDisplay();
	ColorRegistry registry = JFaceResources.getColorRegistry();
	Color foreground= registry.get("org.eclipse.ui.workbench.HOVER_FOREGROUND"); //$NON-NLS-1$
	if (foreground == null) {
		foreground = display.getSystemColor(SWT.COLOR_INFO_FOREGROUND);
	}
	Color background= registry.get("org.eclipse.ui.workbench.HOVER_BACKGROUND"); //$NON-NLS-1$
	if (background == null) {
		background = display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
	}
	StyledText hint = new StyledText(popup, SWT.READ_ONLY | SWT.SINGLE);
	String enterKeyName = getEnterBinding();
	String hintTemplate = "Enter new name, press {0} to refactor";
	hint.setText(Messages.format(hintTemplate, enterKeyName));
	hint.setForeground(foreground);
	hint.setStyleRange(new StyleRange(hintTemplate.indexOf("{0}"), enterKeyName.length(), null, null, SWT.BOLD)); //$NON-NLS-1$
	hint.setEnabled(false); // text must not be selectable
	addViewMenu(parent);
	recursiveSetBackgroundColor(parent, background);
}
 
Example 3
Source File: TransitionTest1.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private void setCompImage(Composite comp) {
    int index = -1;
    if (comp == comp1) {
        index = 0;
    } else if (comp == comp2) {
        index = 1;
    } else if (comp == comp3) {
        index = 2;
    }
    if (index > -1) {
        tf.setSelection(index);
        
        comp.redraw();
        comp.getDisplay().update();
        comp.getDisplay().readAndDispatch();
        
        Image image = new Image(comp.getDisplay(),
                comp.getBounds().width, comp.getBounds().height);
        GC gc = new GC(comp);
        gc.copyArea(image, 0, 0);
        gc.dispose();
        
        compImage[index] = image;
    }
}
 
Example 4
Source File: ChartPrintJob.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
private void printComposite(Composite elementToPrint, GC gc, 
        Rectangle printArea) {
    Image image = new Image(elementToPrint.getDisplay(),
            elementToPrint.getSize().x, elementToPrint.getSize().y);
    try {
        GC imageGC = new GC(image);
        try {
            elementToPrint.print(imageGC);
            Point fittedSize = calcFittedSize(printArea, 
                    elementToPrint.getSize());
            gc.drawImage(image, 0, 0, elementToPrint.getSize().x,
                    elementToPrint.getSize().y, printArea.x, printArea.y, 
                    fittedSize.x, fittedSize.y);

        } finally {
            imageGC.dispose();
        }
    } finally {
        image.dispose();
    }
}
 
Example 5
Source File: ScrolledPageContent.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public ScrolledPageContent(Composite parent, int style)
{
	super(parent, style);

	setFont(parent.getFont());

	FormColors colors = new FormColors(parent.getDisplay());
	colors.setBackground(null);
	colors.setForeground(null);

	fToolkit = new FormToolkit(colors);

	setExpandHorizontal(true);
	setExpandVertical(true);

	Composite body = new Composite(this, SWT.NONE);
	body.setFont(parent.getFont());
	setContent(body);
}
 
Example 6
Source File: ViewStatisticsDistributionHistogram.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance.
 *
 * @param parent
 * @param controller
 * @param target
 * @param reset
 */
public ViewStatisticsDistributionHistogram(final Composite parent,
                                           final Controller controller,
                                           final ModelPart target,
                                           final ModelPart reset) {
    
    super(parent, controller, target, reset, true);
    this.manager = new AnalysisManager(parent.getDisplay());
}
 
Example 7
Source File: CrosstabGrandTotalDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private Composite createTitleArea( Composite parent )
{
	int heightMargins = 3;
	int widthMargins = 8;
	final Composite titleArea = new Composite( parent, SWT.NONE );
	FormLayout layout = new FormLayout( );
	layout.marginHeight = heightMargins;
	layout.marginWidth = widthMargins;
	titleArea.setLayout( layout );

	Display display = parent.getDisplay( );
	Color background = JFaceColors.getBannerBackground( display );
	GridData layoutData = new GridData( GridData.FILL_HORIZONTAL );
	layoutData.heightHint = 20 + ( heightMargins * 2 );
	titleArea.setLayoutData( layoutData );
	titleArea.setBackground( background );

	titleArea.addPaintListener( new PaintListener( ) {

		public void paintControl( PaintEvent e )
		{
			e.gc.setForeground( titleArea.getDisplay( )
					.getSystemColor( SWT.COLOR_WIDGET_NORMAL_SHADOW ) );
			Rectangle bounds = titleArea.getClientArea( );
			bounds.height = bounds.height - 2;
			bounds.width = bounds.width - 1;
			e.gc.drawRectangle( bounds );
		}
	} );

	Label label = new Label( titleArea, SWT.NONE );
	label.setBackground( background );
	label.setFont( FontManager.getFont( label.getFont( ).toString( ),
			10,
			SWT.BOLD ) );
	label.setText( getTitle( ) );
	UIUtil.bindHelp( parent,
			IHelpContextIds.INSERT_EDIT_GRAND_TOTAL_DIALOG_ID );
	return titleArea;
}
 
Example 8
Source File: PrimitiveQuestionnairePage.java    From CogniCrypt with Eclipse Public License 2.0 5 votes vote down vote up
private Composite getPanel(final Composite parent) {
	final Composite titledPanel = new Composite(parent, SWT.NONE);
	final Font boldFont = new Font(titledPanel.getDisplay(), new FontData("Arial", 9, SWT.BOLD));
	titledPanel.setFont(boldFont);
	final GridLayout layout2 = new GridLayout();

	layout2.numColumns = 4;
	titledPanel.setLayout(layout2);

	return titledPanel;
}
 
Example 9
Source File: PipelineOptionsFormComponent.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
public PipelineOptionsFormComponent(
    Composite parent, String argumentSeparator, Set<String> filterProperties) {
  this.argumentSeparator = argumentSeparator;
  this.filterProperties = filterProperties;

  this.parent = parent;

  formToolkit = new FormToolkit(parent.getDisplay());
  formToolkit.setBackground(parent.getBackground());
}
 
Example 10
Source File: FormsPart.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@PostConstruct
public void createPartControl(Composite parent) {
	FormToolkit toolkit = new FormToolkit(parent.getDisplay());
	ScrolledForm form = toolkit.createScrolledForm(parent);
	toolkit.decorateFormHeading(form.getForm());

	form.setText("Eclipse Forms API Example");

	createFirstSection(parent, toolkit);
	createSecondSection(form, toolkit);
}
 
Example 11
Source File: WSO2PluginFormBrowser.java    From developer-studio with Apache License 2.0 5 votes vote down vote up
public void createControl(Composite parent) {
	toolkit = new FormToolkit(parent.getDisplay());
	int borderStyle = toolkit.getBorderStyle() == SWT.BORDER ? SWT.NULL : SWT.BORDER;
	container = new Composite(parent, borderStyle);
	FillLayout flayout = new FillLayout();
	flayout.marginWidth = 1;
	flayout.marginHeight = 1;
	container.setLayout(flayout);
	formText = new ScrolledFormText(container, SWT.V_SCROLL | SWT.H_SCROLL, false);
	if (borderStyle == SWT.NULL) {
		formText.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER);
		toolkit.paintBordersFor(container);
	}
	FormText ftext = toolkit.createFormText(formText, false);
	formText.setFormText(ftext);
	formText.setExpandHorizontal(true);
	formText.setExpandVertical(true);
	formText.setBackground(toolkit.getColors().getBackground());
	formText.setForeground(toolkit.getColors().getForeground());
	ftext.marginWidth = 2;
	ftext.marginHeight = 2;
	ftext.setHyperlinkSettings(toolkit.getHyperlinkGroup());
	formText.addDisposeListener(new DisposeListener() {
		public void widgetDisposed(DisposeEvent e) {
			if (toolkit != null) {
				toolkit.dispose();
				toolkit = null;
			}
		}
	});
	if (text != null)
		formText.setText(text);
}
 
Example 12
Source File: AbstractEditorPropertySection.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public final void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
	toolkit = new FormToolkit(parent.getDisplay());
	toolkit.setBorderStyle(SWT.BORDER);
	super.createControls(parent, aTabbedPropertySheetPage);
	GridDataFactory.fillDefaults().grab(true, true).applyTo(parent);
	parent.setLayout(new GridLayout(1, true));
	form = toolkit.createForm(parent);
	toolkit.decorateFormHeading(form);
	GridDataFactory.fillDefaults().grab(true, true).applyTo(form);
	form.getBody().setLayout(createBodyLayout());
	createControls(form.getBody());
}
 
Example 13
Source File: CrosstabPageBreakDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private Composite createTitleArea( Composite parent )
{
	int heightMargins = 3;
	int widthMargins = 8;
	final Composite titleArea = new Composite( parent, SWT.NONE );
	FormLayout layout = new FormLayout( );
	layout.marginHeight = heightMargins;
	layout.marginWidth = widthMargins;
	titleArea.setLayout( layout );

	Display display = parent.getDisplay( );
	Color background = JFaceColors.getBannerBackground( display );
	GridData layoutData = new GridData( GridData.FILL_HORIZONTAL );
	layoutData.heightHint = 20 + ( heightMargins * 2 );
	titleArea.setLayoutData( layoutData );
	titleArea.setBackground( background );

	titleArea.addPaintListener( new PaintListener( ) {

		public void paintControl( PaintEvent e )
		{
			e.gc.setForeground( titleArea.getDisplay( )
					.getSystemColor( SWT.COLOR_WIDGET_NORMAL_SHADOW ) );
			Rectangle bounds = titleArea.getClientArea( );
			bounds.height = bounds.height - 2;
			bounds.width = bounds.width - 1;
			e.gc.drawRectangle( bounds );
		}
	} );

	Label label = new Label( titleArea, SWT.NONE );
	label.setBackground( background );
	label.setFont( FontManager.getFont( label.getFont( ).toString( ),
			10,
			SWT.BOLD ) );
	label.setText( getTitle( ) );

	return titleArea;
}
 
Example 14
Source File: EyeButton.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
EyeButton(final Composite parent, final int style) {
	super(parent, SWT.DOUBLE_BUFFERED);
	addListeners();
	color = new Color(parent.getDisplay(), 0, 127, 222);
	SWTGraphicUtil.addDisposer(this, color);
	setBackground(getDisplay().getSystemColor(SWT.COLOR_WHITE));
}
 
Example 15
Source File: ViewRisksRiskDistribution.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance.
 *
 * @param parent
 * @param controller
 * @param target
 * @param reset
 */
public ViewRisksRiskDistribution(final Composite parent,
                                 final Controller controller,
                                 final ModelPart target,
                                 final ModelPart reset) {
    
    super(parent, controller, target, reset);
    this.manager = new AnalysisManager(parent.getDisplay());
    controller.addListener(ModelPart.ATTRIBUTE_TYPE, this);
    controller.addListener(ModelPart.ATTRIBUTE_TYPE_BULK_UPDATE, this);
}
 
Example 16
Source File: AbstractStepGeneratorPage.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void createPage ( final Composite parent )
{
    this.display = parent.getDisplay ();
}
 
Example 17
Source File: PercentDisplay.java    From Rel with Apache License 2.0 4 votes vote down vote up
public PercentDisplay(Composite parent, int style, String displaytext, PercentSource percent) {
	super(parent, style);
	
	percentageHistory = new LinkedList<Integer>();
	
	goodColor = greener(getBackground());
	badColor = redder(getBackground());
	okColor = yellower(getBackground());
	black = new Color(parent.getDisplay(), 0, 0, 0);
	lightGray = new Color(parent.getDisplay(), 200, 200, 200);
	
	addListener(SWT.MouseEnter, e -> {
		mouseIn = true;
		refresh();
	});
	
	addListener(SWT.MouseExit, e -> {
		mouseIn = false;
	});
	
	addListener (SWT.Paint, e -> {
		GC gc = e.gc;
		Rectangle rect = getClientArea();
		displayWidth = rect.width;
		Integer[] percentages = getPercentages();
		int lastX = rect.x;
		int lastY = rect.y;
		Point txtExtent = (mouseIn) ? gc.textExtent(emitText) : new Point(0, 0);
		int textX = rect.width - txtExtent.x - 5;
		int textY = (rect.height - txtExtent.y) / 2;
		Rectangle txtRect = new Rectangle(textX, textY, txtExtent.x, txtExtent.y);
		for (int index=0; index<percentages.length; index++) {
			int barY = (100 - percentages[index]) * (rect.height - 5) / 100 + 2;
			int barX = rect.x + index;
			gc.setForeground(getBackground());
			gc.drawLine(barX, rect.y, barX, barY);
			if (percentages[index] < lowerLimit)
				gc.setForeground(goodColor);
			else if (percentages[index] < middleLimit)
				gc.setForeground(okColor);
			else
				gc.setForeground(badColor);
			gc.drawLine(barX, rect.height, barX, barY);
			if (index > 0) {
				if ((txtRect.contains(barX, barY) || txtRect.contains(lastX, lastY)) && mouseIn)
					gc.setForeground(lightGray);
				else
					gc.setForeground(black);
				gc.drawLine(lastX, lastY, barX, barY);
			}
			lastX = barX;
			lastY = barY;
		}
		if (mouseIn) {
			gc.setForeground(black);
			gc.drawText(emitText, textX, textY, true);
		}
	});
	
	Thread painter = new Thread() {
		public void run() {
			int lastPercent = 0;
			while (running) {
				try {sleep(delay);} catch (InterruptedException ie) {}
				int percentValue = percent.getPercent(); 
				addPercentage((percentValue + lastPercent) / 2);	// smoothing, sort-of
				lastPercent = percentValue;
				emitText = String.format("%3d%% ", percentValue) + displaytext; 
				refresh();
			}
		}
	};
	painter.start();
}
 
Example 18
Source File: ConcurrentStringReceiverClient.java    From Rel with Apache License 2.0 4 votes vote down vote up
public ConcurrentStringReceiverClient(Composite parent, StringReceiverClient connection) {
	this.parent = parent;
	display = parent.getDisplay();
	this.connection = connection;
}
 
Example 19
Source File: Block.java    From Rel with Apache License 2.0 4 votes vote down vote up
/** Creates a new instance of Block.  Default black colour. */
public Block(Composite parent, int xpos, int ypos, int width, int height) {
	this(parent, xpos, ypos, width, height, new Color(parent.getDisplay(), 0, 0, 0));
}
 
Example 20
Source File: InternalGeoMap.java    From nebula with Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Initializes a new <code>InternalGeoMap</code>.
 * 
 * @param parent
 *            SWT parent <code>Composite</code>
 * @param style
 *            SWT style as in <code>Canvas</code>, since this class inherits
 *            from it. Double buffering is always enabed.
 * @param mapPosition
 *            initial mapPosition.
 * @param zoom
 *            initial map zoom
 * @param cacheSize
 *            initial cache size, eg number of tile-images that are kept in
 *            cache to prevent reloading from the network.
 */
protected InternalGeoMap(Composite parent, int style, Point mapPosition,
		int zoom, int cacheSize) {
	super(parent, SWT.DOUBLE_BUFFERED | style);
	geoMapHelper = new GeoMapHelper(parent.getDisplay(), mapPosition, zoom,
			cacheSize);
	geoMapHelper.addGeoMapHelperListener(this);

	addDisposeListener(e -> InternalGeoMap.this.geoMapHelper.dispose());
	addPaintListener(e -> InternalGeoMap.this.paintControl(e));
}