use of org.eclipse.egit.ui.internal.repository.RepositoriesViewLabelProvider in project egit by eclipse.
the class BranchAndResetActionTest method setup.
@Before
public void setup() throws Exception {
repositoryFile = createProjectAndCommitToRepository();
Repository repo = lookupRepository(repositoryFile);
TagBuilder tag = new TagBuilder();
tag.setTag("SomeTag");
tag.setTagger(RawParseUtils.parsePersonIdent(TestUtil.TESTAUTHOR));
tag.setMessage("I'm just a little tag");
tag.setObjectId(repo.resolve(repo.getFullBranch()), Constants.OBJ_COMMIT);
TagOperation top = new TagOperation(repo, tag, false);
top.execute(null);
touchAndSubmit(null);
RepositoriesViewLabelProvider provider = GitRepositoriesViewTestUtils.createLabelProvider();
LOCAL_BRANCHES = provider.getText(new LocalNode(new RepositoryNode(null, repo), repo));
TAGS = provider.getText(new TagsNode(new RepositoryNode(null, repo), repo));
}
use of org.eclipse.egit.ui.internal.repository.RepositoriesViewLabelProvider in project egit by eclipse.
the class CompareActionsTest method setup.
@Before
public void setup() throws Exception {
repositoryFile = createProjectAndCommitToRepository();
Repository repo = lookupRepository(repositoryFile);
disablePerspectiveSwitchPrompt();
setEnabledModelProvider(ModelProvider.RESOURCE_MODEL_PROVIDER_ID);
TagBuilder tag = new TagBuilder();
tag.setTag("SomeTag");
tag.setTagger(RawParseUtils.parsePersonIdent(TestUtil.TESTAUTHOR));
tag.setMessage("I'm just a little tag");
tag.setObjectId(repo.resolve(repo.getFullBranch()), Constants.OBJ_COMMIT);
commitOfTag = tag.getObjectId();
TagOperation top = new TagOperation(repo, tag, false);
top.execute(null);
touchAndSubmit(null);
RepositoriesViewLabelProvider provider = GitRepositoriesViewTestUtils.createLabelProvider();
// LOCAL_BRANCHES = provider.getText(new LocalNode(new RepositoryNode(
// null, repo), repo));
TAGS = provider.getText(new TagsNode(new RepositoryNode(null, repo), repo));
}
use of org.eclipse.egit.ui.internal.repository.RepositoriesViewLabelProvider in project egit by eclipse.
the class FetchAndMergeActionTest method setup.
@Before
public void setup() throws Exception {
repositoryFile = createProjectAndCommitToRepository();
childRepositoryFile = createChildRepository(repositoryFile);
RepositoriesViewLabelProvider provider = GitRepositoriesViewTestUtils.createLabelProvider();
Repository repo = lookupRepository(childRepositoryFile);
REMOTE_BRANCHES = provider.getText(new RemoteTrackingNode(new RepositoryNode(null, repo), repo));
LOCAL_BRANCHES = provider.getText(new LocalNode(new RepositoryNode(null, repo), repo));
ObjectId id = repo.resolve(repo.getFullBranch());
initialCommitId = id.name();
}
use of org.eclipse.egit.ui.internal.repository.RepositoriesViewLabelProvider in project egit by eclipse.
the class GitSelectRepositoryPage method createControl.
@Override
public void createControl(Composite parent) {
Composite main = new Composite(parent, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 0).applyTo(main);
GridDataFactory.fillDefaults().grab(true, true).applyTo(main);
// use a filtered tree
FilteredTree tree = new FilteredTree(main, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL, new PatternFilter(), true);
tv = tree.getViewer();
GridDataFactory.fillDefaults().grab(true, true).applyTo(tree);
tv.setContentProvider(new RepositoriesViewContentProvider() {
@Override
public Object[] getElements(Object inputElement) {
Object[] elements = super.getElements(inputElement);
if (allowBare) {
return elements;
}
List<Object> result = new ArrayList<>();
for (Object element : elements) {
if (element instanceof RepositoryTreeNode) {
RepositoryTreeNode node = (RepositoryTreeNode) element;
if (node.getRepository() != null && !node.getRepository().isBare()) {
result.add(element);
}
}
}
bareMsg.setVisible(result.size() != elements.length);
return result.toArray();
}
// we never show children, only the Repository nodes
@Override
public Object[] getChildren(Object parentElement) {
return null;
}
@Override
public boolean hasChildren(Object element) {
return false;
}
});
tv.setLabelProvider(new RepositoriesViewLabelProvider());
Composite tb = new Composite(main, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(1).applyTo(tb);
GridDataFactory.fillDefaults().grab(false, true).applyTo(tb);
addRepo = new Button(tb, SWT.PUSH);
GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.BEGINNING).applyTo(addRepo);
addRepo.setText(UIText.GitSelectRepositoryPage_AddButton);
addRepo.setToolTipText(UIText.GitSelectRepositoryPage_AddTooltip);
addRepo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
List<String> configuredDirs = util.getConfiguredRepositories();
RepositorySearchWizard wizard = new RepositorySearchWizard(configuredDirs, allowBare);
WizardDialog dlg = new WizardDialog(getShell(), wizard);
if (dlg.open() == Window.OK && !wizard.getDirectories().isEmpty()) {
Set<String> dirs = wizard.getDirectories();
for (String dir : dirs) {
File gitDir = FileUtils.canonicalize(new File(dir));
GerritUtil.tryToAutoConfigureForGerrit(gitDir);
util.addConfiguredRepository(gitDir);
}
checkPage();
}
}
});
if (!allowBare) {
bareMsg = new Composite(main, SWT.NONE);
bareMsg.setLayout(new RowLayout());
bareMsg.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
Label imageLabel = new Label(bareMsg, SWT.NONE);
imageLabel.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO));
Label textLabel = new Label(bareMsg, SWT.WRAP);
textLabel.setText(UIText.GitSelectRepositoryPage_BareRepositoriesHidden);
bareMsg.setVisible(false);
}
tv.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
checkPage();
}
});
tv.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
checkPage();
if (isPageComplete())
getContainer().showPage(getNextPage());
}
});
tv.setInput(util.getConfiguredRepositories());
configChangeListener = new IPreferenceChangeListener() {
@Override
public void preferenceChange(PreferenceChangeEvent event) {
if (RepositoryUtil.PREFS_DIRECTORIES_REL.equals(event.getKey())) {
Display display = tv.getControl().getDisplay();
display.asyncExec(() -> {
if (!tv.getControl().isDisposed()) {
refreshRepositoryList();
checkPage();
}
});
}
}
};
util.getPreferences().addPreferenceChangeListener(configChangeListener);
// we need to select at least a repository to become complete
setPageComplete(false);
Dialog.applyDialogFont(main);
setControl(main);
}
use of org.eclipse.egit.ui.internal.repository.RepositoriesViewLabelProvider in project egit by eclipse.
the class GitSelectWizardPage method createControl.
@Override
public void createControl(Composite parent) {
Composite main = new Composite(parent, SWT.NO_RADIO_GROUP);
main.setLayout(new GridLayout(1, false));
SelectionListener sl = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
tv.getTree().setEnabled(!newProjectWizard.getSelection());
if (importExisting.getSelection())
wizardSelection = EXISTING_PROJECTS_WIZARD;
else if (newProjectWizard.getSelection())
wizardSelection = NEW_WIZARD;
else if (generalWizard.getSelection())
wizardSelection = GENERAL_WIZARD;
else
wizardSelection = EXISTING_PROJECTS_WIZARD;
checkPage();
}
};
Group wizardType = new Group(main, SWT.SHADOW_ETCHED_IN);
GridDataFactory.fillDefaults().grab(true, false).applyTo(wizardType);
wizardType.setText(UIText.GitSelectWizardPage_ProjectCreationHeader);
wizardType.setLayout(new GridLayout(1, false));
importExisting = new Button(wizardType, SWT.RADIO);
importExisting.setText(UIText.GitSelectWizardPage_ImportExistingButton);
importExisting.addSelectionListener(sl);
decorateWithFilterCount(importExisting);
newProjectWizard = new Button(wizardType, SWT.RADIO);
newProjectWizard.setText(UIText.GitSelectWizardPage_UseNewProjectsWizardButton);
newProjectWizard.addSelectionListener(sl);
generalWizard = new Button(wizardType, SWT.RADIO);
generalWizard.setText(UIText.GitSelectWizardPage_ImportAsGeneralButton);
generalWizard.addSelectionListener(sl);
IDialogSettings settings = Activator.getDefault().getDialogSettings();
try {
wizardSelection = settings.getInt(PREF_WIZ);
} catch (NumberFormatException e) {
wizardSelection = EXISTING_PROJECTS_WIZARD;
}
switch(wizardSelection) {
default:
case EXISTING_PROJECTS_WIZARD:
importExisting.setSelection(true);
break;
case GENERAL_WIZARD:
generalWizard.setSelection(true);
break;
case NEW_WIZARD:
newProjectWizard.setSelection(true);
break;
}
tv = new TreeViewer(main, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
RepositoriesViewContentProvider cp = new RepositoriesViewContentProvider();
tv.setContentProvider(cp);
GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 200).applyTo(tv.getTree());
tv.setLabelProvider(new RepositoriesViewLabelProvider());
tv.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
checkPage();
}
});
if (initialRepository != null) {
List<WorkingDirNode> input = new ArrayList<>();
WorkingDirNode node = new WorkingDirNode(null, initialRepository);
input.add(node);
tv.setInput(input);
// expand root node
tv.expandToLevel(2);
// select the working directory as default
if (initialPath == null)
tv.setSelection(new StructuredSelection(input.get(0)));
else {
RepositoryTreeNode parentNode = node;
IPath fullPath = new Path(initialPath);
IPath workdirPath = new Path(initialRepository.getWorkTree().getPath());
if (workdirPath.isPrefixOf(fullPath)) {
IPath relPath = fullPath.removeFirstSegments(workdirPath.segmentCount());
for (String segment : relPath.segments()) {
for (Object child : cp.getChildren(parentNode)) {
if (child instanceof FolderNode) {
FolderNode childFolder = (FolderNode) child;
if (childFolder.getObject().getName().equals(segment)) {
parentNode = childFolder;
break;
}
}
}
}
tv.setSelection(new StructuredSelection(parentNode));
}
}
}
tv.getTree().setEnabled(!newProjectWizard.getSelection());
Dialog.applyDialogFont(main);
setControl(main);
}
Aggregations