1515 */
1616package org .exbin .bined .intellij ;
1717
18+ import com .intellij .diff .impl .DiffSettingsHolder ;
19+ import com .intellij .diff .tools .combined .CombinedDiffComponentFactory ;
20+ import com .intellij .diff .tools .combined .CombinedDiffMainUI ;
21+ import com .intellij .diff .tools .combined .CombinedDiffTool ;
22+ import com .intellij .diff .tools .combined .CombinedDiffViewer ;
23+ import com .intellij .diff .tools .fragmented .UnifiedDiffTool ;
24+ import com .intellij .diff .tools .simple .SimpleDiffTool ;
1825import com .intellij .openapi .extensions .ExtensionPointAdapter ;
1926import com .intellij .openapi .extensions .ExtensionPointName ;
2027import com .intellij .openapi .extensions .PluginDescriptor ;
3643import org .exbin .bined .intellij .api .BinaryViewHandler ;
3744import org .exbin .bined .intellij .data .ObjectValueConvertor ;
3845import org .exbin .bined .intellij .debug .gui .DebugViewPanel ;
46+ import org .exbin .bined .intellij .diff .BinEdDiffTool ;
3947import org .exbin .bined .intellij .gui .BinEdComponentFileApi ;
4048import org .exbin .bined .intellij .gui .BinEdComponentPanel ;
4149import org .exbin .bined .intellij .options .IntegrationOptions ;
5159import java .util .ArrayList ;
5260import java .util .List ;
5361import java .util .Optional ;
62+ import java .util .logging .Level ;
63+ import java .util .logging .Logger ;
5464
5565/**
5666 * Post startup activity.
@@ -62,6 +72,7 @@ public final class BinEdPluginStartupActivity implements StartupActivity, DumbAw
6272
6373 private static final ExtensionPointName <BinaryViewData > BINED_VIEW_DATA =
6474 ExtensionPointName .create ("org.exbin.deltahex.intellij.viewBinaryData" );
75+ private static final String BINED_DIFF_TOOL_ID = BinEdDiffTool .class .getCanonicalName ();
6576 private static final List <IntegrationOptionsListener > INTEGRATION_OPTIONS_LISTENERS = new ArrayList <>();
6677 private static IntegrationOptions initialIntegrationOptions = null ;
6778
@@ -124,6 +135,33 @@ public void beforeFileClosed(@Nonnull FileEditorManager source, @Nonnull Virtual
124135 }
125136 }
126137 });
138+
139+ moveBinEdDiffToolToLastPosition ();
140+ }
141+
142+ private static void moveBinEdDiffToolToLastPosition () {
143+ try {
144+ DiffSettingsHolder .DiffSettings settings = DiffSettingsHolder .DiffSettings .getSettings ();
145+ List <String > diffToolsOrder = settings .getDiffToolsOrder ();
146+ if (diffToolsOrder .isEmpty ()) {
147+ // Prefer basic and unified diff tools before added BinEd diff
148+ diffToolsOrder .add (SimpleDiffTool .class .getCanonicalName ());
149+ diffToolsOrder .add (UnifiedDiffTool .class .getCanonicalName ());
150+ diffToolsOrder .add (BINED_DIFF_TOOL_ID );
151+ } else {
152+ for (int i = 0 ; i < diffToolsOrder .size (); i ++) {
153+ if (BINED_DIFF_TOOL_ID .equals (diffToolsOrder .get (i ))) {
154+ diffToolsOrder .remove (i );
155+ break ;
156+ }
157+ }
158+ // Add as last option
159+ diffToolsOrder .add (BINED_DIFF_TOOL_ID );
160+ }
161+ settings .setDiffToolsOrder (diffToolsOrder );
162+ } catch (Exception ex ) {
163+ Logger .getLogger (BinEdPluginStartupActivity .class .getName ()).log (Level .SEVERE , "Unable to move BinEd diff tool to lowest priority" , ex );
164+ }
127165 }
128166
129167 public static void addIntegrationOptionsListener (IntegrationOptionsListener integrationOptionsListener ) {
0 commit comments