use of org.eclipse.egit.ui.internal.repository.RepositoriesView in project egit by eclipse.
the class SelectionForViewsTest method before.
@Before
public void before() throws Exception {
localRepositoryDir = createProjectAndCommitToRepository();
remoteRepositoryDir = createRemoteRepository(localRepositoryDir);
URIish uri = new URIish("file:///" + remoteRepositoryDir.getPath());
File workdir = new File(getTestDirectory(), "ClonedRepo");
CloneOperation op = new CloneOperation(uri, true, null, workdir, "refs/heads/master", "origin", 0);
op.run(null);
clonedRepositoryDir = new File(workdir, Constants.DOT_GIT);
RepositoryUtil repoUtil = Activator.getDefault().getRepositoryUtil();
repoUtil.addConfiguredRepository(localRepositoryDir);
repoUtil.addConfiguredRepository(clonedRepositoryDir);
// it's bare
repoUtil.addConfiguredRepository(remoteRepositoryDir);
stagingView = TestUtil.showView(StagingView.VIEW_ID);
reflogView = TestUtil.showView(ReflogView.VIEW_ID);
rebaseInteractiveView = TestUtil.showView(RebaseInteractiveView.VIEW_ID);
repoView = TestUtil.showView(RepositoriesView.VIEW_ID);
RepositoriesView repos = (RepositoriesView) repoView.getViewReference().getView(false);
repos.setReactOnSelection(true);
historyView = TestUtil.showHistoryView();
IHistoryView history = (IHistoryView) historyView.getViewReference().getView(false);
((GenericHistoryView) history).setLinkingEnabled(true);
// Ensure that the git history page is active
Exception[] exception = { null };
PlatformUI.getWorkbench().getDisplay().syncExec(() -> {
try {
history.showHistoryFor(new RepositoryNode(null, lookupRepository(localRepositoryDir)), true);
} catch (Exception e) {
exception[0] = e;
}
});
if (exception[0] != null) {
throw exception[0];
}
waitForRefreshes();
}
use of org.eclipse.egit.ui.internal.repository.RepositoriesView in project egit by eclipse.
the class AbstractToggleCommand method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
HandlerUtil.toggleCommandState(event.getCommand());
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window != null) {
IWorkbenchPage page = window.getActivePage();
if (page != null) {
IViewPart part = page.findView(RepositoriesView.VIEW_ID);
if (part instanceof RepositoriesView) {
(((RepositoriesView) part).getCommonViewer()).refresh();
}
}
}
return null;
}
use of org.eclipse.egit.ui.internal.repository.RepositoriesView in project egit by eclipse.
the class ShowRepositoriesViewActionHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
RepositoriesView view;
try {
view = (RepositoriesView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(RepositoriesView.VIEW_ID);
ShowInContext ctx = new ShowInContext(ResourcesPlugin.getWorkspace().getRoot(), getSelection(event));
view.show(ctx);
} catch (PartInitException e) {
throw new ExecutionException(e.getMessage(), e);
}
return null;
}
use of org.eclipse.egit.ui.internal.repository.RepositoriesView 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.egit.ui.internal.repository.RepositoriesView in project egit by eclipse.
the class SelectionForViewsTest method after.
@After
public void after() {
RepositoriesView repos = (RepositoriesView) repoView.getViewReference().getView(false);
repos.setReactOnSelection(false);
IHistoryView history = (IHistoryView) historyView.getViewReference().getView(false);
((GenericHistoryView) history).setLinkingEnabled(false);
stagingView = null;
reflogView = null;
rebaseInteractiveView = null;
historyView = null;
repoView = null;
}
Aggregations