Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
12c (12.1.3)

E41664-01

Package oracle.jdeveloper.merge

Contains classes for merge editor abstractions, including an editor addin, commands, a controller, and utilities.

See: Description

Package oracle.jdeveloper.merge Description

Contains classes for merge editor abstractions, including an editor addin, commands, a controller, and utilities. Most importantly this package provides the basis for a textual, wedge-style component for 3-way merge.

Code examples

To create and register a merge editor addin:

import java.net.URL;
import oracle.ide.editor.EditorManager;
import oracle.jdeveloper.merge.AbstractMergeAddin;
...
AbstractMergeAddin mergeEditorAddin = new AbstractMergeAddin( AcmeMergeEditor.class ) {
        protected boolean isEditorAvailable( URL url ) {
                ...
        }
};
EditorManager.getEditorManager().registerDynamic( mergeEditorAddin );

To deregister and dispose a merge editor addin:

import oracle.ide.editor.EditorManager;
import oracle.jdeveloper.merge.AbstractMergeAddin;
...
AbstractMergeAddin mergeEditorAddin = ...
...
EditorManager.getEditorManager().unregister( mergeEditorAddin );

mergeEditorAddin.closeEditors();
mergeEditorAddin = null;

Implementing a textual merge editor which builds and returns a model:

import java.io.IOException;
import java.net.URL;
import oracle.ide.addin.Context;
import oracle.ide.net.URLFileSystem;
import oracle.javatools.buffer.TextBuffer;
import oracle.javatools.buffer.TextBufferFactory;
import oracle.javatools.compare.algorithm.text.OffsetDifferenceBlock;
import oracle.javatools.compare.algorithm.text.TextCompareContributor;
import oracle.javatools.compare.algorithm.text.TextCompareModel;
import oracle.jdeveloper.merge.TextMergeContributor;
import oracle.jdeveloper.merge.TextMergeNodeContributor;
import oracle.jdeveloper.merge.BaseTextMergeEditor;
import oracle.jdeveloper.merge.TextMergeNode;
...
public class AcmeMergeEditor extends BaseTextMergeEditor {

        protected TextCompareModel createTextMergeModel( Context context ) throws IOException {
                TextBuffer textBuffer1 = TextBufferFactory.createTextBuffer();
                TextBuffer textBuffer2 = TextBufferFactory.createTextBuffer();
                TextBuffer textBufferA = TextBufferFactory.createTextBuffer();
                ...

                // Example initialization of a single difference block
                OffsetDifferenceBlock differenceBlock = new OffsetDifferenceBlock( OffsetDifferenceBlock.TYPE_CHANGE,
                        textBuffer1, textBuffer2, textBufferA );

                differenceBlock.setFirstStart( 1 );
                differenceBlock.setSecondStart( 1 );
                differenceBlock.setAncestorStart( 1 );
                differenceBlock.setFirstLength( 2 );
                differenceBlock.setSecondLength( 3 );
                differenceBlock.setAncestorLength( 0 );

                URL url = context.getDocument().getURL();
                setTextMergeNode( new TextMergeNode( url, textBufferA ) );

                TextCompareContributor contributor1 =
                        new TextMergeContributor( textBuffer1, URLFileSystem.getSuffix( url ), "Source" );
                TextCompareContributor contributor2 =
                        new TextMergeContributor( textBuffer2, URLFileSystem.getSuffix( url ), "Target" );
                TextCompareContributor contributorA =
                        new TextMergeNodeContributor( getTextMergeNode(), "Result of Merge" );

                return new TextCompareModel(
                        contributor1, contributor2, contributorA, new OffsetDifferenceBlock[] { differenceBlock } );
        }
}

Implementing a command to make the merge editor of a document visible:

import java.io.IOException;
import oracle.ide.Ide;
import oracle.ide.addin.AbstractCommand;
import oracle.ide.addin.Command;
import oracle.jdeveloper.merge.MergeUtil;
...
public class AcmeMergeCommand extends AbstractCommand {
        public static final int CMD_ID = Ide.findOrCreateCmdID( "AcmeMergeCommand" );

        public AcmeMergeCommand() {
                super( AcmeMergeCommand.CMD_ID );
        }

        public int doit() throws IOException {
                MergeUtil.reopenMergeEditor( getContext().getDocument(), AcmeMergeEditor.class );
                return Command.OK;
        }
}
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
12c (12.1.3)

E41664-01

Copyright © 1997, 2014, Oracle. All rights reserved.