Search in sources :

Example 1 with Font

use of org.eclipse.swt.graphics.Font in project cogtool by cogtool.

the class ActionPropertySet method layoutHelper.

@Override
public void layoutHelper() {
    actionSettings = new Composite(parent, SWT.BORDER);
    actionSettings.setLayout(actionSettingsLayout);
    propLabel = new Label(parent, SWT.CENTER);
    propLabel.setText(designPropertiesLabel);
    Font labelFont = FontUtils.getAdjustedFont(propLabel.getFont(), SWT.BOLD);
    propLabel.setFont(labelFont);
    actionType = new DisplayLabel(parent, SWT.NONE);
    actionType.setText(actionTypeLabel);
    actionChoices = new ComboWithEnableFix(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
    actionChoices.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent evt) {
            int currentSelection = actionChoices.getSelectionIndex();
            if (currentSelection != chosenActionType) {
                editTransitionParms.useWhichParts = choiceUseIndexes[currentSelection];
                chosenActionType = currentSelection;
                view.performAction(DesignEditorLID.EditTransition, editTransitionParms, true);
            }
        }
    });
    delayLabelLabel = new DisplayLabel(parent, SWT.NONE);
    delayLabelLabel.setText(DELAY_LABEL_LABEL);
    delayLabel = new View.PerformActionText(parent, SWT.SINGLE | SWT.BORDER) {

        @Override
        protected void onFocus() {
            super.onFocus();
            view.getTransmuter().setLIDEnabledState();
        }

        @Override
        protected boolean doChangeAction() {
            Point labelSelection = getSelection();
            if ("".equals(getText())) {
                setText(TransitionDelay.DEFAULT_DELAY_LABEL);
                labelSelection = null;
            }
            if (view.performAction(DesignEditorLID.ChangeDelay)) {
                if (labelSelection != null) {
                    setSelection(labelSelection);
                }
                return true;
            }
            return false;
        }
    };
    delayInSecsLabel = new DisplayLabel(parent, SWT.NONE);
    delayInSecsLabel.setText(DELAY_DURATION_LABEL + ":");
    secondsUnit = new Label(parent, SWT.NONE);
    secondsUnit.setText(SECONDS);
    delayInSecs = new View.PerformActionDouble(parent, SWT.SINGLE | SWT.BORDER) {

        @Override
        protected void onFocus() {
            super.onFocus();
            view.getTransmuter().setLIDEnabledState();
        }

        @Override
        protected void onModify() {
            super.onModify();
            delayLabel.setEnabled(getDoubleValue() > 0.0);
        }

        @Override
        protected boolean doChangeAction() {
            Point delaySelection = getSelection();
            if (getDoubleValue() == 0.0) {
                setText("");
                delaySelection = null;
            }
            if (view.performAction(DesignEditorLID.ChangeDelay)) {
                if (delaySelection != null) {
                    setSelection(delaySelection);
                }
                return true;
            }
            return false;
        }
    };
    delayInSecs.setAllowNegative(false);
    delayInSecs.setDecimalPlaces(3);
    delayInSecs.moveAbove(delayLabel.getOuter());
    FormData data = new FormData();
    data.left = leftAttachment;
    data.right = new FormAttachment(100, -5);
    propLabel.setLayoutData(data);
    data = new FormData();
    data.left = leftAttachment;
    data.top = new FormAttachment(actionChoices, 0, SWT.CENTER);
    actionType.setLayoutData(data);
    data = new FormData();
    data.left = new FormAttachment(actionType, 5, SWT.RIGHT);
    data.right = new FormAttachment(100, -5);
    data.top = new FormAttachment(propLabel, 5, SWT.BOTTOM);
    actionChoices.setLayoutData(data);
    data = new FormData();
    data.left = leftAttachment;
    data.top = new FormAttachment(actionChoices, 5, SWT.BOTTOM);
    data.right = new FormAttachment(100, -5);
    actionSettings.setLayoutData(data);
    data = new FormData();
    data.left = leftAttachment;
    data.top = new FormAttachment(actionSettings, 5, SWT.BOTTOM);
    delayInSecsLabel.setLayoutData(data);
    data = new FormData();
    data.left = leftAttachment;
    data.top = new FormAttachment(delayInSecsLabel, 5, SWT.BOTTOM);
    data.width = 100;
    delayInSecs.setLayoutData(data);
    data = new FormData();
    data.left = new FormAttachment(delayInSecs.getOuter(), 5, SWT.RIGHT);
    data.top = new FormAttachment(delayInSecs.getOuter(), 0, SWT.CENTER);
    secondsUnit.setLayoutData(data);
    data = new FormData();
    data.left = leftAttachment;
    data.top = new FormAttachment(delayInSecs.getOuter(), 5, SWT.BOTTOM);
    delayLabelLabel.setLayoutData(data);
    data = new FormData();
    data.left = leftAttachment;
    data.top = new FormAttachment(delayLabelLabel, 5, SWT.BOTTOM);
    data.right = new FormAttachment(100, -5);
    delayLabel.setLayoutData(data);
    emptyParms = createEmptyComposite();
    layOutEmptyComposite();
    multTransParms = new Composite(actionSettings, SWT.NONE);
    multTransParms.setLayout(new FormLayout());
    Label multTransLabel = new Label(multTransParms, SWT.WRAP);
    multTransLabel.setText(noActionAvailableText);
    data = new FormData();
    data.left = leftAttachment;
    data.top = new FormAttachment(0, 5);
    data.right = new FormAttachment(100, -5);
    multTransLabel.setLayoutData(data);
    frameParms = createFrameComposite();
}
Also used : FormData(org.eclipse.swt.layout.FormData) FormLayout(org.eclipse.swt.layout.FormLayout) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) DisplayLabel(edu.cmu.cs.hcii.cogtool.util.DisplayLabel) Label(org.eclipse.swt.widgets.Label) Point(org.eclipse.swt.graphics.Point) Font(org.eclipse.swt.graphics.Font) DisplayLabel(edu.cmu.cs.hcii.cogtool.util.DisplayLabel) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ComboWithEnableFix(edu.cmu.cs.hcii.cogtool.util.ComboWithEnableFix) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 2 with Font

use of org.eclipse.swt.graphics.Font in project cogtool by cogtool.

the class FrameEditorView method layOutPropertiesPane.

/**
     * Layout the properties pane, with the specific list of device types
     * and the parent to lay them out in.
     */
protected void layOutPropertiesPane(int deviceTypes, Composite pane) {
    pane.setLayout(new FormLayout());
    actionSettings = new Composite(pane, SWT.BORDER);
    actionSettings.setLayout(actionSettingsLayout);
    frameParms = new FramePropertiesPane(actionSettings, SWT.NONE, this);
    widgetParms = new WidgetPropertiesPane(actionSettings, SWT.NONE, this);
    eltGroupParms = new EltGroupPropertiesPane(actionSettings, SWT.NONE, this);
    propLabel = new Label(pane, SWT.CENTER);
    propLabel.setText(FRAME_PROPERTIES);
    Font labelFont = FontUtils.getAdjustedFont(propLabel.getFont(), SWT.BOLD);
    propLabel.setFont(labelFont);
    FormData data = new FormData();
    data.right = new FormAttachment(100, -5);
    data.left = new FormAttachment(0, 5);
    data.top = new FormAttachment(0, 5);
    propLabel.setLayoutData(data);
    data = new FormData();
    data.left = new FormAttachment(0, 5);
    data.top = new FormAttachment(propLabel, 5, SWT.BOTTOM);
    data.right = new FormAttachment(100, -5);
    actionSettings.setLayoutData(data);
    // To get N/A set
    setWidgetName(null);
    // To get N/A set
    setWidgetTitle(null);
    // To get N/A set
    setWidgetAuxText(null);
    widgetParms.hideAttributeWidgets();
    widgetParms.setParameterChoices(deviceTypes);
    actionSettingsLayout.topControl = frameParms;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) Font(org.eclipse.swt.graphics.Font) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 3 with Font

use of org.eclipse.swt.graphics.Font in project GT by Tencent.

the class SettingView method createMemTabItem.

/**
	 * 为了迎合兰姐的界面,要求改的好丑啊
	 * @param parent
	 */
private void createMemTabItem(TabFolder parent) {
    TabItem memTabItem = new TabItem(parent, SWT.NONE);
    memTabItem.setText("内存");
    Composite memTabRoot = new Composite(parent, SWT.NONE);
    memTabRoot.setLayout(new FormLayout());
    FormData testPeriodGroupFormData = new FormData();
    testPeriodGroupFormData.left = new FormAttachment(0, Constant.MARGIN_WIDTH);
    testPeriodGroupFormData.right = new FormAttachment(100, -Constant.MARGIN_WIDTH);
    testPeriodGroupFormData.top = new FormAttachment(memTabRoot, Constant.MARGIN_WIDTH_NARROW);
    Group periodGroup = new Group(memTabRoot, SWT.NONE);
    periodGroup.setLayoutData(testPeriodGroupFormData);
    periodGroup.setLayout(new FillLayout(SWT.HORIZONTAL));
    Label memLabel = new Label(periodGroup, SWT.NONE);
    memLabel.setText("采样间隔(ms)");
    itemTestPeriod[Constant.MEM_INDEX] = new Text(periodGroup, SWT.BORDER);
    itemTestPeriod[Constant.MEM_INDEX].setText("3000");
    itemTestPeriod[Constant.MEM_INDEX].addVerifyListener(new SWTNumberVerifyListener());
    itemTestPeriod[Constant.MEM_INDEX].addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            APTState.getInstance().DealWithEventBefore(APTEventEnum.CONFIGRURE_OPER);
            APTState.getInstance().DealWithEventAfter(APTEventEnum.CONFIGRURE_OPER);
        }
    });
    FormData hprofDumpSwitchGroupFormData = new FormData();
    hprofDumpSwitchGroupFormData.left = new FormAttachment(0, Constant.MARGIN_WIDTH);
    hprofDumpSwitchGroupFormData.right = new FormAttachment(100, -Constant.MARGIN_WIDTH);
    hprofDumpSwitchGroupFormData.top = new FormAttachment(periodGroup, Constant.MARGIN_WIDTH_NARROW);
    Group hprofDumpSwitchGroup = new Group(memTabRoot, SWT.NONE);
    hprofDumpSwitchGroup.setLayoutData(hprofDumpSwitchGroupFormData);
    hprofDumpSwitchGroup.setLayout(new FillLayout(SWT.HORIZONTAL));
    Label hprofDumpLabel = new Label(hprofDumpSwitchGroup, SWT.NONE);
    hprofDumpLabel.setText("Dump Hprof");
    hprofDumpSwitch = new Combo(hprofDumpSwitchGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
    hprofDumpSwitch.setItems(new String[] { "否", "是" });
    hprofDumpSwitch.select(0);
    hprofDumpSwitch.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
        //				APTState.getInstance().DealWithEventBefore(APTEventEnum.CONFIGRURE_OPER);
        //				APTState.getInstance().DealWithEventAfter(APTEventEnum.CONFIGRURE_OPER);
        }
    });
    FormData hprofDumpThresholdGroupFormData = new FormData();
    hprofDumpThresholdGroupFormData.left = new FormAttachment(0, Constant.MARGIN_WIDTH);
    hprofDumpThresholdGroupFormData.right = new FormAttachment(100, -Constant.MARGIN_WIDTH);
    hprofDumpThresholdGroupFormData.top = new FormAttachment(hprofDumpSwitchGroup, Constant.MARGIN_WIDTH_NARROW);
    Group hrpofDumpThresholdGroup = new Group(memTabRoot, SWT.NONE);
    hrpofDumpThresholdGroup.setLayoutData(hprofDumpThresholdGroupFormData);
    hrpofDumpThresholdGroup.setLayout(new FillLayout(SWT.HORIZONTAL));
    Label hprofDumpThresholdLabel = new Label(hrpofDumpThresholdGroup, SWT.NONE);
    hprofDumpThresholdLabel.setText("Dump阈值(kB)");
    hprofDumpThreshold = new Text(hrpofDumpThresholdGroup, SWT.BORDER);
    hprofDumpThreshold.setText("30000");
    hprofDumpThreshold.addVerifyListener(new SWTNumberVerifyListener());
    hprofDumpThreshold.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            APTState.getInstance().DealWithEventBefore(APTEventEnum.CONFIGRURE_OPER);
            APTState.getInstance().DealWithEventAfter(APTEventEnum.CONFIGRURE_OPER);
        }
    });
    //Priv Dirty Group
    FormData privGroupFormData = new FormData();
    privGroupFormData.left = new FormAttachment(0, Constant.MARGIN_WIDTH);
    privGroupFormData.right = new FormAttachment(100, -Constant.MARGIN_WIDTH);
    privGroupFormData.top = new FormAttachment(hrpofDumpThresholdGroup, Constant.MARGIN_WIDTH_NARROW);
    Group privGroup = new Group(memTabRoot, SWT.NONE);
    privGroup.setText("Priv Dirty");
    privGroup.setLayoutData(privGroupFormData);
    privGroup.setLayout(new GridLayout(3, true));
    //PSS Group
    FormData pssGroupFormData = new FormData();
    pssGroupFormData.left = new FormAttachment(0, Constant.MARGIN_WIDTH);
    pssGroupFormData.right = new FormAttachment(100, -Constant.MARGIN_WIDTH);
    pssGroupFormData.top = new FormAttachment(privGroup, Constant.MARGIN_WIDTH_NARROW);
    Group pssGroup = new Group(memTabRoot, SWT.NONE);
    pssGroup.setText("PSS");
    pssGroup.setLayoutData(pssGroupFormData);
    pssGroup.setLayout(new GridLayout(3, true));
    //Heap Allocated Group
    FormData heapGroupFormData = new FormData();
    heapGroupFormData.left = new FormAttachment(0, Constant.MARGIN_WIDTH);
    heapGroupFormData.right = new FormAttachment(100, -Constant.MARGIN_WIDTH);
    heapGroupFormData.top = new FormAttachment(pssGroup, Constant.MARGIN_WIDTH_NARROW);
    Group heapGroup = new Group(memTabRoot, SWT.NONE);
    heapGroup.setText("Heap Allocated");
    heapGroup.setLayoutData(heapGroupFormData);
    heapGroup.setLayout(new GridLayout(3, true));
    //Heap Size Group
    FormData heapsizeGroupFormData = new FormData();
    heapsizeGroupFormData.left = new FormAttachment(0, Constant.MARGIN_WIDTH);
    heapsizeGroupFormData.right = new FormAttachment(100, -Constant.MARGIN_WIDTH);
    heapsizeGroupFormData.top = new FormAttachment(heapGroup, Constant.MARGIN_WIDTH_NARROW);
    Group heapsizeGroup = new Group(memTabRoot, SWT.NONE);
    heapsizeGroup.setText("Heap Size");
    heapsizeGroup.setLayoutData(heapsizeGroupFormData);
    heapsizeGroup.setLayout(new GridLayout(3, true));
    memStatCheckBtns = new Button[Constant.ALL_MEM_KIND_COUNT];
    for (int i = 0; i < Constant.ALL_MEM_KIND_COUNT; i++) {
        Group group = null;
        if (i < 3) {
            group = privGroup;
        } else if (i < 6) {
            group = pssGroup;
        } else if (i < 9) {
            group = heapGroup;
        } else {
            group = heapsizeGroup;
        }
        //final int index = i;
        memStatCheckBtns[i] = new Button(group, SWT.CHECK);
        memStatCheckBtns[i].setText(memStatCheckBtnTitles[i]);
        memStatCheckBtns[i].addSelectionListener(new SelectionListener() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                if (isSupportCheckChangeOper) {
                    //APTConsoleFactory.getInstance().APTPrint("内存check更新");
                    GetCurCheckedStateUtil.update();
                }
            }

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
            }
        });
    }
    //memStatCheckBtns[Constant.PRIV_TOTAL_INDEX].setSelection(true);
    memStatCheckBtns[Constant.PSS_TOTAL_INDEX].setSelection(true);
    //memStatCheckBtns[Constant.HEAPALLOC_TOTAL_INDEX].setSelection(true);
    FormData labelFormData = new FormData();
    labelFormData.left = new FormAttachment(0, Constant.MARGIN_WIDTH);
    labelFormData.right = new FormAttachment(100, -Constant.MARGIN_WIDTH);
    labelFormData.bottom = new FormAttachment(100, -Constant.MARGIN_WIDTH);
    Label showLabel = new Label(memTabRoot, SWT.NONE);
    showLabel.setLayoutData(labelFormData);
    showLabel.setText("提示:测试过程中可动态调整曲线显示");
    showLabel.setForeground(new Color(parent.getDisplay(), 0, 64, 64));
    showLabel.setFont(new Font(parent.getDisplay(), "宋体", 10, SWT.BOLD));
    memTabItem.setControl(memTabRoot);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) Color(org.eclipse.swt.graphics.Color) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) FillLayout(org.eclipse.swt.layout.FillLayout) Font(org.eclipse.swt.graphics.Font) TabItem(org.eclipse.swt.widgets.TabItem) ModifyEvent(org.eclipse.swt.events.ModifyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SWTNumberVerifyListener(com.tencent.wstt.apt.ui.custom.SWTNumberVerifyListener) FormAttachment(org.eclipse.swt.layout.FormAttachment) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 4 with Font

use of org.eclipse.swt.graphics.Font in project GT by Tencent.

the class PMAPView method createToolGroup.

/**
	 * 初始化工具条
	 * @param parent
	 */
private void createToolGroup(Composite parent) {
    FormData toolBarGroupFromData = new FormData();
    toolBarGroupFromData.top = new FormAttachment(0, 5);
    toolBarGroupFromData.left = new FormAttachment(0, 5);
    toolBarGroupFromData.right = new FormAttachment(100, -5);
    //绝对位置
    toolBarGroupFromData.bottom = new FormAttachment(parent, 50);
    toolGroup = new Group(parent, SWT.NONE);
    toolGroup.setLayoutData(toolBarGroupFromData);
    toolGroup.setLayout(new FillLayout(SWT.HORIZONTAL));
    Label label = new Label(toolGroup, SWT.NONE | SWT.BOLD);
    label.setText("饼图中显示数据项个数");
    label.setFont(new Font(parent.getDisplay(), "宋体", 10, SWT.BOLD));
    showDataItemCountText = new Text(toolGroup, SWT.BORDER);
    showDataItemCountText.setText("10");
}
Also used : FormData(org.eclipse.swt.layout.FormData) Group(org.eclipse.swt.widgets.Group) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) FillLayout(org.eclipse.swt.layout.FillLayout) FormAttachment(org.eclipse.swt.layout.FormAttachment) Font(org.eclipse.swt.graphics.Font)

Example 5 with Font

use of org.eclipse.swt.graphics.Font in project OpenGrok by OpenGrok.

the class TextUtils method makeEditable.

public static void makeEditable(Text text) {
    Object isdefault = text.getData("default");
    if (isdefault != null && (Boolean) isdefault == true) {
        text.setForeground(new Color(null, 0x00, 0x00, 0x00));
        text.setText("");
        FontData fontData = text.getFont().getFontData()[0];
        Font font = new Font(Display.getCurrent(), new FontData(fontData.getName(), fontData.getHeight(), SWT.NORMAL));
        text.setFont(font);
        text.setData("default", false);
    }
}
Also used : Color(org.eclipse.swt.graphics.Color) FontData(org.eclipse.swt.graphics.FontData) Font(org.eclipse.swt.graphics.Font)

Aggregations

Font (org.eclipse.swt.graphics.Font)113 FontData (org.eclipse.swt.graphics.FontData)38 Composite (org.eclipse.swt.widgets.Composite)29 GridData (org.eclipse.swt.layout.GridData)27 GridLayout (org.eclipse.swt.layout.GridLayout)25 Color (org.eclipse.swt.graphics.Color)20 Label (org.eclipse.swt.widgets.Label)17 Point (org.eclipse.swt.graphics.Point)14 SelectionEvent (org.eclipse.swt.events.SelectionEvent)11 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)10 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)9 FormData (org.eclipse.swt.layout.FormData)9 Text (org.eclipse.swt.widgets.Text)9 Rectangle (org.eclipse.swt.graphics.Rectangle)8 FormAttachment (org.eclipse.swt.layout.FormAttachment)8 Button (org.eclipse.swt.widgets.Button)8 StyledText (org.eclipse.swt.custom.StyledText)6 CLabel (org.eclipse.swt.custom.CLabel)5 FillLayout (org.eclipse.swt.layout.FillLayout)5 ColorStyledText (org.talend.commons.ui.swt.colorstyledtext.ColorStyledText)5