use of org.eclipse.jface.action.ToolBarManager in project egit by eclipse.
the class StagingView method createStagedToolBarComposite.
private void createStagedToolBarComposite() {
Composite stagedToolbarComposite = toolkit.createComposite(stagedSection);
stagedToolbarComposite.setBackground(null);
stagedToolbarComposite.setLayout(createRowLayoutWithoutMargin());
stagedSection.setTextClient(stagedToolbarComposite);
stagedExpandAllAction = new Action(UIText.UIUtils_ExpandAll, IAction.AS_PUSH_BUTTON) {
@Override
public void run() {
stagedViewer.expandAll();
enableAutoExpand(stagedViewer);
}
};
stagedExpandAllAction.setImageDescriptor(UIIcons.EXPAND_ALL);
stagedExpandAllAction.setId(EXPAND_ALL_ITEM_TOOLBAR_ID);
stagedCollapseAllAction = new Action(UIText.UIUtils_CollapseAll, IAction.AS_PUSH_BUTTON) {
@Override
public void run() {
stagedViewer.collapseAll();
disableAutoExpand(stagedViewer);
}
};
stagedCollapseAllAction.setImageDescriptor(UIIcons.COLLAPSEALL);
stagedCollapseAllAction.setId(COLLAPSE_ALL_ITEM_TOOLBAR_ID);
stagedToolBarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL);
stagedToolBarManager.add(unstageAction);
stagedToolBarManager.add(unstageAllAction);
stagedToolBarManager.add(stagedExpandAllAction);
stagedToolBarManager.add(stagedCollapseAllAction);
stagedToolBarManager.update(true);
stagedToolBarManager.createControl(stagedToolbarComposite);
}
use of org.eclipse.jface.action.ToolBarManager in project egit by eclipse.
the class StagingView method setExpandCollapseActionsVisible.
private void setExpandCollapseActionsVisible(boolean staged, boolean visibleExpandAll, boolean visibleCollapseAll) {
ToolBarManager toolBarManager = staged ? stagedToolBarManager : unstagedToolBarManager;
for (IContributionItem item : toolBarManager.getItems()) {
String id = item.getId();
if (EXPAND_ALL_ITEM_TOOLBAR_ID.equals(id)) {
item.setVisible(visibleExpandAll);
} else if (COLLAPSE_ALL_ITEM_TOOLBAR_ID.equals(id)) {
item.setVisible(visibleCollapseAll);
}
}
(staged ? stagedExpandAllAction : unstagedExpandAllAction).setEnabled(visibleExpandAll);
(staged ? stagedCollapseAllAction : unstagedCollapseAllAction).setEnabled(visibleCollapseAll);
toolBarManager.update(true);
}
use of org.eclipse.jface.action.ToolBarManager in project egit by eclipse.
the class CommitEditor method createHeaderContents.
/**
* @see org.eclipse.ui.forms.editor.SharedHeaderFormEditor#createHeaderContents(org.eclipse.ui.forms.IManagedForm)
*/
@Override
protected void createHeaderContents(IManagedForm headerForm) {
headerForm.addPart(new FocusManagerFormPart(headerFocusTracker) {
@Override
public void setDefaultFocus() {
headerForm.getForm().getForm().setFocus();
}
});
RepositoryCommit commit = getCommit();
ScrolledForm form = headerForm.getForm();
String commitName = commit.getRevCommit().name();
String title = getFormattedHeaderTitle(commitName);
HeaderText text = new HeaderText(form.getForm(), title, commitName);
Control textControl = text.getControl();
if (textControl != null) {
headerFocusTracker.addToFocusTracking(textControl);
}
form.setToolTipText(commitName);
getToolkit().decorateFormHeading(form.getForm());
toolbar = form.getToolBarManager();
ControlContribution repositoryLabelControl = new ControlContribution(// $NON-NLS-1$
"repositoryLabel") {
@Override
protected Control createControl(Composite parent) {
FormToolkit toolkit = getHeaderForm().getToolkit();
String label = getCommit().getRepositoryName();
ImageHyperlink link = new ImageHyperlink(parent, SWT.NONE);
// Focus tracking on this link doesn't really work. It's a
// focusable control inside another focusable control (the
// toolbar). When focus leaves this control through tabbing
// or deactivating the editor, the toolbar gets the focus (and
// possibly loses it right away again). Thus the focus tracker
// will always see the toolbar as the last focused control.
// Unfortunately there is no other way to get some text onto
// the first line of a FormHeading.
headerFocusTracker.addToFocusTracking(link);
link.setText(label);
link.setFont(JFaceResources.getBannerFont());
link.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
link.setToolTipText(UIText.CommitEditor_showGitRepo);
link.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent event) {
RepositoriesView view;
try {
view = (RepositoriesView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(RepositoriesView.VIEW_ID);
view.showRepository(getCommit().getRepository());
} catch (PartInitException e) {
Activator.handleError(UIText.CommitEditor_couldNotShowRepository, e, false);
}
}
});
return link;
}
};
toolbar.add(repositoryLabelControl);
CommonUtils.getService(getSite(), IPartService.class).addPartListener(activationListener);
if (commit.isStash()) {
toolbar.add(createActionContributionItem(StashApplyHandler.ID, UIText.CommitEditor_toolbarApplyStash, UIIcons.STASH_APPLY));
toolbar.add(createActionContributionItem(StashDropHandler.ID, UIText.CommitEditor_toolbarDeleteStash, PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE)));
} else {
toolbar.add(createActionContributionItem(CreateTagHandler.ID, UIText.CommitEditor_toolbarCreateTag, UIIcons.TAG));
toolbar.add(createActionContributionItem(CreateBranchHandler.ID, UIText.CommitEditor_toolbarCreateBranch, UIIcons.BRANCH));
toolbar.add(createActionContributionItem(CheckoutHandler.ID, UIText.CommitEditor_toolbarCheckOut, UIIcons.CHECKOUT));
toolbar.add(createActionContributionItem(CherryPickHandler.ID, UIText.CommitEditor_toolbarCherryPick, UIIcons.CHERRY_PICK));
toolbar.add(createActionContributionItem(RevertHandler.ID, UIText.CommitEditor_toolbarRevert, UIIcons.REVERT));
toolbar.add(createActionContributionItem(ShowInHistoryHandler.ID, UIText.CommitEditor_toolbarShowInHistory, UIIcons.HISTORY));
}
addContributions(toolbar);
toolbar.update(true);
getSite().setSelectionProvider(new ISelectionProvider() {
@Override
public void setSelection(ISelection selection) {
// Ignored
}
@Override
public void removeSelectionChangedListener(ISelectionChangedListener listener) {
// Ignored
}
@Override
public ISelection getSelection() {
return new StructuredSelection(getCommit());
}
@Override
public void addSelectionChangedListener(ISelectionChangedListener listener) {
// Ignored
}
});
if (toolbar instanceof ToolBarManager) {
Control control = ((ToolBarManager) toolbar).getControl();
if (control != null) {
headerFocusTracker.addToFocusTracking(control);
}
}
}
use of org.eclipse.jface.action.ToolBarManager in project webtools.servertools by eclipse.
the class NewManualServerComposite method createControl.
/**
* Returns this page's initial visual components.
*/
protected void createControl() {
// top level group
GridLayout layout = new GridLayout();
layout.numColumns = 3;
layout.horizontalSpacing = SWTUtil.convertHorizontalDLUsToPixels(this, 4);
layout.verticalSpacing = SWTUtil.convertVerticalDLUsToPixels(this, 4);
layout.marginWidth = 0;
layout.marginHeight = 0;
setLayout(layout);
this.setFont(getParent().getFont());
IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem();
whs.setHelp(this, ContextIds.NEW_SERVER_WIZARD);
List<ServerCreationWizardPageExtension> pageExtensionLst = ServerUIPlugin.getServerCreationWizardPageExtensions();
// Add the page modifier top section UI.
for (ServerCreationWizardPageExtension curPageExtension : pageExtensionLst) {
curPageExtension.createControl(ServerCreationWizardPageExtension.UI_POSITION.TOP, this);
curPageExtension.setUIControlListener(this);
}
serverTypeComposite = new ServerTypeComposite(this, moduleType, serverTypeId, new ServerTypeComposite.ServerTypeSelectionListener() {
public void serverTypeSelected(IServerType type2) {
handleTypeSelection(type2);
// WizardUtil.defaultSelect(parent, CreateServerWizardPage.this);
}
});
serverTypeComposite.setIncludeIncompatibleVersions(includeIncompatible);
GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
data.horizontalSpan = 3;
data.minimumHeight = 150;
serverTypeComposite.setLayoutData(data);
whs.setHelp(serverTypeComposite, ContextIds.NEW_SERVER_TYPE);
// Add the page modifier middle section UI.
for (ServerCreationWizardPageExtension curPageExtension : pageExtensionLst) {
curPageExtension.createControl(ServerCreationWizardPageExtension.UI_POSITION.MIDDLE, this);
}
hostnameListener = new IHostnameSelectionListener() {
public void hostnameSelected(String selectedHostname) {
setHost(selectedHostname);
}
};
hostnameLabel = new Label(this, SWT.NONE);
hostnameLabel.setText(Messages.hostname);
hostname = new Text(this, SWT.SINGLE | SWT.BORDER | SWT.CANCEL);
hostname.setText(HostnameComposite.LOCALHOST);
hostnameDecoration = new ControlDecoration(hostname, SWT.TOP | SWT.LEAD);
GridData data2 = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
hostname.setLayoutData(data2);
new Label(this, SWT.NONE);
hostname.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
setHostnameChangeTimer(hostname.getText());
}
});
FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault();
fd = registry.getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
hostnameDecoration.setImage(fd.getImage());
hostnameDecoration.setDescriptionText(fd.getDescription());
hostname.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
hostnameDecoration.show();
}
public void focusLost(FocusEvent e) {
hostnameDecoration.hide();
}
});
List<String> hosts = ServerUIPlugin.getPreferences().getHostnames();
String[] hosts2 = hosts.toArray(new String[hosts.size()]);
new AutoCompleteField(hostname, new TextContentAdapter(), hosts2);
serverNameLabel = new Label(this, SWT.NONE);
serverNameLabel.setText(Messages.serverName);
serverName = new Text(this, SWT.SINGLE | SWT.BORDER | SWT.CANCEL);
data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
if ((serverName.getStyle() & SWT.CANCEL) != 0)
data.horizontalSpan = 2;
serverName.setLayoutData(data);
if (server != null)
serverName.setText(server.getName());
serverName.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
if (updatingServerName)
return;
String name = serverName.getText();
IServerType selectedServerType = serverTypeComposite.getSelectedServerType();
if (!validate(selectedServerType)) {
// Do not set the server name if it is invalid
return;
}
if (server != null) {
server.setName(name);
String base = serverName.getText().trim();
if (ServerPlugin.isIdInUse(server, base)) {
server.setAttribute("id", generateUniqueId(base));
}
IRuntime runtime2 = server.getRuntime();
if (runtime2 != null && runtime2 instanceof IRuntimeWorkingCopy) {
IRuntimeWorkingCopy rwc = (IRuntimeWorkingCopy) runtime2;
rwc.setName(name);
}
}
if (serverNameModified)
return;
serverNameModified = true;
if (serverNameToolBar != null)
serverNameToolBar.getControl().setVisible(true);
}
});
if ((serverName.getStyle() & SWT.CANCEL) == 0) {
serverNameToolBar = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL);
serverNameToolBar.createControl(this);
IAction resetDefaultAction = new // $NON-NLS-1$
Action(// $NON-NLS-1$
"", // $NON-NLS-1$
IAction.AS_PUSH_BUTTON) {
public void run() {
((ServerWorkingCopy) server).setDefaults(null);
serverName.setText(server.getName());
serverNameModified = false;
if (serverNameToolBar != null)
serverNameToolBar.getControl().setVisible(false);
}
};
resetDefaultAction.setToolTipText(Messages.serverNameDefault);
resetDefaultAction.setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_ETOOL_RESET_DEFAULT));
resetDefaultAction.setDisabledImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_DTOOL_RESET_DEFAULT));
serverNameToolBar.add(resetDefaultAction);
serverNameToolBar.update(false);
serverNameToolBar.getControl().setVisible(false);
}
runtimeLabel = new Label(this, SWT.NONE);
runtimeLabel.setText(Messages.wizNewServerRuntime);
runtimeCombo = new Combo(this, SWT.READ_ONLY);
runtimeCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
runtimeCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
try {
setRuntime(runtimes[runtimeCombo.getSelectionIndex()]);
} catch (Exception ex) {
// ignore
}
}
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
addRuntime = new Link(this, SWT.NONE);
addRuntime.setText("<a>" + Messages.addRuntime + "</a>");
addRuntime.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
addRuntime.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
IServerType serverType = serverTypeComposite.getSelectedServerType();
showRuntimeWizard(serverType);
}
});
configureRuntimes = new Link(this, SWT.NONE);
configureRuntimes.setText("<a>" + Messages.configureRuntimes + "</a>");
data = new GridData(GridData.HORIZONTAL_ALIGN_END);
data.horizontalSpan = 3;
configureRuntimes.setLayoutData(data);
configureRuntimes.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (showPreferencePage()) {
runtime = null;
IServerType serverType = serverTypeComposite.getSelectedServerType();
updateRuntimeCombo(serverType);
}
}
});
// Add the page modifier bottom section UI.
for (ServerCreationWizardPageExtension curPageExtension : pageExtensionLst) {
curPageExtension.createControl(ServerCreationWizardPageExtension.UI_POSITION.BOTTOM, this);
}
Dialog.applyDialogFont(this);
}
use of org.eclipse.jface.action.ToolBarManager in project mdw-designer by CenturyLinkCloud.
the class MdwActionBarAdvisor method fillCoolBar.
@Override
protected void fillCoolBar(ICoolBarManager coolBar) {
IToolBarManager toolbar = new ToolBarManager(SWT.FLAT | SWT.RIGHT);
coolBar.add(new ToolBarContributionItem(toolbar, "mdwMain"));
toolbar.add(newAction);
toolbar.add(saveAction);
}
Aggregations