use of org.eclipse.jgit.transport.RemoteConfig in project egit by eclipse.
the class PushTagsPage method createControl.
@Override
public void createControl(Composite parent) {
Composite main = new Composite(parent, SWT.NONE);
main.setLayout(GridLayoutFactory.swtDefaults().spacing(LayoutConstants.getSpacing()).numColumns(2).create());
Label remoteLabel = new Label(main, SWT.NONE);
remoteLabel.setText(UIText.PushTagsPage_RemoteLabel);
RemoteSelectionCombo remoteSelectionCombo = new RemoteSelectionCombo(main, SWT.NONE, SelectionType.PUSH);
remoteSelectionCombo.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
selectedRemoteConfig = remoteSelectionCombo.setItems(getRemoteConfigs());
remoteSelectionCombo.addRemoteSelectionListener(new RemoteSelectionCombo.IRemoteSelectionListener() {
@Override
public void remoteSelected(RemoteConfig remoteConfig) {
selectedRemoteConfig = remoteConfig;
}
});
tagsLabel = new Label(main, SWT.NONE);
tagsLabel.setText(UIText.PushTagsPage_TagsLabelNoneSelected);
tagsLabel.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create());
FilteredCheckboxTree tree = new FilteredCheckboxTree(main, null, SWT.BORDER);
tree.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(2, 1).hint(400, 300).create());
final Button forceUpdateButton = new Button(main, SWT.CHECK);
forceUpdateButton.setText(UIText.PushTagsPage_ForceUpdateButton);
forceUpdateButton.setSelection(false);
forceUpdateButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create());
forceUpdateButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
forceUpdateSelected = forceUpdateButton.getSelection();
}
});
final CachedCheckboxTreeViewer treeViewer = tree.getCheckboxTreeViewer();
TagsNode tagsNode = new TagsNode(null, repository);
ContentProvider contentProvider = new ContentProvider(tagsNode);
treeViewer.setContentProvider(contentProvider);
treeViewer.setLabelProvider(new RepositoriesViewStyledCellLabelProvider());
treeViewer.setComparator(new ViewerComparator(CommonUtils.STRING_ASCENDING_COMPARATOR));
treeViewer.setInput(tagsNode);
final Object[] tagNodes = contentProvider.getElements(tagsNode);
initiallySelectTags(tagNodes, treeViewer);
treeViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
setSelectedTags(treeViewer.getCheckedElements());
}
});
setControl(main);
}
use of org.eclipse.jgit.transport.RemoteConfig in project egit by eclipse.
the class PushToGerritPage method createControl.
@Override
public void createControl(Composite parent) {
loadKnownRemoteRefs();
Composite main = new Composite(parent, SWT.NONE);
main.setLayout(new GridLayout(3, false));
GridDataFactory.fillDefaults().grab(true, true).applyTo(main);
new Label(main, SWT.NONE).setText(UIText.PushToGerritPage_UriLabel);
uriCombo = new Combo(main, SWT.DROP_DOWN);
GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(uriCombo);
uriCombo.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
checkPage();
}
});
branchTextlabel = new Label(main, SWT.NONE);
// we visualize the prefix here
prefixCombo = new Combo(main, SWT.READ_ONLY | SWT.DROP_DOWN);
prefixCombo.add(GerritUtil.REFS_FOR);
prefixCombo.add(GerritUtil.REFS_DRAFTS);
prefixCombo.select(0);
branchTextlabel.setText(UIText.PushToGerritPage_BranchLabel);
branchText = new Text(main, SWT.SINGLE | SWT.BORDER);
GridDataFactory.fillDefaults().grab(true, false).applyTo(branchText);
branchText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
checkPage();
}
});
// give focus to the branchText if label is activated using the mnemonic
branchTextlabel.addTraverseListener(new TraverseListener() {
@Override
public void keyTraversed(TraverseEvent e) {
branchText.setFocus();
branchText.selectAll();
}
});
addRefContentProposalToText(branchText);
useTopic = new Button(main, SWT.CHECK | SWT.LEFT);
useTopic.setText(UIText.PushToGerritPage_TopicUseLabel);
GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(useTopic);
topicLabel = new Label(main, SWT.NONE);
topicLabel.setText(UIText.PushToGerritPage_TopicLabel);
topicText = new Text(main, SWT.SINGLE | SWT.BORDER);
GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(topicText);
topicText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
checkPage();
}
});
topicLabel.addTraverseListener(new TraverseListener() {
@Override
public void keyTraversed(TraverseEvent e) {
topicText.setFocus();
topicText.selectAll();
}
});
useTopic.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
topicText.setEnabled(useTopic.getSelection());
checkPage();
}
});
// get all available Gerrit URIs from the repository
SortedSet<String> uris = new TreeSet<>();
try {
for (RemoteConfig rc : RemoteConfig.getAllRemoteConfigs(repository.getConfig())) {
if (GerritUtil.isGerritPush(rc)) {
if (rc.getURIs().size() > 0) {
uris.add(rc.getURIs().get(0).toPrivateString());
}
for (URIish u : rc.getPushURIs()) {
uris.add(u.toPrivateString());
}
}
}
} catch (URISyntaxException e) {
Activator.handleError(e.getMessage(), e, false);
setErrorMessage(e.getMessage());
}
for (String aUri : uris) {
uriCombo.add(aUri);
}
selectLastUsedUri();
setLastUsedBranch();
initializeTopic(branchText.getText());
addTopicProposal(topicText);
branchText.setFocus();
Dialog.applyDialogFont(main);
setControl(main);
}
use of org.eclipse.jgit.transport.RemoteConfig in project egit by eclipse.
the class PushWizard method saveRefSpecs.
private void saveRefSpecs() {
final RemoteConfig rc = repoPage.getSelection().getConfig();
rc.setPushRefSpecs(refSpecPage.getRefSpecs());
final StoredConfig config = localDb.getConfig();
rc.update(config);
try {
config.save();
} catch (final IOException e) {
ErrorDialog.openError(getShell(), UIText.PushWizard_cantSaveTitle, UIText.PushWizard_cantSaveMessage, new Status(IStatus.WARNING, Activator.getPluginId(), e.getMessage(), e));
// Continue, it's not critical.
}
}
use of org.eclipse.jgit.transport.RemoteConfig in project egit by eclipse.
the class PullWizard method configureNewRemote.
private void configureNewRemote(URIish uri) throws URISyntaxException, IOException {
StoredConfig config = repository.getConfig();
String remoteName = this.page.getRemoteConfig().getName();
RemoteConfig remoteConfig = new RemoteConfig(config, remoteName);
remoteConfig.addURI(uri);
RefSpec defaultFetchSpec = new RefSpec().setForceUpdate(true).setSourceDestination(// $NON-NLS-1$
Constants.R_HEADS + "*", // $NON-NLS-1$
Constants.R_REMOTES + remoteName + "/*");
remoteConfig.addFetchRefSpec(defaultFetchSpec);
remoteConfig.update(config);
config.save();
}
use of org.eclipse.jgit.transport.RemoteConfig in project egit by eclipse.
the class PullWizardPage method setRemoteConfigs.
private void setRemoteConfigs() {
remoteSelectionCombo.setItems(remoteConfigs);
if (this.head != null) {
String branchName = Repository.shortenRefName(this.head.getName());
BranchConfig branchConfig = new BranchConfig(repository.getConfig(), branchName);
String remoteName = branchConfig.getRemote();
if (remoteName != null) {
for (RemoteConfig rc : remoteConfigs) {
if (remoteName.equals(rc.getName()))
remoteSelectionCombo.setSelectedRemote(rc);
}
}
}
remoteConfig = remoteSelectionCombo.getSelectedRemote();
setRefAssist(remoteConfig);
}
Aggregations