junichi11 closed pull request #1015: [NETBEANS-1622] Sort editor tabs when a
document opens
URL: https://github.com/apache/incubator-netbeans/pull/1015
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/platform/core.windows/apichanges.xml
b/platform/core.windows/apichanges.xml
index 92f40cf389..9fa948ce93 100644
--- a/platform/core.windows/apichanges.xml
+++ b/platform/core.windows/apichanges.xml
@@ -84,6 +84,25 @@ is the proper place.
<changes>
+ <change id="sort-editor-tabs" >
+ <api name="winsys"/>
+ <summary>Add preference for sorting editor tabs</summary>
+ <version major="2" minor="87"/>
+ <date day="14" month="11" year="2018"/>
+ <author login="junichi11"/>
+ <compatibility addition="yes" binary="compatible" source="compatible"
semantic="compatible" deprecation="no" deletion="no" modification="no"/>
+ <description>
+ A new preference option for the windowing system was added:
+ <code>EDITOR_SORT_TABS</code>. The option allows the user to
+ let the window system sort the opened tabs according to the opened
+ files. The default value is <code>None</code>, which is the
netbeans
+ default behaviour. Other supported values are:
+ <code>FileName</code>, <code>FileNameWithParent</code> and
+ <code>FullFilePath</code>.
+ </description>
+ <issue number="NETBEANS-1622"/>
+ </change>
+
<change id="help-button-at-left-side" >
<api name="winsys"/>
<summary>Allow to move the Help button to the left side</summary>
diff --git a/platform/core.windows/manifest.mf
b/platform/core.windows/manifest.mf
index 312d88c6ef..a4d1d2fba5 100644
--- a/platform/core.windows/manifest.mf
+++ b/platform/core.windows/manifest.mf
@@ -6,5 +6,5 @@ OpenIDE-Module-Provides: org.netbeans.core.WindowSystem,
org.openide.windows.Win
OpenIDE-Module-Recommends:
org.netbeans.core.windows.nativeaccess.NativeWindowSystem
AutoUpdate-Show-In-Client: false
AutoUpdate-Essential-Module: true
-OpenIDE-Module-Specification-Version: 2.86
+OpenIDE-Module-Specification-Version: 2.87
diff --git
a/platform/core.windows/src/org/netbeans/core/windows/model/DefaultModeModel.java
b/platform/core.windows/src/org/netbeans/core/windows/model/DefaultModeModel.java
index 48f56da334..9b9bda1243 100644
---
a/platform/core.windows/src/org/netbeans/core/windows/model/DefaultModeModel.java
+++
b/platform/core.windows/src/org/netbeans/core/windows/model/DefaultModeModel.java
@@ -37,6 +37,10 @@
import org.netbeans.core.windows.SplitConstraint;
import org.netbeans.core.windows.Switches;
import org.netbeans.core.windows.WindowManagerImpl;
+import org.netbeans.core.windows.options.TabsPanel.EditorSortType;
+import org.netbeans.core.windows.options.WinSysPrefs;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
import org.openide.windows.TopComponent;
@@ -140,47 +144,118 @@ public void insertOpenedTopComponent(TopComponent tc,
int index) {
sortOpenedTopComponents();
}
}
-
+
private void sortOpenedTopComponents() {
- if( getKind() != Constants.MODE_KIND_SLIDING )
- return;
- if( !Switches.isModeSlidingEnabled() )
+ if (getKind() == Constants.MODE_KIND_EDITOR) {
+ sortByFile(getEditorSortType());
+ } else if( getKind() == Constants.MODE_KIND_SLIDING &&
Switches.isModeSlidingEnabled()) {
+ WindowManagerImpl wm = WindowManagerImpl.getInstance();
+ List<TopComponent> opened =
topComponentSubModel.getOpenedTopComponents();
+ final List<String> prevModes = new ArrayList<>(opened.size());
+ final Map<TopComponent, String> tc2modeName = new
HashMap<>(opened.size());
+ for (TopComponent tc : opened) {
+ String tcId = wm.findTopComponentID(tc);
+ if (null == tcId) {
+ continue;
+ }
+ ModeImpl prevMode = getTopComponentPreviousMode(tcId);
+ if (null == prevMode) {
+ continue;
+ }
+ if (!prevModes.contains(prevMode.getName())) {
+ prevModes.add(prevMode.getName());
+ }
+ tc2modeName.put(tc, prevMode.getName());
+ }
+
+ if (prevModes.isEmpty()) {
+ return; //nothing to sort by (shouldn't really happen)
+ }
+ Collections.sort(opened, new Comparator<TopComponent>() {
+ @Override
+ public int compare(TopComponent o1, TopComponent o2) {
+ String mode1 = tc2modeName.get(o1);
+ String mode2 = tc2modeName.get(o2);
+ if (null == mode1 && null != mode2) {
+ return 1;
+ } else if (null != mode1 && null == mode2) {
+ return -1;
+ }
+ return prevModes.indexOf(mode1) - prevModes.indexOf(mode2);
+ }
+ });
+ topComponentSubModel.setOpenedTopComponents(opened);
+ }
+ }
+
+ private EditorSortType getEditorSortType() {
+ EditorSortType sortType = EditorSortType.None;
+ try {
+ sortType =
EditorSortType.valueOf(WinSysPrefs.HANDLER.get(WinSysPrefs.EDITOR_SORT_TABS,
EditorSortType.None.name()));
+ } catch (IllegalArgumentException ex) {
+ // no-op
+ }
+ return sortType;
+ }
+
+ private void sortByFile(final EditorSortType sortType) {
+ if (sortType == EditorSortType.None) {
return;
- WindowManagerImpl wm = WindowManagerImpl.getInstance();
- List<TopComponent> opened =
topComponentSubModel.getOpenedTopComponents();
- final List<String> prevModes = new ArrayList<String>( opened.size() );
- final Map<TopComponent, String> tc2modeName = new
HashMap<TopComponent, String>( opened.size() );
- for( TopComponent tc : opened ) {
- String tcId = wm.findTopComponentID( tc );
- if( null == tcId )
- continue;
- ModeImpl prevMode = getTopComponentPreviousMode( tcId );
- if( null == prevMode )
- continue;
- if( !prevModes.contains( prevMode.getName() ) )
- prevModes.add( prevMode.getName() );
- tc2modeName.put( tc, prevMode.getName() );
}
-
- if( prevModes.isEmpty() )
- return; //nothing to sort by (shouldn't really happen)
-
- Collections.sort( opened, new Comparator<TopComponent>() {
+ List<TopComponent> openedComponents =
topComponentSubModel.getOpenedTopComponents();
+ Collections.sort(openedComponents, new Comparator<TopComponent>() {
@Override
- public int compare( TopComponent o1, TopComponent o2 ) {
- String mode1 = tc2modeName.get( o1 );
- String mode2 = tc2modeName.get( o2 );
- if( null == mode1 && null != mode2 ) {
+ public int compare(TopComponent tc1, TopComponent tc2) {
+ FileObject f1 = tc1.getLookup().lookup(FileObject.class);
+ FileObject f2 = tc2.getLookup().lookup(FileObject.class);
+ if (f1 == null && f2 == null) {
+ return 0;
+ } else if (f1 != null && f2 == null) {
return 1;
- } else if( null != mode1 && null == mode2 ) {
+ } else if (f1 == null && f2 != null) {
return -1;
+ } else {
+ switch (sortType) {
+ case FullFilePath:
+ return compareFullFilePath(f1, f2);
+ case FileName:
+ return compareFileName(f1, f2);
+ case FileNameWithParent:
+ return compareFileNameWithParent(f1, f2);
+ default:
+ throw new AssertionError();
+ }
}
- return prevModes.indexOf( mode1 ) - prevModes.indexOf( mode2 );
}
});
- topComponentSubModel.setOpenedTopComponents( opened );
+ topComponentSubModel.setOpenedTopComponents(openedComponents);
}
-
+
+ private int compareFullFilePath(FileObject f1, FileObject f2) {
+ return FileUtil.toFile(f1).compareTo(FileUtil.toFile(f2));
+ }
+
+ private int compareFileName(FileObject f1, FileObject f2) {
+ return f1.getName().compareToIgnoreCase(f2.getName());
+ }
+
+ private int compareFileNameWithParent(FileObject f1, FileObject f2) {
+ FileObject p1 = f1.getParent();
+ FileObject p2 = f2.getParent();
+ if (p1 == null && p2 == null) {
+ return 0;
+ } else if (p1 != null && p2 == null) {
+ return 1;
+ } else if (p1 == null && p2 != null) {
+ return -1;
+ } else {
+ if (p1.getName().equals(p2.getName())) {
+ return f1.getName().compareToIgnoreCase(f2.getName());
+ }
+ return p1.getName().compareToIgnoreCase(p2.getName());
+ }
+ }
+
@Override
public void addClosedTopComponent(TopComponent tc) {
synchronized(LOCK_TOPCOMPONENTS) {
diff --git
a/platform/core.windows/src/org/netbeans/core/windows/options/Bundle.properties
b/platform/core.windows/src/org/netbeans/core/windows/options/Bundle.properties
index 8ff60f9f2e..955dcc08a2 100644
---
a/platform/core.windows/src/org/netbeans/core/windows/options/Bundle.properties
+++
b/platform/core.windows/src/org/netbeans/core/windows/options/Bundle.properties
@@ -59,3 +59,8 @@ Laf_DisplayName=Look and Feel
KW_LafOptions=look, feel, Look and feel
KW_TabsOptions=editor tabs, multi-row
Tabs_DisplayName=Document Tabs
+TabsPanel.radioSortNothing.text=&Sort nothing
+TabsPanel.radioSortFullFilePath.text=Sort by &full file path
+TabsPanel.radioSortFileNameWithParent.text=Sort by file name with &parent
directory
+TabsPanel.radioSortFileName.text=Sort by file &name
+TabsPanel.sortTabsLabel.text=Sort tabs when a document opens:
diff --git
a/platform/core.windows/src/org/netbeans/core/windows/options/TabsPanel.form
b/platform/core.windows/src/org/netbeans/core/windows/options/TabsPanel.form
index 5c49c5eb80..f3d63028a5 100644
--- a/platform/core.windows/src/org/netbeans/core/windows/options/TabsPanel.form
+++ b/platform/core.windows/src/org/netbeans/core/windows/options/TabsPanel.form
@@ -25,6 +25,8 @@
<NonVisualComponents>
<Component class="javax.swing.ButtonGroup" name="buttonGroup1">
</Component>
+ <Component class="javax.swing.ButtonGroup" name="sortButtonGroup">
+ </Component>
</NonVisualComponents>
<Properties>
<Property name="border" type="javax.swing.border.Border"
editor="org.netbeans.modules.form.editors2.BorderEditor">
@@ -43,7 +45,7 @@
<AuxValue name="FormSettings_listenerGenerationStyle"
type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean"
value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer"
value="2"/>
- <AuxValue name="designerSize" type="java.awt.Dimension"
value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-100,0,0,1,-88"/>
+ <AuxValue name="designerSize" type="java.awt.Dimension"
value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-100,0,0,1,-114"/>
</AuxValues>
<Layout
class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
@@ -76,7 +78,7 @@
</Events>
<Constraints>
<Constraint
layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"
value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
- <GridBagConstraints gridX="0" gridY="1" gridWidth="2"
gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0"
insetsBottom="6" insetsRight="0" anchor="18" weightX="0.0" weightY="1.0"/>
+ <GridBagConstraints gridX="0" gridY="1" gridWidth="2"
gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0"
insetsBottom="0" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
@@ -95,10 +97,95 @@
</Constraint>
</Constraints>
</Component>
+ <Component class="javax.swing.JLabel" name="sortTabsLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String"
editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString
bundle="org/netbeans/core/windows/options/Bundle.properties"
key="TabsPanel.sortTabsLabel.text"
replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class,
"{key}")"/>
+ </Property>
+ </Properties>
+ <Constraints>
+ <Constraint
layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"
value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="0" gridY="2" gridWidth="2"
gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="6" insetsLeft="0"
insetsBottom="0" insetsRight="0" anchor="23" weightX="0.0" weightY="0.0"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ <Component class="javax.swing.JRadioButton" name="radioSortNothing">
+ <Properties>
+ <Property name="buttonGroup" type="javax.swing.ButtonGroup"
editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+ <ComponentRef name="sortButtonGroup"/>
+ </Property>
+ <Property name="selected" type="boolean" value="true"/>
+ <Property name="text" type="java.lang.String"
editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString
bundle="org/netbeans/core/windows/options/Bundle.properties"
key="TabsPanel.radioSortNothing.text"
replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class,
"{key}")"/>
+ </Property>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed"
listener="java.awt.event.ActionListener"
parameters="java.awt.event.ActionEvent"
handler="radioSortNothingActionPerformed"/>
+ </Events>
+ <Constraints>
+ <Constraint
layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"
value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="1" gridY="3" gridWidth="1"
gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0"
insetsBottom="0" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ <Component class="javax.swing.JRadioButton" name="radioSortFileName">
+ <Properties>
+ <Property name="buttonGroup" type="javax.swing.ButtonGroup"
editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+ <ComponentRef name="sortButtonGroup"/>
+ </Property>
+ <Property name="text" type="java.lang.String"
editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString
bundle="org/netbeans/core/windows/options/Bundle.properties"
key="TabsPanel.radioSortFileName.text"
replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class,
"{key}")"/>
+ </Property>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed"
listener="java.awt.event.ActionListener"
parameters="java.awt.event.ActionEvent"
handler="radioSortFileNameActionPerformed"/>
+ </Events>
+ <Constraints>
+ <Constraint
layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"
value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="1" gridY="4" gridWidth="1"
gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0"
insetsBottom="0" insetsRight="0" anchor="23" weightX="0.0" weightY="0.0"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ <Component class="javax.swing.JRadioButton"
name="radioSortFileNameWithParent">
+ <Properties>
+ <Property name="buttonGroup" type="javax.swing.ButtonGroup"
editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+ <ComponentRef name="sortButtonGroup"/>
+ </Property>
+ <Property name="text" type="java.lang.String"
editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString
bundle="org/netbeans/core/windows/options/Bundle.properties"
key="TabsPanel.radioSortFileNameWithParent.text"
replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class,
"{key}")"/>
+ </Property>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed"
listener="java.awt.event.ActionListener"
parameters="java.awt.event.ActionEvent"
handler="radioSortFileNameWithParentActionPerformed"/>
+ </Events>
+ <Constraints>
+ <Constraint
layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"
value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="1" gridY="5" gridWidth="1"
gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0"
insetsBottom="0" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ <Component class="javax.swing.JRadioButton"
name="radioSortFullFilePath">
+ <Properties>
+ <Property name="buttonGroup" type="javax.swing.ButtonGroup"
editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+ <ComponentRef name="sortButtonGroup"/>
+ </Property>
+ <Property name="text" type="java.lang.String"
editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString
bundle="org/netbeans/core/windows/options/Bundle.properties"
key="TabsPanel.radioSortFullFilePath.text"
replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class,
"{key}")"/>
+ </Property>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed"
listener="java.awt.event.ActionListener"
parameters="java.awt.event.ActionEvent"
handler="radioSortFullFilePathActionPerformed"/>
+ </Events>
+ <Constraints>
+ <Constraint
layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"
value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="1" gridY="6" gridWidth="1"
gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0"
insetsBottom="6" insetsRight="0" anchor="23" weightX="0.0" weightY="1.0"/>
+ </Constraint>
+ </Constraints>
+ </Component>
<Container class="javax.swing.JPanel" name="panelTabs">
<Constraints>
<Constraint
layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"
value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
- <GridBagConstraints gridX="0" gridY="2" gridWidth="2"
gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0"
insetsBottom="0" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
+ <GridBagConstraints gridX="0" gridY="7" gridWidth="2"
gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0"
insetsBottom="0" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
diff --git
a/platform/core.windows/src/org/netbeans/core/windows/options/TabsPanel.java
b/platform/core.windows/src/org/netbeans/core/windows/options/TabsPanel.java
index a7c7a3a59a..0d2d6d51ec 100644
--- a/platform/core.windows/src/org/netbeans/core/windows/options/TabsPanel.java
+++ b/platform/core.windows/src/org/netbeans/core/windows/options/TabsPanel.java
@@ -31,14 +31,21 @@
public class TabsPanel extends javax.swing.JPanel {
protected final TabsOptionsPanelController controller;
-
+
private final Preferences prefs = NbPreferences.forModule(TabsPanel.class);
-
+
private final boolean isAquaLaF =
"Aqua".equals(UIManager.getLookAndFeel().getID()); //NOI18N
private boolean defMultiRow;
private int defTabPlacement;
-
+
+ public enum EditorSortType {
+ None,
+ FileName,
+ FileNameWithParent,
+ FullFilePath,
+ }
+
protected TabsPanel(final TabsOptionsPanelController controller) {
this.controller = controller;
initComponents();
@@ -55,9 +62,15 @@ private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
buttonGroup1 = new javax.swing.ButtonGroup();
+ sortButtonGroup = new javax.swing.ButtonGroup();
panelDocTabs = new javax.swing.JPanel();
isCloseActivatesMostRecentDocument = new javax.swing.JCheckBox();
isNewDocumentOpensNextToActiveTab = new javax.swing.JCheckBox();
+ sortTabsLabel = new javax.swing.JLabel();
+ radioSortNothing = new javax.swing.JRadioButton();
+ radioSortFileName = new javax.swing.JRadioButton();
+ radioSortFileNameWithParent = new javax.swing.JRadioButton();
+ radioSortFullFilePath = new javax.swing.JRadioButton();
panelTabs = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
radioTop = new javax.swing.JRadioButton();
@@ -84,8 +97,6 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
gridBagConstraints.gridy = 1;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
- gridBagConstraints.weighty = 1.0;
- gridBagConstraints.insets = new java.awt.Insets(0, 0, 6, 0);
panelDocTabs.add(isCloseActivatesMostRecentDocument,
gridBagConstraints);
isCloseActivatesMostRecentDocument.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TabsPanel.class,
"TabsPanel.isCloseActivatesMostRecentDocument.AccessibleContext.accessibleDescription"));
// NOI18N
@@ -102,6 +113,70 @@ public void actionPerformed(java.awt.event.ActionEvent
evt) {
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
panelDocTabs.add(isNewDocumentOpensNextToActiveTab,
gridBagConstraints);
+ org.openide.awt.Mnemonics.setLocalizedText(sortTabsLabel,
org.openide.util.NbBundle.getMessage(TabsPanel.class,
"TabsPanel.sortTabsLabel.text")); // NOI18N
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 2;
+ gridBagConstraints.gridwidth = 2;
+ gridBagConstraints.anchor =
java.awt.GridBagConstraints.FIRST_LINE_START;
+ gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
+ panelDocTabs.add(sortTabsLabel, gridBagConstraints);
+
+ sortButtonGroup.add(radioSortNothing);
+ radioSortNothing.setSelected(true);
+ org.openide.awt.Mnemonics.setLocalizedText(radioSortNothing,
org.openide.util.NbBundle.getMessage(TabsPanel.class,
"TabsPanel.radioSortNothing.text")); // NOI18N
+ radioSortNothing.addActionListener(new java.awt.event.ActionListener()
{
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ radioSortNothingActionPerformed(evt);
+ }
+ });
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 3;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
+ panelDocTabs.add(radioSortNothing, gridBagConstraints);
+
+ sortButtonGroup.add(radioSortFileName);
+ org.openide.awt.Mnemonics.setLocalizedText(radioSortFileName,
org.openide.util.NbBundle.getMessage(TabsPanel.class,
"TabsPanel.radioSortFileName.text")); // NOI18N
+ radioSortFileName.addActionListener(new
java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ radioSortFileNameActionPerformed(evt);
+ }
+ });
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 4;
+ gridBagConstraints.anchor =
java.awt.GridBagConstraints.FIRST_LINE_START;
+ panelDocTabs.add(radioSortFileName, gridBagConstraints);
+
+ sortButtonGroup.add(radioSortFileNameWithParent);
+
org.openide.awt.Mnemonics.setLocalizedText(radioSortFileNameWithParent,
org.openide.util.NbBundle.getMessage(TabsPanel.class,
"TabsPanel.radioSortFileNameWithParent.text")); // NOI18N
+ radioSortFileNameWithParent.addActionListener(new
java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ radioSortFileNameWithParentActionPerformed(evt);
+ }
+ });
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 5;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
+ panelDocTabs.add(radioSortFileNameWithParent, gridBagConstraints);
+
+ sortButtonGroup.add(radioSortFullFilePath);
+ org.openide.awt.Mnemonics.setLocalizedText(radioSortFullFilePath,
org.openide.util.NbBundle.getMessage(TabsPanel.class,
"TabsPanel.radioSortFullFilePath.text")); // NOI18N
+ radioSortFullFilePath.addActionListener(new
java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ radioSortFullFilePathActionPerformed(evt);
+ }
+ });
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 6;
+ gridBagConstraints.anchor =
java.awt.GridBagConstraints.FIRST_LINE_START;
+ gridBagConstraints.weighty = 1.0;
+ gridBagConstraints.insets = new java.awt.Insets(0, 0, 6, 0);
+ panelDocTabs.add(radioSortFullFilePath, gridBagConstraints);
+
panelTabs.setLayout(new java.awt.GridBagLayout());
org.openide.awt.Mnemonics.setLocalizedText(jLabel1,
NbBundle.getMessage(TabsPanel.class, "TabsPanel.jLabel1.text")); // NOI18N
@@ -159,7 +234,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt)
{
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 2;
+ gridBagConstraints.gridy = 7;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
panelDocTabs.add(panelTabs, gridBagConstraints);
@@ -186,18 +261,50 @@ private void
isCloseActivatesMostRecentDocumentActionPerformed(java.awt.event.Ac
fireChanged();
}//GEN-LAST:event_isCloseActivatesMostRecentDocumentActionPerformed
+ private void radioSortNothingActionPerformed(java.awt.event.ActionEvent
evt) {//GEN-FIRST:event_radioSortNothingActionPerformed
+ fireChanged();
+ }//GEN-LAST:event_radioSortNothingActionPerformed
+
+ private void
radioSortFileNameWithParentActionPerformed(java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_radioSortFileNameWithParentActionPerformed
+ fireChanged();
+ }//GEN-LAST:event_radioSortFileNameWithParentActionPerformed
+
+ private void
radioSortFullFilePathActionPerformed(java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_radioSortFullFilePathActionPerformed
+ fireChanged();
+ }//GEN-LAST:event_radioSortFullFilePathActionPerformed
+
+ private void radioSortFileNameActionPerformed(java.awt.event.ActionEvent
evt) {//GEN-FIRST:event_radioSortFileNameActionPerformed
+ fireChanged();
+ }//GEN-LAST:event_radioSortFileNameActionPerformed
+
private void fireChanged() {
boolean isChanged = false;
if(isCloseActivatesMostRecentDocument.isSelected() !=
prefs.getBoolean(WinSysPrefs.EDITOR_CLOSE_ACTIVATES_RECENT, true)
- || isNewDocumentOpensNextToActiveTab.isSelected() !=
prefs.getBoolean(WinSysPrefs.OPEN_DOCUMENTS_NEXT_TO_ACTIVE_TAB, false)) {
+ || isNewDocumentOpensNextToActiveTab.isSelected() !=
prefs.getBoolean(WinSysPrefs.OPEN_DOCUMENTS_NEXT_TO_ACTIVE_TAB, false)
+ || getSelectedSortType() !=
EditorSortType.valueOf(prefs.get(WinSysPrefs.EDITOR_SORT_TABS,
EditorSortType.None.name()))) {
isChanged = true;
}
controller.changed(isChanged, null);
}
-
+
protected void load() {
isCloseActivatesMostRecentDocument.setSelected(prefs.getBoolean(WinSysPrefs.EDITOR_CLOSE_ACTIVATES_RECENT,
true));
isNewDocumentOpensNextToActiveTab.setSelected(prefs.getBoolean(WinSysPrefs.OPEN_DOCUMENTS_NEXT_TO_ACTIVE_TAB,
false));
+ EditorSortType sortType =
EditorSortType.valueOf(prefs.get(WinSysPrefs.EDITOR_SORT_TABS,
EditorSortType.None.name()));
+ switch (sortType) {
+ case FullFilePath:
+ radioSortFullFilePath.setSelected(true);
+ break;
+ case FileName:
+ radioSortFileName.setSelected(true);
+ break;
+ case FileNameWithParent:
+ radioSortFileNameWithParent.setSelected(true);
+ break;
+ default:
+ radioSortNothing.setSelected(true);
+ break;
+ }
defMultiRow = prefs.getBoolean( WinSysPrefs.DOCUMENT_TABS_MULTIROW,
false );
checkMultiRow.setSelected( defMultiRow );
@@ -215,7 +322,7 @@ protected void load() {
default:
radioTop.setSelected( true );
}
-
+
if( isAquaLaF ) {
checkMultiRow.setSelected(false);
checkMultiRow.setEnabled(false);
@@ -230,7 +337,8 @@ protected void load() {
protected boolean store() {
prefs.putBoolean(WinSysPrefs.EDITOR_CLOSE_ACTIVATES_RECENT,
isCloseActivatesMostRecentDocument.isSelected());
prefs.putBoolean(WinSysPrefs.OPEN_DOCUMENTS_NEXT_TO_ACTIVE_TAB,
isNewDocumentOpensNextToActiveTab.isSelected());
-
+ prefs.put(WinSysPrefs.EDITOR_SORT_TABS, getSelectedSortType().name());
+
boolean needsWinsysRefresh = false;
needsWinsysRefresh = checkMultiRow.isSelected() != defMultiRow;
prefs.putBoolean(WinSysPrefs.DOCUMENT_TABS_MULTIROW,
checkMultiRow.isSelected());
@@ -248,6 +356,18 @@ else if( radioRight.isSelected() )
return needsWinsysRefresh;
}
+ private EditorSortType getSelectedSortType() {
+ EditorSortType sortType = EditorSortType.None;
+ if (radioSortFullFilePath.isSelected()) {
+ sortType = EditorSortType.FullFilePath;
+ } else if (radioSortFileName.isSelected()) {
+ sortType = EditorSortType.FileName;
+ } else if (radioSortFileNameWithParent.isSelected()) {
+ sortType = EditorSortType.FileNameWithParent;
+ }
+ return sortType;
+ }
+
boolean valid() {
// TODO check whether form is consistent and complete
return true;
@@ -256,7 +376,7 @@ boolean valid() {
protected void initTabsPanel( JPanel panel ) {
}
-
+
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.ButtonGroup buttonGroup1;
@@ -270,7 +390,13 @@ protected void initTabsPanel( JPanel panel ) {
private javax.swing.JRadioButton radioBottom;
private javax.swing.JRadioButton radioLeft;
private javax.swing.JRadioButton radioRight;
+ private javax.swing.JRadioButton radioSortFileName;
+ private javax.swing.JRadioButton radioSortFileNameWithParent;
+ private javax.swing.JRadioButton radioSortFullFilePath;
+ private javax.swing.JRadioButton radioSortNothing;
private javax.swing.JRadioButton radioTop;
+ private javax.swing.ButtonGroup sortButtonGroup;
+ private javax.swing.JLabel sortTabsLabel;
// End of variables declaration//GEN-END:variables
}
diff --git
a/platform/core.windows/src/org/netbeans/core/windows/options/WinSysPrefs.java
b/platform/core.windows/src/org/netbeans/core/windows/options/WinSysPrefs.java
index c0744d5719..b1897d4a09 100644
---
a/platform/core.windows/src/org/netbeans/core/windows/options/WinSysPrefs.java
+++
b/platform/core.windows/src/org/netbeans/core/windows/options/WinSysPrefs.java
@@ -82,5 +82,9 @@
* @since 2.54
*/
public static String MAXIMIZE_NATIVE_LAF = "laf.maximize.native"; //NOI18N
-
+
+ /**
+ * @since 2.87
+ */
+ public static String EDITOR_SORT_TABS = "editor.sort.tabs"; //NOI18N
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists