Search in sources :

Example 16 with FontDialog

use of org.eclipse.swt.widgets.FontDialog in project pentaho-kettle by pentaho.

the class EnterOptionsDialog method addLookTab.

private void addLookTab() {
    int h = 40;
    // ////////////////////////
    // START OF LOOK TAB///
    // /
    wLookTab = new CTabItem(wTabFolder, SWT.NONE);
    wLookTab.setText(BaseMessages.getString(PKG, "EnterOptionsDialog.LookAndFeel.Label"));
    sLookComp = new ScrolledComposite(wTabFolder, SWT.V_SCROLL | SWT.H_SCROLL);
    sLookComp.setLayout(new FillLayout());
    wLookComp = new Composite(sLookComp, SWT.NONE);
    props.setLook(wLookComp);
    FormLayout lookLayout = new FormLayout();
    lookLayout.marginWidth = 3;
    lookLayout.marginHeight = 3;
    wLookComp.setLayout(lookLayout);
    // Fixed font
    int nr = 0;
    Label wlFFont = new Label(wLookComp, SWT.RIGHT);
    wlFFont.setText(BaseMessages.getString(PKG, "EnterOptionsDialog.FixedWidthFont.Label"));
    props.setLook(wlFFont);
    FormData fdlFFont = new FormData();
    fdlFFont.left = new FormAttachment(0, 0);
    fdlFFont.right = new FormAttachment(middle, -margin);
    fdlFFont.top = new FormAttachment(0, nr * h + margin + 10);
    wlFFont.setLayoutData(fdlFFont);
    wdFFont = new Button(wLookComp, SWT.PUSH | SWT.CENTER);
    props.setLook(wdFFont);
    FormData fddFFont = layoutResetOptionButton(wdFFont);
    fddFFont.right = new FormAttachment(100, 0);
    fddFFont.top = new FormAttachment(0, nr * h + margin);
    fddFFont.bottom = new FormAttachment(0, (nr + 1) * h + margin);
    wdFFont.setLayoutData(fddFFont);
    wdFFont.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            fixedFontData = new FontData(PropsUI.getInstance().getFixedFont().getName(), PropsUI.getInstance().getFixedFont().getHeight(), PropsUI.getInstance().getFixedFont().getStyle());
            fixedFont.dispose();
            fixedFont = new Font(display, fixedFontData);
            wFFont.redraw();
        }
    });
    wbFFont = new Button(wLookComp, SWT.PUSH);
    props.setLook(wbFFont);
    FormData fdbFFont = layoutEditOptionButton(wbFFont);
    fdbFFont.right = new FormAttachment(wdFFont, -margin);
    fdbFFont.top = new FormAttachment(0, nr * h + margin);
    fdbFFont.bottom = new FormAttachment(0, (nr + 1) * h + margin);
    wbFFont.setLayoutData(fdbFFont);
    wbFFont.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            FontDialog fd = new FontDialog(shell);
            fd.setFontList(new FontData[] { fixedFontData });
            FontData newfd = fd.open();
            if (newfd != null) {
                fixedFontData = newfd;
                fixedFont.dispose();
                fixedFont = new Font(display, fixedFontData);
                wFFont.redraw();
            }
        }
    });
    wFFont = new Canvas(wLookComp, SWT.BORDER);
    props.setLook(wFFont);
    FormData fdFFont = new FormData();
    fdFFont.left = new FormAttachment(middle, 0);
    fdFFont.right = new FormAttachment(wbFFont, -margin);
    fdFFont.top = new FormAttachment(0, margin);
    fdFFont.bottom = new FormAttachment(0, h);
    wFFont.setLayoutData(fdFFont);
    wFFont.addPaintListener(new PaintListener() {

        public void paintControl(PaintEvent pe) {
            pe.gc.setFont(fixedFont);
            Rectangle max = wFFont.getBounds();
            String name = fixedFontData.getName() + " - " + fixedFontData.getHeight();
            Point size = pe.gc.textExtent(name);
            pe.gc.drawText(name, (max.width - size.x) / 2, (max.height - size.y) / 2, true);
        }
    });
    // Graph font
    nr++;
    Label wlGFont = new Label(wLookComp, SWT.RIGHT);
    wlGFont.setText(BaseMessages.getString(PKG, "EnterOptionsDialog.GraphFont.Label"));
    props.setLook(wlGFont);
    FormData fdlGFont = new FormData();
    fdlGFont.left = new FormAttachment(0, 0);
    fdlGFont.right = new FormAttachment(middle, -margin);
    fdlGFont.top = new FormAttachment(0, nr * h + margin + 10);
    wlGFont.setLayoutData(fdlGFont);
    wdGFont = new Button(wLookComp, SWT.PUSH);
    props.setLook(wdGFont);
    FormData fddGFont = layoutResetOptionButton(wdGFont);
    fddGFont.right = new FormAttachment(100, 0);
    fddGFont.top = new FormAttachment(0, nr * h + margin);
    fddGFont.bottom = new FormAttachment(0, (nr + 1) * h + margin);
    wdGFont.setLayoutData(fddGFont);
    wdGFont.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            graphFont.dispose();
            graphFontData = props.getDefaultFontData();
            graphFont = new Font(display, graphFontData);
            wGFont.redraw();
        }
    });
    wbGFont = new Button(wLookComp, SWT.PUSH);
    props.setLook(wbGFont);
    FormData fdbGFont = layoutEditOptionButton(wbGFont);
    fdbGFont.right = new FormAttachment(wdGFont, -margin);
    fdbGFont.top = new FormAttachment(0, nr * h + margin);
    fdbGFont.bottom = new FormAttachment(0, (nr + 1) * h + margin);
    wbGFont.setLayoutData(fdbGFont);
    wbGFont.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            FontDialog fd = new FontDialog(shell);
            fd.setFontList(new FontData[] { graphFontData });
            FontData newfd = fd.open();
            if (newfd != null) {
                graphFontData = newfd;
                graphFont.dispose();
                graphFont = new Font(display, graphFontData);
                wGFont.redraw();
            }
        }
    });
    wGFont = new Canvas(wLookComp, SWT.BORDER);
    props.setLook(wGFont);
    FormData fdGFont = new FormData();
    fdGFont.left = new FormAttachment(middle, 0);
    fdGFont.right = new FormAttachment(wbGFont, -margin);
    fdGFont.top = new FormAttachment(0, nr * h + margin);
    fdGFont.bottom = new FormAttachment(0, (nr + 1) * h + margin);
    wGFont.setLayoutData(fdGFont);
    wGFont.addPaintListener(new PaintListener() {

        public void paintControl(PaintEvent pe) {
            pe.gc.setFont(graphFont);
            Rectangle max = wGFont.getBounds();
            String name = graphFontData.getName() + " - " + graphFontData.getHeight();
            Point size = pe.gc.textExtent(name);
            pe.gc.drawText(name, (max.width - size.x) / 2, (max.height - size.y) / 2, true);
        }
    });
    // Note font
    nr++;
    Label wlNFont = new Label(wLookComp, SWT.RIGHT);
    wlNFont.setText(BaseMessages.getString(PKG, "EnterOptionsDialog.NoteFont.Label"));
    props.setLook(wlNFont);
    FormData fdlNFont = new FormData();
    fdlNFont.left = new FormAttachment(0, 0);
    fdlNFont.right = new FormAttachment(middle, -margin);
    fdlNFont.top = new FormAttachment(0, nr * h + margin + 10);
    wlNFont.setLayoutData(fdlNFont);
    wdNFont = new Button(wLookComp, SWT.PUSH);
    props.setLook(wdNFont);
    FormData fddNFont = layoutResetOptionButton(wdNFont);
    fddNFont.right = new FormAttachment(100, 0);
    fddNFont.top = new FormAttachment(0, nr * h + margin);
    fddNFont.bottom = new FormAttachment(0, (nr + 1) * h + margin);
    wdNFont.setLayoutData(fddNFont);
    wdNFont.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            noteFontData = props.getDefaultFontData();
            noteFont.dispose();
            noteFont = new Font(display, noteFontData);
            wNFont.redraw();
        }
    });
    wbNFont = new Button(wLookComp, SWT.PUSH);
    props.setLook(wbNFont);
    FormData fdbNFont = layoutEditOptionButton(wbNFont);
    fdbNFont.right = new FormAttachment(wdNFont, -margin);
    fdbNFont.top = new FormAttachment(0, nr * h + margin);
    fdbNFont.bottom = new FormAttachment(0, (nr + 1) * h + margin);
    wbNFont.setLayoutData(fdbNFont);
    wbNFont.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            FontDialog fd = new FontDialog(shell);
            fd.setFontList(new FontData[] { noteFontData });
            FontData newfd = fd.open();
            if (newfd != null) {
                noteFontData = newfd;
                noteFont.dispose();
                noteFont = new Font(display, noteFontData);
                wNFont.redraw();
            }
        }
    });
    wNFont = new Canvas(wLookComp, SWT.BORDER);
    props.setLook(wNFont);
    FormData fdNFont = new FormData();
    fdNFont.left = new FormAttachment(middle, 0);
    fdNFont.right = new FormAttachment(wbNFont, -margin);
    fdNFont.top = new FormAttachment(0, nr * h + margin);
    fdNFont.bottom = new FormAttachment(0, (nr + 1) * h + margin);
    wNFont.setLayoutData(fdNFont);
    wNFont.addPaintListener(new PaintListener() {

        public void paintControl(PaintEvent pe) {
            pe.gc.setFont(noteFont);
            Rectangle max = wNFont.getBounds();
            String name = noteFontData.getName() + " - " + noteFontData.getHeight();
            Point size = pe.gc.textExtent(name);
            pe.gc.drawText(name, (max.width - size.x) / 2, (max.height - size.y) / 2, true);
        }
    });
    // Background color
    nr++;
    Label wlBGColor = new Label(wLookComp, SWT.RIGHT);
    wlBGColor.setText(BaseMessages.getString(PKG, "EnterOptionsDialog.BackgroundColor.Label"));
    props.setLook(wlBGColor);
    FormData fdlBGColor = new FormData();
    fdlBGColor.left = new FormAttachment(0, 0);
    fdlBGColor.right = new FormAttachment(middle, -margin);
    fdlBGColor.top = new FormAttachment(0, nr * h + margin + 10);
    wlBGColor.setLayoutData(fdlBGColor);
    wdBGcolor = new Button(wLookComp, SWT.PUSH);
    props.setLook(wdBGcolor);
    FormData fddBGColor = layoutResetOptionButton(wdBGcolor);
    // to the right of the
    fddBGColor.right = new FormAttachment(100, 0);
    // dialog
    fddBGColor.top = new FormAttachment(0, nr * h + margin);
    fddBGColor.bottom = new FormAttachment(0, (nr + 1) * h + margin);
    wdBGcolor.setLayoutData(fddBGColor);
    wdBGcolor.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            background.dispose();
            backgroundRGB = new RGB(ConstUI.COLOR_BACKGROUND_RED, ConstUI.COLOR_BACKGROUND_GREEN, ConstUI.COLOR_BACKGROUND_BLUE);
            background = new Color(display, backgroundRGB);
            wBGColor.setBackground(background);
            wBGColor.redraw();
        }
    });
    wbBGColor = new Button(wLookComp, SWT.PUSH);
    props.setLook(wbBGColor);
    FormData fdbBGColor = layoutEditOptionButton(wbBGColor);
    // to the
    fdbBGColor.right = new FormAttachment(wdBGcolor, -margin);
    // left of
    // the
    // "default"
    // button
    fdbBGColor.top = new FormAttachment(0, nr * h + margin);
    fdbBGColor.bottom = new FormAttachment(0, (nr + 1) * h + margin);
    wbBGColor.setLayoutData(fdbBGColor);
    wbBGColor.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            ColorDialog cd = new ColorDialog(shell);
            cd.setRGB(props.getBackgroundRGB());
            RGB newbg = cd.open();
            if (newbg != null) {
                backgroundRGB = newbg;
                background.dispose();
                background = new Color(display, backgroundRGB);
                wBGColor.setBackground(background);
                wBGColor.redraw();
            }
        }
    });
    wBGColor = new Canvas(wLookComp, SWT.BORDER);
    props.setLook(wBGColor);
    wBGColor.setBackground(background);
    FormData fdBGColor = new FormData();
    fdBGColor.left = new FormAttachment(middle, 0);
    fdBGColor.right = new FormAttachment(wbBGColor, -margin);
    fdBGColor.top = new FormAttachment(0, nr * h + margin);
    fdBGColor.bottom = new FormAttachment(0, (nr + 1) * h + margin);
    wBGColor.setLayoutData(fdBGColor);
    // Graph background color
    nr++;
    Label wlGrColor = new Label(wLookComp, SWT.RIGHT);
    wlGrColor.setText(BaseMessages.getString(PKG, "EnterOptionsDialog.BackgroundColorGraph.Label"));
    props.setLook(wlGrColor);
    FormData fdlGrColor = new FormData();
    fdlGrColor.left = new FormAttachment(0, 0);
    fdlGrColor.right = new FormAttachment(middle, -margin);
    fdlGrColor.top = new FormAttachment(0, nr * h + margin + 10);
    wlGrColor.setLayoutData(fdlGrColor);
    wdGrColor = new Button(wLookComp, SWT.PUSH);
    props.setLook(wdGrColor);
    FormData fddGrColor = layoutResetOptionButton(wdGrColor);
    fddGrColor.right = new FormAttachment(100, 0);
    fddGrColor.top = new FormAttachment(0, nr * h + margin);
    fddGrColor.bottom = new FormAttachment(0, (nr + 1) * h + margin);
    wdGrColor.setLayoutData(fddGrColor);
    wdGrColor.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            graphColor.dispose();
            graphColorRGB = new RGB(ConstUI.COLOR_GRAPH_RED, ConstUI.COLOR_GRAPH_GREEN, ConstUI.COLOR_GRAPH_BLUE);
            graphColor = new Color(display, graphColorRGB);
            wGrColor.setBackground(graphColor);
            wGrColor.redraw();
        }
    });
    wbGrColor = new Button(wLookComp, SWT.PUSH);
    props.setLook(wbGrColor);
    FormData fdbGrColor = layoutEditOptionButton(wbGrColor);
    fdbGrColor.right = new FormAttachment(wdGrColor, -margin);
    fdbGrColor.top = new FormAttachment(0, nr * h + margin);
    fdbGrColor.bottom = new FormAttachment(0, (nr + 1) * h + margin);
    wbGrColor.setLayoutData(fdbGrColor);
    wbGrColor.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            ColorDialog cd = new ColorDialog(shell);
            cd.setRGB(props.getGraphColorRGB());
            RGB newbg = cd.open();
            if (newbg != null) {
                graphColorRGB = newbg;
                graphColor.dispose();
                graphColor = new Color(display, graphColorRGB);
                wGrColor.setBackground(graphColor);
                wGrColor.redraw();
            }
        }
    });
    wGrColor = new Canvas(wLookComp, SWT.BORDER);
    props.setLook(wGrColor);
    wGrColor.setBackground(graphColor);
    FormData fdGrColor = new FormData();
    fdGrColor.left = new FormAttachment(middle, 0);
    fdGrColor.right = new FormAttachment(wbGrColor, -margin);
    fdGrColor.top = new FormAttachment(0, nr * h + margin);
    fdGrColor.bottom = new FormAttachment(0, (nr + 1) * h + margin);
    wGrColor.setLayoutData(fdGrColor);
    // Tab selected color
    nr++;
    Label wlTabColor = new Label(wLookComp, SWT.RIGHT);
    wlTabColor.setText(BaseMessages.getString(PKG, "EnterOptionsDialog.TabColor.Label"));
    props.setLook(wlTabColor);
    FormData fdlTabColor = new FormData();
    fdlTabColor.left = new FormAttachment(0, 0);
    fdlTabColor.right = new FormAttachment(middle, -margin);
    fdlTabColor.top = new FormAttachment(0, nr * h + margin + 10);
    wlTabColor.setLayoutData(fdlTabColor);
    wdTabColor = new Button(wLookComp, SWT.PUSH | SWT.CENTER);
    props.setLook(wdTabColor);
    FormData fddTabColor = layoutResetOptionButton(wdTabColor);
    fddTabColor.right = new FormAttachment(100, 0);
    fddTabColor.top = new FormAttachment(0, nr * h + margin);
    fddTabColor.bottom = new FormAttachment(0, (nr + 1) * h + margin);
    wdTabColor.setLayoutData(fddTabColor);
    wdTabColor.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            tabColor.dispose();
            tabColorRGB = new RGB(ConstUI.COLOR_TAB_RED, ConstUI.COLOR_TAB_GREEN, ConstUI.COLOR_TAB_BLUE);
            tabColor = new Color(display, tabColorRGB);
            wTabColor.setBackground(tabColor);
            wTabColor.redraw();
        }
    });
    wbTabColor = new Button(wLookComp, SWT.PUSH);
    props.setLook(wbTabColor);
    FormData fdbTabColor = layoutEditOptionButton(wbTabColor);
    fdbTabColor.right = new FormAttachment(wdTabColor, -margin);
    fdbTabColor.top = new FormAttachment(0, nr * h + margin);
    fdbTabColor.bottom = new FormAttachment(0, (nr + 1) * h + margin);
    wbTabColor.setLayoutData(fdbTabColor);
    wbTabColor.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            ColorDialog cd = new ColorDialog(shell);
            cd.setRGB(props.getTabColorRGB());
            RGB newbg = cd.open();
            if (newbg != null) {
                tabColorRGB = newbg;
                tabColor.dispose();
                tabColor = new Color(display, tabColorRGB);
                wTabColor.setBackground(tabColor);
                wTabColor.redraw();
            }
        }
    });
    wTabColor = new Canvas(wLookComp, SWT.BORDER);
    props.setLook(wTabColor);
    wTabColor.setBackground(tabColor);
    FormData fdTabColor = new FormData();
    fdTabColor.left = new FormAttachment(middle, 0);
    fdTabColor.right = new FormAttachment(wbTabColor, -margin);
    fdTabColor.top = new FormAttachment(0, nr * h + margin);
    fdTabColor.bottom = new FormAttachment(0, (nr + 1) * h + margin);
    wTabColor.setLayoutData(fdTabColor);
    // Iconsize line
    Label wlIconsize = new Label(wLookComp, SWT.RIGHT);
    wlIconsize.setText(BaseMessages.getString(PKG, "EnterOptionsDialog.IconSize.Label"));
    props.setLook(wlIconsize);
    FormData fdlIconsize = new FormData();
    fdlIconsize.left = new FormAttachment(0, 0);
    fdlIconsize.right = new FormAttachment(middle, -margin);
    fdlIconsize.top = new FormAttachment(wTabColor, margin);
    wlIconsize.setLayoutData(fdlIconsize);
    wIconsize = new Text(wLookComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wIconsize.setText(Integer.toString(props.getIconSize()));
    props.setLook(wIconsize);
    FormData fdIconsize = new FormData();
    fdIconsize.left = new FormAttachment(middle, 0);
    fdIconsize.right = new FormAttachment(100, -margin);
    fdIconsize.top = new FormAttachment(wTabColor, margin);
    wIconsize.setLayoutData(fdIconsize);
    // LineWidth line
    Label wlLineWidth = new Label(wLookComp, SWT.RIGHT);
    wlLineWidth.setText(BaseMessages.getString(PKG, "EnterOptionsDialog.LineWidth.Label"));
    props.setLook(wlLineWidth);
    FormData fdlLineWidth = new FormData();
    fdlLineWidth.left = new FormAttachment(0, 0);
    fdlLineWidth.right = new FormAttachment(middle, -margin);
    fdlLineWidth.top = new FormAttachment(wIconsize, margin);
    wlLineWidth.setLayoutData(fdlLineWidth);
    wLineWidth = new Text(wLookComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wLineWidth.setText(Integer.toString(props.getLineWidth()));
    props.setLook(wLineWidth);
    FormData fdLineWidth = new FormData();
    fdLineWidth.left = new FormAttachment(middle, 0);
    fdLineWidth.right = new FormAttachment(100, -margin);
    fdLineWidth.top = new FormAttachment(wIconsize, margin);
    wLineWidth.setLayoutData(fdLineWidth);
    // ShadowSize line
    Label wlShadowSize = new Label(wLookComp, SWT.RIGHT);
    wlShadowSize.setText(BaseMessages.getString(PKG, "EnterOptionsDialog.ShadowSize.Label"));
    props.setLook(wlShadowSize);
    FormData fdlShadowSize = new FormData();
    fdlShadowSize.left = new FormAttachment(0, 0);
    fdlShadowSize.right = new FormAttachment(middle, -margin);
    fdlShadowSize.top = new FormAttachment(wLineWidth, margin);
    wlShadowSize.setLayoutData(fdlShadowSize);
    wShadowSize = new Text(wLookComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wShadowSize.setText(Integer.toString(props.getShadowSize()));
    props.setLook(wShadowSize);
    FormData fdShadowSize = new FormData();
    fdShadowSize.left = new FormAttachment(middle, 0);
    fdShadowSize.right = new FormAttachment(100, -margin);
    fdShadowSize.top = new FormAttachment(wLineWidth, margin);
    wShadowSize.setLayoutData(fdShadowSize);
    // MiddlePct line
    Label wlMiddlePct = new Label(wLookComp, SWT.RIGHT);
    wlMiddlePct.setText(BaseMessages.getString(PKG, "EnterOptionsDialog.DialogMiddlePercentage.Label"));
    props.setLook(wlMiddlePct);
    FormData fdlMiddlePct = new FormData();
    fdlMiddlePct.left = new FormAttachment(0, 0);
    fdlMiddlePct.right = new FormAttachment(middle, -margin);
    fdlMiddlePct.top = new FormAttachment(wShadowSize, margin);
    wlMiddlePct.setLayoutData(fdlMiddlePct);
    wMiddlePct = new Text(wLookComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wMiddlePct.setText(Integer.toString(props.getMiddlePct()));
    props.setLook(wMiddlePct);
    FormData fdMiddlePct = new FormData();
    fdMiddlePct.left = new FormAttachment(middle, 0);
    fdMiddlePct.right = new FormAttachment(100, -margin);
    fdMiddlePct.top = new FormAttachment(wShadowSize, margin);
    wMiddlePct.setLayoutData(fdMiddlePct);
    // GridSize line
    Label wlGridSize = new Label(wLookComp, SWT.RIGHT);
    wlGridSize.setText(BaseMessages.getString(PKG, "EnterOptionsDialog.GridSize.Label"));
    wlGridSize.setToolTipText(BaseMessages.getString(PKG, "EnterOptionsDialog.GridSize.ToolTip"));
    props.setLook(wlGridSize);
    FormData fdlGridSize = new FormData();
    fdlGridSize.left = new FormAttachment(0, 0);
    fdlGridSize.right = new FormAttachment(middle, -margin);
    fdlGridSize.top = new FormAttachment(wMiddlePct, margin);
    wlGridSize.setLayoutData(fdlGridSize);
    wGridSize = new Text(wLookComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wGridSize.setText(Integer.toString(props.getCanvasGridSize()));
    wGridSize.setToolTipText(BaseMessages.getString(PKG, "EnterOptionsDialog.GridSize.ToolTip"));
    props.setLook(wGridSize);
    FormData fdGridSize = new FormData();
    fdGridSize.left = new FormAttachment(middle, 0);
    fdGridSize.right = new FormAttachment(100, -margin);
    fdGridSize.top = new FormAttachment(wMiddlePct, margin);
    wGridSize.setLayoutData(fdGridSize);
    // Show Canvas Grid
    Label wlShowCanvasGrid = new Label(wLookComp, SWT.RIGHT);
    wlShowCanvasGrid.setText(BaseMessages.getString(PKG, "EnterOptionsDialog.ShowCanvasGrid.Label"));
    wlShowCanvasGrid.setToolTipText(BaseMessages.getString(PKG, "EnterOptionsDialog.ShowCanvasGrid.ToolTip"));
    props.setLook(wlShowCanvasGrid);
    FormData fdlShowCanvasGrid = new FormData();
    fdlShowCanvasGrid.left = new FormAttachment(0, 0);
    fdlShowCanvasGrid.right = new FormAttachment(middle, -margin);
    fdlShowCanvasGrid.top = new FormAttachment(wGridSize, margin);
    wlShowCanvasGrid.setLayoutData(fdlShowCanvasGrid);
    wShowCanvasGrid = new Button(wLookComp, SWT.CHECK);
    props.setLook(wShowCanvasGrid);
    wShowCanvasGrid.setSelection(props.isShowCanvasGridEnabled());
    FormData fdShowCanvasGrid = new FormData();
    fdShowCanvasGrid.left = new FormAttachment(middle, 0);
    fdShowCanvasGrid.right = new FormAttachment(100, -margin);
    fdShowCanvasGrid.top = new FormAttachment(wGridSize, margin);
    wShowCanvasGrid.setLayoutData(fdShowCanvasGrid);
    // Enable anti-aliasing
    Label wlAntiAlias = new Label(wLookComp, SWT.RIGHT);
    wlAntiAlias.setText(BaseMessages.getString(PKG, "EnterOptionsDialog.CanvasAntiAliasing.Label"));
    props.setLook(wlAntiAlias);
    FormData fdlAntiAlias = new FormData();
    fdlAntiAlias.left = new FormAttachment(0, 0);
    fdlAntiAlias.top = new FormAttachment(wShowCanvasGrid, margin);
    fdlAntiAlias.right = new FormAttachment(middle, -margin);
    wlAntiAlias.setLayoutData(fdlAntiAlias);
    wAntiAlias = new Button(wLookComp, SWT.CHECK);
    props.setLook(wAntiAlias);
    wAntiAlias.setSelection(props.isAntiAliasingEnabled());
    FormData fdAntiAlias = new FormData();
    fdAntiAlias.left = new FormAttachment(middle, 0);
    fdAntiAlias.top = new FormAttachment(wShowCanvasGrid, margin);
    fdAntiAlias.right = new FormAttachment(100, 0);
    wAntiAlias.setLayoutData(fdAntiAlias);
    // Enable anti-aliasing
    Label wlIndicateSlowSteps = new Label(wLookComp, SWT.RIGHT);
    wlIndicateSlowSteps.setText(BaseMessages.getString(PKG, "EnterOptionsDialog.CanvasIndicateSlowSteps.Label"));
    props.setLook(wlIndicateSlowSteps);
    FormData fdlIndicateSlowSteps = new FormData();
    fdlIndicateSlowSteps.left = new FormAttachment(0, 0);
    fdlIndicateSlowSteps.top = new FormAttachment(wAntiAlias, margin);
    fdlIndicateSlowSteps.right = new FormAttachment(middle, -margin);
    wlIndicateSlowSteps.setLayoutData(fdlIndicateSlowSteps);
    wIndicateSlowSteps = new Button(wLookComp, SWT.CHECK);
    props.setLook(wIndicateSlowSteps);
    wIndicateSlowSteps.setSelection(props.isIndicateSlowTransStepsEnabled());
    wIndicateSlowSteps.setToolTipText(BaseMessages.getString(PKG, "EnterOptionsDialog.CanvasIndicateSlowSteps.Tooltip"));
    FormData fdIndicateSlowSteps = new FormData();
    fdIndicateSlowSteps.left = new FormAttachment(middle, 0);
    fdIndicateSlowSteps.top = new FormAttachment(wAntiAlias, margin);
    fdIndicateSlowSteps.right = new FormAttachment(100, 0);
    wIndicateSlowSteps.setLayoutData(fdIndicateSlowSteps);
    // Show original look
    Label wlOriginalLook = new Label(wLookComp, SWT.RIGHT);
    wlOriginalLook.setText(BaseMessages.getString(PKG, "EnterOptionsDialog.UseOSLook.Label"));
    props.setLook(wlOriginalLook);
    FormData fdlOriginalLook = new FormData();
    fdlOriginalLook.left = new FormAttachment(0, 0);
    fdlOriginalLook.top = new FormAttachment(wIndicateSlowSteps, margin);
    fdlOriginalLook.right = new FormAttachment(middle, -margin);
    wlOriginalLook.setLayoutData(fdlOriginalLook);
    wOriginalLook = new Button(wLookComp, SWT.CHECK);
    props.setLook(wOriginalLook);
    wOriginalLook.setSelection(props.isOSLookShown());
    FormData fdOriginalLook = new FormData();
    fdOriginalLook.left = new FormAttachment(middle, 0);
    fdOriginalLook.top = new FormAttachment(wIndicateSlowSteps, margin);
    fdOriginalLook.right = new FormAttachment(100, 0);
    wOriginalLook.setLayoutData(fdOriginalLook);
    // Show branding graphics
    Label wlBranding = new Label(wLookComp, SWT.RIGHT);
    wlBranding.setText(BaseMessages.getString(PKG, "EnterOptionsDialog.Branding.Label"));
    props.setLook(wlBranding);
    FormData fdlBranding = new FormData();
    fdlBranding.left = new FormAttachment(0, 0);
    fdlBranding.top = new FormAttachment(wOriginalLook, margin);
    fdlBranding.right = new FormAttachment(middle, -margin);
    wlBranding.setLayoutData(fdlBranding);
    wBranding = new Button(wLookComp, SWT.CHECK);
    props.setLook(wBranding);
    wBranding.setSelection(props.isBrandingActive());
    FormData fdBranding = new FormData();
    fdBranding.left = new FormAttachment(middle, 0);
    fdBranding.top = new FormAttachment(wOriginalLook, margin);
    fdBranding.right = new FormAttachment(100, 0);
    wBranding.setLayoutData(fdBranding);
    // DefaultLocale line
    Label wlDefaultLocale = new Label(wLookComp, SWT.RIGHT);
    wlDefaultLocale.setText(BaseMessages.getString(PKG, "EnterOptionsDialog.DefaultLocale.Label"));
    props.setLook(wlDefaultLocale);
    FormData fdlDefaultLocale = new FormData();
    fdlDefaultLocale.left = new FormAttachment(0, 0);
    fdlDefaultLocale.right = new FormAttachment(middle, -margin);
    fdlDefaultLocale.top = new FormAttachment(wBranding, margin);
    wlDefaultLocale.setLayoutData(fdlDefaultLocale);
    wDefaultLocale = new Combo(wLookComp, SWT.SINGLE | SWT.READ_ONLY | SWT.LEFT | SWT.BORDER);
    wDefaultLocale.setItems(GlobalMessages.localeDescr);
    wDefaultLocale.setEnabled(!Const.isRunningOnWebspoonMode());
    props.setLook(wDefaultLocale);
    FormData fdDefaultLocale = new FormData();
    fdDefaultLocale.left = new FormAttachment(middle, 0);
    fdDefaultLocale.right = new FormAttachment(100, -margin);
    fdDefaultLocale.top = new FormAttachment(wBranding, margin);
    wDefaultLocale.setLayoutData(fdDefaultLocale);
    // language selections...
    int idxDefault = Const.indexOfString(LanguageChoice.getInstance().getDefaultLocale().toString(), GlobalMessages.localeCodes);
    if (idxDefault >= 0) {
        wDefaultLocale.select(idxDefault);
    }
    fdLookComp = new FormData();
    fdLookComp.left = new FormAttachment(0, 0);
    fdLookComp.right = new FormAttachment(100, 0);
    fdLookComp.top = new FormAttachment(0, 0);
    fdLookComp.bottom = new FormAttachment(100, 100);
    wLookComp.setLayoutData(fdLookComp);
    wLookComp.pack();
    Rectangle bounds = wLookComp.getBounds();
    sLookComp.setContent(wLookComp);
    sLookComp.setExpandHorizontal(true);
    sLookComp.setExpandVertical(true);
    sLookComp.setMinWidth(bounds.width);
    sLookComp.setMinHeight(bounds.height);
    wLookTab.setControl(sLookComp);
// ///////////////////////////////////////////////////////////
// / END OF LOOK TAB
// ///////////////////////////////////////////////////////////
}
Also used : FontDialog(org.eclipse.swt.widgets.FontDialog) Label(org.eclipse.swt.widgets.Label) Rectangle(org.eclipse.swt.graphics.Rectangle) Combo(org.eclipse.swt.widgets.Combo) CTabItem(org.eclipse.swt.custom.CTabItem) Font(org.eclipse.swt.graphics.Font) ColorDialog(org.eclipse.swt.widgets.ColorDialog) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) FormAttachment(org.eclipse.swt.layout.FormAttachment) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) PaintEvent(org.eclipse.swt.events.PaintEvent) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) PaintListener(org.eclipse.swt.events.PaintListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) FontData(org.eclipse.swt.graphics.FontData) Canvas(org.eclipse.swt.widgets.Canvas) Color(org.eclipse.swt.graphics.Color) Text(org.eclipse.swt.widgets.Text) FillLayout(org.eclipse.swt.layout.FillLayout) Point(org.eclipse.swt.graphics.Point) RGB(org.eclipse.swt.graphics.RGB) Point(org.eclipse.swt.graphics.Point)

Example 17 with FontDialog

use of org.eclipse.swt.widgets.FontDialog in project archi by archimatetool.

the class FontChooser method chooseFont.

/**
 * Activate the editor for this selector. This causes the font selection
 * dialog to appear and wait for user input.
 */
public void chooseFont() {
    FontDialog dialog = new FontDialog(getControl().getShell());
    dialog.setText(Messages.FontChooser_3);
    dialog.setFontList(new FontData[] { fFontData });
    dialog.setRGB(fFontRGB);
    FontData selectedFontData = dialog.open();
    if (selectedFontData != null) {
        FontData oldValue = fFontData;
        fFontData = selectedFontData;
        fFontRGB = dialog.getRGB();
        fireActionListenerEvent(PROP_FONTCHANGE, oldValue, fFontData);
        updateButtonText();
    }
}
Also used : FontDialog(org.eclipse.swt.widgets.FontDialog) FontData(org.eclipse.swt.graphics.FontData)

Example 18 with FontDialog

use of org.eclipse.swt.widgets.FontDialog in project archi by archimatetool.

the class FontAction method run.

@Override
public void run() {
    List<?> selection = getSelectedObjects();
    IFontAttribute model = (IFontAttribute) getFirstValidSelectedModelObject(selection);
    if (model == null) {
        return;
    }
    // Set default font on first selected object
    FontData fontData = FontFactory.getDefaultUserViewFontData();
    String rgbValue = null;
    rgbValue = model.getFontColor();
    String fontValue = model.getFont();
    if (fontValue != null) {
        try {
            fontData = new FontData(fontValue);
        } catch (Exception ex) {
        // ex.printStackTrace();
        }
    }
    FontDialog dialog = new FontDialog(getWorkbenchPart().getSite().getShell());
    dialog.setText(Messages.FontAction_1);
    dialog.setFontList(new FontData[] { fontData });
    dialog.setRGB(ColorFactory.convertStringToRGB(rgbValue));
    FontData selectedFontData = dialog.open();
    if (selectedFontData != null) {
        execute(createCommand(selection, selectedFontData, dialog.getRGB()));
    }
}
Also used : FontDialog(org.eclipse.swt.widgets.FontDialog) FontData(org.eclipse.swt.graphics.FontData) IFontAttribute(com.archimatetool.model.IFontAttribute)

Example 19 with FontDialog

use of org.eclipse.swt.widgets.FontDialog in project archi by archimatetool.

the class FontsPreferencePage method openFontDialog.

private FontData openFontDialog(FontInfo fontInfo) {
    FontDialog dialog = new FontDialog(fTableViewer.getControl().getShell());
    dialog.setText(Messages.FontsPreferencePage_3);
    dialog.setFontList(new FontData[] { fontInfo.getFontData() });
    return dialog.open();
}
Also used : FontDialog(org.eclipse.swt.widgets.FontDialog)

Example 20 with FontDialog

use of org.eclipse.swt.widgets.FontDialog in project core by jcryptool.

the class PreferencesPage method createContents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
protected Control createContents(Composite parent) {
    // 
    // Get default or previously selected font
    // 
    fontData = PreferenceConverter.getFontDataArray(getPreferenceStore(), EHEP.PROPERTY_FONT);
    // 
    // Create font dialog
    // 
    fontDialog = new FontDialog(workbench.getActiveWorkbenchWindow().getShell());
    // 
    // Create main panel
    // 
    Composite mainPanel = new Composite(parent, SWT.NULL);
    mainPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    GridLayout innerLayout = new GridLayout();
    innerLayout.numColumns = 1;
    innerLayout.marginHeight = 0;
    innerLayout.marginWidth = 0;
    mainPanel.setLayout(innerLayout);
    // 
    // Create font panel
    // 
    createFontPanel(mainPanel);
    // 
    // Create color panel
    // 
    createColorPanel(mainPanel);
    // 
    // Create Plugin Association panel
    // 
    createPluginAssociationPanel(mainPanel);
    // 
    // Create Misc. panel for Debug & Undo/Redo subpanels
    // 
    Composite miscPanel = new Composite(mainPanel, SWT.NULL);
    miscPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    GridLayout miscLayout = new GridLayout();
    miscLayout.numColumns = 2;
    miscLayout.marginHeight = 0;
    miscLayout.marginWidth = 0;
    miscPanel.setLayout(miscLayout);
    // 
    // Create Debug panel
    // 
    createDebugPanel(miscPanel);
    // 
    // Create Undo panel
    // 
    createUndoPanel(miscPanel);
    return mainPanel;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) FontDialog(org.eclipse.swt.widgets.FontDialog) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData)

Aggregations

FontDialog (org.eclipse.swt.widgets.FontDialog)20 FontData (org.eclipse.swt.graphics.FontData)16 GridData (org.eclipse.swt.layout.GridData)10 GridLayout (org.eclipse.swt.layout.GridLayout)10 Button (org.eclipse.swt.widgets.Button)10 Composite (org.eclipse.swt.widgets.Composite)10 SelectionEvent (org.eclipse.swt.events.SelectionEvent)8 RGB (org.eclipse.swt.graphics.RGB)8 Label (org.eclipse.swt.widgets.Label)8 Text (org.eclipse.swt.widgets.Text)8 ColorDialog (org.eclipse.swt.widgets.ColorDialog)7 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)6 Group (org.eclipse.swt.widgets.Group)5 SWT (org.eclipse.swt.SWT)4 SelectionListener (org.eclipse.swt.events.SelectionListener)4 Font (org.eclipse.swt.graphics.Font)4 FileDialog (org.eclipse.swt.widgets.FileDialog)4 Combo (org.eclipse.swt.widgets.Combo)3 OPIFont (org.csstudio.opibuilder.util.OPIFont)2 ModifyEvent (org.eclipse.swt.events.ModifyEvent)2