use of org.archicontribs.modelrepository.grafico.BranchStatus in project archi-modelrepository-plugin by archi-contribs.
the class BranchesViewer method doSetInput.
void doSetInput(IArchiRepository archiRepo) {
// Get BranchStatus
BranchStatus branchStatus = null;
try {
branchStatus = archiRepo.getBranchStatus();
} catch (IOException | GitAPIException ex) {
ex.printStackTrace();
}
setInput(branchStatus);
// Set selection to current branch
if (branchStatus != null) {
BranchInfo branchInfo = branchStatus.getCurrentLocalBranch();
if (branchInfo != null) {
setSelection(new StructuredSelection(branchInfo));
}
}
// And relayout
getControl().getParent().layout();
}
use of org.archicontribs.modelrepository.grafico.BranchStatus in project archi-modelrepository-plugin by archi-contribs.
the class HistoryTableViewer method doSetInput.
public void doSetInput(IArchiRepository archiRepo) {
// Get BranchStatus and currentLocalBranch
try {
BranchStatus branchStatus = archiRepo.getBranchStatus();
if (branchStatus != null) {
fSelectedBranch = branchStatus.getCurrentLocalBranch();
}
} catch (IOException | GitAPIException ex) {
ex.printStackTrace();
}
setInput(archiRepo);
// Do the Layout kludge
((UpdatingTableColumnLayout) getTable().getParent().getLayout()).doRelayout();
// Select first row
// Object element = getElementAt(0);
// if(element != null) {
// setSelection(new StructuredSelection(element), true);
// }
}
use of org.archicontribs.modelrepository.grafico.BranchStatus 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.BranchStatus 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.BranchStatus in project archi-modelrepository-plugin by archi-contribs.
the class RefreshModelAction method pull.
protected int pull(UsernamePassword npw, ProgressMonitorDialog pmDialog) throws IOException, GitAPIException {
PullResult pullResult = null;
pmDialog.getProgressMonitor().subTask(Messages.RefreshModelAction_6);
// update dialog
Display.getCurrent().readAndDispatch();
try {
pullResult = getRepository().pullFromRemote(npw, new ProgressMonitorWrapper(pmDialog.getProgressMonitor()));
} catch (Exception ex) {
// So quietly absorb this and return OK
if (ex instanceof RefNotAdvertisedException) {
return PULL_STATUS_OK;
}
throw ex;
}
// Check for tracking updates
FetchResult fetchResult = pullResult.getFetchResult();
boolean newTrackingRefUpdates = fetchResult != null && !fetchResult.getTrackingRefUpdates().isEmpty();
// Merge is already up to date...
if (pullResult.getMergeResult().getMergeStatus() == MergeStatus.ALREADY_UP_TO_DATE) {
// Check if any tracked refs were updated
if (newTrackingRefUpdates) {
return PULL_STATUS_OK;
}
return PULL_STATUS_UP_TO_DATE;
}
pmDialog.getProgressMonitor().subTask(Messages.RefreshModelAction_7);
BranchStatus branchStatus = getRepository().getBranchStatus();
// Setup the Graphico Model Loader
GraficoModelLoader loader = new GraficoModelLoader(getRepository());
// Merge failure
if (!pullResult.isSuccessful() && pullResult.getMergeResult().getMergeStatus() == MergeStatus.CONFLICTING) {
// Get the remote ref name
String remoteRef = branchStatus.getCurrentRemoteBranch().getFullName();
// Try to handle the merge conflict
MergeConflictHandler handler = new MergeConflictHandler(pullResult.getMergeResult(), remoteRef, getRepository(), fWindow.getShell());
try {
handler.init(pmDialog.getProgressMonitor());
} catch (IOException | GitAPIException ex) {
// Clean up
handler.resetToLocalState();
if (ex instanceof CanceledException) {
return PULL_STATUS_MERGE_CANCEL;
}
throw ex;
}
String dialogMessage = NLS.bind(Messages.RefreshModelAction_4, branchStatus.getCurrentLocalBranch().getShortName());
pmDialog.getShell().setVisible(false);
boolean result = handler.openConflictsDialog(dialogMessage);
pmDialog.getShell().setVisible(true);
if (result) {
handler.merge();
} else // User cancelled - we assume they committed all changes so we can reset
{
handler.resetToLocalState();
return PULL_STATUS_MERGE_CANCEL;
}
// We now have to check if model can be reloaded
pmDialog.getProgressMonitor().subTask(Messages.RefreshModelAction_8);
// Reload the model from the Grafico XML files
try {
loader.loadModel();
} catch (IOException ex) {
// Clean up
handler.resetToLocalState();
throw ex;
}
} else {
// Reload the model from the Grafico XML files
pmDialog.getProgressMonitor().subTask(Messages.RefreshModelAction_8);
loader.loadModel();
}
// Do a commit if needed
if (getRepository().hasChangesToCommit()) {
pmDialog.getProgressMonitor().subTask(Messages.RefreshModelAction_9);
String commitMessage = NLS.bind(Messages.RefreshModelAction_1, branchStatus.getCurrentLocalBranch().getShortName());
// Did we restore any missing objects?
String restoredObjects = loader.getRestoredObjectsAsString();
// Add to commit message
if (restoredObjects != null) {
// $NON-NLS-1$ //$NON-NLS-2$
commitMessage += "\n\n" + Messages.RefreshModelAction_3 + "\n" + restoredObjects;
}
// TODO - not sure if amend should be false or true here?
getRepository().commitChanges(commitMessage, false);
}
return PULL_STATUS_OK;
}
Aggregations