Skip to content

Commit

Permalink
Merge pull request #4906 from mbien/maven-hintspanel-ui-fixes
Browse files Browse the repository at this point in the history
Maven HintsPanel UI layout fixes and minor cleanup.
  • Loading branch information
neilcsmith-net authored Nov 8, 2022
2 parents 4c94d5e + 575f38d commit d57e5f4
Show file tree
Hide file tree
Showing 14 changed files with 149 additions and 182 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,14 @@
<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,44,0,0,2,24"/>
<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,63,0,0,2,48"/>
</AuxValues>

<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Container class="javax.swing.JSplitPane" name="jSplitPane1">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="null"/>
</Property>
<Property name="dividerLocation" type="int" value="320"/>
<Property name="dividerLocation" type="int" value="260"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
Expand Down Expand Up @@ -100,17 +97,29 @@
</Constraint>
</Constraints>

<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="optionsPanel" pref="273" max="32767" attributes="0"/>
<Component id="descriptionPanel" pref="0" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="optionsPanel" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Component id="descriptionPanel" pref="230" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="1" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="optionsPanel">
<Properties>
<Property name="opaque" type="boolean" value="false"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="12" insetsRight="0" anchor="18" weightX="1.0" weightY="0.7"/>
</Constraint>
</Constraints>

<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
Expand Down Expand Up @@ -176,11 +185,6 @@
<Properties>
<Property name="opaque" type="boolean" value="false"/>
</Properties>
<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="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="0.3"/>
</Constraint>
</Constraints>

<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

import java.awt.Component;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
Expand Down Expand Up @@ -94,39 +92,36 @@ public HintsPanel(OptionsFilter filter,
// Expand all
for(int lastRow = errorTree.getRowCount(); lastRow >= 0; --lastRow) {
errorTree.expandRow(lastRow);
}
}
}

private DefaultMutableTreeNode sort(DefaultMutableTreeNode parent) {
List<DefaultMutableTreeNode> nodes = new ArrayList<DefaultMutableTreeNode>();
List<DefaultMutableTreeNode> nodes = new ArrayList<>();

for (int i = 0; i < parent.getChildCount(); i++) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) parent.getChildAt(i);
nodes.add(sort(node));
}

Collections.sort(nodes, new Comparator<DefaultMutableTreeNode>() {
@Override
public int compare(DefaultMutableTreeNode p1, DefaultMutableTreeNode p2) {
Object o1 = p1.getUserObject();
String s1 = "";
if (o1 instanceof Rule) {
s1 = ((Rule) o1).getDisplayName();
}
if (o1 instanceof FileObject) {
s1 = getFileObjectLocalizedName((FileObject) o1);
}

Object o2 = p2.getUserObject();
String s2 = "";
if (o2 instanceof Rule) {
s2 = ((Rule) o2).getDisplayName();
}
if (o2 instanceof FileObject) {
s2 = getFileObjectLocalizedName((FileObject) o2);
}
return s1.compareTo(s2);
nodes.sort((DefaultMutableTreeNode p1, DefaultMutableTreeNode p2) -> {
Object o1 = p1.getUserObject();
String s1 = "";
if (o1 instanceof Rule) {
s1 = ((Rule) o1).getDisplayName();
}
if (o1 instanceof FileObject) {
s1 = getFileObjectLocalizedName((FileObject) o1);
}

Object o2 = p2.getUserObject();
String s2 = "";
if (o2 instanceof Rule) {
s2 = ((Rule) o2).getDisplayName();
}
if (o2 instanceof FileObject) {
s2 = getFileObjectLocalizedName((FileObject) o2);
}
return s1.compareTo(s2);
});
parent.removeAllChildren();
for (DefaultMutableTreeNode node : nodes) {
Expand Down Expand Up @@ -191,8 +186,7 @@ private void initComponents() {
setBorder(javax.swing.BorderFactory.createEmptyBorder(8, 8, 8, 8));
setLayout(new java.awt.GridBagLayout());

jSplitPane1.setBorder(null);
jSplitPane1.setDividerLocation(320);
jSplitPane1.setDividerLocation(260);

treePanel.setOpaque(false);
treePanel.setLayout(new java.awt.BorderLayout());
Expand All @@ -205,7 +199,6 @@ private void initComponents() {

detailsPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 6, 0, 0));
detailsPanel.setOpaque(false);
detailsPanel.setLayout(new java.awt.GridBagLayout());

optionsPanel.setOpaque(false);
optionsPanel.setLayout(new java.awt.GridBagLayout());
Expand Down Expand Up @@ -249,16 +242,6 @@ private void initComponents() {
gridBagConstraints.insets = new java.awt.Insets(8, 0, 0, 0);
optionsPanel.add(customizerPanel, gridBagConstraints);

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 0.7;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 0);
detailsPanel.add(optionsPanel, gridBagConstraints);

descriptionPanel.setOpaque(false);
descriptionPanel.setLayout(new java.awt.GridBagLayout());

Expand All @@ -284,13 +267,21 @@ private void initComponents() {
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
descriptionPanel.add(descriptionLabel, gridBagConstraints);

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 0.3;
detailsPanel.add(descriptionPanel, gridBagConstraints);
javax.swing.GroupLayout detailsPanelLayout = new javax.swing.GroupLayout(detailsPanel);
detailsPanel.setLayout(detailsPanelLayout);
detailsPanelLayout.setHorizontalGroup(
detailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(optionsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 273, Short.MAX_VALUE)
.addComponent(descriptionPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
);
detailsPanelLayout.setVerticalGroup(
detailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(detailsPanelLayout.createSequentialGroup()
.addComponent(optionsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(descriptionPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 230, Short.MAX_VALUE)
.addGap(1, 1, 1))
);

jSplitPane1.setRightComponent(detailsPanel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<SubComponents>
<Container class="javax.swing.JSplitPane" name="jSplitPane1">
<Properties>
<Property name="dividerLocation" type="int" value="320"/>
<Property name="dividerLocation" type="int" value="260"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
Expand Down Expand Up @@ -274,7 +274,7 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="openInEditor" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="212" max="32767" attributes="0"/>
<EmptySpace pref="272" max="32767" attributes="0"/>
<Component id="saveButton" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="cancelEdit" min="-2" max="-2" attributes="0"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ private void handleClick(MouseEvent e) {
okButton.setVisible(showOkCancel);
cancelButton.setVisible(showOkCancel);
validate();
jSplitPane1.setDividerLocation(getDividerLocation());
}

private void updateEnabledState() {
Expand All @@ -346,11 +345,6 @@ private void enableDisableRecursively(Component what, boolean enable) {
}
}
}

private int getDividerLocation() {
final int location = (int) ((jSplitPane1.getWidth() - jSplitPane1.getDividerSize()) * 0.4f);
return Math.min(400, location);
}

/** This method is called from within the constructor to
* initialize the form.
Expand Down Expand Up @@ -399,7 +393,7 @@ private void initComponents() {
setBorder(javax.swing.BorderFactory.createEmptyBorder(8, 8, 8, 8));
setLayout(new java.awt.GridBagLayout());

jSplitPane1.setDividerLocation(320);
jSplitPane1.setDividerLocation(260);

treePanel.setOpaque(false);
treePanel.setLayout(new java.awt.BorderLayout());
Expand Down Expand Up @@ -509,7 +503,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
editingButtonsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, editingButtonsLayout.createSequentialGroup()
.addComponent(openInEditor)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 212, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 272, Short.MAX_VALUE)
.addComponent(saveButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(cancelEdit))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@
<SubComponents>
<Container class="javax.swing.JSplitPane" name="jSplitPane1">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="null"/>
</Property>
<Property name="dividerLocation" type="int" value="320"/>
<Property name="dividerLocation" type="int" value="260"/>
<Property name="opaque" type="boolean" value="false"/>
</Properties>
<Constraints>
Expand Down Expand Up @@ -118,17 +115,29 @@
</Constraint>
</Constraints>

<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="descriptionPanel" pref="249" max="32767" attributes="0"/>
<Component id="optionsPanel" alignment="1" pref="0" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="optionsPanel" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Component id="descriptionPanel" pref="213" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="1" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="optionsPanel">
<Properties>
<Property name="opaque" type="boolean" value="false"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="12" insetsRight="0" anchor="18" weightX="1.0" weightY="0.7"/>
</Constraint>
</Constraints>

<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
Expand Down Expand Up @@ -215,11 +224,6 @@
<Properties>
<Property name="opaque" type="boolean" value="false"/>
</Properties>
<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="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="0.3"/>
</Constraint>
</Constraints>

<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
Expand Down
Loading

0 comments on commit d57e5f4

Please sign in to comment.