Java Code Examples for org.eclipse.swt.graphics.FontData#getHeight()

The following examples show how to use org.eclipse.swt.graphics.FontData#getHeight() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CDateTimePropertyHandler.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private void applyCSSPropertySize(final Control widget, final CSSValue value, final boolean picker) throws Exception {
	if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
		final FontData fd = CSSEngineHelper.getFontData(widget);
		final Measure m = (Measure) value;

		final int newSize = Math.round(m.getFloatValue((short) 0));
		final boolean modified = fd.getHeight() != newSize;
		if (modified) {
			fd.setHeight(newSize);
			if (picker) {
				applyFontForPicker((CDateTime) widget, fd);
			} else {
				applyFont(widget, fd);
			}
		}
	}
}
 
Example 2
Source File: ThemeUIComposite.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private void setDefaultFont(Font newFont) {
	String[] fontIds = { "org.eclipse.jface.textfont",
			"org.eclipse.ui.workbench.texteditor.blockSelectionModeFont" };
	FontData[] newData = newFont.getFontData();
	for (String fontId : fontIds) {
		setFont(fontId, newData);
	}

	newData = newFont.getFontData();
	FontData[] smaller = new FontData[newData.length];
	int j = 0;
	for (FontData fd : newData) {
		int height = fd.getHeight();
		if (height >= 12) {
			fd.setHeight(height - 2);
		} else if (height >= 10) {
			fd.setHeight(height - 1);
		}
		smaller[(j++)] = fd;
	}
	setFont("com.aptana.explorer.font", smaller);
}
 
Example 3
Source File: SeparatorPanel.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public void initComponents(String label) {
       GridLayout gridLayout = new GridLayout(2, false);
	setLayout(gridLayout);
	
	GridData layoutData = new GridData();
	layoutData.grabExcessHorizontalSpace = true;
	layoutData.horizontalAlignment = GridData.FILL;
	setLayoutData(layoutData);

	// Text label
	StyledText gridLinesLabel = new StyledText(this, SWT.NONE);
	gridLinesLabel.setEditable(false);
	Display display = Display.getDefault();
	FontData data = display .getSystemFont().getFontData()[0];
	Font font = new Font(display, data.getName(), data.getHeight(), SWT.BOLD);
	gridLinesLabel.setFont(font);
	gridLinesLabel.setBackground(Display.getCurrent().getSystemColor (SWT.COLOR_WIDGET_BACKGROUND));
	gridLinesLabel.setText(label);

	// Separator line
	Label separator = new Label (this, SWT.SEPARATOR | SWT.HORIZONTAL);
	GridData separatorData = new GridData();
	separatorData.grabExcessHorizontalSpace = true;
	separatorData.horizontalAlignment = GridData.FILL;
	separatorData.horizontalIndent = 5;
	separator.setLayoutData(separatorData);
}
 
Example 4
Source File: FontScalingUtil.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
public static FontData scaleFont(FontData fontData, int style) {
	if (OPERATING_SYSTEM.indexOf("win") == -1 || DiagramActivator.getDefault().getPreferenceStore()
			.getBoolean(StatechartPreferenceConstants.PREF_FONT_SCALING)) {
		return new FontData(fontData.getName(), fontData.getHeight(), fontData.getStyle() | style);
	}
	int DPI = Display.getCurrent().getDPI().y;
	if (DPI != WINDOWS_DEFAULT_DPI) {
		double factor = (double) WINDOWS_DEFAULT_DPI / DPI;
		return new FontData(fontData.getName(), (int) (fontData.getHeight() * factor), fontData.getStyle() | style);
	}
	return new FontData(fontData.getName(), fontData.getHeight(), fontData.getStyle() | style);

}
 
Example 5
Source File: Style.java    From Rel with Apache License 2.0 5 votes vote down vote up
private String getBodyFontStyleString() {
	FontData[] data = Preferences.getPreferenceFont(PreferencePageCmd.CMD_FONT);
	FontData datum = data[0];
	// eliminate leading '.', if there is one
	String fontName = (datum.getName().startsWith(".") ? datum.getName().substring(1) : datum.getName());
	int fullSize = (int)((double)(datum.getHeight() + sizeOffset) * sizeMultiplier);
	int smaller = (int)((double)fullSize * 0.75);
	return 
			"body, p, td, th {font-family: " + fontName + ", sans-serif; font-size: " + fullSize + "pt;}\n" +
			"small {font-family: " + fontName + ", sans-serif; font-size: " + smaller + "pt;}\n";
}
 
Example 6
Source File: SeparatorPanel.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public void initComponents(String label) {
       GridLayout gridLayout = new GridLayout(2, false);
	setLayout(gridLayout);
	
	GridData layoutData = new GridData();
	layoutData.grabExcessHorizontalSpace = true;
	layoutData.horizontalAlignment = GridData.FILL;
	setLayoutData(layoutData);

	// Text label
	StyledText gridLinesLabel = new StyledText(this, SWT.NONE);
	gridLinesLabel.setEditable(false);
	Display display = Display.getDefault();
	FontData data = display .getSystemFont().getFontData()[0];
	Font font = new Font(display, data.getName(), data.getHeight(), SWT.BOLD);
	gridLinesLabel.setFont(font);
	gridLinesLabel.setBackground(Display.getCurrent().getSystemColor (SWT.COLOR_WIDGET_BACKGROUND));
	gridLinesLabel.setText(label);

	// Separator line
	Label separator = new Label (this, SWT.SEPARATOR | SWT.HORIZONTAL);
	GridData separatorData = new GridData();
	separatorData.grabExcessHorizontalSpace = true;
	separatorData.horizontalAlignment = GridData.FILL;
	separatorData.horizontalIndent = 5;
	separator.setLayoutData(separatorData);
}
 
Example 7
Source File: GridPropertyHandler.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private boolean applyCSSPropertySize(final Object element, final Grid grid, final CSSValue value, String target) throws Exception {
	if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
		final FontData fd = CSSEngineHelper.getFontData(grid);
		final Measure m = (Measure) value;

		final int newSize = Math.round(m.getFloatValue((short) 0));
		final boolean modified = fd.getHeight() != newSize;
		if (modified) {
			fd.setHeight(newSize);
			applyFont(grid, fd, target);
		}
	}

	return true;
}
 
Example 8
Source File: GamlHighlightingConfiguration.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
public static GamaFont get(final FontData fd) {
	return fd == null ? getDefaultFont() : new GamaFont(fd.getName(), fd.getStyle(), fd.getHeight());
}
 
Example 9
Source File: FontEditor.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
private GamaFont toGamaFont(final FontData fd) {
	return new GamaFont(fd.getName(), fd.getStyle(), fd.getHeight());
}
 
Example 10
Source File: UpdaterDialog.java    From developer-studio with Apache License 2.0 4 votes vote down vote up
private void listFeatures(Group group, ActiveTab tab) {
	IPreferenceStore prefPage = PlatformUI.getPreferenceStore();
	boolean showHiddenFeatures = prefPage.getBoolean(DeveloperPreferencePage.SHOW_HIDDEN_FEATURES);

	Iterator<Entry<String, EnhancedFeature>> featureList;
	if (tab == ActiveTab.ALL_FEATURES) {
		featureList = updateManager.getAvailableFeaturesMap().entrySet().iterator();
	} else {
		featureList = updateManager.getPossibleUpdatesMap().entrySet().iterator();
	}
	while (featureList.hasNext()) {
		EnhancedFeature feature = featureList.next().getValue();
		// set isKernelFeature=true or isHidden=true in update.properties
		// file in features to
		// ignore them in available Features tab
		if (tab == ActiveTab.ALL_FEATURES && !showHiddenFeatures) {
			if (feature.isKernelFeature() || feature.isHidden()) {
				continue;
			}
		}
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
		final Group featureGroup = createFeatureRepresentationGroup(group, gridData);
		createCheckBoxInFeatureGroup(feature, featureGroup, tab);

		Label featureImageLabel = new Label(featureGroup, SWT.NONE);
		try {
			Image image = new Image(Display.getDefault(), feature.getIconURL().replace(FILE_PROTOCOL, "")); //$NON-NLS-1$
			featureImageLabel.setImage(image);
		} catch (Exception ex) {
			log.warn(Messages.UpdaterDialog_8 + feature.getId(), ex);
		}
		final Group featureInfoGroup = createFeatureInfoRepresentationGroup(featureGroup);
		StyledText featureName = createFeatureNameText(feature, featureInfoGroup);
		FontData fontData = featureName.getFont().getFontData()[0];
		Font font = new Font(featureInfoGroup.getDisplay(),
				new FontData(fontData.getName(), fontData.getHeight() + 1, SWT.BOLD));
		featureName.setFont(font);
		createFeatureNewVersionText(feature, featureInfoGroup);
		if (feature.isUpdateFeature() && feature.getWhatIsNew() != null && !feature.getWhatIsNew().isEmpty()) {
			createFeatureDescr(feature.getWhatIsNew(), feature.getBugFixes(), featureInfoGroup);
		}
	}
}
 
Example 11
Source File: GamlHighlightingConfiguration.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
public static GamaFont getDefaultFont() {
	final FontData fd = PreferenceConverter.getFontData(EditorsPlugin.getDefault().getPreferenceStore(),
			JFaceResources.TEXT_FONT);
	return new GamaFont(fd.getName(), fd.getStyle(), fd.getHeight());
}
 
Example 12
Source File: FontFactoryTest.java    From swt-bling with MIT License 4 votes vote down vote up
private boolean isFontDataMatch(Font font, int size, int style) {
  final FontData fontData = font.getFontData()[0];
  return size == fontData.getHeight() && style == fontData.getStyle();
}
 
Example 13
Source File: PrinterFacade.java    From http4e with Apache License 2.0 4 votes vote down vote up
public void print(){
   if (printer.startJob("Text")) { // the string is the job name - shows up

      try {// in the printer's job list
         Rectangle clientArea = printer.getClientArea();
         Rectangle trim = printer.computeTrim(0, 0, 0, 0);
         Point dpi = printer.getDPI();
         leftMargin = dpi.x + trim.x; // one inch from left side of paper
         rightMargin = clientArea.width - dpi.x + trim.x + trim.width; // one
         // inch
         // from
         // right
         // side
         // of
         // paper
         topMargin = dpi.y + trim.y; // one inch from top edge of paper
         bottomMargin = clientArea.height - dpi.y + trim.y + trim.height; // one
         // inch
         // from
         // bottom
         // edge
         // of
         // paper

         /* Create a buffer for computing tab width. */
         int tabSize = 4; // is tab width a user setting in your UI?
         StringBuilder tabBuffer = new StringBuilder(tabSize);
         for (int i = 0; i < tabSize; i++)
            tabBuffer.append(' ');
         tabs = tabBuffer.toString();

         /*
          * Create printer GC, and create and set the printer font &
          * foreground color.
          */
         gc = new GC(printer);

         font = printer.getSystemFont(); // ResourceUtils.getFont(Styles.getInstance().FONT_COURIER);
         // foregroundColor = ResourceUtils.getColor(Styles.DARK_RGB_TEXT);
         // backgroundColor =
         // ResourceUtils.getColor(Styles.BACKGROUND_ENABLED);

         FontData fontData = font.getFontData()[0];
         printerFont = new Font(printer, fontData.getName(), fontData.getHeight(), fontData.getStyle());
         gc.setFont(printerFont);
         tabWidth = gc.stringExtent(tabs).x;
         lineHeight = gc.getFontMetrics().getHeight();

         // RGB rgb = foregroundColor.getRGB();
         // printerForegroundColor = new Color(printer, rgb);
         // gc.setForeground(printerForegroundColor);

         // rgb = backgroundColor.getRGB();
         // printerBackgroundColor = new Color(printer, rgb);
         // gc.setBackground(printerBackgroundColor);

         /* Print text to current gc using word wrap */
         printText(printer);
         printer.endJob();

      } catch (Exception e) {
         throw new RuntimeException(e);

      } finally {
         /* Cleanup graphics resources used in printing */
         if (printerFont != null)
            printerFont.dispose();
         // if(printerForegroundColor != null)
         // printerForegroundColor.dispose();
         // if(printerBackgroundColor != null)
         // printerBackgroundColor.dispose();
         if (gc != null)
            gc.dispose();
      }
   }
}
 
Example 14
Source File: CaptureDialog.java    From logbook with MIT License 4 votes vote down vote up
/**
 * Create contents of the dialog.
 */
private void createContents() {
    // シェル
    this.shell = new Shell(this.getParent(), this.getStyle());
    this.shell.setText(this.getText());
    // レイアウト
    GridLayout glShell = new GridLayout(1, false);
    glShell.horizontalSpacing = 1;
    glShell.marginHeight = 1;
    glShell.marginWidth = 1;
    glShell.verticalSpacing = 1;
    this.shell.setLayout(glShell);

    // 太字にするためのフォントデータを作成する
    FontData defaultfd = this.shell.getFont().getFontData()[0];
    FontData fd = new FontData(defaultfd.getName(), defaultfd.getHeight(), SWT.BOLD);
    this.font = new Font(Display.getDefault(), fd);

    // コンポジット
    Composite rangeComposite = new Composite(this.shell, SWT.NONE);
    rangeComposite.setLayout(new GridLayout(2, false));

    // 範囲設定
    this.text = new Text(rangeComposite, SWT.BORDER | SWT.READ_ONLY);
    GridData gdText = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gdText.widthHint = 120;
    this.text.setLayoutData(gdText);
    this.text.setText("範囲が未設定です");

    Button button = new Button(rangeComposite, SWT.NONE);
    button.setText("範囲を選択");
    button.addSelectionListener(new SelectRectangleAdapter());

    // コンポジット
    this.composite = new Composite(this.shell, SWT.NONE);
    GridLayout loglayout = new GridLayout(3, false);
    this.composite.setLayout(loglayout);
    this.composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL));

    // 周期設定
    this.interval = new Button(this.composite, SWT.CHECK);
    this.interval.addSelectionListener((SelectedListener) e -> {
        this.capture.setText(getCaptureButtonText(false, this.interval.getSelection()));
    });
    this.interval.setText("周期");

    this.intervalms = new Spinner(this.composite, SWT.BORDER);
    this.intervalms.setMaximum(60000);
    this.intervalms.setMinimum(100);
    this.intervalms.setSelection(1000);
    this.intervalms.setIncrement(100);

    Label label = new Label(this.composite, SWT.NONE);
    label.setText("ミリ秒");

    this.capture = new Button(this.shell, SWT.NONE);
    this.capture.setFont(this.font);
    GridData gdCapture = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
    gdCapture.horizontalSpan = 3;
    gdCapture.heightHint = 64;
    this.capture.setLayoutData(gdCapture);
    this.capture.setEnabled(false);
    this.capture.setText(getCaptureButtonText(false, this.interval.getSelection()));
    this.capture.addSelectionListener(new CaptureStartAdapter());

    this.shell.pack();
}
 
Example 15
Source File: FleetComposite.java    From logbook with MIT License 4 votes vote down vote up
/**
 * @param parent 艦隊タブの親
 * @param tabItem 艦隊タブ
 */
public FleetComposite(CTabFolder parent, CTabItem tabItem, ApplicationMain main) {
    super(parent, SWT.NONE);
    this.tab = tabItem;
    this.main = main;
    this.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    GridLayout glParent = new GridLayout(1, false);
    glParent.horizontalSpacing = 0;
    glParent.marginTop = 0;
    glParent.marginWidth = 0;
    glParent.marginHeight = 0;
    glParent.marginBottom = 0;
    glParent.verticalSpacing = 0;
    this.setLayout(glParent);

    FontData normalfd = parent.getShell().getFont().getFontData()[0];
    FontData largefd = new FontData(normalfd.getName(), normalfd.getHeight() + 2, normalfd.getStyle());
    FontData smallfd = new FontData(normalfd.getName(), normalfd.getHeight() - 1, normalfd.getStyle());

    this.large = new Font(Display.getCurrent(), largefd);
    this.small = new Font(Display.getCurrent(), smallfd);

    this.fleetGroup = new Composite(this, SWT.NONE);
    this.fleetGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    GridLayout glShipGroup = new GridLayout(3, false);
    glShipGroup.horizontalSpacing = 0;
    glShipGroup.marginTop = 0;
    glShipGroup.marginWidth = 1;
    glShipGroup.marginHeight = 0;
    glShipGroup.marginBottom = 0;
    glShipGroup.verticalSpacing = 0;
    this.fleetGroup.setLayout(glShipGroup);
    this.init();

    // セパレーター
    Label separator = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL);
    separator.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    // メッセージ
    this.message = new StyledText(this, SWT.READ_ONLY | SWT.WRAP);
    this.message.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    this.message.setWordWrap(true);
    this.message.setBackground(this.getBackground());
    this.message.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseUp(MouseEvent event) {
            try {
                int offset = FleetComposite.this.message.getOffsetAtLocation(new Point(event.x, event.y));
                StyleRange style = FleetComposite.this.message.getStyleRangeAtOffset(offset);
                if ((style != null) && (style.data instanceof Date)) {

                    TimerSettingDialog dialog = new TimerSettingDialog(FleetComposite.this.getShell());
                    dialog.setTime((Date) style.data);
                    dialog.setMessage(MessageFormat.format("「{0}」の疲労が回復しました", FleetComposite.this.dock.getName()));
                    dialog.open();
                }
            } catch (IllegalArgumentException e) {
                // no character under event.x, event.y
            }

        }
    });

    this.fleetGroup.layout();
}
 
Example 16
Source File: TmfAbstractToolTipHandler.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
@SuppressWarnings("nls")
        private String toHtml() {
            GC gc = new GC(Display.getDefault());
            FontData fontData = gc.getFont().getFontData()[0];
            String fontName = fontData.getName();
            String fontHeight = fontData.getHeight() + "pt";
            gc.dispose();
            Table<ToolTipString, ToolTipString, ToolTipString> model = getModel();
            StringBuilder toolTipContent = new StringBuilder();
            toolTipContent.append("<head>\n" +
                    "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n" +
                    "<style>\n" +
                    ".collapsible {\n" +
                    "  background-color: #777;\n" +
                    "  color: white;\n" +
//                    "  cursor: pointer;\n" + // Add when enabling JavaScript
                    "  padding: 0px;\n" +
                    "  width: 100%;\n" +
                    "  border: none;\n" +
                    "  text-align: left;\n" +
                    "  outline: none;\n" +
                    "  font-family: " + fontName +";\n" +
                    "  font-size: " + fontHeight + ";\n" +
                    "}\n" +
                    "\n" +
                    ".active, .collapsible:hover {\n" +
                    "  background-color: #555;\n" +
                    "}\n" +
                    "\n" +
                    ".content {\n" +
                    "  padding: 0px 0px;\n" +
                    "  display: block;\n" +
                    "  overflow: hidden;\n" +
                    "  background-color: #f1f1f1;\n" +
                    "}\n" +
                    ".tab {\n" +
                    "  padding:0px;\n" +
                    "  font-family: " + fontName + ";\n" +
                    "  font-size: " + fontHeight + ";\n" +
                    "}\n" +
                    ".leftPadding {\n" +
                    "  padding:0px 0px 0px " + CELL_PADDING + "px;\n" +
                    "}\n" +
                    ".bodystyle {\n" +
                    "  margin:" + BODY_MARGIN + "px;\n" +
                    "  padding:0px 0px;\n" +
                    "}\n" +
                    "</style>\n" +
                    "</head>");
            toolTipContent.append("<body class=\"bodystyle\">"); //$NON-NLS-1$

            toolTipContent.append("<div class=\"content\">");
            toolTipContent.append("<table class=\"tab\">");
            Set<ToolTipString> rowKeySet = model.rowKeySet();
            for (ToolTipString row : rowKeySet) {
                if (!row.equals(UNCATEGORIZED)) {
                    toolTipContent.append("<tr><th colspan=\"2\"><button class=\"collapsible\">").append(row.toHtmlString()).append("</button></th></tr>");
                }
                Set<Entry<ToolTipString, ToolTipString>> entrySet = model.row(row).entrySet();
                for (Entry<ToolTipString, ToolTipString> entry : entrySet) {
                    toolTipContent.append("<tr>");
                    toolTipContent.append("<td>");
                    toolTipContent.append(entry.getKey().toHtmlString());
                    toolTipContent.append("</td>");
                    toolTipContent.append("<td class=\"leftPadding\">");
                    toolTipContent.append(entry.getValue().toHtmlString());
                    toolTipContent.append("</td>");
                    toolTipContent.append("</tr>");
                }
            }
            toolTipContent.append("</table></div>");
            /* Add when enabling JavaScript
            toolTipContent.append("\n" +
                    "<script>\n" +
                    "var coll = document.getElementsByClassName(\"collapsible\");\n" +
                    "var i;\n" +
                    "\n" +
                    "for (i = 0; i < coll.length; i++) {\n" +
                    "  coll[i].addEventListener(\"click\", function() {\n" +
                    "    this.classList.toggle(\"active\");\n" +
                    "    var content = this.nextElementSibling;\n" +
                    "    if (content.style.display === \"block\") {\n" +
                    "      content.style.display = \"none\";\n" +
                    "    } else {\n" +
                    "      content.style.display = \"block\";\n" +
                    "    }\n" +
                    "  });\n" +
                    "}\n" +
                    "</script>");
            */
            toolTipContent.append("</body>"); //$NON-NLS-1$
            return toolTipContent.toString();
        }
 
Example 17
Source File: OrderImportDialog.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
private Font createBoldFont(Font baseFont){
	FontData fd = baseFont.getFontData()[0];
	Font font =
		new Font(baseFont.getDevice(), fd.getName(), fd.getHeight(), fd.getStyle() | SWT.BOLD);
	return font;
}
 
Example 18
Source File: MessageModal.java    From Universal-FE-Randomizer with MIT License 4 votes vote down vote up
public MessageModal(Shell parent, String title, String message) {
	display = Display.getDefault();
	yuneImage = new Image(display, Main.class.getClassLoader().getResourceAsStream("YuneIcon_100x100.png"));
	
	dialogShell = new Shell(parent, SWT.PRIMARY_MODAL | SWT.DIALOG_TRIM);
	dialogShell.setText(title);
	dialogShell.setImage(yuneImage);
	
	dialogShell.addListener(SWT.CLOSE, new Listener() {

		@Override
		public void handleEvent(Event event) {
			event.doit = false;
		}
		
	});
	
	FormLayout mainLayout = new FormLayout();
	mainLayout.marginWidth = 5;
	mainLayout.marginHeight = 5;
	dialogShell.setLayout(mainLayout);
	
	imageLabel = new Label(dialogShell, SWT.NONE);
	imageLabel.setImage(yuneImage);
	
	FormData imageData = new FormData(100, 100);
	imageData.left = new FormAttachment(0, 10);
	imageData.top = new FormAttachment(0, 10);
	imageLabel.setLayoutData(imageData);
	
	contentGroup = new Composite(dialogShell, SWT.NONE);
	FormLayout contentLayout = new FormLayout();
	contentLayout.marginTop = 5;
	contentLayout.marginLeft = 5;
	contentLayout.marginBottom = 5;
	contentLayout.marginRight = 5;
	contentGroup.setLayout(contentLayout);
	
	titleLabel = new Label(contentGroup, SWT.LEFT);
	titleLabel.setText(title);
	FontData normalFont = titleLabel.getFont().getFontData()[0];
	Font boldFont = new Font(display, normalFont.getName(), normalFont.getHeight(), SWT.BOLD);
	titleLabel.setFont(boldFont);
	
	FormData titleData = new FormData();
	titleData.top = new FormAttachment(0, 0);
	titleData.left = new FormAttachment(0, 0);
	titleData.right = new FormAttachment(100, 0);
	titleLabel.setLayoutData(titleData);
	
	descriptionLabel = new Label(contentGroup, SWT.LEFT | SWT.WRAP);
	descriptionLabel.setText(message);
	
	FormData descriptionData = new FormData();
	descriptionData.left = new FormAttachment(titleLabel, 0, SWT.LEFT);
	descriptionData.right = new FormAttachment(titleLabel, 0, SWT.RIGHT);
	descriptionData.top = new FormAttachment(titleLabel, 10);
	descriptionData.bottom = new FormAttachment(100, -5);
	Point expectedSize = descriptionLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT);
	descriptionData.width = Math.max(200, expectedSize.x);
	descriptionData.height = Math.max(60, expectedSize.y);
	descriptionLabel.setLayoutData(descriptionData);
	
	FormData groupData = new FormData();
	groupData.left = new FormAttachment(imageLabel, 10);
	groupData.top = new FormAttachment(imageLabel, 0, SWT.TOP);
	groupData.right = new FormAttachment(100, -10);
	contentGroup.setLayoutData(groupData);
	
	layoutSize();
	Rectangle parentBounds = parent.getBounds();
	Rectangle dialogBounds = dialogShell.getBounds();
	
	dialogShell.setLocation(parentBounds.x + (parentBounds.width - dialogBounds.width) / 2, parentBounds.y + (parentBounds.height - dialogBounds.height) / 2);
}
 
Example 19
Source File: TableViewEditPart.java    From ermaster-b with Apache License 2.0 3 votes vote down vote up
protected Font changeFont(TableFigure tableFigure) {
	Font font = super.changeFont(tableFigure);

	FontData fonData = font.getFontData()[0];

	this.titleFont = new Font(Display.getCurrent(), fonData.getName(),
			fonData.getHeight(), SWT.BOLD);

	tableFigure.setFont(font, this.titleFont);

	return font;
}
 
Example 20
Source File: RemovedERTableEditPart.java    From ermaster-b with Apache License 2.0 3 votes vote down vote up
private Font changeFont(TableFigure tableFigure) {
	Font font = super.changeFont(tableFigure);

	FontData fonDatat = font.getFontData()[0];

	this.titleFont = new Font(Display.getCurrent(), fonDatat.getName(),
			fonDatat.getHeight(), SWT.BOLD);

	tableFigure.setFont(font, this.titleFont);

	return font;
}