X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=eclipse%2Fruntime%2Forg.argeo.eclipse.ui%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Feclipse%2Fui%2FEclipseUiUtils.java;h=03d0c3883b3f940ff6556dbdd17de7c56c791fd2;hb=1fafef02e1eb08ea9d69742ef9b23c2d3a346c48;hp=333db5b8899a1b1a732a6b5c0f1110265bf143cb;hpb=019e0f2af17286be08ab17c1c9e1d8ba871ec9b2;p=lgpl%2Fargeo-commons.git diff --git a/eclipse/runtime/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/ui/EclipseUiUtils.java b/eclipse/runtime/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/ui/EclipseUiUtils.java index 333db5b88..03d0c3883 100644 --- a/eclipse/runtime/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/ui/EclipseUiUtils.java +++ b/eclipse/runtime/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/ui/EclipseUiUtils.java @@ -1,7 +1,24 @@ +/* + * Copyright (C) 2007-2012 Mathieu Baudier + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.argeo.eclipse.ui; +import org.eclipse.jface.resource.JFaceResources; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.graphics.Font; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; @@ -21,17 +38,64 @@ public class EclipseUiUtils { * a {@link ModifyListener} to listen on events on the text, can * be null * @return the created text + * + * @deprecated use {@link #createGridLT(Composite, String)} instead */ + @Deprecated public static Text createGridLT(Composite parent, String label, ModifyListener modifyListener) { Label lbl = new Label(parent, SWT.LEAD); lbl.setText(label); lbl.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); Text txt = new Text(parent, SWT.LEAD | SWT.BORDER); - txt.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false)); + txt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + if (modifyListener != null) + txt.addModifyListener(modifyListener); + return txt; + } + + public static Text createGridLT(Composite parent, String label) { + return createGridLT(parent, label, null); + } + + /** + * Creates one label and a text field not editable with background color of + * the parent (like a label but with selectable text) + */ + public static Text createGridLL(Composite parent, String label, String text) { + Text txt = createGridLT(parent, label); + txt.setText(text); + txt.setEditable(false); + txt.setBackground(parent.getBackground()); + return txt; + } + + public static Text createGridLP(Composite parent, String label, + ModifyListener modifyListener) { + Label lbl = new Label(parent, SWT.LEAD); + lbl.setText(label); + lbl.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); + Text txt = new Text(parent, SWT.LEAD | SWT.BORDER | SWT.PASSWORD); + txt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); if (txt != null) txt.addModifyListener(modifyListener); return txt; } + public static Font getItalicFont(Composite parent) { + return JFaceResources.getFontRegistry().defaultFontDescriptor() + .setStyle(SWT.ITALIC).createFont(parent.getDisplay()); + } + + public static Font getBoldFont(Composite parent) { + return JFaceResources.getFontRegistry().defaultFontDescriptor() + .setStyle(SWT.BOLD).createFont(parent.getDisplay()); + } + + public static Font getBoldItalicFont(Composite parent) { + return JFaceResources.getFontRegistry().defaultFontDescriptor() + .setStyle(SWT.BOLD | SWT.ITALIC) + .createFont(parent.getDisplay()); + } + }