Java Code Examples for org.eclipse.swt.widgets.Label#setAlignment()

The following examples show how to use org.eclipse.swt.widgets.Label#setAlignment() . 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: ProgressBarDemo.java    From slr-toolkit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Create contents of the dialog.
 * @param parent
 */
@Override
protected Control createDialogArea(Composite parent) {
	Composite container = (Composite) super.createDialogArea(parent);
	container.setLayout(new GridLayout(1, false));
       completedInfo = new Label(container, SWT.NONE);
       completedInfo.setAlignment(SWT.CENTER);
       GridData gd_completedInfo = new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1);
       gd_completedInfo.minimumWidth = 250;
       completedInfo.setLayoutData(gd_completedInfo);
       completedInfo.setSize(250, 40);
       completedInfo.setText("Processing Data ...");
       new Label(container, SWT.NONE);
       
       progressBar = new ProgressBar(container, SWT.INDETERMINATE);
       GridData gd_progressBar = new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1);
       gd_progressBar.minimumWidth = 250;
       progressBar.setLayoutData(gd_progressBar);
       progressBar.setBounds(10, 23, 400, 17);
       progressBar.setSelection(100);
       
	return container;
}
 
Example 2
Source File: GroupOrWrap.java    From Rel with Apache License 2.0 6 votes vote down vote up
private void addRowAllButAndAs(Composite parent, boolean selected, String astext) {
	Label lblNewLabel = new Label(parent, SWT.NONE);
	lblNewLabel.setText("ALL BUT");

	checkAllBut = new Button(parent, SWT.CHECK);
	checkAllBut.setSelection(selected);

	Label dummy = new Label(parent, SWT.NONE);
	dummy.setVisible(false);

	Label asPrompt = new Label(parent, SWT.NONE);
	asPrompt.setAlignment(SWT.RIGHT);
	asPrompt.setText("As:");

	as = new Text(parent, SWT.NONE);
	as.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	as.setText(astext);
}
 
Example 3
Source File: PagesDialog.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Control createDialogArea(Composite parent) {

    Group ret = new Group(parent, SWT.NONE);
    GridData data = new GridData();
    data.grabExcessHorizontalSpace = true;
    data.horizontalAlignment = GridData.FILL;
    ret.setLayoutData(data);
    ret.setText(Messages.SequenceDiagram_PageNavigation);

    FillLayout fillLayout = new FillLayout(SWT.VERTICAL);
    ret.setLayout(fillLayout);

    Label label = new Label(ret, SWT.NONE);
    label.setText(Messages.SequenceDiagram_CurrentPage);

    fCurrentPage = new TextArea(ret);
    fCurrentPage.setBounds(1, fProvider.pagesCount());
    fCurrentPage.setValue(fProvider.currentPage() + 1);

    fTotalPageComment = new Label(ret, SWT.NONE);
    fTotalPageComment.setAlignment(SWT.RIGHT);

    updateComments();

    getShell().setText(Messages.SequenceDiagram_SequenceDiagramPages);
    return ret;
}
 
Example 4
Source File: ProgressBarDialog.java    From slr-toolkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Create contents of the dialog.
 * @param parent
 */
@Override
protected Control createDialogArea(Composite parent) {
	Composite container = (Composite) super.createDialogArea(parent);
	container.setLayout(new GridLayout(1, false));
       completedInfo = new Label(container, SWT.NONE);
       completedInfo.setAlignment(SWT.CENTER);
       GridData gd_completedInfo = new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1);
       gd_completedInfo.minimumWidth = 250;
       completedInfo.setLayoutData(gd_completedInfo);
       completedInfo.setSize(250, 40);
       completedInfo.setText("Processing Data ...");
       new Label(container, SWT.NONE);
       
       progressBar = new ProgressBar(container, SWT.SMOOTH);
       GridData gd_progressBar = new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1);
       gd_progressBar.minimumWidth = 250;
       progressBar.setLayoutData(gd_progressBar);
       progressBar.setBounds(10, 23, 400, 17);
       
       taskLabel = new Label(container, SWT.NONE);
       taskLabel.setAlignment(SWT.CENTER);
       GridData gd_taskLabel = new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1);
       gd_taskLabel.heightHint = 15;
       gd_taskLabel.minimumWidth = 250;
       taskLabel.setLayoutData(gd_taskLabel);
       taskLabel.setSize(250, 40);
       
	return container;
}
 
Example 5
Source File: RelvarEditorPanel.java    From Rel with Apache License 2.0 5 votes vote down vote up
public RelvarEditorPanel(Composite parent, DbConnection connection, String title, int style) {
	super(parent, style);
	setLayout(new FormLayout());
	
	Label editorTitle = new Label(this, SWT.NONE);
	editorTitle.setText(title);
	editorTitle.setAlignment(SWT.CENTER);
	editorTitle.setBackground(SWTResourceManager.getColor(SWT.COLOR_GRAY));
	
	FormData fd_editorTitle = new FormData();
	fd_editorTitle.top = new FormAttachment(0);
	fd_editorTitle.left = new FormAttachment(0);
	fd_editorTitle.right = new FormAttachment(100);
	editorTitle.setLayoutData(fd_editorTitle);
	
	Composite editorComposite = new Composite(this, SWT.NONE);		
	GridLayout gridLayout = new GridLayout(1, false);
	gridLayout.verticalSpacing = 0;
	gridLayout.marginWidth = 0;
	gridLayout.marginHeight = 0;
	editorComposite.setLayout(gridLayout);
	
	filterSorter = new FilterSorter(editorComposite, SWT.BORDER, title, connection);
	filterSorter.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	filterSorter.addUpdateListener(source -> editor.refresh());
	
	editor = new RelvarEditor(editorComposite, connection, this);		
	editor.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	editor.refresh();
	
	FormData fd_editor = new FormData();
	fd_editor.top = new FormAttachment(editorTitle);
	fd_editor.left = new FormAttachment(0);
	fd_editor.right = new FormAttachment(100);
	fd_editor.bottom = new FormAttachment(100);
	editorComposite.setLayoutData(fd_editor);
}
 
Example 6
Source File: EditboxPreferencePage.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
protected Control createCategoryControl(final Composite parent) {
	final Composite c = new Composite(parent, SWT.NONE);
	c.setLayout(new GridLayout(2, true));

	final Label categoryLabel = new Label(c, SWT.NONE);
	categoryLabel.setText("Themes");

	final Label namesLabel = new Label(c, SWT.NONE);
	namesLabel.setText("Associated file names");
	namesLabel.setAlignment(SWT.RIGHT);

	categoryList = new List(c, SWT.V_SCROLL | SWT.BORDER);
	categoryList.setLayoutData(new GridData(GridData.FILL_BOTH));
	categoryList.addSelectionListener(new SelectCategory());
	namesList = new List(c, SWT.V_SCROLL | SWT.BORDER);
	namesList.setLayoutData(new GridData(GridData.FILL_BOTH));

	final Composite cLeft = new Composite(c, SWT.NONE);
	cLeft.setLayout(new GridLayout(2, true));
	final Button bAddCategory = new Button(cLeft, SWT.NONE);
	bAddCategory.setText("Add");
	bAddCategory.addSelectionListener(new AddCategory());
	bAddCategory.setLayoutData(new GridData(GridData.FILL_BOTH));
	final Button bRemoveCategory = new Button(cLeft, SWT.NONE);
	bRemoveCategory.setText("Remove");
	bRemoveCategory.setLayoutData(new GridData(GridData.FILL_BOTH));
	bRemoveCategory.addSelectionListener(new RemoveCategory());

	final Composite cRight = new Composite(c, SWT.NONE);
	cRight.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
	cRight.setLayout(new GridLayout(2, true));
	bAddFile = new Button(cRight, SWT.NONE);
	bAddFile.setText("Add");
	bAddFile.setLayoutData(new GridData(GridData.FILL_BOTH));
	bAddFile.addSelectionListener(new AddFile());
	bAddFile.setEnabled(false);
	final Button bRemoveFile = new Button(cRight, SWT.NONE);
	bRemoveFile.setText("Remove");
	bRemoveFile.setLayoutData(new GridData(GridData.FILL_BOTH));
	bRemoveFile.addSelectionListener(new RemoveFile());

	loadData();

	return c;
}
 
Example 7
Source File: XLIFFEditorStatusLineItem.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
public void fill(Composite parent) {
		statusLine = parent;
		new Label(parent, SWT.SEPARATOR);
		
		Composite container = new Composite(parent, SWT.NONE);		
		GridLayout gl = new GridLayout(1, false);
		gl.marginWidth = 0;
		gl.marginHeight = 0;
		gl.marginTop = 0;
		gl.marginRight = 0;
		gl.marginBottom = 0;
		container.setLayout(gl);
		
		label = new Label(container, SWT.SHADOW_NONE);	
		label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, true, 1, 1));
		label.setAlignment(SWT.CENTER);
		label.setText(text);
		if (image != null) {
			label.setImage(image);
			label.setToolTipText(text);
		}

//		Point preferredSize = label.computeSize(SWT.DEFAULT, SWT.DEFAULT);
//		int widthHint = preferredSize.x;
//		int heightHint = preferredSize.y;
//		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() * 40;
//			heightHint = fm.getHeight();
//			gc.dispose();
//		}
		
//		StatusLineLayoutData data = new StatusLineLayoutData();
//		data.widthHint = widthHint;
//		label.setLayoutData(data);
		
//		StatusLineLayoutData data = new StatusLineLayoutData();
//		data.heightHint = heightHint;
//		speLb.setLayoutData(data);
	}
 
Example 8
Source File: AddOrEditElementOfXmlConvertDialog.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
	Composite tparent = (Composite) super.createDialogArea(parent);
	GridDataFactory.fillDefaults().grab(true, true).applyTo(tparent);

	Composite composite = new Composite(tparent, SWT.NONE);
	GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);
	GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).applyTo(composite);

	// 元素类型下拉框的值, 备注:不能本地化
	String[] typeValues = { "segment", "inline", "ignore" };
	// 内联类型下拉框的值, 备注:不能本地化
	String[] internalValues = { "", "image", "pb", "lb", "x-bold", "x-entry", "x-font", "x-italic", "x-link",
			"x-underlined", "x-other" };
	// 保留空格下拉框的值, 备注:不能本地化
	String[] remainSpaceVlaues = { "", "yes", "no" };

	GridData textData = new GridData(SWT.FILL, SWT.CENTER, true, false);
	textData.widthHint = 100;

	// 元素名称
	Label nameLbl = new Label(composite, SWT.NONE);
	nameLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.nameLbl"));
	nameLbl.setAlignment(SWT.RIGHT);
	GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(nameLbl);

	nameTxt = new Text(composite, SWT.BORDER);
	nameTxt.setLayoutData(textData);

	// 元素类型
	Label typeLbl = new Label(composite, SWT.NONE);
	typeLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.typeLbl"));
	GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(typeLbl);

	typeCmb = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
	typeCmb.setLayoutData(textData);
	typeCmb.setItems(typeValues);
	typeCmb.select(0);

	// 内联类型
	Label inlineLbl = new Label(composite, SWT.NONE);
	inlineLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.inlineLbl"));
	GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(inlineLbl);

	inlineCmb = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
	inlineCmb.setLayoutData(textData);
	inlineCmb.setItems(internalValues);
	inlineCmb.setEnabled(false);

	// 可翻译属性
	Label transAttriLbl = new Label(composite, SWT.NONE);
	transAttriLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.transAttriLbl"));
	GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(transAttriLbl);

	transAtrriTxt = new Text(composite, SWT.BORDER);
	transAtrriTxt.setLayoutData(textData);

	// 保留空格
	Label remainSpaceLbl = new Label(composite, SWT.NONE);
	remainSpaceLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.remainSpaceLbl"));
	GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(remainSpaceLbl);

	remainSpaceCmb = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
	remainSpaceCmb.setLayoutData(textData);
	remainSpaceCmb.setItems(remainSpaceVlaues);

	// 当元素类型是segment时,禁用内联内型,当元素类型是inline时,禁用可翻译属性。当元素类型是ignore时,禁用可翻译属性与内联内型
	typeCmb.addModifyListener(new ModifyListener() {
		public void modifyText(ModifyEvent e) {
			String type = typeCmb.getText();
			if ("segment".equals(type)) {
				inlineCmb.setText("");
				inlineCmb.setEnabled(false);
				transAtrriTxt.setEnabled(true);
			} else if ("inline".equals(type)) {
				inlineCmb.setEnabled(true);
				transAtrriTxt.setText("");
				transAtrriTxt.setEnabled(false);
			} else if ("ignore".equals(type)) {
				inlineCmb.setText("");
				inlineCmb.setEnabled(false);
				transAtrriTxt.setText("");
				transAtrriTxt.setEnabled(false);
			}
		}
	});

	return tparent;
}
 
Example 9
Source File: About.java    From Flashtool with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Open the dialog.
 * @return the result
 */
public Object open() {
	createContents();
	
	Composite composite = new Composite(shlAbout, SWT.NONE);
	composite.setLayout(new GridLayout(1, false));
	FormData fd_composite = new FormData();
	fd_composite.top = new FormAttachment(0, 10);
	fd_composite.left = new FormAttachment(0, 10);
	fd_composite.right = new FormAttachment(100, -10);
	composite.setLayoutData(fd_composite);
	
	lblNewLabel = new Label(composite, SWT.NONE);
	lblNewLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1));
	lblNewLabel.setAlignment(SWT.CENTER);
	lblNewLabel.setText("Xperia flashing tool "+OS.getChannel());
	
	lblNewLabel_2 = new Label(composite, SWT.NONE);
	lblNewLabel_2.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
	lblNewLabel_2.setAlignment(SWT.CENTER);
	lblNewLabel_2.setText(getVersion());
	
	lblNewLabel_1 = new Label(composite, SWT.NONE);
	lblNewLabel_1.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
	lblNewLabel_1.setAlignment(SWT.CENTER);
	lblNewLabel_1.setText("Java Version " + System.getProperty("java.version") + " " + System.getProperty("sun.arch.data.model") + "bits Edition");
	
	lblNewLabel_3 = new Label(composite, SWT.NONE);
	lblNewLabel_3.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
	lblNewLabel_3.setAlignment(SWT.CENTER);
	lblNewLabel_3.setText("OS Version "+OS.getVersion());
	
	lblNewLabel_4 = new Label(composite, SWT.NONE);
	lblNewLabel_4.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
	lblNewLabel_4.setAlignment(SWT.CENTER);
	lblNewLabel_4.setText("By Androxyde");
	
	Label lblManyThanksTo = new Label(composite, SWT.NONE);
	lblManyThanksTo.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
	lblManyThanksTo.setAlignment(SWT.CENTER);
	lblManyThanksTo.setText("Many thanks to contributors : Bin4ry, DooMLoRD, [NUT],");
	
	Label lblDevshaft = new Label(composite, SWT.NONE);
	lblDevshaft.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
	lblDevshaft.setAlignment(SWT.CENTER);
	lblDevshaft.setText("DevShaft, IaguCool");
	
	Link link = new Link(composite, SWT.NONE);
	link.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
	link.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			Program.launch("http://www.flashtool.net");
		}
	});
	link.setText("<a href=\"http://androxyde.github.com\">Homepage</a>");
	shlAbout.open();
	shlAbout.layout();
	Display display = getParent().getDisplay();
	while (!shlAbout.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
	return result;
}
 
Example 10
Source File: AddOrEditElementOfXmlConvertDialog.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
	Composite tparent = (Composite) super.createDialogArea(parent);
	GridDataFactory.fillDefaults().grab(true, true).applyTo(tparent);

	Composite composite = new Composite(tparent, SWT.NONE);
	GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);
	GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).applyTo(composite);

	// 元素类型下拉框的值, 备注:不能本地化
	String[] typeValues = { "segment", "inline", "ignore" };
	// 内联类型下拉框的值, 备注:不能本地化
	String[] internalValues = { "", "image", "pb", "lb", "x-bold", "x-entry", "x-font", "x-italic", "x-link",
			"x-underlined", "x-other" };
	// 保留空格下拉框的值, 备注:不能本地化
	String[] remainSpaceVlaues = { "", "yes", "no" };

	GridData textData = new GridData(SWT.FILL, SWT.CENTER, true, false);
	textData.widthHint = 100;

	// 元素名称
	Label nameLbl = new Label(composite, SWT.NONE);
	nameLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.nameLbl"));
	nameLbl.setAlignment(SWT.RIGHT);
	GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(nameLbl);

	nameTxt = new Text(composite, SWT.BORDER);
	nameTxt.setLayoutData(textData);

	// 元素类型
	Label typeLbl = new Label(composite, SWT.NONE);
	typeLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.typeLbl"));
	GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(typeLbl);

	typeCmb = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
	typeCmb.setLayoutData(textData);
	typeCmb.setItems(typeValues);
	typeCmb.select(0);

	// 内联类型
	Label inlineLbl = new Label(composite, SWT.NONE);
	inlineLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.inlineLbl"));
	GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(inlineLbl);

	inlineCmb = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
	inlineCmb.setLayoutData(textData);
	inlineCmb.setItems(internalValues);
	inlineCmb.setEnabled(false);

	// 可翻译属性
	Label transAttriLbl = new Label(composite, SWT.NONE);
	transAttriLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.transAttriLbl"));
	GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(transAttriLbl);

	transAtrriTxt = new Text(composite, SWT.BORDER);
	transAtrriTxt.setLayoutData(textData);

	// 保留空格
	Label remainSpaceLbl = new Label(composite, SWT.NONE);
	remainSpaceLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.remainSpaceLbl"));
	GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(remainSpaceLbl);

	remainSpaceCmb = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
	remainSpaceCmb.setLayoutData(textData);
	remainSpaceCmb.setItems(remainSpaceVlaues);

	// 当元素类型是segment时,禁用内联内型,当元素类型是inline时,禁用可翻译属性。当元素类型是ignore时,禁用可翻译属性与内联内型
	typeCmb.addModifyListener(new ModifyListener() {
		public void modifyText(ModifyEvent e) {
			String type = typeCmb.getText();
			if ("segment".equals(type)) {
				inlineCmb.setText("");
				inlineCmb.setEnabled(false);
				transAtrriTxt.setEnabled(true);
			} else if ("inline".equals(type)) {
				inlineCmb.setEnabled(true);
				transAtrriTxt.setText("");
				transAtrriTxt.setEnabled(false);
			} else if ("ignore".equals(type)) {
				inlineCmb.setText("");
				inlineCmb.setEnabled(false);
				transAtrriTxt.setText("");
				transAtrriTxt.setEnabled(false);
			}
		}
	});

	return tparent;
}