Example usage for org.eclipse.swt.widgets Composite getParent

List of usage examples for org.eclipse.swt.widgets Composite getParent

Introduction

In this page you can find the example usage for org.eclipse.swt.widgets Composite getParent.

Prototype

public Composite getParent() 

Source Link

Document

Returns the receiver's parent, which must be a Composite or null when the receiver is a shell that was created with null or a display for a parent.

Usage

From source file:com.jaspersoft.studio.components.chart.model.theme.util.PadUtil.java

public static Composite createWidgets4Property(Composite parent, String preID, String prefix,
        AbstractSection section) {// w  w w.ja  va  2 s . co  m
    Composite group = section.getWidgetFactory().createSection(parent, prefix, true, 4);
    ((Section) group.getParent()).setExpanded(false);

    section.createWidget4Property(group, preID + PadUtil.PADDING_TOP);
    section.createWidget4Property(group, preID + PadUtil.PADDING_BOTTOM);
    section.createWidget4Property(group, preID + PadUtil.PADDING_LEFT);
    section.createWidget4Property(group, preID + PadUtil.PADDING_RIGHT);

    return group;
}

From source file:org.eclipse.swt.examples.graphics.PathClippingAnimTab.java

/**
 * Creates the widgets used to control the drawing.
 *//* w ww. jav a  2  s  .  c  o  m*/
@Override
public void createControlPanel(Composite parent) {
    super.createControlPanel(parent);

    // color menu
    ColorMenu cm = new ColorMenu();
    cm.setPatternItems(example.checkAdvancedGraphics());
    menu = cm.createMenu(parent.getParent(), gb -> {
        background = gb;
        colorButton.setImage(gb.getThumbNail());
        example.redraw();
    });

    // initialize the background to the 5th item in the menu (blue)
    background = (GraphicsBackground) menu.getItem(4).getData();

    // color button
    Composite comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout(2, false));

    colorButton = new Button(comp, SWT.PUSH);
    colorButton.setText(GraphicsExample.getResourceString("Color")); //$NON-NLS-1$
    colorButton.setImage(background.getThumbNail());
    colorButton.addListener(SWT.Selection, event -> {
        final Button button = (Button) event.widget;
        final Composite parent1 = button.getParent();
        Rectangle bounds = button.getBounds();
        Point point = parent1.toDisplay(new Point(bounds.x, bounds.y));
        menu.setLocation(point.x, point.y + bounds.height);
        menu.setVisible(true);
    });
}

From source file:org.eclipse.swt.examples.graphics.LineCapTab.java

@Override
public void createControlPanel(Composite parent) {

    Composite comp;//ww w  . jav a2s .  com

    // create color button
    comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout());

    ColorMenu cm = new ColorMenu();
    cm.setPatternItems(example.checkAdvancedGraphics());
    menu = cm.createMenu(parent.getParent(), gb -> {
        foreground = gb;
        colorButton.setImage(gb.getThumbNail());
        example.redraw();
    });

    // initialize the foreground to the 3rd item in the menu (red)
    foreground = (GraphicsBackground) menu.getItem(2).getData();

    // color button
    colorButton = new Button(comp, SWT.PUSH);
    colorButton.setText(GraphicsExample.getResourceString("Color")); //$NON-NLS-1$
    colorButton.setImage(foreground.getThumbNail());
    colorButton.addListener(SWT.Selection, event -> {
        final Button button = (Button) event.widget;
        final Composite parent1 = button.getParent();
        Rectangle bounds = button.getBounds();
        Point point = parent1.toDisplay(new Point(bounds.x, bounds.y));
        menu.setLocation(point.x, point.y + bounds.height);
        menu.setVisible(true);
    });
}

From source file:org.eclipse.swt.examples.graphics.GradientTab.java

@Override
public void createControlPanel(final Composite parent) {
    final Display display = parent.getDisplay();

    toolBar = new ToolBar(parent, SWT.FLAT);

    ColorMenu colorMenu = new ColorMenu();

    // menu for colorItem1
    menu1 = colorMenu.createMenu(parent.getParent(), gb -> {
        colorGB1 = gb;/*  ww w .  ja  va  2 s.c  o  m*/
        colorItem1.setImage(gb.getThumbNail());
        example.redraw();
    });

    // initialize the background to the 5th item in the menu (blue)
    colorGB1 = (GraphicsBackground) menu1.getItem(4).getData();

    // toolbar item for color1
    colorItem1 = new ToolItem(toolBar, SWT.PUSH);
    colorItem1.setText(GraphicsExample.getResourceString("GradientTabItem1"));
    colorItem1.setImage(colorGB1.getThumbNail());
    colorItem1.addListener(SWT.Selection, event -> {
        final ToolItem toolItem = (ToolItem) event.widget;
        final ToolBar toolBar = toolItem.getParent();
        Rectangle toolItemBounds = toolItem.getBounds();
        Point point = toolBar.toDisplay(new Point(toolItemBounds.x, toolItemBounds.y));
        menu1.setLocation(point.x, point.y + toolItemBounds.height);
        menu1.setVisible(true);
    });

    // menu for colorItem2
    menu2 = colorMenu.createMenu(parent.getParent(), gb -> {
        colorGB2 = gb;
        colorItem2.setImage(gb.getThumbNail());
        example.redraw();
    });

    // initialize the background to the 3rd item in the menu (red)
    colorGB2 = (GraphicsBackground) menu2.getItem(2).getData();

    // toolbar item for color2
    colorItem2 = new ToolItem(toolBar, SWT.PUSH);
    colorItem2.setText(GraphicsExample.getResourceString("GradientTabItem2"));
    colorItem2.setImage(colorGB2.getThumbNail());
    colorItem2.addListener(SWT.Selection, event -> {
        final ToolItem toolItem = (ToolItem) event.widget;
        final ToolBar toolBar = toolItem.getParent();
        Rectangle toolItemBounds = toolItem.getBounds();
        Point point = toolBar.toDisplay(new Point(toolItemBounds.x, toolItemBounds.y));
        menu2.setLocation(point.x, point.y + toolItemBounds.height);
        menu2.setVisible(true);
    });

    // toolbar item for swapping colors
    ToolItem swapItem = new ToolItem(toolBar, SWT.PUSH);
    swapItem.setText(GraphicsExample.getResourceString("SwapColors")); //$NON-NLS-1$
    swapItem.setImage(example.loadImage(display, "swap.gif"));
    swapItem.addListener(SWT.Selection, event -> {
        GraphicsBackground tmp = colorGB1;
        colorGB1 = colorGB2;
        colorGB2 = tmp;
        colorItem1.setImage(colorGB1.getThumbNail());
        colorItem2.setImage(colorGB2.getThumbNail());
        example.redraw();
    });
}

From source file:org.eclipse.swt.examples.graphics.GraphicAntialiasTab.java

@Override
public void createControlPanel(Composite parent) {

    Composite comp;// w  w w  .j  av  a2  s. c om

    // create drop down combo for antialiasing
    comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout(2, false));
    new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("Antialiasing")); //$NON-NLS-1$
    aliasCombo = new Combo(comp, SWT.DROP_DOWN);
    aliasCombo.add("OFF");
    aliasCombo.add("DEFAULT");
    aliasCombo.add("ON");
    aliasCombo.select(0);
    aliasCombo.addListener(SWT.Selection, event -> example.redraw());

    ColorMenu cm = new ColorMenu();
    cm.setColorItems(true);
    menu = cm.createMenu(parent.getParent(), gb -> {
        ovalColorGB = gb;
        colorButton.setImage(gb.getThumbNail());
        example.redraw();
    });

    // create color button
    comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout());

    // initialize the background to the 5th item in the menu (blue)
    ovalColorGB = (GraphicsBackground) menu.getItem(4).getData();

    // color button
    colorButton = new Button(comp, SWT.PUSH);
    colorButton.setText(GraphicsExample.getResourceString("Color")); //$NON-NLS-1$
    colorButton.setImage(ovalColorGB.getThumbNail());
    colorButton.addListener(SWT.Selection, event -> {
        final Button button = (Button) event.widget;
        final Composite parent1 = button.getParent();
        Rectangle bounds = button.getBounds();
        Point point = parent1.toDisplay(new Point(bounds.x, bounds.y));
        menu.setLocation(point.x, point.y + bounds.height);
        menu.setVisible(true);
    });
}

From source file:org.eclipse.swt.examples.graphics.LineStyleTab.java

@Override
public void createControlPanel(Composite parent) {

    Composite comp;/*from ww  w .  j  av a2 s  . c  o  m*/

    comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout(2, false));

    new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("LineWidth")); //$NON-NLS-1$
    lineWidthSpinner = new Spinner(comp, SWT.BORDER | SWT.WRAP);
    lineWidthSpinner.setSelection(10);
    lineWidthSpinner.setMinimum(1);
    lineWidthSpinner.setMaximum(30);
    lineWidthSpinner.addListener(SWT.Selection, event -> example.redraw());

    ColorMenu cm = new ColorMenu();
    cm.setPatternItems(example.checkAdvancedGraphics());
    menu = cm.createMenu(parent.getParent(), gb -> {
        lineColor = gb;
        colorButton.setImage(gb.getThumbNail());
        example.redraw();
    });

    // create color button
    comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout());

    // initialize the foreground to the 5th item in the menu (blue)
    lineColor = (GraphicsBackground) menu.getItem(4).getData();

    // color button
    colorButton = new Button(comp, SWT.PUSH);
    colorButton.setText(GraphicsExample.getResourceString("Color")); //$NON-NLS-1$
    colorButton.setImage(lineColor.getThumbNail());
    colorButton.addListener(SWT.Selection, event -> {
        final Button button = (Button) event.widget;
        final Composite parent1 = button.getParent();
        Rectangle bounds = button.getBounds();
        Point point = parent1.toDisplay(new Point(bounds.x, bounds.y));
        menu.setLocation(point.x, point.y + bounds.height);
        menu.setVisible(true);
    });
}

From source file:org.eclipse.swt.examples.graphics.TextAntialiasTab.java

@Override
public void createControlPanel(Composite parent) {

    Composite comp;/* ww w. ja va 2s  . c om*/

    // create drop down combo for antialiasing
    comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout(2, false));
    new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("Antialiasing")); //$NON-NLS-1$
    aliasCombo = new Combo(comp, SWT.DROP_DOWN);
    aliasCombo.add("OFF");
    aliasCombo.add("DEFAULT");
    aliasCombo.add("ON");
    aliasCombo.select(0);
    aliasCombo.addListener(SWT.Selection, event -> example.redraw());

    ColorMenu cm = new ColorMenu();
    cm.setColorItems(true);
    menu = cm.createMenu(parent.getParent(), gb -> {
        textColor = gb;
        colorButton.setImage(gb.getThumbNail());
        example.redraw();
    });

    // create color button
    comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout());

    // initialize the color to black
    textColor = (GraphicsBackground) menu.getItem(1).getData();

    colorButton = new Button(comp, SWT.PUSH);
    colorButton.setText(GraphicsExample.getResourceString("Color")); //$NON-NLS-1$
    colorButton.setImage(textColor.getThumbNail());

    colorButton.addListener(SWT.Selection, event -> {
        final Button button = (Button) event.widget;
        final Composite parent1 = button.getParent();
        Rectangle bounds = button.getBounds();
        Point point = parent1.toDisplay(new Point(bounds.x, bounds.y));
        menu.setLocation(point.x, point.y + bounds.height);
        menu.setVisible(true);
    });
}

From source file:org.eclipse.swt.examples.graphics.CustomAlphaTab.java

/**
 * Creates the widgets used to control the drawing.
 */// w  w w. j av a2 s  .  com
@Override
public void createControlPanel(Composite parent) {
    super.createControlPanel(parent);

    // create drop down combo for choosing clipping
    Composite comp;

    // create spinner for line width
    comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout(2, false));
    new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("Alpha")); //$NON-NLS-1$
    alphaSpinner = new Spinner(comp, SWT.BORDER | SWT.WRAP);
    alphaSpinner.setMinimum(0);
    alphaSpinner.setMaximum(255);
    alphaSpinner.setSelection(127);
    alphaSpinner.addListener(SWT.Selection, event -> example.redraw());

    // color menu
    ColorMenu cm = new ColorMenu();
    cm.setPatternItems(example.checkAdvancedGraphics());
    menu = cm.createMenu(parent.getParent(), gb -> {
        background = gb;
        colorButton.setImage(gb.getThumbNail());
        example.redraw();
    });

    // initialize the background to the 5th item in the menu (blue)
    background = (GraphicsBackground) menu.getItem(4).getData();

    // color button
    comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout(2, false));

    colorButton = new Button(comp, SWT.PUSH);
    colorButton.setText(GraphicsExample.getResourceString("Color")); //$NON-NLS-1$
    colorButton.setImage(background.getThumbNail());
    colorButton.addListener(SWT.Selection, event -> {
        final Button button = (Button) event.widget;
        final Composite parent1 = button.getParent();
        Rectangle bounds = button.getBounds();
        Point point = parent1.toDisplay(new Point(bounds.x, bounds.y));
        menu.setLocation(point.x, point.y + bounds.height);
        menu.setVisible(true);
    });
}

From source file:org.eclipse.swt.examples.graphics.LineJoinTab.java

@Override
public void createControlPanel(Composite parent) {

    // create drop down combo for choosing clipping
    Composite comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout(2, false));

    new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("LineJoin")); //$NON-NLS-1$
    joinCb = new Combo(comp, SWT.DROP_DOWN);
    joinCb.add(GraphicsExample.getResourceString("bevel")); //$NON-NLS-1$
    joinCb.add(GraphicsExample.getResourceString("miter")); //$NON-NLS-1$
    joinCb.add(GraphicsExample.getResourceString("round")); //$NON-NLS-1$
    joinCb.select(1);/*from w ww.  j  a v  a  2 s .c  om*/
    joinCb.addListener(SWT.Selection, event -> example.redraw());

    // color menu
    ColorMenu cm = new ColorMenu();
    cm.setPatternItems(example.checkAdvancedGraphics());
    menu = cm.createMenu(parent.getParent(), gb -> {
        shapeColor = gb;
        colorButton.setImage(gb.getThumbNail());
        example.redraw();
    });

    // initialize the shape color to the 4th item in the menu (green)
    shapeColor = (GraphicsBackground) menu.getItem(3).getData();

    // color button
    comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout(2, false));

    colorButton = new Button(comp, SWT.PUSH);
    colorButton.setText(GraphicsExample.getResourceString("Color")); //$NON-NLS-1$
    colorButton.setImage(shapeColor.getThumbNail());
    colorButton.addListener(SWT.Selection, event -> {
        final Button button = (Button) event.widget;
        final Composite parent1 = button.getParent();
        Rectangle bounds = button.getBounds();
        Point point = parent1.toDisplay(new Point(bounds.x, bounds.y));
        menu.setLocation(point.x, point.y + bounds.height);
        menu.setVisible(true);
    });

}

From source file:org.eclipse.swt.examples.graphics.SpiralTab.java

/**
 * This method creates a spinner for specifying the number of petals. The call to the
 * createControlPanel method in the super class create the controls that are
 * defined in the super class./*from  ww  w  .j a v  a2 s  .  c o m*/
 *
 * @param parent The parent composite
 */
@Override
public void createControlPanel(Composite parent) {
    super.createControlPanel(parent);

    // create spinner number of petals
    Composite comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout(2, false));

    new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("Petals")); //$NON-NLS-1$
    petalSpinner = new Spinner(comp, SWT.BORDER | SWT.WRAP);
    petalSpinner.setSelection(8);
    petalSpinner.setMinimum(3);
    petalSpinner.setMaximum(20);
    petalSpinner.addListener(SWT.Selection, event -> example.redraw());

    // create color button
    comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout());

    ColorMenu cm = new ColorMenu();
    cm.setPatternItems(example.checkAdvancedGraphics());
    menu = cm.createMenu(parent.getParent(), gb -> {
        foreground = gb;
        colorButton.setImage(gb.getThumbNail());
        example.redraw();
    });

    // initialize the foreground to the 2nd item in the menu
    foreground = (GraphicsBackground) menu.getItem(1).getData();

    // color button
    colorButton = new Button(comp, SWT.PUSH);
    colorButton.setText(GraphicsExample.getResourceString("Color")); //$NON-NLS-1$
    colorButton.setImage(foreground.getThumbNail());
    colorButton.addListener(SWT.Selection, event -> {
        final Button button = (Button) event.widget;
        final Composite parent1 = button.getParent();
        Rectangle bounds = button.getBounds();
        Point point = parent1.toDisplay(new Point(bounds.x, bounds.y));
        menu.setLocation(point.x, point.y + bounds.height);
        menu.setVisible(true);
    });
}