use of org.eclipse.compare.CompareEditorInput in project egit by eclipse.
the class CompareUtils method compareLocalWithRef.
/**
* Opens a compare editor comparing the working directory version of the
* file at the given location with the version corresponding to
* {@code refName} of the same file.
*
* @param repository
* The repository to load file revisions from.
* @param location
* Location of the file to compare revisions for.
* @param refName
* Reference to compare with the workspace version of
* {@code file}. Can be either a commit ID, a reference or a
* branch name.
* @param page
* If not {@null} try to re-use a compare editor on this
* page if any is available. Otherwise open a new one.
*/
private static void compareLocalWithRef(@NonNull final Repository repository, @NonNull final IPath location, final String refName, final IWorkbenchPage page) {
Job job = new Job(UIText.CompareUtils_jobName) {
@Override
public IStatus run(IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
final String gitPath = getRepoRelativePath(location, repository);
final ITypedElement base = new LocalNonWorkspaceTypedElement(repository, location);
CompareEditorInput in;
try {
in = prepareCompareInput(repository, gitPath, base, refName);
} catch (IOException e) {
return Activator.createErrorStatus(UIText.CompareWithRefAction_errorOnSynchronize, e);
}
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
openCompareEditorRunnable(page, in);
return Status.OK_STATUS;
}
};
job.setUser(true);
job.schedule();
}
use of org.eclipse.compare.CompareEditorInput in project egit by eclipse.
the class RebaseResultDialog method buttonPressed.
@Override
protected void buttonPressed(int buttonId) {
// store the preference to hide these dialogs
if (toggleButton != null)
Activator.getDefault().getPreferenceStore().setValue(UIPreferences.SHOW_REBASE_CONFIRM, !toggleButton.getSelection());
if (buttonId == IDialogConstants.OK_ID) {
if (result.getStatus() != Status.STOPPED) {
super.buttonPressed(buttonId);
return;
}
if (startMergeButton.getSelection()) {
super.buttonPressed(buttonId);
// open the merge tool
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
for (IProject project : projects) {
RepositoryMapping mapping = RepositoryMapping.getMapping(project);
if (mapping != null && mapping.getRepository().equals(repo)) {
try {
// make sure to refresh before opening the merge
// tool
project.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (CoreException e) {
Activator.handleError(e.getMessage(), e, false);
}
}
}
List<IPath> locationList = new ArrayList<>();
IPath repoWorkdirPath = new Path(repo.getWorkTree().getPath());
for (String repoPath : conflictPaths) {
IPath location = repoWorkdirPath.append(repoPath);
locationList.add(location);
}
IPath[] locations = locationList.toArray(new IPath[locationList.size()]);
int mergeMode = Activator.getDefault().getPreferenceStore().getInt(UIPreferences.MERGE_MODE);
CompareEditorInput input;
if (mergeMode == 0) {
MergeModeDialog dlg = new MergeModeDialog(getParentShell());
if (dlg.open() != Window.OK)
return;
input = new GitMergeEditorInput(dlg.useWorkspace(), locations);
} else {
boolean useWorkspace = mergeMode == 1;
input = new GitMergeEditorInput(useWorkspace, locations);
}
CompareUI.openCompareEditor(input);
return;
} else if (skipCommitButton.getSelection()) {
// skip the rebase
SkipRebaseCommand skipCommand = new SkipRebaseCommand();
execute(skipCommand);
} else if (abortRebaseButton.getSelection()) {
// abort the rebase
AbortRebaseCommand abortCommand = new AbortRebaseCommand();
execute(abortCommand);
} else if (doNothingButton.getSelection()) {
// nothing
}
}
super.buttonPressed(buttonId);
}
use of org.eclipse.compare.CompareEditorInput in project InformationSystem by ObeoNetwork.
the class ExportAsSQLScriptsAction method setActiveEditor.
@Override
public void setActiveEditor(final IAction action, final IEditorPart activeEditor) {
this.activeEditor = activeEditor;
editorPluginAction = action;
action.setEnabled(false);
if (activeEditor != null && activeEditor.getEditorSite() != null && COMPARE_EDITOR_ID.equals(activeEditor.getEditorSite().getId())) {
final IEditorInput editorInput = activeEditor.getEditorInput();
if (editorInput instanceof CompareEditorInput) {
final CompareConfiguration config = ((CompareEditorInput) editorInput).getCompareConfiguration();
if (propertyChangeListener == null) {
propertyChangeListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
// FIX for EMFCompare 2.2
if (isInitEventBus(event) && eventBusChangeRecorder == null) {
eventBusChangeRecorder = new EventBusChangeRecorder();
((EventBus) event.getNewValue()).register(eventBusChangeRecorder);
}
}
};
config.addPropertyChangeListener(propertyChangeListener);
}
if (comparison != null) {
editorPluginAction.setEnabled(areDatabaseDifferences(comparison));
}
}
}
}
use of org.eclipse.compare.CompareEditorInput in project cubrid-manager by CUBRID.
the class TableSchemaCompareInfoPart method showEntireSchemaCompareEditor.
/**
* Display entire schemas comparison
*/
private void showEntireSchemaCompareEditor(String leftDatabase, String rightDatabase, final String leftContent, final String rightContent) {
CompareConfiguration config = new CompareConfiguration();
config.setProperty(CompareConfiguration.SHOW_PSEUDO_CONFLICTS, Boolean.FALSE);
config.setProperty(CompareConfiguration.IGNORE_WHITESPACE, Boolean.TRUE);
config.setLeftEditable(false);
config.setLeftLabel(leftDatabase);
config.setRightEditable(false);
config.setRightLabel(rightDatabase);
CompareEditorInput editorInput = new CompareEditorInput(config) {
protected Object prepareInput(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
return new DiffNode(null, Differencer.CHANGE, null, new TextCompareInput(leftContent), new TextCompareInput(rightContent));
}
public void saveChanges(IProgressMonitor pm) throws CoreException {
super.saveChanges(pm);
}
};
editorInput.setTitle(Messages.entireDbSchemaComparison);
CompareUI.openCompareEditor(editorInput);
}
use of org.eclipse.compare.CompareEditorInput in project linuxtools by eclipse.
the class ChangeLogAction method getDocumentLocation.
protected String getDocumentLocation(IEditorPart currentEditor, boolean appendRoot) {
IFile loc = getDocumentIFile(currentEditor);
IEditorInput cc = null;
String WorkspaceRoot;
IWorkspaceRoot myWorkspaceRoot = getWorkspaceRoot();
WorkspaceRoot = myWorkspaceRoot.getLocation().toOSString();
if (currentEditor instanceof MultiPageEditorPart) {
Object ed = ((MultiPageEditorPart) currentEditor).getSelectedPage();
if (ed instanceof IEditorPart)
cc = ((IEditorPart) ed).getEditorInput();
if (cc instanceof FileEditorInput)
return (appendRoot) ? WorkspaceRoot + ((FileEditorInput) cc).getFile().getFullPath().toOSString() : ((FileEditorInput) cc).getFile().getFullPath().toOSString();
}
cc = currentEditor.getEditorInput();
if (cc == null)
return "";
if ((cc instanceof SyncInfoCompareInput) || (cc instanceof CompareEditorInput)) {
CompareEditorInput test = (CompareEditorInput) cc;
if (test.getCompareResult() == null) {
return "";
} else if (test.getCompareResult() instanceof ICompareInput) {
ITypedElement leftCompare = ((ICompareInput) test.getCompareResult()).getLeft();
if (leftCompare instanceof IResourceProvider) {
String localPath = ((IResourceProvider) leftCompare).getResource().getFullPath().toString();
if (appendRoot) {
return WorkspaceRoot + localPath;
}
return localPath;
}
} else {
if (appendRoot)
return WorkspaceRoot + test.getCompareResult().toString();
return test.getCompareResult().toString();
}
} else if (cc instanceof FileStoreEditorInput) {
return ((FileStoreEditorInput) cc).getName();
}
if (appendRoot) {
return WorkspaceRoot + loc.getFullPath().toOSString();
} else if (loc != null) {
return loc.getFullPath().toOSString();
} else {
return "";
}
}
Aggregations