private void addResourcesArea(Composite composite) { ResourceSelectionTree.IToolbarControlCreator toolbarControlCreator = new ResourceSelectionTree.IToolbarControlCreator() { public void createToolbarControls(ToolBarManager toolbarManager) { toolbarManager.add(new ControlContribution("stealLock") { protected Control createControl(Composite parent) { stealButton = new Button(parent, SWT.CHECK); stealButton.setText(Policy.bind("LockDialog.stealLock")); //$NON-NLS-1$ return stealButton; } }); } public int getControlCount() { return 1; } }; resourceSelectionTree = new ResourceSelectionTree(composite, SWT.NONE, "These files will be locked:", files, new HashMap(), null, false, toolbarControlCreator, null); //$NON-NLS-1$ resourceSelectionTree.setShowRemoveFromViewAction(false); }
private void fillLocalToolBar(IToolBarManager manager) { manager.add(new ControlContribution("connection status") { @Override protected Control createControl(Composite parent) { connectionLabel = new Label(parent, SWT.NONE); connectionLabel.setImage(redIcon); return connectionLabel; } }); manager.add(autoReconnectAction); manager.add(new Separator()); manager.add(pauseAction); manager.add(discardAction); manager.add(showWarningAction); manager.add(showPrintAction); manager.add(showTimestampAction); manager.add(new Separator()); manager.add(clearAction); }
@Override protected void contributeToToolBar(IToolBarManager toolBarManager) { super.contributeToToolBar(toolBarManager); ControlContribution toolBarCompositeContribution = new ControlContribution(getToolBarCompositeContributionId()) { @Override protected Control createControl(Composite parent) { FormToolkit toolkit = getManagedForm().getToolkit(); Composite toolBarComposite = toolkit.createComposite(parent); FormLayout toolBarCompositeLayout = new FormLayout(); toolBarCompositeLayout.marginTop = 0; toolBarCompositeLayout.marginBottom = 0; toolBarCompositeLayout.marginLeft = 4; toolBarCompositeLayout.marginRight = 4; toolBarCompositeLayout.spacing = 4; toolBarComposite.setLayout(toolBarCompositeLayout); _ToolBarLabel = toolkit.createLabel(toolBarComposite, "", SWT.RIGHT); FormData toolBarLabelFormData = new FormData(); toolBarLabelFormData.top = new FormAttachment(0, 0); toolBarLabelFormData.left = new FormAttachment(0, 0); toolBarLabelFormData.right = new FormAttachment(100, 0); // HACK: I really struggled to get this label to show up. toolBarLabelFormData.width = 100; _ToolBarLabel.setLayoutData(toolBarLabelFormData); return toolBarComposite; } }; toolBarManager.add(toolBarCompositeContribution); }