use of org.archicontribs.modelrepository.grafico.BranchInfo in project archi-modelrepository-plugin by archi-contribs.
the class ModelRepositoryTreeViewer method updateStatusCache.
/**
* Update the status cache
*/
private void updateStatusCache(List<IArchiRepository> repos) {
cache = new Hashtable<IArchiRepository, StatusCache>();
for (IArchiRepository repo : repos) {
try {
BranchInfo branchInfo = repo.getBranchStatus().getCurrentLocalBranch();
if (branchInfo != null) {
// This can be null!!
StatusCache sc = new StatusCache(branchInfo, repo.hasLocalChanges());
cache.put(repo, sc);
}
} catch (IOException | GitAPIException ex) {
ex.printStackTrace();
// $NON-NLS-1$
ModelRepositoryPlugin.INSTANCE.log(IStatus.ERROR, "Error getting Model Repository Status", ex);
}
}
}
use of org.archicontribs.modelrepository.grafico.BranchInfo in project archi-modelrepository-plugin by archi-contribs.
the class RepoInfoSection method handleSelection.
@Override
protected void handleSelection(IStructuredSelection selection) {
if (selection.getFirstElement() instanceof IArchiRepository) {
fArchiRepo = (IArchiRepository) selection.getFirstElement();
try {
fFile = fArchiRepo.getLocalRepositoryFolder().getAbsolutePath();
fTextFile.setText(fFile);
fURL = fArchiRepo.getOnlineRepositoryURL();
fTextURL.setText(StringUtils.safeString(fURL));
// $NON-NLS-1$
fBranch = "";
BranchStatus status = fArchiRepo.getBranchStatus();
if (status != null) {
BranchInfo branchInfo = status.getCurrentLocalBranch();
if (branchInfo != null) {
fBranch = branchInfo.getShortName();
}
}
fTextCurrentBranch.setText(StringUtils.safeString(fBranch));
} catch (IOException | GitAPIException ex) {
ex.printStackTrace();
}
}
}
use of org.archicontribs.modelrepository.grafico.BranchInfo in project archi-modelrepository-plugin by archi-contribs.
the class HistoryView method createInfoSection.
private void createInfoSection(Composite parent) {
Composite mainComp = new Composite(parent, SWT.NONE);
mainComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
GridLayout layout = new GridLayout(3, false);
layout.marginWidth = 0;
layout.marginHeight = 0;
mainComp.setLayout(layout);
// Repository name
fRepoLabel = new Label(mainComp, SWT.NONE);
fRepoLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fRepoLabel.setText(Messages.HistoryView_0);
// Branches
Label label = new Label(mainComp, SWT.NONE);
label.setText(Messages.HistoryView_2);
fBranchesViewer = new BranchesViewer(mainComp);
GridData gd = new GridData(SWT.END);
fBranchesViewer.getControl().setLayoutData(gd);
/*
* Listen to Branch Selections and forward on to History Viewer
*/
fBranchesViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
BranchInfo branchInfo = (BranchInfo) event.getStructuredSelection().getFirstElement();
getHistoryViewer().setSelectedBranch(branchInfo);
updateActions();
}
});
}
use of org.archicontribs.modelrepository.grafico.BranchInfo in project archi-modelrepository-plugin by archi-contribs.
the class CommitDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
setMessage(Messages.CommitDialog_1, IMessageProvider.INFORMATION);
setTitleImage(IModelRepositoryImages.ImageFactory.getImage(IModelRepositoryImages.BANNER_COMMIT));
Composite area = (Composite) super.createDialogArea(parent);
Composite container = new Composite(area, SWT.NONE);
container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
GridLayout layout = new GridLayout(2, false);
container.setLayout(layout);
// Repo and branch
// $NON-NLS-1$
String shortBranchName = "unknown";
try {
BranchStatus status = fRepository.getBranchStatus();
if (status != null) {
BranchInfo branchInfo = status.getCurrentLocalBranch();
if (branchInfo != null) {
shortBranchName = branchInfo.getShortName();
}
}
} catch (IOException | GitAPIException ex) {
ex.printStackTrace();
}
Label label = new Label(container, SWT.NONE);
label.setText(Messages.CommitDialog_6);
label = new Label(container, SWT.NONE);
label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// $NON-NLS-1$ //$NON-NLS-2$
label.setText(fRepository.getName() + " [" + shortBranchName + "]");
// User name & email
// $NON-NLS-1$
String userName = "";
// $NON-NLS-1$
String userEmail = "";
try {
PersonIdent result = fRepository.getUserDetails();
userName = result.getName();
userEmail = result.getEmailAddress();
} catch (IOException ex) {
ex.printStackTrace();
}
label = new Label(container, SWT.NONE);
label.setText(Messages.CommitDialog_2);
fTextUserName = UIUtils.createSingleTextControl(container, SWT.BORDER, false);
fTextUserName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fTextUserName.setText(userName);
label = new Label(container, SWT.NONE);
label.setText(Messages.CommitDialog_3);
fTextUserEmail = UIUtils.createSingleTextControl(container, SWT.BORDER, false);
fTextUserEmail.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fTextUserEmail.setText(userEmail);
label = new Label(container, SWT.NONE);
label.setText(Messages.CommitDialog_4);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
label.setLayoutData(gd);
fTextCommitMessage = new Text(container, SWT.BORDER | SWT.V_SCROLL | SWT.WRAP | SWT.MULTI);
gd = new GridData(GridData.FILL_BOTH);
gd.horizontalSpan = 2;
fTextCommitMessage.setLayoutData(gd);
// TODO: After Archi 4.7 remove this code and use
// UIUtils.applyTraverseListener(fTextCommitMessage, SWT.TRAVERSE_TAB_NEXT | SWT.TRAVERSE_TAB_PREVIOUS | SWT.TRAVERSE_RETURN);
fTextCommitMessage.addTraverseListener((e) -> {
// Ctrl + Enter
if (e.detail == SWT.TRAVERSE_RETURN && (e.stateMask & SWT.MOD1) != 0) {
e.doit = true;
} else // Tabs and other SWT.TRAVERSE_* flags
if (e.detail == SWT.TRAVERSE_TAB_NEXT || e.detail == SWT.TRAVERSE_TAB_PREVIOUS) {
e.doit = true;
}
});
fAmendLastCommitCheckbox = new Button(container, SWT.CHECK);
fAmendLastCommitCheckbox.setText(Messages.CommitDialog_5);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
fAmendLastCommitCheckbox.setLayoutData(gd);
try {
fAmendLastCommitCheckbox.setEnabled(isAmendAllowed());
} catch (IOException | GitAPIException ex) {
fAmendLastCommitCheckbox.setEnabled(false);
ex.printStackTrace();
}
if (!StringUtils.isSet(userName)) {
fTextUserName.setFocus();
} else if (!StringUtils.isSet(userEmail)) {
fTextUserEmail.setFocus();
} else {
fTextCommitMessage.setFocus();
}
return area;
}
use of org.archicontribs.modelrepository.grafico.BranchInfo in project archi-modelrepository-plugin by archi-contribs.
the class DeleteBranchAction method run.
@Override
public void run() {
if (!shouldBeEnabled()) {
return;
}
// Keep a local reference in case of a notification event changing the current branch selection in the UI
BranchInfo branchInfo = fBranchInfo;
boolean response = MessageDialog.openConfirm(fWindow.getShell(), Messages.DeleteBranchAction_0, NLS.bind(Messages.DeleteBranchAction_1, branchInfo.getShortName()));
if (!response) {
return;
}
try {
// If the branch has a remote ref or is remote we should delete that too
boolean deleteRemote = branchInfo.hasRemoteRef() || branchInfo.isRemote();
if (deleteRemote) {
// Check primary key set
if (!EncryptedCredentialsStorage.checkPrimaryKeySet()) {
return;
}
// Get for this before opening the progress dialog
// UsernamePassword will be null if using SSH
UsernamePassword npw = getUsernamePassword();
// User cancelled on HTTP
if (npw == null && GraficoUtils.isHTTP(getRepository().getOnlineRepositoryURL())) {
return;
}
Exception[] exception = new Exception[1];
PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor pm) {
try {
// Update Proxy
ProxyAuthenticator.update();
pm.beginTask(Messages.DeleteBranchAction_2, IProgressMonitor.UNKNOWN);
deleteBranchAndPush(branchInfo, npw);
} catch (Exception ex) {
exception[0] = ex;
} finally {
// Clear Proxy
ProxyAuthenticator.clear();
}
}
});
if (exception[0] != null) {
throw exception[0];
}
} else {
deleteLocalBranch(branchInfo);
}
} catch (GeneralSecurityException ex) {
displayCredentialsErrorDialog(ex);
} catch (Exception ex) {
displayErrorDialog(Messages.DeleteBranchAction_0, ex);
} finally {
// Notify listeners
notifyChangeListeners(IRepositoryListener.BRANCHES_CHANGED);
}
}
Aggregations