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

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

Introduction

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

Prototype

public void setForeground(Color color) 

Source Link

Document

Sets the receiver's foreground color to the color specified by the argument, or to the default system color for the control if the argument is null.

Usage

From source file:WidgetTest2.java

public static Composite createComposite(Composite parent) {
    /** * Composite ** */
    //       Create new Composite instance
    final Composite composite = new Composite(parent, 0);
    //       Get properties from the containing composite
    composite.setBackground(parent.getBackground());
    composite.setForeground(parent.getForeground());
    composite.setFont(parent.getFont());
    //       Set position and size
    composite.setBounds(X, Y, WIDTH, HEIGHT);
    return composite;
}

From source file:eu.stratosphere.addons.visualization.swt.SWTGateToolTip.java

public SWTGateToolTip(Shell parent, ManagementGate managementGate, int x, int y) {
    super(parent, x, y);

    int height;/*from w w w.j  a v a 2  s . co  m*/

    this.managementGate = managementGate;

    if (managementGate.isInputGate()) {
        setTitle("Input Gate " + managementGate.getIndex());
    } else {
        setTitle("Output Gate " + managementGate.getIndex());
    }

    final Color backgroundColor = getShell().getBackground();
    final Color foregroundColor = getShell().getForeground();

    final GateVisualizationData gateVisualizationData = (GateVisualizationData) managementGate.getAttachment();

    if (gateVisualizationData.isProfilingEnabled()) {
        this.chart = createChart(gateVisualizationData, backgroundColor);
        this.chart.setLayoutData(new GridData(GridData.FILL_BOTH));
        height = 200;
    } else {
        this.chart = null;
        height = 100;
    }

    final Composite tableComposite = new Composite(getShell(), SWT.NONE);
    tableComposite.setBackground(backgroundColor);
    tableComposite.setForeground(foregroundColor);

    final GridLayout tableGridLayout = new GridLayout(2, false);
    tableGridLayout.marginHeight = 0;
    tableGridLayout.marginLeft = 0;
    tableComposite.setLayout(tableGridLayout);

    // Channel type
    ChannelType channelType;
    if (managementGate.isInputGate()) {
        channelType = managementGate.getVertex().getGroupVertex().getBackwardEdge(managementGate.getIndex())
                .getChannelType();
    } else {
        channelType = managementGate.getVertex().getGroupVertex().getForwardEdge(managementGate.getIndex())
                .getChannelType();
    }

    final Label channelTypeTextLabel = new Label(tableComposite, SWT.NONE);
    channelTypeTextLabel.setBackground(backgroundColor);
    channelTypeTextLabel.setForeground(foregroundColor);
    channelTypeTextLabel.setText("Channel type:");

    this.channelTypeLabel = new Label(tableComposite, SWT.NONE);
    this.channelTypeLabel.setBackground(backgroundColor);
    this.channelTypeLabel.setForeground(foregroundColor);
    this.channelTypeLabel.setText(channelType.toString());

    if (!this.managementGate.isInputGate()) {
        final ManagementGroupEdge groupEdge = this.managementGate.getVertex().getGroupVertex()
                .getForwardEdge(this.managementGate.getIndex());
        final GroupEdgeVisualizationData groupEdgeVisualizationData = (GroupEdgeVisualizationData) groupEdge
                .getAttachment();

        if (groupEdgeVisualizationData.isIOBottleneck()) {
            this.warningComposite = createWarningComposite(WARNINGTEXT, SWT.ICON_WARNING);
            height += ICONSIZE;
        } else {
            this.warningComposite = null;
        }
    } else {
        this.warningComposite = null;
    }

    getShell().setSize(WIDTH, height);

    finishInstantiation(x, y, WIDTH, false);
}

From source file:eu.stratosphere.addons.visualization.swt.SWTInstanceToolTip.java

public SWTInstanceToolTip(Shell parent, final SWTToolTipCommandReceiver commandReceiver,
        NetworkNode networkNode, int x, int y) {
    super(parent, x, y);

    this.networkNode = networkNode;

    final Color backgroundColor = getShell().getBackground();
    final Color foregroundColor = getShell().getForeground();

    boolean isProfilingEnabled = false;
    final InstanceVisualizationData instanceVisualizationData = (InstanceVisualizationData) networkNode
            .getAttachment();/* w  w w .j  a  v a2 s.c om*/
    if (instanceVisualizationData != null) {
        isProfilingEnabled = instanceVisualizationData.isProfilingEnabledForJob();
    }

    int height;

    // Set the title
    setTitle(networkNode.getName());

    // Only create chart if profiling is enabled
    if (isProfilingEnabled) {
        this.cpuChart = createCPUChart(instanceVisualizationData, backgroundColor);
        this.cpuChart.setLayoutData(new GridData(GridData.FILL_BOTH));
        this.memoryChart = createMemoryChart(instanceVisualizationData, backgroundColor);
        this.memoryChart.setLayoutData(new GridData(GridData.FILL_BOTH));
        this.networkChart = createNetworkChart(instanceVisualizationData, backgroundColor);
        this.networkChart.setLayoutData(new GridData(GridData.FILL_BOTH));
        height = 460;
    } else {
        this.cpuChart = null;
        this.memoryChart = null;
        this.networkChart = null;
        height = 75;
    }

    // Available instance actions
    final Composite instanceActionComposite = new Composite(getShell(), SWT.NONE);
    instanceActionComposite.setLayout(new RowLayout(SWT.HORIZONTAL));
    instanceActionComposite.setBackground(backgroundColor);
    instanceActionComposite.setForeground(foregroundColor);

    final Button killInstanceButton = new Button(instanceActionComposite, SWT.PUSH);
    final String instanceName = this.networkNode.getName();
    killInstanceButton.setText("Kill instance...");
    killInstanceButton.setEnabled(this.networkNode.isLeafNode());
    killInstanceButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event arg0) {
            commandReceiver.killInstance(instanceName);
        }

    });

    getShell().setSize(WIDTH, height);

    finishInstantiation(x, y, WIDTH, false);
}

From source file:eu.stratosphere.addons.visualization.swt.SWTVertexToolTip.java

public SWTVertexToolTip(Shell parent, final SWTToolTipCommandReceiver commandReceiver,
        ManagementVertex managementVertex, int x, int y) {
    super(parent, x, y);

    this.managementVertex = managementVertex;

    final VertexVisualizationData vertexVisualizationData = (VertexVisualizationData) managementVertex
            .getAttachment();// w w  w.  j a  v a  2s. c o  m

    int height;

    final Color backgroundColor = getShell().getBackground();
    final Color foregroundColor = getShell().getForeground();

    // Set the title
    final String taskName = managementVertex.getName() + " (" + (managementVertex.getIndexInGroup() + 1)
            + " of " + managementVertex.getNumberOfVerticesInGroup() + ")";
    setTitle(taskName);

    // Only create chart if profiling is enabled
    if (vertexVisualizationData.isProfilingEnabledForJob()) {
        this.threadChart = createThreadChart(vertexVisualizationData, backgroundColor);
        this.threadChart.setLayoutData(new GridData(GridData.FILL_BOTH));
        height = 240; // should be 265 when cancel button is enabled
    } else {
        this.threadChart = null;
        height = 125;
    }

    final Composite tableComposite = new Composite(getShell(), SWT.NONE);
    tableComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    tableComposite.setBackground(backgroundColor);
    tableComposite.setForeground(foregroundColor);
    final GridLayout tableGridLayout = new GridLayout(3, false);
    tableGridLayout.marginHeight = 0;
    tableGridLayout.marginLeft = 0;
    tableComposite.setLayout(tableGridLayout);

    final GridData gridData1 = new GridData();
    gridData1.horizontalSpan = 2;
    gridData1.grabExcessHorizontalSpace = true;
    gridData1.widthHint = 200;

    final GridData gridData2 = new GridData();
    gridData2.grabExcessHorizontalSpace = true;

    // Instance type
    final Label instanceTypeTextLabel = new Label(tableComposite, SWT.NONE);
    instanceTypeTextLabel.setBackground(backgroundColor);
    instanceTypeTextLabel.setForeground(foregroundColor);
    instanceTypeTextLabel.setText("Instance type:");

    this.instanceTypeLabel = new Label(tableComposite, SWT.NONE);
    this.instanceTypeLabel.setBackground(backgroundColor);
    this.instanceTypeLabel.setForeground(foregroundColor);
    this.instanceTypeLabel.setText(this.managementVertex.getInstanceType());
    this.instanceTypeLabel.setLayoutData(gridData1);

    // Instance ID
    final Label instanceIDTextLabel = new Label(tableComposite, SWT.NONE);
    instanceIDTextLabel.setBackground(backgroundColor);
    instanceIDTextLabel.setForeground(foregroundColor);
    instanceIDTextLabel.setText("Instance ID:");

    this.instanceIDLabel = new Label(tableComposite, SWT.NONE);
    this.instanceIDLabel.setBackground(backgroundColor);
    this.instanceIDLabel.setForeground(foregroundColor);
    this.instanceIDLabel.setText(this.managementVertex.getInstanceName());
    this.instanceIDLabel.setLayoutData(gridData2);

    final Button switchToInstanceButton = new Button(tableComposite, SWT.PUSH);
    switchToInstanceButton.setText("Switch to instance...");
    switchToInstanceButton.setEnabled(vertexVisualizationData.isProfilingEnabledForJob());
    switchToInstanceButton.setVisible(false);

    /*
     * final String instanceName = this.managementVertex.getInstanceName();
     * switchToInstanceButton.addListener(SWT.Selection, new Listener() {
     * @Override
     * public void handleEvent(Event arg0) {
     * commandReceiver.switchToInstance(instanceName);
     * }
     * });
     */

    // Execution state
    final Label executionStateTextLabel = new Label(tableComposite, SWT.NONE);
    executionStateTextLabel.setBackground(backgroundColor);
    executionStateTextLabel.setForeground(foregroundColor);
    executionStateTextLabel.setText("Execution state:");

    this.executionStateLabel = new Label(tableComposite, SWT.NONE);
    this.executionStateLabel.setBackground(backgroundColor);
    this.executionStateLabel.setForeground(foregroundColor);
    this.executionStateLabel.setText(this.managementVertex.getExecutionState().toString());
    this.executionStateLabel.setLayoutData(gridData1);

    final ManagementGroupVertex groupVertex = this.managementVertex.getGroupVertex();
    final GroupVertexVisualizationData groupVertexVisualizationData = (GroupVertexVisualizationData) groupVertex
            .getAttachment();
    if (groupVertexVisualizationData.isCPUBottleneck()) {
        this.warningComposite = createWarningComposite(WARNINGTEXT, SWT.ICON_WARNING);
        height += ICONSIZE;
    } else {
        this.warningComposite = null;
    }

    // Available task actions
    final Composite taskActionComposite = new Composite(getShell(), SWT.NONE);
    taskActionComposite.setLayout(new RowLayout(SWT.HORIZONTAL));
    taskActionComposite.setBackground(backgroundColor);
    taskActionComposite.setForeground(foregroundColor);

    /*
     * final Button cancelTaskButton = new Button(taskActionComposite, SWT.PUSH);
     * final ManagementVertexID vertexID = this.managementVertex.getID();
     * cancelTaskButton.setText("Cancel task");
     * cancelTaskButton.setEnabled(this.managementVertex.getExecutionState() == ExecutionState.RUNNING);
     * cancelTaskButton.addListener(SWT.Selection, new Listener() {
     * @Override
     * public void handleEvent(Event arg0) {
     * commandReceiver.cancelTask(vertexID, taskName);
     * }
     * });
     */

    getShell().setSize(WIDTH, height);

    finishInstantiation(x, y, WIDTH, false);
}

From source file:eu.stratosphere.nephele.visualization.swt.SWTVertexToolTip.java

public SWTVertexToolTip(Shell parent, final SWTToolTipCommandReceiver commandReceiver,
        ManagementVertex managementVertex, int x, int y) {
    super(parent, x, y);

    this.managementVertex = managementVertex;

    final VertexVisualizationData vertexVisualizationData = (VertexVisualizationData) managementVertex
            .getAttachment();//from   w  ww  .ja v  a2 s .c om

    int height;

    final Color backgroundColor = getShell().getBackground();
    final Color foregroundColor = getShell().getForeground();

    // Set the title
    final String taskName = managementVertex.getName() + " (" + (managementVertex.getIndexInGroup() + 1)
            + " of " + managementVertex.getNumberOfVerticesInGroup() + ")";
    setTitle(taskName);

    // Only create chart if profiling is enabled
    if (vertexVisualizationData.isProfilingEnabledForJob()) {
        this.threadChart = createThreadChart(vertexVisualizationData, backgroundColor);
        this.threadChart.setLayoutData(new GridData(GridData.FILL_BOTH));
        height = 240; // should be 265 when cancel button is enabled
    } else {
        this.threadChart = null;
        height = 125;
    }

    final Composite tableComposite = new Composite(getShell(), SWT.NONE);
    tableComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    tableComposite.setBackground(backgroundColor);
    tableComposite.setForeground(foregroundColor);
    final GridLayout tableGridLayout = new GridLayout(3, false);
    tableGridLayout.marginHeight = 0;
    tableGridLayout.marginLeft = 0;
    tableComposite.setLayout(tableGridLayout);

    final GridData gridData1 = new GridData();
    gridData1.horizontalSpan = 2;
    gridData1.grabExcessHorizontalSpace = true;
    gridData1.widthHint = 200;

    final GridData gridData2 = new GridData();
    gridData2.grabExcessHorizontalSpace = true;

    // Instance type
    final Label instanceTypeTextLabel = new Label(tableComposite, SWT.NONE);
    instanceTypeTextLabel.setBackground(backgroundColor);
    instanceTypeTextLabel.setForeground(foregroundColor);
    instanceTypeTextLabel.setText("Instance type:");

    this.instanceTypeLabel = new Label(tableComposite, SWT.NONE);
    this.instanceTypeLabel.setBackground(backgroundColor);
    this.instanceTypeLabel.setForeground(foregroundColor);
    this.instanceTypeLabel.setText(this.managementVertex.getInstanceType());
    this.instanceTypeLabel.setLayoutData(gridData1);

    // Instance ID
    final Label instanceIDTextLabel = new Label(tableComposite, SWT.NONE);
    instanceIDTextLabel.setBackground(backgroundColor);
    instanceIDTextLabel.setForeground(foregroundColor);
    instanceIDTextLabel.setText("Instance ID:");

    this.instanceIDLabel = new Label(tableComposite, SWT.NONE);
    this.instanceIDLabel.setBackground(backgroundColor);
    this.instanceIDLabel.setForeground(foregroundColor);
    this.instanceIDLabel.setText(this.managementVertex.getInstanceName());
    this.instanceIDLabel.setLayoutData(gridData2);

    final Button switchToInstanceButton = new Button(tableComposite, SWT.PUSH);
    switchToInstanceButton.setText("Switch to instance...");
    switchToInstanceButton.setEnabled(vertexVisualizationData.isProfilingEnabledForJob());
    switchToInstanceButton.setVisible(false);

    /*
     * final String instanceName = this.managementVertex.getInstanceName();
     * switchToInstanceButton.addListener(SWT.Selection, new Listener() {
     * @Override
     * public void handleEvent(Event arg0) {
     * commandReceiver.switchToInstance(instanceName);
     * }
     * });
     */

    // Execution state
    final Label executionStateTextLabel = new Label(tableComposite, SWT.NONE);
    executionStateTextLabel.setBackground(backgroundColor);
    executionStateTextLabel.setForeground(foregroundColor);
    executionStateTextLabel.setText("Execution state:");

    this.executionStateLabel = new Label(tableComposite, SWT.NONE);
    this.executionStateLabel.setBackground(backgroundColor);
    this.executionStateLabel.setForeground(foregroundColor);
    this.executionStateLabel.setText(this.managementVertex.getExecutionState().toString());
    this.executionStateLabel.setLayoutData(gridData1);

    // Checkpoint state
    final Label checkpointStateTextLabel = new Label(tableComposite, SWT.NONE);
    checkpointStateTextLabel.setBackground(backgroundColor);
    checkpointStateTextLabel.setForeground(foregroundColor);
    checkpointStateTextLabel.setText("Checkpoint state:");

    this.checkpointStateLabel = new Label(tableComposite, SWT.NONE);
    this.checkpointStateLabel.setBackground(backgroundColor);
    this.checkpointStateLabel.setForeground(foregroundColor);
    this.checkpointStateLabel.setText(this.managementVertex.getCheckpointState().toString());
    this.checkpointStateLabel.setLayoutData(gridData1);

    final ManagementGroupVertex groupVertex = this.managementVertex.getGroupVertex();
    final GroupVertexVisualizationData groupVertexVisualizationData = (GroupVertexVisualizationData) groupVertex
            .getAttachment();
    if (groupVertexVisualizationData.isCPUBottleneck()) {
        this.warningComposite = createWarningComposite(WARNINGTEXT, SWT.ICON_WARNING);
        height += ICONSIZE;
    } else {
        this.warningComposite = null;
    }

    // Available task actions
    final Composite taskActionComposite = new Composite(getShell(), SWT.NONE);
    taskActionComposite.setLayout(new RowLayout(SWT.HORIZONTAL));
    taskActionComposite.setBackground(backgroundColor);
    taskActionComposite.setForeground(foregroundColor);

    /*
     * final Button cancelTaskButton = new Button(taskActionComposite, SWT.PUSH);
     * final ManagementVertexID vertexID = this.managementVertex.getID();
     * cancelTaskButton.setText("Cancel task");
     * cancelTaskButton.setEnabled(this.managementVertex.getExecutionState() == ExecutionState.RUNNING);
     * cancelTaskButton.addListener(SWT.Selection, new Listener() {
     * @Override
     * public void handleEvent(Event arg0) {
     * commandReceiver.cancelTask(vertexID, taskName);
     * }
     * });
     */

    getShell().setSize(WIDTH, height);

    finishInstantiation(x, y, WIDTH, false);
}