Example usage for org.eclipse.jface.action StatusLineLayoutData StatusLineLayoutData

List of usage examples for org.eclipse.jface.action StatusLineLayoutData StatusLineLayoutData

Introduction

In this page you can find the example usage for org.eclipse.jface.action StatusLineLayoutData StatusLineLayoutData.

Prototype

public StatusLineLayoutData() 

Source Link

Document

Creates an initial status line layout data object.

Usage

From source file:codeOrchestra.lcs.status.StatusLineContributionItemEx.java

License:Open Source License

public void fill(Composite parent) {
    statusLine = parent;//from w  w  w  .j  a  v a2 s  .  c  o m

    Label sep = new Label(parent, SWT.SEPARATOR);
    label = new CLabel(statusLine, SWT.SHADOW_NONE);
    label.setText(text);
    label.setImage(image);
    if (mouseListener != null) {
        label.addMouseListener(mouseListener);
    }

    if (charWidth == CALC_TRUE_WIDTH) {
        // compute the size of the label to get the width hint for the
        // contribution
        Point preferredSize = label.computeSize(SWT.DEFAULT, SWT.DEFAULT);
        widthHint = preferredSize.x;
        heightHint = preferredSize.y;
    } else if (widthHint < 0) {
        // Compute the size base on 'charWidth' average char widths
        GC gc = new GC(statusLine);
        gc.setFont(statusLine.getFont());
        FontMetrics fm = gc.getFontMetrics();
        widthHint = fm.getAverageCharWidth() * charWidth;
        heightHint = fm.getHeight();
        gc.dispose();
    }

    StatusLineLayoutData data = new StatusLineLayoutData();
    data.widthHint = widthHint;
    label.setLayoutData(data);

    data = new StatusLineLayoutData();
    data.heightHint = heightHint;
    sep.setLayoutData(data);
}

From source file:com.xored.glance.internal.ui.panels.SearchStatusLine.java

License:Open Source License

@Override
public void createContent(Composite parent) {
    super.createContent(parent);
    StatusLineLayoutData data = new StatusLineLayoutData();
    data.widthHint = getPreferedWidth();
    data.heightHint = getPreferredHeight();
    getControl().setLayoutData(data);//  w  w w  . java2  s .  co  m
    createMatchLabel(parent);
}

From source file:com.xored.glance.internal.ui.panels.SearchStatusLine.java

License:Open Source License

private void createMatchLabel(Composite parent) {
    Label separator = new Label(parent, SWT.SEPARATOR);
    setLayoutData(separator);// w  ww .  j  a v  a 2 s.c  om
    matchLabel = new CLabel(parent, SWT.SHADOW_NONE);
    matchLabel.setData("name", "searchStatus");
    StatusLineLayoutData data = new StatusLineLayoutData();
    data.widthHint = getTextWidth(parent, 10) + 15;
    data.heightHint = getPreferredHeight();
    matchLabel.setLayoutData(data);
    matchLabel.setText(matchText);
}

From source file:com.xored.glance.internal.ui.panels.SearchStatusLine.java

License:Open Source License

private void setLayoutData(Label separator) {
    StatusLineLayoutData data = new StatusLineLayoutData();
    data.heightHint = getPreferredHeight();
    separator.setLayoutData(data);/*from w  w w  .  ja va 2s  .c o m*/
}

From source file:de.vonloesch.pdf4eclipse.editors.StatusLinePageSelector.java

License:Open Source License

public void fill(Composite parent) {
    statusLine = parent;//from w  ww.  j  a  v  a  2 s  .co m

    Label sep = new Label(parent, SWT.SEPARATOR);
    Composite c = new Composite(parent, SWT.NO_FOCUS);
    c.setLayout(new GridLayout(2, false));

    pageField = new Text(c, SWT.SINGLE | SWT.RIGHT | SWT.BORDER);
    pageField.setToolTipText(Messages.StatusLinePageSelector_tooltip);
    pageField.setTextLimit(("" + this.pageNr).length()); //$NON-NLS-1$

    pageNrField = new Label(c, SWT.SHADOW_NONE);
    pageNrField.setText(" / " + this.pageNr); //$NON-NLS-1$

    pageField.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.keyCode == 13 || e.keyCode == 8 || e.keyCode == 127
                    || (e.character >= '0' && e.character <= '9')) {
                return;
            } else if (e.keyCode == SWT.PAGE_UP && page > 1) {
                pageField.setText("" + (page - 1)); //$NON-NLS-1$
                firePageNrChangeListener();
            } else if (e.keyCode == SWT.PAGE_DOWN && page < pageNr) {
                pageField.setText("" + (page + 1)); //$NON-NLS-1$
                firePageNrChangeListener();
            }

            if (e.character == 0)
                return;
            e.doit = false;
        }

        public void keyReleased(org.eclipse.swt.events.KeyEvent e) {
            if (e.keyCode == 13) {
                if (!checkPage()) {
                    MessageDialog.openError(statusLine.getShell(), Messages.StatusLinePageSelector_errorMsg1,
                            Messages.StatusLinePageSelector_errorMsg2 + pageNr);
                    e.doit = false;
                    return;
                }
                firePageNrChangeListener();
            }
        }
    });
    // Compute the size base on 'charWidth' average char widths
    GC gc = new GC(statusLine);
    gc.setFont(statusLine.getFont());
    FontMetrics fm = gc.getFontMetrics();
    int widthHint = fm.getAverageCharWidth() * charWidth;
    int heightHint = fm.getHeight();

    GridData d = new GridData(fm.getAverageCharWidth() * 4 + pageField.getBorderWidth(),
            fm.getHeight() + pageField.getBorderWidth());
    pageField.setLayoutData(d);
    pageField.setText("" + this.page); //$NON-NLS-1$
    gc.dispose();

    StatusLineLayoutData data = new StatusLineLayoutData();
    data.widthHint = widthHint;
    c.setLayoutData(data);

    data = new StatusLineLayoutData();
    data.heightHint = heightHint;
    sep.setLayoutData(data);
}

From source file:edu.pdx.svl.coDoc.poppler.editor.StatusLinePageSelector.java

License:Open Source License

public void fill(Composite parent) {
    statusLine = parent;/*from   w  ww.j a v  a  2s.com*/

    Label sep = new Label(parent, SWT.SEPARATOR);
    Composite c = new Composite(parent, SWT.NO_FOCUS);
    c.setLayout(new GridLayout(2, false));

    pageField = new Text(c, SWT.SINGLE | SWT.RIGHT | SWT.BORDER);
    pageField.setToolTipText("Messages.StatusLinePageSelector_tooltip");
    pageField.setTextLimit(("" + this.pageNr).length()); //$NON-NLS-1$

    pageNrField = new Label(c, SWT.SHADOW_NONE);
    pageNrField.setText(" / " + this.pageNr); //$NON-NLS-1$

    pageField.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.keyCode == 13 || e.keyCode == 8 || e.keyCode == 127
                    || (e.character >= '0' && e.character <= '9')) {
                return;
            } else if (e.keyCode == SWT.PAGE_UP && page > 1) {
                pageField.setText("" + (page - 1)); //$NON-NLS-1$
                firePageNrChangeListener();
            } else if (e.keyCode == SWT.PAGE_DOWN && page < pageNr) {
                pageField.setText("" + (page + 1)); //$NON-NLS-1$
                firePageNrChangeListener();
            }

            if (e.character == 0)
                return;
            e.doit = false;
        }

        public void keyReleased(org.eclipse.swt.events.KeyEvent e) {
            if (e.keyCode == 13) {
                if (!checkPage()) {
                    MessageDialog.openError(statusLine.getShell(), "Messages.StatusLinePageSelector_errorMsg1",
                            "Messages.StatusLinePageSelector_errorMsg2: " + pageNr);
                    e.doit = false;
                    return;
                }
                firePageNrChangeListener();
            }
        }
    });
    // Compute the size base on 'charWidth' average char widths
    GC gc = new GC(statusLine);
    gc.setFont(statusLine.getFont());
    FontMetrics fm = gc.getFontMetrics();
    int widthHint = fm.getAverageCharWidth() * charWidth;
    int heightHint = fm.getHeight();

    GridData d = new GridData(fm.getAverageCharWidth() * 4 + pageField.getBorderWidth(),
            fm.getHeight() + pageField.getBorderWidth());
    pageField.setLayoutData(d);
    pageField.setText("" + this.page); //$NON-NLS-1$
    gc.dispose();

    StatusLineLayoutData data = new StatusLineLayoutData();
    data.widthHint = widthHint;
    c.setLayoutData(data);

    data = new StatusLineLayoutData();
    data.heightHint = heightHint;
    sep.setLayoutData(data);
}

From source file:fable.framework.ui.internal.MainStatusBar.java

License:Open Source License

public void fill(Composite parent) {
    Label sep = new Label(parent, SWT.SEPARATOR);
    label = new CLabel(parent, SWT.SHADOW_NONE);

    GC gc = new GC(parent);
    gc.setFont(parent.getFont());//from  ww w .ja  va2 s .c  o m
    FontMetrics fm = gc.getFontMetrics();
    Point extent = gc.textExtent(text);

    int nwidthHint;

    if (widthHint > 0) {
        nwidthHint = fm.getAverageCharWidth() * widthHint;
    } else {
        nwidthHint = extent.x;
    }
    heightHint = fm.getHeight();
    gc.dispose();

    StatusLineLayoutData statusLineLayoutData = new StatusLineLayoutData();
    statusLineLayoutData.widthHint = nwidthHint;
    statusLineLayoutData.heightHint = heightHint;
    label.setLayoutData(statusLineLayoutData);
    label.setText(text);
    label.setImage(image);
    if (listener != null) {
        label.addListener(eventType, listener);
    }
    if (tooltip != null) {
        label.setToolTipText(tooltip);
    }

    statusLineLayoutData = new StatusLineLayoutData();
    statusLineLayoutData.heightHint = heightHint * 2;
    sep.setLayoutData(statusLineLayoutData);
}

From source file:fr.irit.ifclipse.actions.StatusLineContribution.java

License:Open Source License

public void fill(Composite parent) {
    Label sep = new Label(parent, SWT.SEPARATOR);
    label = new CLabel(parent, SWT.SHADOW_NONE);

    GC gc = new GC(parent);
    gc.setFont(parent.getFont());//from  ww  w .  java  2  s . co  m
    FontMetrics fm = gc.getFontMetrics();
    Point extent = gc.textExtent(text);
    if (widthHint > 0) {
        widthHint = fm.getAverageCharWidth() * widthHint;
    } else {
        widthHint = extent.x;
    }
    heightHint = fm.getHeight();
    gc.dispose();

    StatusLineLayoutData statusLineLayoutData = new StatusLineLayoutData();
    statusLineLayoutData.widthHint = widthHint;
    statusLineLayoutData.heightHint = heightHint;
    label.setLayoutData(statusLineLayoutData);
    label.setText(text);
    label.setImage(image);
    if (listener != null) {
        label.addListener(eventType, listener);
    }
    if (tooltip != null) {
        label.setToolTipText(tooltip);
    }

    statusLineLayoutData = new StatusLineLayoutData();
    statusLineLayoutData.heightHint = heightHint;
    sep.setLayoutData(statusLineLayoutData);
}

From source file:gov.nasa.ensemble.core.rcp.StatusLineContribution.java

License:Open Source License

@Override
public void fill(Composite parent) {
    Label sep = new Label(parent, SWT.SEPARATOR);
    label = new CLabel(parent, SWT.SHADOW_NONE);

    GC gc = new GC(parent);
    gc.setFont(parent.getFont());/* ww w .j ava 2s . co  m*/
    FontMetrics fm = gc.getFontMetrics();
    Point extent = gc.textExtent(text);
    if (widthHint > 0) {
        widthHint = fm.getAverageCharWidth() * widthHint;
    } else {
        widthHint = extent.x;
    }
    heightHint = fm.getHeight();
    gc.dispose();

    StatusLineLayoutData statusLineLayoutData = new StatusLineLayoutData();
    statusLineLayoutData.widthHint = widthHint;
    statusLineLayoutData.heightHint = heightHint;
    label.setLayoutData(statusLineLayoutData);
    label.setText(text);
    label.setImage(image);
    if (listener != null) {
        label.addListener(eventType, listener);
    }
    if (tooltip != null) {
        label.setToolTipText(tooltip);
    }

    statusLineLayoutData = new StatusLineLayoutData();
    statusLineLayoutData.heightHint = heightHint;
    sep.setLayoutData(statusLineLayoutData);
}

From source file:it.uniba.di.cdg.xcore.ui.contribution.OnlineStatusIndicator.java

License:Open Source License

@Override
public void fill(Composite parent) {
    CLabel sep = new CLabel(parent, SWT.SEPARATOR);
    StatusLineLayoutData data = new StatusLineLayoutData();
    sep.setLayoutData(data);//from ww  w.ja v  a 2s  . co m

    for (String id : backendStatus.keySet())
        createLabelForBackend(parent, id);

}