Java Code Examples for org.eclipse.swt.widgets.Button.pack()

The following are Jave code examples for showing how to use pack() of the org.eclipse.swt.widgets.Button class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Hydrograph   File: TransformViewDataDialog.java   View Source Code Vote up 6 votes
/**
 * Creates the copy button 
 * @param buttonComposite
 */
private void createCopyButton(Composite buttonComposite){
	Button copyButton = new Button(buttonComposite, SWT.PUSH);
 
    	copyButton.setImage(ImagePathConstant.ENABLE_COPY_ICON.getImageFromRegistry());
    	copyButton.setToolTipText(COPY_BUTTON_TOOL_TIP);
    	copyButton.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
			if (StringUtils.isNotBlank(styledText.getSelectionText())) {
				styledText.copy();
			} else {
				styledText.selectAll();
				styledText.copy();
				styledText.setSelection(0);
			}

		}
	});
		copyButton.pack();
}
 
Example 2
Project: Hydrograph   File: TransformViewDataDialog.java   View Source Code Vote up 5 votes
/**
 * Creates the word wrap button 
 * @param buttonComposite
 */
private void createWrapButton(Composite buttonComposite)
{
	final Button btnCheckButton = new Button(buttonComposite, SWT.CHECK);
    btnCheckButton.setText("Wrap Text");
    btnCheckButton.pack();
    
    btnCheckButton.addSelectionListener(new SelectionAdapter() {
    	@Override
		public void widgetSelected(SelectionEvent e) {
    		styledText.setWordWrap(btnCheckButton.getSelection());
		}
    	
	});
}
 
Example 3
Project: eZooKeeper   File: ZnodeAclComposite.java   View Source Code Vote up 4 votes
public TableItem addAclTableItem(ACL acl) {

        final Table table = getTable();

        final TableItem item = new TableItem(table, SWT.NONE);
        item.setData("ACL", acl);
        Id id = acl.getId();

        int aclPerms = acl.getPerms();
        boolean hasAll = ((aclPerms & ZooDefs.Perms.ALL) == ZooDefs.Perms.ALL);

        item.setText(0, id.getScheme());
        item.setText(1, id.getId());

        for (final int perm : PERMS) {
            final int permColumnIndex = getPermissionColumnIndex(perm);
            TableEditor permCheckBoxTableEditor = new TableEditor(table);
            setItemPermTableEditor(item, perm, permCheckBoxTableEditor);

            final Button permCheckBox = new Button(table, SWT.CHECK);

            boolean hasPerm = ((aclPerms & perm) == perm);
            permCheckBox.setSelection(hasPerm);
            permCheckBox.setEnabled(!hasAll || (hasAll && perm == ZooDefs.Perms.ALL));

            permCheckBox.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {

                    if (perm == ZooDefs.Perms.ALL) {
                        for (int subPerm : PERMS) {
                            if (subPerm == ZooDefs.Perms.ALL) {
                                continue;
                            }

                            Button subPermCheckBox = getItemPermCheckBox(item, subPerm);
                            boolean allIsSelected = permCheckBox.getSelection();
                            if (allIsSelected) {
                                subPermCheckBox.setSelection(true);
                            }
                            subPermCheckBox.setEnabled(!allIsSelected);
                        }
                    }

                    fireOrchestrationChange();
                }

            });

            permCheckBox.pack();
            permCheckBoxTableEditor.minimumWidth = permCheckBox.getSize().x;
            permCheckBoxTableEditor.horizontalAlignment = SWT.CENTER;
            permCheckBoxTableEditor.setEditor(permCheckBox, item, permColumnIndex);

        }

        return item;
    }