Java Code Examples for org.eclipse.compare.CompareConfiguration#setRightEditable()

The following examples show how to use org.eclipse.compare.CompareConfiguration#setRightEditable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SpecComparePage.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
private Control createPreviewer(Composite parent) {
	final CompareConfiguration compareConfiguration = new CompareConfiguration();
	compareConfiguration.setLeftLabel("Original " + docTypeName);
	compareConfiguration.setLeftEditable(false);
	compareConfiguration.setRightLabel("Updated " + docTypeName);
	compareConfiguration.setRightEditable(false);
	compareConfiguration.setProperty(CompareConfiguration.IGNORE_WHITESPACE, Boolean.FALSE);
	compareConfiguration.setProperty(PREFIX_SUFFIX_PROPERTY, fPrefixSuffix);

	fViewer = new TextMergeViewer(parent, SWT.NONE, compareConfiguration);
	// add initial input in order to avoid problems when disposing the viewer later:
	fViewer.setInput(new DiffNode(new TargetElementFromString(""), new TargetElementFromString("")));

	Control control = fViewer.getControl();
	control.addDisposeListener(new DisposeListener() {
		@Override
		public void widgetDisposed(DisposeEvent e) {
			compareConfiguration.dispose();
		}
	});
	return control;
}
 
Example 2
Source File: SVNLocalCompareInput.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * initialize the labels : the title, the lft label and the right one
 */
private void initLabels() {
	CompareConfiguration cc = getCompareConfiguration();
	String resourceName = resource.getName();	
	setTitle(Policy.bind("SVNCompareRevisionsInput.compareResourceAndVersions", new Object[] {resourceName})); //$NON-NLS-1$
	cc.setLeftEditable(! readOnly);
	cc.setRightEditable(false);
	
	String leftLabel = Policy.bind("SVNCompareRevisionsInput.workspace", new Object[] {resourceName}); //$NON-NLS-1$
	cc.setLeftLabel(leftLabel);
	String remoteResourceName = null;
	if (remoteResource != null) {
		remoteResourceName = remoteResource.getName();
	} else {
		remoteResourceName = resourceName;
	}
	String rightLabel = Policy.bind("SVNCompareRevisionsInput.repository", new Object[] {remoteResourceName}); //$NON-NLS-1$
	cc.setRightLabel(rightLabel);
}
 
Example 3
Source File: SVNLocalBaseCompareInput.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private void initLabels() {
	CompareConfiguration cc = getCompareConfiguration();
	cc.setLeftEditable(! readOnly);
	cc.setRightEditable(false);
	String title;
	String leftLabel;
	String rightLabel;
	if (localResourceNodes.length > 1) {
		title = Policy.bind("SVNLocalBaseCompareInput.0") + remoteRevision; //$NON-NLS-1$
		leftLabel = Policy.bind("SVNLocalBaseCompareInput.1"); //$NON-NLS-1$
		rightLabel = remoteRevision.toString();
	} else {
		title = Policy.bind("SVNCompareRevisionsInput.compareResourceAndVersions", new Object[] {localResourceNodes[0].getName()}); //$NON-NLS-1$
		leftLabel = Policy.bind("SVNCompareRevisionsInput.workspace", new Object[] {localResourceNodes[0].getName()}); //$NON-NLS-1$
		rightLabel = Policy.bind("SVNCompareRevisionsInput.repository", new Object[] {localResourceNodes[0].getName()}); //$NON-NLS-1$
	}
	setTitle(title);			
	cc.setLeftLabel(leftLabel);		
	cc.setRightLabel(rightLabel);
}
 
Example 4
Source File: SVNLocalCompareSummaryInput.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * initialize the labels : the title, the lft label and the right one
 */
private void initLabels() {
	CompareConfiguration cc = getCompareConfiguration();
	cc.setLeftEditable(! readOnly);
	cc.setRightEditable(false);
	String title;
	String leftLabel;
	String rightLabel;
	if (resources.length > 1) {
		title = Policy.bind("SVNLocalBaseCompareInput.0") + remoteRevision; //$NON-NLS-1$
		leftLabel = Policy.bind("SVNLocalBaseCompareInput.1"); //$NON-NLS-1$
		rightLabel = remoteRevision.toString();			
	} else {
		title = Policy.bind("SVNCompareRevisionsInput.compareResourceAndVersions", new Object[] {resources[0].getName()}); //$NON-NLS-1$
		leftLabel = Policy.bind("SVNCompareRevisionsInput.workspace", new Object[] {resources[0].getName()}); //$NON-NLS-1$
		rightLabel = Policy.bind("SVNCompareRevisionsInput.repository", new Object[] {resources[0].getName()}); //$NON-NLS-1$
	}
	setTitle(title);		
	cc.setLeftLabel(leftLabel);
	cc.setRightLabel(rightLabel);
}
 
Example 5
Source File: ScriptRefactoringAction.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private BonitaCompareEditorInput createCompareEditorInput() {
    final CompareConfiguration config = new CompareConfiguration();
    config.setRightEditable(true);
    config.setLeftEditable(false);
    config.setLeftLabel(Messages.currentScript);
    config.setRightLabel(Messages.refactoredScript);
    config.setProperty(CompareConfiguration.USE_OUTLINE_VIEW, true);
    String oldNames = "";
    String newNames = "";
    boolean canBeContainedInscript = true;
    for (final RefactorPair<?, ?> pairRefactor : pairsToRefactor) {
        oldNames += oldNames.isEmpty() ? pairRefactor.getOldValueName() : "," + pairRefactor.getOldValueName();
        newNames += newNames.isEmpty() ? pairRefactor.getNewValueName() : "," + pairRefactor.getNewValueName();
        canBeContainedInscript = canBeContainedInscript && pairRefactor.canBeContainedInScript();
    }
    return new BonitaCompareEditorInput(config, scriptExpressions, operationType, oldNames,
            newNames, canBeContainedInscript);
}
 
Example 6
Source File: DatastoreIndexesUpdatedStatusHandler.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Override
protected ICompareInput prepareCompareInput(IProgressMonitor monitor)
    throws InvocationTargetException, InterruptedException {
  CompareConfiguration cc = getCompareConfiguration();
  cc.setLeftEditable(true);
  cc.setRightEditable(false);
  cc.setLeftLabel(source.getName());
  cc.setLeftImage(CompareUI.getImage(source));
  cc.setRightLabel(generatedUpdate.getName());
  cc.setRightImage(CompareUI.getImage(source)); // same type
  ITypedElement left = SaveableCompareEditorInput.createFileElement(source);
  ITypedElement right = new LocalDiskContent(generatedUpdate);
  return new DiffNode(left, right);
}
 
Example 7
Source File: PropertyCompareInput.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private void initLabels() {
	CompareConfiguration cc = getCompareConfiguration();
	setTitle(Policy.bind("PropertyCompareInput.2")); //$NON-NLS-1$
	cc.setLeftEditable(left.isEditable());
	cc.setRightEditable(right.isEditable());
	cc.setLeftLabel(left.getLabel());
	cc.setRightLabel(right.getLabel());
}
 
Example 8
Source File: SVNLocalBranchTagCompareInput.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private void initLabels() {
	CompareConfiguration cc = getCompareConfiguration();	
	setTitle("Compare <workspace> and versions");
	cc.setLeftEditable(true);
	cc.setRightEditable(false);		
	String leftLabel = "<workspace>";
	cc.setLeftLabel(leftLabel);
	String rightLabel = "Repository";
	cc.setRightLabel(rightLabel);
}
 
Example 9
Source File: SVNCompareRevisionsInput.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
    * initialize the labels : the title, the lft label and the right one
    */
private void initLabels() {
	CompareConfiguration cc = getCompareConfiguration();
	String resourceName = resource.getName();	
	setTitle(Policy.bind("SVNCompareRevisionsInput.compareResourceAndVersions", new Object[] {resourceName})); //$NON-NLS-1$
	cc.setLeftEditable(true);
	cc.setRightEditable(false);
	
	String leftLabel = Policy.bind("SVNCompareRevisionsInput.workspace", new Object[] {resourceName}); //$NON-NLS-1$
	cc.setLeftLabel(leftLabel);
	String rightLabel = Policy.bind("SVNCompareRevisionsInput.repository", new Object[] {resourceName}); //$NON-NLS-1$
	cc.setRightLabel(rightLabel);
}
 
Example 10
Source File: CompareDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
CompareDialog(Shell parent, ResourceBundle bundle) {
	super(parent, bundle);

	fCompareConfiguration= new CompareConfiguration();
	fCompareConfiguration.setLeftEditable(false);
	fCompareConfiguration.setRightEditable(false);
}
 
Example 11
Source File: JavaCompareWithEditionActionImpl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void run(ISelection selection) {

	IMember input= getEditionElement(selection);
	if (input == null) {
		MessageDialog.openInformation(getShell(), CompareMessages.CompareWithHistory_title, CompareMessages.CompareWithHistory_invalidSelectionMessage);
		return;
	}

	JavaElementHistoryPageSource pageSource = JavaElementHistoryPageSource.getInstance();
	final IFile file= pageSource.getFile(input);
	if (file == null) {
		MessageDialog.openError(getShell(), CompareMessages.CompareWithHistory_title, CompareMessages.CompareWithHistory_internalErrorMessage);
		return;
	}

	if (USE_MODAL_COMPARE) {
		CompareConfiguration cc = new CompareConfiguration();
		cc.setLeftEditable(false);
		cc.setRightEditable(false);
		HistoryPageCompareEditorInput ci = new HistoryPageCompareEditorInput(cc, pageSource, input);
		ci.setTitle(CompareMessages.JavaCompareWithEditionActionImpl_0);
		ci.setHelpContextId(IJavaHelpContextIds.COMPARE_ELEMENT_WITH_HISTORY_DIALOG);
		CompareUI.openCompareDialog(ci);
	} else {
		TeamUI.showHistoryFor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), input, pageSource);
	}
}
 
Example 12
Source File: PyContentMergeViewerCreator.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a new configuration with the pydev preference store so that the colors appear correctly when using
 * Aptana themes.
 * 
 * Also copies the available data from the original compare configuration to the new configuration.
 */
private CompareConfiguration createNewCompareConfiguration(CompareConfiguration mp) {
    List<IPreferenceStore> stores = PyDevUiPrefs.getDefaultStores(false);
    IPreferenceStore prefs = mp.getPreferenceStore();
    if (prefs != null) {
        //Note, we could use the CompareUIPlugin.getDefault().getPreferenceStore() directly, but it's access
        //is restricted, so, we go to the preferences of the previously created compare configuration.
        stores.add(prefs);
    }

    CompareConfiguration cc = new CompareConfiguration(new ChainedPreferenceStore(
            stores.toArray(new IPreferenceStore[stores.size()])));
    cc.setAncestorImage(mp.getAncestorImage(null));
    cc.setAncestorLabel(mp.getAncestorLabel(null));

    cc.setLeftImage(mp.getLeftImage(null));
    cc.setLeftLabel(mp.getLeftLabel(null));
    cc.setLeftEditable(mp.isLeftEditable());

    cc.setRightImage(mp.getRightImage(null));
    cc.setRightLabel(mp.getRightLabel(null));
    cc.setRightEditable(mp.isRightEditable());

    try {
        cc.setContainer(mp.getContainer());
    } catch (Throwable e) {
        //Ignore: not available in Eclipse 3.2.
    }

    return cc;
}
 
Example 13
Source File: ModulaContentViewerCreator.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public Viewer createViewer(Composite parent, CompareConfiguration config) {
	config.setLeftEditable(false);
	config.setRightEditable(false);
	return new ModulaMergeViewer(parent, config);
}
 
Example 14
Source File: PktContentViewerCreator.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public Viewer createViewer(Composite parent, CompareConfiguration config) {
	config.setLeftEditable(false);
	config.setRightEditable(false);
	return new PktMergeViewer(parent, config);
}
 
Example 15
Source File: JavaReplaceWithEditionActionImpl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void run(ISelection selection) {

	Shell shell= getShell();

	final IMember input= getEditionElement(selection);
	if (input == null) {
		MessageDialog.openInformation(shell, CompareMessages.ReplaceFromHistory_title, CompareMessages.ReplaceFromHistory_invalidSelectionMessage);
		return;
	}

	final IFile file= getFile(input);
	if (file == null) {
		showError();
		return;
	}

	IStatus status= Resources.makeCommittable(file, shell);
	if (!status.isOK()) {
		return;
	}

	if (fPrevious) {
		String errorTitle= CompareMessages.ReplaceFromHistory_title;
		String errorMessage= CompareMessages.ReplaceFromHistory_internalErrorMessage;
		try {
			ITypedElement ti = ElementLocalHistoryPageSource.getPreviousEdition(file, input);
			if (ti == null) {
				MessageDialog.openInformation(shell, errorTitle, CompareMessages.ReplaceFromHistory_parsingErrorMessage);
				return;
			}
			replace(input, file, ti);
		} catch (TeamException e) {
			ExceptionHandler.handle(e, shell, errorTitle, errorMessage);
		}
	} else {
		JavaElementHistoryPageSource pageSource = JavaElementHistoryPageSource.getInstance();
		CompareConfiguration cc = new CompareConfiguration();
		cc.setLeftEditable(false);
		cc.setRightEditable(false);
		HistoryPageCompareEditorInput ci = new HistoryPageCompareEditorInput(cc, pageSource, input) {
			@Override
			protected void performReplace(Object selectedElement) {
				if (selectedElement instanceof ITypedElement) {
					JavaReplaceWithEditionActionImpl.this.replace(input, file, (ITypedElement)selectedElement);
				}
			}
		};
		ci.setReplace(true);
		ci.setTitle(CompareMessages.JavaReplaceWithEditionActionImpl_0);
		ci.setHelpContextId(IJavaHelpContextIds.REPLACE_ELEMENT_WITH_HISTORY_DIALOG);
		CompareUI.openCompareDialog(ci);
	}
}