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

The following examples show how to use org.eclipse.swt.widgets.Button#getSize() . 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: CategoryManageDialog.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
private void initNodeTable() {
	this.nodeTable.removeAll();

	this.nodeCheckMap = new HashMap<NodeElement, TableEditor>();

	for (NodeElement nodeElement : this.diagram.getDiagramContents()
			.getContents()) {
		TableItem tableItem = new TableItem(this.nodeTable, SWT.NONE);

		Button selectCheckButton = new Button(this.nodeTable, SWT.CHECK);
		selectCheckButton.pack();

		TableEditor editor = new TableEditor(this.nodeTable);

		editor.minimumWidth = selectCheckButton.getSize().x;
		editor.horizontalAlignment = SWT.CENTER;
		editor.setEditor(selectCheckButton, tableItem, 0);

		tableItem.setText(1, ResourceString
				.getResourceString("label.object.type."
						+ nodeElement.getObjectType()));
		tableItem.setText(2, nodeElement.getName());

		this.nodeCheckMap.put(nodeElement, editor);
	}
}
 
Example 2
Source File: VGroupManageDialog.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
private void initNodeTable() {
	this.nodeTable.removeAll();

	this.nodeCheckMap = new HashMap<NodeElement, TableEditor>();

	for (ERVirtualTable vtable : erModel.getTables()) {
		NodeElement nodeElement = vtable; //.getRawTable();
		TableItem tableItem = new TableItem(this.nodeTable, SWT.NONE);

		Button selectCheckButton = new Button(this.nodeTable, SWT.CHECK);
		selectCheckButton.pack();

		TableEditor editor = new TableEditor(this.nodeTable);

		editor.minimumWidth = selectCheckButton.getSize().x;
		editor.horizontalAlignment = SWT.CENTER;
		editor.setEditor(selectCheckButton, tableItem, 0);

		tableItem.setText(1, ResourceString
				.getResourceString("label.object.type."
						+ nodeElement.getObjectType()));
		tableItem.setText(2, nodeElement.getName());

		this.nodeCheckMap.put(nodeElement, editor);
	}
}
 
Example 3
Source File: IndexDialog.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
private void setTableEditor(final NormalColumn normalColumn, final TableItem tableItem, final Boolean desc) {
    final Button descCheckButton = new Button(indexColumnList, SWT.CHECK);
    descCheckButton.pack();

    if (DBManagerFactory.getDBManager(table.getDiagram()).isSupported(DBManager.SUPPORT_DESC_INDEX)) {

        final TableEditor editor = new TableEditor(indexColumnList);

        editor.minimumWidth = descCheckButton.getSize().x;
        editor.horizontalAlignment = SWT.CENTER;
        editor.setEditor(descCheckButton, tableItem, 1);

        columnCheckMap.put(normalColumn, editor);
    }

    descCheckBoxMap.put(normalColumn, descCheckButton);
    descCheckButton.setSelection(desc.booleanValue());
}
 
Example 4
Source File: CategoryManageDialog.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
private void initNodeTable() {
    nodeTable.removeAll();

    nodeCheckMap = new HashMap<NodeElement, TableEditor>();

    for (final NodeElement nodeElement : diagram.getDiagramContents().getContents()) {
        final TableItem tableItem = new TableItem(nodeTable, SWT.NONE);

        final Button selectCheckButton = new Button(nodeTable, SWT.CHECK);
        selectCheckButton.pack();

        final TableEditor editor = new TableEditor(nodeTable);

        editor.minimumWidth = selectCheckButton.getSize().x;
        editor.horizontalAlignment = SWT.CENTER;
        editor.setEditor(selectCheckButton, tableItem, 0);

        tableItem.setText(1, ResourceString.getResourceString("label.object.type." + nodeElement.getObjectType()));
        tableItem.setText(2, Format.null2blank(nodeElement.getName()));

        nodeCheckMap.put(nodeElement, editor);
    }
}
 
Example 5
Source File: IndexDialog.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
private void setTableEditor(final NormalColumn normalColumn,
		TableItem tableItem, Boolean desc) {
	Button descCheckButton = new Button(this.indexColumnList, SWT.CHECK);
	descCheckButton.pack();

	if (DBManagerFactory.getDBManager(this.table.getDiagram()).isSupported(
			DBManager.SUPPORT_DESC_INDEX)) {

		TableEditor editor = new TableEditor(this.indexColumnList);

		editor.minimumWidth = descCheckButton.getSize().x;
		editor.horizontalAlignment = SWT.CENTER;
		editor.setEditor(descCheckButton, tableItem, 1);

		this.columnCheckMap.put(normalColumn, editor);
	}

	this.descCheckBoxMap.put(normalColumn, descCheckButton);
	descCheckButton.setSelection(desc.booleanValue());
}
 
Example 6
Source File: MainWalkerGroupManageDialog.java    From erflute with Apache License 2.0 6 votes vote down vote up
private void initNodeTable() {
    nodeTable.removeAll();
    nodeCheckMap = new HashMap<>();
    for (final DiagramWalker walker : getTableWalkers()) {
        final TableItem tableItem = new TableItem(nodeTable, SWT.NONE);
        final Button selectCheckButton = new Button(nodeTable, SWT.CHECK);
        selectCheckButton.pack();
        final TableEditor editor = new TableEditor(nodeTable);
        editor.minimumWidth = selectCheckButton.getSize().x;
        editor.horizontalAlignment = SWT.CENTER;
        editor.setEditor(selectCheckButton, tableItem, 0);
        tableItem.setText(1, DisplayMessages.getMessage("label.object.type." + walker.getObjectType()));
        tableItem.setText(2, walker.getName());
        nodeCheckMap.put(walker, editor);
    }
}
 
Example 7
Source File: CompositeFactory.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
public static TableEditor createCheckBoxTableEditor(TableItem tableItem,
		boolean selection, int column) {
	Table table = tableItem.getParent();

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

	TableEditor editor = new TableEditor(table);

	editor.minimumWidth = checkBox.getSize().x;
	editor.horizontalAlignment = SWT.CENTER;
	editor.setEditor(checkBox, tableItem, column);

	checkBox.setSelection(selection);

	return editor;
}
 
Example 8
Source File: AbapGitWizardPageApack.java    From ADT_Frontend with MIT License 6 votes vote down vote up
private void addThePackageButton(IApackDependency dependency, final int packageColumnIndex, TableItem tableItem) {
	Button button = new Button(this.table, SWT.NONE);
	button.setText("..."); //$NON-NLS-1$
	button.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			IAdtPackageServiceUI packageServiceUI = AdtPackageServiceUIFactory.getOrCreateAdtPackageServiceUI();
			IAdtObjectReference[] selectedPackages = packageServiceUI.openPackageSelectionDialog(e.display.getActiveShell(), false,
					AbapGitWizardPageApack.this.destination, tableItem.getText(packageColumnIndex));
			if (selectedPackages != null && selectedPackages.length > 0) {
				setPageComplete(true);
				setMessage(null);
				tableItem.setText(packageColumnIndex, selectedPackages[0].getName());
				dependency.setTargetPackage(selectedPackages[0]);
				packTheTable();
			}
		}
	});
	button.pack();
	TableEditor editor = new TableEditor(this.table);
	editor.horizontalAlignment = SWT.RIGHT;
	editor.minimumWidth = button.getSize().x;
	editor.setEditor(button, tableItem, packageColumnIndex);
	editor.layout();
}
 
Example 9
Source File: CategoryManageDialog.java    From erflute with Apache License 2.0 6 votes vote down vote up
private void initNodeTable() {
    nodeTable.removeAll();
    nodeCheckMap = new HashMap<>();
    for (final DiagramWalker nodeElement : diagram.getDiagramContents().getDiagramWalkers()) {
        final TableItem tableItem = new TableItem(nodeTable, SWT.NONE);

        final Button selectCheckButton = new Button(nodeTable, SWT.CHECK);
        selectCheckButton.pack();

        final TableEditor editor = new TableEditor(nodeTable);

        editor.minimumWidth = selectCheckButton.getSize().x;
        editor.horizontalAlignment = SWT.CENTER;
        editor.setEditor(selectCheckButton, tableItem, 0);

        tableItem.setText(1, DisplayMessages.getMessage("label.object.type." + nodeElement.getObjectType()));
        tableItem.setText(2, nodeElement.getName());

        nodeCheckMap.put(nodeElement, editor);
    }
}
 
Example 10
Source File: IndexDialog.java    From erflute with Apache License 2.0 5 votes vote down vote up
private void setTableEditor(final NormalColumn normalColumn, TableItem tableItem, Boolean desc) {
    final Button descCheckButton = new Button(indexColumnList, SWT.CHECK);
    descCheckButton.pack();
    if (DBManagerFactory.getDBManager(table.getDiagram()).isSupported(DBManager.SUPPORT_DESC_INDEX)) {
        final TableEditor editor = new TableEditor(indexColumnList);
        editor.minimumWidth = descCheckButton.getSize().x;
        editor.horizontalAlignment = SWT.CENTER;
        editor.setEditor(descCheckButton, tableItem, 1);
        columnCheckMap.put(normalColumn, editor);
    }
    descCheckBoxMap.put(normalColumn, descCheckButton);
    descCheckButton.setSelection(desc.booleanValue());
}
 
Example 11
Source File: AbstractSection.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * New push button.
 *
 * @param parent the parent
 * @param label the label
 * @param tip the tip
 * @param enabled the enabled
 * @param style the style
 * @return the button
 */
public Button newPushButton(Composite parent, String label, String tip, boolean enabled, int style) {
  Button button = toolkit.createButton(parent, label, SWT.PUSH | style);
  GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
  button.setLayoutData(gd);
  button.pack(false);
  button.setToolTipText(tip);
  button.setEnabled(enabled);
  button.addListener(SWT.Selection, this);
  Point buttonSize = button.getSize();
  gd.heightHint = buttonSize.y - 2;
  gd.widthHint = buttonSize.x - 2;
  return button;
}
 
Example 12
Source File: CompositeFactory.java    From erflute with Apache License 2.0 5 votes vote down vote up
public static TableEditor createCheckBoxTableEditor(TableItem tableItem, boolean selection, int column) {
    final Table table = tableItem.getParent();

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

    final TableEditor editor = new TableEditor(table);
    editor.minimumWidth = checkBox.getSize().x;
    editor.horizontalAlignment = SWT.CENTER;
    editor.setEditor(checkBox, tableItem, column);

    checkBox.setSelection(selection);

    return editor;
}
 
Example 13
Source File: IndexTabWrapper.java    From erflute with Apache License 2.0 4 votes vote down vote up
private void setTableData() {
    final List<ERIndex> indexes = copyData.getIndexes();

    final TableItem radioTableItem = new TableItem(indexTable, SWT.NONE);

    for (int i = 0; i < indexes.size(); i++) {
        final TableColumn tableColumn = new TableColumn(indexTable, SWT.CENTER);
        tableColumn.setWidth(60);
        tableColumn.setResizable(false);
        tableColumn.setText("Index" + (i + 1));
        final TableEditor editor = new TableEditor(indexTable);
        final Button radioButton = new Button(indexTable, SWT.RADIO);
        radioButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent event) {
                setButtonEnabled(true);
            }
        });
        radioButton.pack();
        editor.minimumWidth = radioButton.getSize().x;
        editor.horizontalAlignment = SWT.CENTER;
        editor.setEditor(radioButton, radioTableItem, i + 2);
        checkButtonList.add(radioButton);
        editorList.add(editor);
    }

    for (final NormalColumn normalColumn : copyData.getExpandedColumns()) {
        final TableItem tableItem = new TableItem(indexTable, SWT.NONE);
        tableItem.setText(0, Format.null2blank(normalColumn.getName()));

        for (int i = 0; i < indexes.size(); i++) {
            final ERIndex index = indexes.get(i);

            final List<NormalColumn> indexColumns = index.getColumns();
            for (int j = 0; j < indexColumns.size(); j++) {
                final NormalColumn indexColumn = indexColumns.get(j);

                if (normalColumn.equals(indexColumn)) {
                    tableItem.setText(i + 2, String.valueOf(j + 1));
                    break;
                }
            }
        }
    }

    setButtonEnabled(false);
}
 
Example 14
Source File: IndexTabWrapper.java    From ermaster-b with Apache License 2.0 4 votes vote down vote up
private void setTableData() {
	List<Index> indexes = this.copyData.getIndexes();

	TableItem radioTableItem = new TableItem(this.indexTable, SWT.NONE);

	for (int i = 0; i < indexes.size(); i++) {
		TableColumn tableColumn = new TableColumn(this.indexTable,
				SWT.CENTER);
		tableColumn.setWidth(60);
		tableColumn.setResizable(false);
		tableColumn.setText("Index" + (i + 1));

		TableEditor editor = new TableEditor(this.indexTable);

		Button radioButton = new Button(this.indexTable, SWT.RADIO);
		radioButton.addSelectionListener(new SelectionAdapter() {

			/**
			 * {@inheritDoc}
			 */
			@Override
			public void widgetSelected(SelectionEvent event) {
				setButtonEnabled(true);
			}
		});

		radioButton.pack();

		editor.minimumWidth = radioButton.getSize().x;
		editor.horizontalAlignment = SWT.CENTER;
		editor.setEditor(radioButton, radioTableItem, i + 2);

		this.checkButtonList.add(radioButton);
		this.editorList.add(editor);
	}

	for (NormalColumn normalColumn : this.copyData.getExpandedColumns()) {
		TableItem tableItem = new TableItem(this.indexTable, SWT.NONE);
		tableItem.setText(0, Format.null2blank(normalColumn.getName()));

		for (int i = 0; i < indexes.size(); i++) {
			Index index = indexes.get(i);

			List<NormalColumn> indexColumns = index.getColumns();
			for (int j = 0; j < indexColumns.size(); j++) {
				NormalColumn indexColumn = indexColumns.get(j);

				if (normalColumn.equals(indexColumn)) {
					tableItem.setText(i + 2, String.valueOf(j + 1));
					break;
				}
			}
		}
	}

	setButtonEnabled(false);
}
 
Example 15
Source File: ThemePreferencePage.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
private void createButton(final Table table, final TableItem tableItem, final int index, final RGBa color)
{
	TableEditor editor = new TableEditor(table);
	Button button = new Button(table, SWT.PUSH | SWT.FLAT);
	Image image = createColorImage(table, color);
	button.setImage(image);
	button.pack();
	editor.minimumWidth = button.getSize().x - 4;
	editor.horizontalAlignment = SWT.CENTER;
	editor.setEditor(button, tableItem, index);
	fTableEditors.add(editor);
	button.setData("color", color); //$NON-NLS-1$

	button.addSelectionListener(new SelectionAdapter()
	{
		@Override
		public void widgetSelected(SelectionEvent e)
		{
			ColorDialog colorDialog = new ColorDialog(table.getShell());
			Button self = ((Button) e.widget);
			RGBa theColor = (RGBa) self.getData("color"); //$NON-NLS-1$
			if (theColor == null)
			{
				theColor = color;
			}
			colorDialog.setRGB(theColor.toRGB());
			RGB newRGB = colorDialog.open();
			if (newRGB == null)
			{
				return;
			}
			ThemeRule token = (ThemeRule) tableItem.getData();
			RGBa newColor = new RGBa(newRGB);
			if (index == 1)
			{
				getTheme().updateRule(table.indexOf(tableItem), token.updateFG(newColor));
			}
			else
			{
				getTheme().updateRule(table.indexOf(tableItem), token.updateBG(newColor));
			}
			// Update the image for this button!
			self.setImage(createColorImage(table, newColor));
			self.setData("color", newColor); //$NON-NLS-1$
			tableViewer.refresh();
		}
	});

	// Allow dragging the button out of it's location to remove the fg/bg for the rule!
	Transfer[] types = new Transfer[] { TextTransfer.getInstance() };
	final DragSource source = new DragSource(button, DND.DROP_MOVE);
	source.setTransfer(types);

	source.addDragListener(new DragSourceAdapter()
	{
		public void dragSetData(DragSourceEvent event)
		{
			event.data = "button:" + table.indexOf(tableItem) + ":" + index; //$NON-NLS-1$ //$NON-NLS-2$
		}
	});
}
 
Example 16
Source File: IndexTabWrapper.java    From ermasterr with Apache License 2.0 4 votes vote down vote up
private void setTableData() {
    final List<Index> indexes = copyData.getIndexes();

    final TableItem radioTableItem = new TableItem(indexTable, SWT.NONE);

    for (int i = 0; i < indexes.size(); i++) {
        final TableColumn tableColumn = CompositeFactory.createTableColumn(indexTable, "Index" + (i + 1), -1, SWT.CENTER);
        tableColumn.setResizable(false);

        final TableEditor editor = new TableEditor(indexTable);

        final Button radioButton = new Button(indexTable, SWT.RADIO);
        radioButton.addSelectionListener(new SelectionAdapter() {

            /**
             * {@inheritDoc}
             */
            @Override
            public void widgetSelected(final SelectionEvent event) {
                setButtonEnabled(true);
            }
        });

        radioButton.pack();

        editor.minimumWidth = radioButton.getSize().x;
        editor.horizontalAlignment = SWT.CENTER;
        editor.setEditor(radioButton, radioTableItem, i + 2);

        checkButtonList.add(radioButton);
        editorList.add(editor);
    }

    for (final NormalColumn normalColumn : copyData.getExpandedColumns()) {
        final TableItem tableItem = new TableItem(indexTable, SWT.NONE);
        tableItem.setText(0, Format.null2blank(normalColumn.getName()));

        for (int i = 0; i < indexes.size(); i++) {
            final Index index = indexes.get(i);

            final List<NormalColumn> indexColumns = index.getColumns();
            for (int j = 0; j < indexColumns.size(); j++) {
                final NormalColumn indexColumn = indexColumns.get(j);

                if (normalColumn.equals(indexColumn)) {
                    tableItem.setText(i + 2, String.valueOf(j + 1));
                    break;
                }
            }
        }
    }

    indexTable.getColumns()[0].pack();

    setButtonEnabled(false);
}
 
Example 17
Source File: CompositeFactory.java    From ermasterr with Apache License 2.0 4 votes vote down vote up
public static TableEditor createCheckBoxTableEditor(final TableItem tableItem, final boolean selection, final int column) {
    final Table table = tableItem.getParent();

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

    final TableEditor editor = new TableEditor(table);

    editor.minimumWidth = checkBox.getSize().x;
    editor.horizontalAlignment = SWT.CENTER;
    editor.setEditor(checkBox, tableItem, column);

    checkBox.setSelection(selection);

    return editor;
}