Search in sources :

Example 1 with RepositoriesView

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();
}
Also used : URIish(org.eclipse.jgit.transport.URIish) GenericHistoryView(org.eclipse.team.internal.ui.history.GenericHistoryView) RepositoriesView(org.eclipse.egit.ui.internal.repository.RepositoriesView) RepositoryNode(org.eclipse.egit.ui.internal.repository.tree.RepositoryNode) File(java.io.File) IHistoryView(org.eclipse.team.ui.history.IHistoryView) CloneOperation(org.eclipse.egit.core.op.CloneOperation) RepositoryUtil(org.eclipse.egit.core.RepositoryUtil) Before(org.junit.Before)

Example 2 with RepositoriesView

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;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) RepositoriesView(org.eclipse.egit.ui.internal.repository.RepositoriesView) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Example 3 with RepositoriesView

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;
}
Also used : ShowInContext(org.eclipse.ui.part.ShowInContext) RepositoriesView(org.eclipse.egit.ui.internal.repository.RepositoriesView) PartInitException(org.eclipse.ui.PartInitException) ExecutionException(org.eclipse.core.commands.ExecutionException)

Example 4 with RepositoriesView

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);
        }
    }
}
Also used : HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ControlContribution(org.eclipse.jface.action.ControlContribution) IPartService(org.eclipse.ui.IPartService) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ToolBarManager(org.eclipse.jface.action.ToolBarManager) Control(org.eclipse.swt.widgets.Control) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ScrolledForm(org.eclipse.ui.forms.widgets.ScrolledForm) RepositoriesView(org.eclipse.egit.ui.internal.repository.RepositoriesView) ISelection(org.eclipse.jface.viewers.ISelection) PartInitException(org.eclipse.ui.PartInitException) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 5 with RepositoriesView

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;
}
Also used : GenericHistoryView(org.eclipse.team.internal.ui.history.GenericHistoryView) RepositoriesView(org.eclipse.egit.ui.internal.repository.RepositoriesView) IHistoryView(org.eclipse.team.ui.history.IHistoryView) After(org.junit.After)

Aggregations

RepositoriesView (org.eclipse.egit.ui.internal.repository.RepositoriesView)7 GenericHistoryView (org.eclipse.team.internal.ui.history.GenericHistoryView)2 IHistoryView (org.eclipse.team.ui.history.IHistoryView)2 PartInitException (org.eclipse.ui.PartInitException)2 File (java.io.File)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 IPath (org.eclipse.core.runtime.IPath)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 RepositoryUtil (org.eclipse.egit.core.RepositoryUtil)1 CloneOperation (org.eclipse.egit.core.op.CloneOperation)1 DeletePathsOperationUI (org.eclipse.egit.ui.internal.operations.DeletePathsOperationUI)1 RepositoryNode (org.eclipse.egit.ui.internal.repository.tree.RepositoryNode)1 ControlContribution (org.eclipse.jface.action.ControlContribution)1 IToolBarManager (org.eclipse.jface.action.IToolBarManager)1 ToolBarManager (org.eclipse.jface.action.ToolBarManager)1 ISelection (org.eclipse.jface.viewers.ISelection)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 URIish (org.eclipse.jgit.transport.URIish)1