本文整理汇总了Java中org.eclipse.swt.widgets.ToolBar.pack方法的典型用法代码示例。如果您正苦于以下问题:Java ToolBar.pack方法的具体用法?Java ToolBar.pack怎么用?Java ToolBar.pack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.widgets.ToolBar
的用法示例。
在下文中一共展示了ToolBar.pack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTagComposite
import org.eclipse.swt.widgets.ToolBar; //导入方法依赖的package包/类
/**
* Creates the actual GUI widgets.
*/
private static Composite createTagComposite(Composite parent, TagVM tagVm, TagToolItemConfigurator configurator) {
Composite tagContainer = new Composite(parent, SWT.BORDER);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
tagContainer.setLayout(layout);
Label tagLabel = new Label(tagContainer, SWT.NONE);
tagLabel.setText(tagVm.getName());
GridData gdl = new GridData();
gdl.verticalAlignment = GridData.CENTER;
tagLabel.setLayoutData(gdl);
ToolBar toolBar = new ToolBar(tagContainer, SWT.FLAT);
Rectangle clientArea = tagContainer.getClientArea();
toolBar.setLocation(clientArea.x, clientArea.y);
configurator.setupToolbar(toolBar, tagVm);
toolBar.pack();
return tagContainer;
}
示例2: main
import org.eclipse.swt.widgets.ToolBar; //导入方法依赖的package包/类
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
ToolBar bar = new ToolBar(shell, SWT.BORDER|SWT.VERTICAL);
for (int i = 0; i < 4; i++) {
ToolItem item = new ToolItem(bar, 0);
// item.setText("Item " + i);
item.setImage(Images.APPLICATION);
}
bar.pack();
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
示例3: createSingleColors
import org.eclipse.swt.widgets.ToolBar; //导入方法依赖的package包/类
/**
* Create a toolitem to represent a color. In the passed composite will be
* created two element, a label with a text and the toolitem
*
* @param text the text that will be used into the label
* @param parent the composite where the controls will be placed
* @param color the color used to initialize the control
* @return the created toolitem
*/
private ToolItem createSingleColors(String text, Composite parent, AlfaRGB color){
new Label(parent, SWT.NONE).setText(text);
final ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.WRAP | SWT.LEFT);
toolBar.setBackground(parent.getBackground());
final ToolItem foreButton = new ToolItem(toolBar, SWT.PUSH);
setButtonColor(color, foreButton);
foreButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
ColorDialog cd = new ColorDialog(toolBar.getShell());
cd.setText(Messages.TableWizardLayoutPage_colorSelectionDialog);
if (foreButton.getData() instanceof AlfaRGB) cd.setRGB((AlfaRGB)foreButton.getData());
AlfaRGB newColor = cd.openAlfaRGB();
if (newColor != null) {
setButtonColor(newColor,foreButton);
selectionChangeButton.widgetSelected(e);
}
}
});
toolBar.pack();
return foreButton;
}
示例4: setSelected
import org.eclipse.swt.widgets.ToolBar; //导入方法依赖的package包/类
public void setSelected(DataAdapterDescriptor d) {
selectedDA = d;
// set current
String name = d.getName();
if (name.length() > 17)
name = name.substring(0, 17) + "..."; //$NON-NLS-1$
setText(name);
setDescription(d.getDescription());
setToolTipText(d.getName());
if (parent != null) {
ToolBar toolBar = (ToolBar) parent;
toolBar.pack(true);
toolBar.getParent().getParent().layout(true);
}
}
示例5: createToolBar
import org.eclipse.swt.widgets.ToolBar; //导入方法依赖的package包/类
/**
* Creates the toolbar.
*/
private void createToolBar(Composite composite, Object layoutData) {
toolBar = new ToolBar(composite, SWT.FLAT);
toolBar.addListener(SWT.KeyUp, createToolbarCommandHandler());
if (layoutData != null) toolBar.setLayoutData(layoutData);
if (nativeFilter != null) {
nativeFilterAdapter = (FilterAdapter) nativeFilterAdapterMap.get(nativeFilter.getClass());
if (nativeFilterAdapter != null) {
nativeToolItem = nativeFilterAdapter.create(toolBar);
nativeToolItem.setSelection(true);
}
}
hexDumpToolItem = createHexDumpToolItem();
if (nativeFilterAdapter == null) {
// Default button changes for these instances.
hexDumpToolItem.setSelection(true);
// Prevent NullPointerExceptions if the nativeFilterAdapter does not apply.
nativeFilterAdapter = hexFilterAdapter;
}
rawDumpToolItem = createRawDumpToolItem();
new ToolItem(toolBar, SWT.SEPARATOR);
copyToolItem = createCopyToolItem();
new ToolItem(toolBar, SWT.SEPARATOR);
createPrintToolItem();
toolBar.pack();
}
示例6: createCoolItem
import org.eclipse.swt.widgets.ToolBar; //导入方法依赖的package包/类
private void createCoolItem(final CoolBar coolBar, final ToolBar toolBar) {
Check.notNull(coolBar, "coolBar"); //$NON-NLS-1$
Check.notNull(toolBar, "toolBar"); //$NON-NLS-1$
// Compute the size of the toolbar
toolBar.pack();
final Point toolBarSize = toolBar.getSize();
// Create a CoolItem to hold the toolbar
final CoolItem coolItem = new CoolItem(coolBar, SWT.NONE);
coolItem.setControl(toolBar);
// Set the preferred size to what was computed from the toolbar
final Point coolItemSize = coolItem.computeSize(toolBarSize.x, toolBarSize.y);
/*
* SWT Quirk (Bug?)
*
* The cool item should have its PREFERRED size set to the result of its
* OWN computeSize() calculation, but its MINIMUM size should be set to
* its "child" TOOL BAR's computed size. I think it should rightly use
* the same size (its OWN computed size) for minimum size, but this
* leaves way too much empty space in the right side of the toolbar.
*/
coolItem.setPreferredSize(coolItemSize);
coolItem.setMinimumSize(toolBarSize);
}
示例7: adjustCoolbar
import org.eclipse.swt.widgets.ToolBar; //导入方法依赖的package包/类
public static void adjustCoolbar(ChessBoard board, ToolBar toolbar) {
clearCoolbar(board);
toolbar.pack();
Point size = toolbar.getSize();
board.getCoolbar().setVisible(true);
board.getCoolbar().setLocked(true);
CoolItem coolItem = new CoolItem(board.getCoolbar(), SWT.NONE);
coolItem.setControl(toolbar);
coolItem.setSize(size.x, size.y);
coolItem.setPreferredSize(size.x, size.y);
coolItem.setMinimumSize(size);
board.getControl().layout();
}
示例8: createToolbar
import org.eclipse.swt.widgets.ToolBar; //导入方法依赖的package包/类
public Composite createToolbar(Composite parent) {
final Composite comp = new Composite(parent, SWT.NONE);
comp.setLayout(new GridLayout(4, false));
comp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
comp.setBackgroundMode(SWT.INHERIT_FORCE);
Label lbl = new Label(comp, SWT.NONE);
lbl.setImage(JaspersoftStudioPlugin.getInstance().getImage(MDataAdapters.getIconDescriptor().getIcon16()));
final ToolBar tb = new ToolBar(comp, SWT.FLAT | SWT.RIGHT);
tb.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
final ToolBarManager manager = new ToolBarManager(tb);
IDataAdapterRunnable adapterRunReport = new IDataAdapterRunnable() {
public void runReport(DataAdapterDescriptor da) {
if (da != null)
newdataset.setProperty(DEFAULT_DATAADAPTER, da.getName());
currentDesigner.setDataAdapter(da);
qStatus.showInfo("");
}
public boolean isNotRunning() {
return true;
}
};
dscombo = new DataAdapterAction(adapterRunReport, DataAdapterManager.getDataAdapter(file));
manager.add(dscombo);
manager.update(true);
tb.pack();
createStatusBar(comp);
createProgressBar(comp);
return comp;
}
示例9: getMenu
import org.eclipse.swt.widgets.ToolBar; //导入方法依赖的package包/类
public Menu getMenu(final Control parent) {
if (listMenu != null)
listMenu.dispose();
listMenu = new Menu(parent);
SelectionAdapter listener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
MenuItem menuItem = (MenuItem) e.getSource();
menuItem.setSelection(true);
setText(menuItem.getText());
if (parent != null) {
ToolBar toolBar = (ToolBar) parent;
toolBar.pack(true);
toolBar.getParent().getParent().layout(true);
}
run();
}
};
MenuItem m1 = new MenuItem(listMenu, SWT.PUSH);
m1.setText("Read Fields (Automatically) ");
m1.addSelectionListener(listener);
m1.setData("da.key", "aa");
m1 = new MenuItem(listMenu, SWT.PUSH);
m1.setText("Read Fields (Manually) ");
m1.addSelectionListener(listener);
m1.setData("da.key", "aa");
return listMenu;
}
示例10: buildMainToolBar
import org.eclipse.swt.widgets.ToolBar; //导入方法依赖的package包/类
public static void buildMainToolBar(Composite parent) {
ToolBar bar = new ToolBar(parent, SWT.FLAT);
addOpenItems(bar);
addSeparator(bar);
addEditItems(bar);
addSeparator(bar);
addActionItems(bar);
addSeparator(bar);
addHelpItems(bar);
bar.pack();
}
示例11: initToolbar
import org.eclipse.swt.widgets.ToolBar; //导入方法依赖的package包/类
/**
* Populate toolbar with buttons.
*
* @param composite
* Parent composite.
*/
private void initToolbar(final Composite composite) {
Display display = composite.getDisplay();
ClassLoader loader = getClass().getClassLoader();
// Instantiate toolbar.
ToolBar toolBar = new ToolBar(composite, SWT.BORDER);
// Add button.
imgRefresh = new Image(display, loader.getResourceAsStream("toolbar/refresh.png"));
itemRefresh = new ToolItem(toolBar, SWT.PUSH);
itemRefresh.setImage(imgRefresh);
itemRefresh.setText("Refresh");
itemRefresh.setToolTipText("Refresh system information");
itemRefresh.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
try {
tree.refresh();
} catch (SophieException e) {
ExceptionDialog.open(composite.getShell(), new SophieException("Unable to refresh system tree", e));
}
}
});
// Pack.
toolBar.pack();
}
示例12: initToolbar
import org.eclipse.swt.widgets.ToolBar; //导入方法依赖的package包/类
/**
* Populate toolbar with buttons.
*
* @param composite
* Parent composite.
*/
private void initToolbar(final Composite composite) {
Display display = composite.getDisplay();
ClassLoader loader = getClass().getClassLoader();
// Instantiate toolbar.
ToolBar toolBar = new ToolBar(composite, SWT.BORDER);
// Add button.
imgRefresh = new Image(display, loader.getResourceAsStream("toolbar/refresh.png"));
itemRefresh = new ToolItem(toolBar, SWT.PUSH);
itemRefresh.setImage(imgRefresh);
itemRefresh.setText("Refresh");
itemRefresh.setToolTipText("Refresh list of files from Solr");
itemRefresh.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
try {
tree.refresh();
} catch (SophieException e) {
ExceptionDialog.open(composite.getShell(), new SophieException("Unable to refresh files", e));
}
}
});
// Pack.
toolBar.pack();
}
示例13: initToolbar
import org.eclipse.swt.widgets.ToolBar; //导入方法依赖的package包/类
/**
* Populate toolbar with buttons.
*
* @param composite
* Parent composite.
*/
private void initToolbar(final Composite composite) {
Display display = composite.getDisplay();
ClassLoader loader = getClass().getClassLoader();
// Instantiate toolbar.
ToolBar toolBar = new ToolBar(composite, SWT.BORDER);
// Add button.
imgRefresh = new Image(display, loader.getResourceAsStream("toolbar/refresh.png"));
itemRefresh = new ToolItem(toolBar, SWT.PUSH);
itemRefresh.setImage(imgRefresh);
itemRefresh.setText("Refresh");
itemRefresh.setToolTipText("Refresh list of fields");
itemRefresh.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
try {
table.refresh();
} catch (SophieException e) {
ExceptionDialog.open(composite.getShell(), new SophieException("Unable to refresh fields table", e));
}
}
});
// Pack.
toolBar.pack();
}
示例14: createCustomArea
import org.eclipse.swt.widgets.ToolBar; //导入方法依赖的package包/类
@Override
protected Control createCustomArea(final Composite parent) {
Composite body = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(body);
GridLayoutFactory.fillDefaults().numColumns(2).applyTo(body);
ToolBar bar = new ToolBar(body, SWT.HORIZONTAL);
ToolBarManager barMgr = new ToolBarManager(bar);
barMgr.add(new AlignLeftAction());
barMgr.add(new AlignCenterAction());
barMgr.add(new AlignRightAction());
barMgr.add(new InsColBeforeAction());
barMgr.add(new InsColAfterAction());
barMgr.add(new RmvColAction());
barMgr.add(new InsRowAboveAction());
barMgr.add(new InsRowBelowAction());
barMgr.add(new RmvRowAction());
barMgr.update(true);
bar.pack();
viewer = new TableViewer(body, style);
GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(viewer.getControl());
table = viewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
cellMgr = new TableViewerFocusCellManager(viewer, new FocusCellOwnerDrawHighlighter(viewer));
ColumnViewerEditorActivationStrategy activator = new ColumnViewerEditorActivationStrategy(viewer) {
@Override
protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
|| event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
|| (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.CR)
|| event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC;
}
};
TableViewerEditor.create(viewer, cellMgr, activator, features);
MenuManager mgr = new MenuManager();
mgr.add(new InsColBeforeAction());
mgr.add(new InsColAfterAction());
mgr.add(new RmvColAction());
mgr.add(new Separator());
mgr.add(new InsRowAboveAction());
mgr.add(new InsRowBelowAction());
mgr.add(new RmvRowAction());
viewer.getControl().setMenu(mgr.createContextMenu(viewer.getControl()));
tableModel = new TableModel();
setInput(part);
return body;
}
示例15: createToolbar
import org.eclipse.swt.widgets.ToolBar; //导入方法依赖的package包/类
protected ToolBar createToolbar() {
final ToolBar t = new ToolBar(composite, SWT.FLAT | SWT.LEFT | SWT.HORIZONTAL | SWT.WRAP);
final GridData d = new GridData(SWT.FILL, SWT.TOP, false, false);
t.setLayoutData(d);
final String unitText = computeUnitLabel();
if (!unitText.isEmpty()) {
unitItem = new ToolItem(t, SWT.READ_ONLY | SWT.FLAT);
unitItem.setText(unitText);
unitItem.setEnabled(false);
}
if (!isEditable)
return t;
final int[] codes = this.getToolItems();
for (final int i : codes) {
ToolItem item = null;
switch (i) {
case REVERT:
item = createItem(t, "Revert to original value", GamaIcons.create("small.revert").image());
break;
case PLUS:
item = createPlusItem(t);
break;
case MINUS:
item = createItem(t, "Decrement the parameter", GamaIcons.create(IGamaIcons.SMALL_MINUS).image());
break;
case EDIT:
item = createItem(t, "Edit the parameter", GamaIcons.create("small.edit").image());
break;
case INSPECT:
item = createItem(t, "Inspect the agent", GamaIcons.create("small.inspect").image());
break;
case BROWSE:
item = createItem(t, "Browse the list of agents", GamaIcons.create("small.browse").image());
break;
case CHANGE:
item = createItem(t, "Choose another agent", GamaIcons.create("small.change").image());
break;
case DEFINE:
item = createItem(t, "Set the parameter to undefined", GamaIcons.create("small.undefine").image());
}
if (item != null) {
items[i] = item;
item.addSelectionListener(new ItemSelectionListener(i));
}
}
t.layout();
t.pack();
return t;
}