use of org.eclipse.swt.custom.CLabel in project eclipse.platform.swt by eclipse.
the class ControlsWithLabelsExample method main.
public static void main(String[] args) {
display = new Display();
shell = new Shell(display);
shell.setLayout(new GridLayout(4, true));
shell.setText("All Controls Test");
new Label(shell, SWT.NONE).setText("Label for Label");
label = new Label(shell, SWT.NONE);
label.setText("Label");
new Label(shell, SWT.NONE).setText("Label for CLabel");
cLabel = new CLabel(shell, SWT.NONE);
cLabel.setText("CLabel");
new Label(shell, SWT.NONE).setText("Label for Push Button");
buttonPush = new Button(shell, SWT.PUSH);
buttonPush.setText("Push Button");
new Label(shell, SWT.NONE).setText("Label for Radio Button");
buttonRadio = new Button(shell, SWT.RADIO);
buttonRadio.setText("Radio Button");
new Label(shell, SWT.NONE).setText("Label for Check Button");
buttonCheck = new Button(shell, SWT.CHECK);
buttonCheck.setText("Check Button");
new Label(shell, SWT.NONE).setText("Label for Toggle Button");
buttonToggle = new Button(shell, SWT.TOGGLE);
buttonToggle.setText("Toggle Button");
new Label(shell, SWT.NONE).setText("Label for Editable Combo");
combo = new Combo(shell, SWT.BORDER);
for (int i = 0; i < 4; i++) {
combo.add("item" + i);
}
combo.select(0);
new Label(shell, SWT.NONE).setText("Label for Read-Only Combo");
combo = new Combo(shell, SWT.READ_ONLY | SWT.BORDER);
for (int i = 0; i < 4; i++) {
combo.add("item" + i);
}
combo.select(0);
new Label(shell, SWT.NONE).setText("Label for CCombo");
cCombo = new CCombo(shell, SWT.BORDER);
for (int i = 0; i < 5; i++) {
cCombo.add("item" + i);
}
cCombo.select(0);
new Label(shell, SWT.NONE).setText("Label for List");
list = new List(shell, SWT.SINGLE | SWT.BORDER);
list.setItems("Item0", "Item1", "Item2");
new Label(shell, SWT.NONE).setText("Label for Spinner");
spinner = new Spinner(shell, SWT.BORDER);
new Label(shell, SWT.NONE).setText("Label for Single-line Text");
textSingle = new Text(shell, SWT.SINGLE | SWT.BORDER);
textSingle.setText("Contents of Single-line Text");
new Label(shell, SWT.NONE).setText("Label for Multi-line Text");
textMulti = new Text(shell, SWT.MULTI | SWT.BORDER);
textMulti.setText("\nContents of Multi-line Text\n");
new Label(shell, SWT.NONE).setText("Label for StyledText");
styledText = new StyledText(shell, SWT.MULTI | SWT.BORDER);
styledText.setText("\nContents of Multi-line StyledText\n");
new Label(shell, SWT.NONE).setText("Label for Table");
table = new Table(shell, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
table.setHeaderVisible(true);
table.setLinesVisible(true);
for (int col = 0; col < 3; col++) {
TableColumn column = new TableColumn(table, SWT.NONE);
column.setText("Col " + col);
column.setWidth(50);
}
for (int row = 0; row < 3; row++) {
TableItem item = new TableItem(table, SWT.NONE);
item.setText(new String[] { "C0R" + row, "C1R" + row, "C2R" + row });
}
new Label(shell, SWT.NONE).setText("Label for Tree");
tree = new Tree(shell, SWT.BORDER | SWT.MULTI);
for (int i = 0; i < 3; i++) {
TreeItem item = new TreeItem(tree, SWT.NONE);
item.setText("Item" + i);
for (int j = 0; j < 4; j++) {
new TreeItem(item, SWT.NONE).setText("Item" + i + j);
}
}
new Label(shell, SWT.NONE).setText("Label for Tree with columns");
treeTable = new Tree(shell, SWT.BORDER | SWT.MULTI);
treeTable.setHeaderVisible(true);
treeTable.setLinesVisible(true);
for (int col = 0; col < 3; col++) {
TreeColumn column = new TreeColumn(treeTable, SWT.NONE);
column.setText("Col " + col);
column.setWidth(50);
}
for (int i = 0; i < 3; i++) {
TreeItem item = new TreeItem(treeTable, SWT.NONE);
item.setText(new String[] { "I" + i + "C0", "I" + i + "C1", "I" + i + "C2" });
for (int j = 0; j < 4; j++) {
new TreeItem(item, SWT.NONE).setText(new String[] { "I" + i + j + "C0", "I" + i + j + "C1", "I" + i + j + "C2" });
}
}
new Label(shell, SWT.NONE).setText("Label for ToolBar");
toolBar = new ToolBar(shell, SWT.FLAT);
for (int i = 0; i < 3; i++) {
ToolItem item = new ToolItem(toolBar, SWT.PUSH);
item.setText("Item" + i);
item.setToolTipText("ToolItem ToolTip" + i);
}
new Label(shell, SWT.NONE).setText("Label for CoolBar");
coolBar = new CoolBar(shell, SWT.FLAT);
for (int i = 0; i < 2; i++) {
CoolItem coolItem = new CoolItem(coolBar, SWT.PUSH);
ToolBar coolItemToolBar = new ToolBar(coolBar, SWT.FLAT);
int toolItemWidth = 0;
for (int j = 0; j < 2; j++) {
ToolItem item = new ToolItem(coolItemToolBar, SWT.PUSH);
item.setText("Item" + i + j);
item.setToolTipText("ToolItem ToolTip" + i + j);
if (item.getWidth() > toolItemWidth)
toolItemWidth = item.getWidth();
}
coolItem.setControl(coolItemToolBar);
Point size = coolItemToolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT);
Point coolSize = coolItem.computeSize(size.x, size.y);
coolItem.setMinimumSize(toolItemWidth, coolSize.y);
coolItem.setPreferredSize(coolSize);
coolItem.setSize(coolSize);
}
new Label(shell, SWT.NONE).setText("Label for Canvas");
canvas = new Canvas(shell, SWT.BORDER);
canvas.setLayoutData(new GridData(64, 64));
canvas.addPaintListener(e -> e.gc.drawString("Canvas", 15, 25));
canvas.setCaret(new Caret(canvas, SWT.NONE));
/* Hook key listener so canvas will take focus during traversal in. */
canvas.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
}
});
/* Hook traverse listener to make canvas give up focus during traversal out. */
canvas.addTraverseListener(e -> e.doit = true);
new Label(shell, SWT.NONE).setText("Label for Group");
group = new Group(shell, SWT.NONE);
group.setText("Group");
group.setLayout(new FillLayout());
new Text(group, SWT.SINGLE | SWT.BORDER).setText("Text in Group");
new Label(shell, SWT.NONE).setText("Label for TabFolder");
tabFolder = new TabFolder(shell, SWT.NONE);
for (int i = 0; i < 3; i++) {
TabItem item = new TabItem(tabFolder, SWT.NONE);
item.setText("TabItem &" + i);
item.setToolTipText("TabItem ToolTip" + i);
Text itemText = new Text(tabFolder, SWT.SINGLE | SWT.BORDER);
itemText.setText("Text for TabItem " + i);
item.setControl(itemText);
}
new Label(shell, SWT.NONE).setText("Label for CTabFolder");
cTabFolder = new CTabFolder(shell, SWT.BORDER);
for (int i = 0; i < 3; i++) {
CTabItem item = new CTabItem(cTabFolder, SWT.NONE);
item.setText("CTabItem &" + i);
item.setToolTipText("CTabItem ToolTip" + i);
Text itemText = new Text(cTabFolder, SWT.SINGLE | SWT.BORDER);
itemText.setText("Text for CTabItem " + i);
item.setControl(itemText);
}
cTabFolder.setSelection(cTabFolder.getItem(0));
new Label(shell, SWT.NONE).setText("Label for Scale");
scale = new Scale(shell, SWT.NONE);
new Label(shell, SWT.NONE).setText("Label for Slider");
slider = new Slider(shell, SWT.NONE);
new Label(shell, SWT.NONE).setText("Label for ProgressBar");
progressBar = new ProgressBar(shell, SWT.NONE);
progressBar.setSelection(50);
new Label(shell, SWT.NONE).setText("Label for Sash");
sash = new Sash(shell, SWT.NONE);
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
use of org.eclipse.swt.custom.CLabel in project cubrid-manager by CUBRID.
the class SelectColorCombo method buildServerTypeLabels.
/**
* Build the server type labels
*
* @param selectedColor
*/
private void buildServerTypeLabels(RGB selectedColor) {
serverTypeLabel = new CLabel(this, SWT.None);
serverTypeLabel.setLayoutData(formDataForLabel());
if (selectedColor != null) {
serverTypeLabel.setBackground(ResourceManager.getColor(selectedColor));
}
serverTypeLabel.addMouseListener(new MouseListener() {
public void mouseUp(MouseEvent e) {
noOp();
}
public void mouseDown(MouseEvent e) {
expandMenu();
}
public void mouseDoubleClick(MouseEvent e) {
noOp();
}
});
if (selectedColor != null) {
String[] labels = { Messages.lblColor0, Messages.lblColor1, Messages.lblColor2, Messages.lblColor3, Messages.lblColor4, Messages.lblColor5 };
List<RGB> rgbs = EditorConstance.getAvaliableBackground();
for (int i = 0; i < labels.length; i++) {
if (selectedColor.equals(rgbs.get(i))) {
serverTypeLabel.setText(labels[i]);
}
}
}
}
use of org.eclipse.swt.custom.CLabel in project translationstudio8 by heartsome.
the class TerminologyViewPart method createPartControl.
/**
* 创建控件。
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
this.parent = parent;
createAction();
GridLayout parentGl = new GridLayout(1, false);
parentGl.marginWidth = 0;
parentGl.marginHeight = 0;
parent.setLayout(parentGl);
final Composite contentPanel = new Composite(parent, SWT.NONE);
GridLayout secondPageCompositeGl = new GridLayout(1, false);
secondPageCompositeGl.marginBottom = -1;
secondPageCompositeGl.marginLeft = -1;
secondPageCompositeGl.marginRight = -1;
secondPageCompositeGl.marginTop = -1;
secondPageCompositeGl.marginWidth = 0;
secondPageCompositeGl.marginHeight = 0;
contentPanel.setLayout(secondPageCompositeGl);
contentPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
contentPanel.setLayout(secondPageCompositeGl);
contentPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
// firstPageComposite = new Composite(contentPanel, SWT.NONE);
// firstPageComposite.setLayout(new GridLayout(1, false));
// secondPageComposite = new Composite(contentPanel, SWT.NONE);
// GridLayout secondPageCompositeGl = new GridLayout(1, false);
// secondPageCompositeGl.marginBottom = -1;
// secondPageCompositeGl.marginLeft = -1;
// secondPageCompositeGl.marginRight = -1;
// secondPageCompositeGl.marginTop = -1;
// secondPageCompositeGl.marginWidth = 0;
// secondPageCompositeGl.marginHeight = 0;
// secondPageComposite.setLayout(secondPageCompositeGl);
// secondPageComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
gridTable = new Grid(contentPanel, SWT.BORDER | SWT.V_SCROLL);
gridTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
gridTable.setHeaderVisible(true);
gridTable.setAutoHeight(true);
gridTable.setRowsResizeable(true);
gridTable.setData("selectedBgColor", selectedBgColor);
final GridColumn idItem = new GridColumn(gridTable, SWT.NONE);
idItem.setText(Messages.getString("view.TerminologyViewPart.idItem"));
idColumnCellRenderer.setFont(JFaceResources.getFont(Constants.MATCH_VIEWER_TEXT_FONT));
idColumnCellRenderer.setVerticalAlignment(SWT.CENTER);
idItem.setCellRenderer(idColumnCellRenderer);
idItem.setWordWrap(true);
srcTableColumn = new GridColumn(gridTable, SWT.NONE);
srcTableColumn.setText(Messages.getString("view.TerminologyViewPart.srcTableColumn"));
srcColumnCellRenderer.setFont(JFaceResources.getFont(Constants.MATCH_VIEWER_TEXT_FONT));
srcTableColumn.setCellRenderer(srcColumnCellRenderer);
srcTableColumn.setWordWrap(true);
tgtTableColumn = new GridColumn(gridTable, SWT.NONE);
tgtTableColumn.setText(Messages.getString("view.TerminologyViewPart.tgtTableColumn"));
tgtColumnCellRenderer.setFont(JFaceResources.getFont(Constants.MATCH_VIEWER_TEXT_FONT));
tgtTableColumn.setCellRenderer(tgtColumnCellRenderer);
tgtTableColumn.setWordWrap(true);
final GridColumn propertyColumn = new GridColumn(gridTable, SWT.NONE);
propertyColumn.setText(Messages.getString("view.TerminologyViewPart.propertyColumn"));
propColumnCellRenderer.setFont(JFaceResources.getFont(Constants.MATCH_VIEWER_TEXT_FONT));
propertyColumn.setCellRenderer(propColumnCellRenderer);
propertyColumn.setWordWrap(true);
copyEnable = new GridCopyEnable(gridTable);
srcColumnCellRenderer.setCopyEnable(copyEnable);
tgtColumnCellRenderer.setCopyEnable(copyEnable);
// 设置列宽按比例
contentPanel.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
Rectangle area = contentPanel.getClientArea();
Point preferredSize = gridTable.computeSize(SWT.DEFAULT, SWT.DEFAULT);
// - 2 * gridTable.getBorderWidth();
int width = area.width;
if (preferredSize.y > area.height + gridTable.getHeaderHeight()) {
Point vBarSize = gridTable.getVerticalBar().getSize();
width -= vBarSize.x;
}
gridTable.setSize(area.width, area.height);
width -= 45;
idItem.setWidth(45);
srcTableColumn.setWidth((int) (width * 0.4));
tgtTableColumn.setWidth((int) (width * 0.4));
propertyColumn.setWidth((int) (width * 0.2));
}
});
Composite statusComposite = new Composite(contentPanel, SWT.NONE);
GridLayout statusComptGridLayout = new GridLayout(2, false);
statusComptGridLayout.marginBottom = -1;
statusComptGridLayout.marginLeft = -1;
statusComptGridLayout.marginRight = -1;
statusComptGridLayout.marginTop = -1;
statusComptGridLayout.marginWidth = 0;
statusComptGridLayout.marginHeight = 0;
statusComposite.setLayout(statusComptGridLayout);
statusComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
tipLabel = new CLabel(statusComposite, SWT.NONE);
tipLabel.setAlignment(SWT.LEFT);
CLabel label = new CLabel(statusComposite, SWT.None);
GridData gd = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
gd.heightHint = 20;
label.setLayoutData(gd);
gridTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
selectItem();
}
});
gridTable.addListener(SWT.MouseDoubleClick, new Listener() {
public void handleEvent(Event event) {
firstAction.run();
}
});
initHookMenu();
}
use of org.eclipse.swt.custom.CLabel in project cubrid-manager by CUBRID.
the class SelectWorkspaceDialog method createDialogArea.
/**
* Create the dialog area
*
* @param parent Composite
* @return Control
*/
protected Control createDialogArea(Composite parent) {
Composite parentComp = (Composite) super.createDialogArea(parent);
Composite composite = new Composite(parentComp, SWT.NONE);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout();
layout.numColumns = 3;
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
composite.setLayout(layout);
CLabel label = new CLabel(composite, SWT.NONE);
label.setText(Messages.lblWorkspace);
label.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
workspacePathCombo = new Combo(composite, SWT.BORDER);
workspacePathCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
// fill in the all workspaces to combo
String lastUsed = PREFERENCES.get(KEY_RECENT_WORKSPACES, null);
recentUsedWorkspaces = new ArrayList<String>();
if (lastUsed != null) {
String[] all = lastUsed.split(WORKSPACE_SPLIT_CHAR);
for (String str : all) {
recentUsedWorkspaces.add(str);
}
}
for (String last : recentUsedWorkspaces) {
workspacePathCombo.add(last);
}
String rootDir = PREFERENCES.get(KEY_LAST_WORKSPACE, null);
if (rootDir == null || rootDir.length() == 0) {
rootDir = getSuggestedWorkspacePath();
}
workspacePathCombo.setText(rootDir == null ? "" : rootDir);
Button btnBrowse = new Button(composite, SWT.PUSH);
btnBrowse.setLayoutData(CommonUITool.createGridData(1, 1, 80, -1));
btnBrowse.setText(Messages.btnBrowse);
btnBrowse.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
DirectoryDialog dialog = new DirectoryDialog(getShell());
dialog.setText(Messages.titleSelectWorkspaceDialog);
dialog.setMessage(Messages.msgSelectWorksapce);
String text = workspacePathCombo.getText();
File file = new File(text);
while (file != null && !file.exists()) {
file = file.getParentFile();
}
if (file != null) {
text = file.getAbsolutePath();
}
dialog.setFilterPath(text);
String path = dialog.open();
if (path == null && workspacePathCombo.getText().length() == 0) {
setErrorMessage(Messages.errNoSelectWorkspace);
} else if (path != null) {
setErrorMessage(null);
workspacePathCombo.setText(path);
}
}
});
label = new CLabel(composite, SWT.NONE);
label.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 3, 1, -1, -1));
label.setVisible(false);
// checkbox below
rememberWorkspaceButton = new Button(composite, SWT.CHECK);
rememberWorkspaceButton.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
rememberWorkspaceButton.setText(Messages.btnAsDefault);
rememberWorkspaceButton.setSelection(PREFERENCES.getBoolean(KEY_NOT_SHOW_WORKSPACE_SELECTION_DIALOG, false));
if (isSwitchWorkspace) {
setTitle(Messages.titleSwitchWorkspaceDialog);
} else {
setTitle(Messages.titleSelectWorkspaceDialog);
}
setMessage(Messages.msgSelectWorkspaceDialog);
return parentComp;
}
use of org.eclipse.swt.custom.CLabel in project cubrid-manager by CUBRID.
the class UserEditor method createPartControl.
/**
* Create the page content
*
* @param parent the parent composite
*/
public void createPartControl(Composite parent) {
GridLayout gridLayout = new GridLayout();
gridLayout.marginHeight = 5;
gridLayout.marginWidth = 5;
GridData gridData = new GridData();
gridData.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
Composite top = new Composite(parent, SWT.NONE);
top.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
top.setLayout(gridLayout);
CLabel lblUser = new CLabel(top, SWT.NONE);
lblUser.setFont(new Font(top.getDisplay(), lblUser.getFont().toString(), 14, SWT.BOLD));
lblUser.setBackground(top.getBackground());
lblUser.setLayoutData(gridData);
lblUser.setText(userName);
lblUserGroup = new Label(top, SWT.NONE);
lblUserGroup.setBackground(top.getBackground());
lblUserGroup.setText("");
lblUserGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
lblUserMember = new Label(top, SWT.NONE);
lblUserMember.setBackground(top.getBackground());
lblUserMember.setText("");
lblUserMember.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
GridData gridData1 = new GridData(GridData.FILL_HORIZONTAL);
gridData1.heightHint = 4;
CLabel lbl = new CLabel(top, SWT.SHADOW_IN);
lbl.setLayoutData(gridData1);
lbl = new CLabel(top, SWT.NONE);
lbl.setBackground(top.getBackground());
lbl.setText(Messages.lblOwnerClassList);
Composite ownerComp = new Composite(top, SWT.NONE);
ownerComp.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout();
layout.marginWidth = 1;
layout.marginHeight = 1;
ownerComp.setLayout(layout);
final String[] columnNameArr = new String[] { Messages.tblColOwnerClassName, Messages.tblColOwnerClassSchema, Messages.tblColOwnerClassType };
ownerClassTableViewer = CommonUITool.createCommonTableViewer(ownerComp, new TableViewerSorter(), columnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, 200));
ownerClassTableViewer.setInput(ownerClassListData);
lbl = new CLabel(top, SWT.SHADOW_IN);
lbl.setLayoutData(gridData1);
lbl = new CLabel(top, SWT.NONE);
lbl.setBackground(top.getBackground());
lbl.setText(Messages.lblAuthorizationList);
Composite authComp = new Composite(top, SWT.NONE);
authComp.setLayoutData(new GridData(GridData.FILL_BOTH));
layout = new GridLayout();
layout.marginWidth = 1;
layout.marginHeight = 1;
authComp.setLayout(layout);
authComp.setBackground(top.getBackground());
if (DB_DBA_USERNAME.equalsIgnoreCase(userName)) {
CLabel clbl = new CLabel(authComp, SWT.NONE);
clbl.setBackground(top.getBackground());
clbl.setText(Messages.lblDbaAllAuth);
} else {
final String[] authColumnNameArr = new String[] { Messages.tblColAuthTable, Messages.tblColAuthSelect, Messages.tblColAuthInsert, Messages.tblColAuthUpdate, Messages.tblColAuthDelete, Messages.tblColAuthAlter, Messages.tblColAuthIndex, Messages.tblColAuthExecute, Messages.tblColAuthGrantselect, Messages.tblColAuthGrantinsert, Messages.tblColAuthGrantupdate, Messages.tblColAuthGrantdelete, Messages.tblColAuthGrantalter, Messages.tblColAuthGrantindex, Messages.tblColAuthGrantexecute };
authTableViewer = createCommonTableViewer(authComp, authColumnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, 200));
authTableViewer.setLabelProvider(new ExTableLabelProvider());
authTableViewer.setInput(authListData);
}
loadData();
}
Aggregations