Skip to content

Improve/fix handling of XML Catalogs #8489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
</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="3" gridHeight="0" fill="1" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="1.0"/>
<GridBagConstraints gridX="0" gridY="2" gridWidth="3" gridHeight="2" fill="1" ipadX="0" ipadY="0" insetsTop="6" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
</Component>
Expand All @@ -106,5 +106,18 @@
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JLabel" name="warningLabel">
<Properties>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" red="ff" type="rgb"/>
</Property>
<Property name="text" type="java.lang.String" value=" "/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="1" gridY="1" gridWidth="2" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="6" insetsLeft="12" insetsBottom="0" insetsRight="12" anchor="10" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Form>
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.beans.*;
import java.io.File;
import java.net.MalformedURLException;
import org.netbeans.modules.xml.catalog.impl.XCatalog;

import static org.netbeans.modules.xml.catalog.impl.res.Bundle.*;

/**
Expand All @@ -44,6 +44,8 @@ public XCatalogCustomizer() {
this.getAccessibleContext().setAccessibleDescription(ACSD_XCatalogCustomizer());
locationLabel.setDisplayedMnemonic(XCatalogCustomizer_locationLabel_mne().charAt(0));
locationTextField.getAccessibleContext().setAccessibleDescription(ACSD_locationTextField());

updateValidity();
}

/** This method is called from within the constructor to
Expand All @@ -59,6 +61,7 @@ private void initComponents() {
locationTextField = new javax.swing.JTextField();
descTextArea = new javax.swing.JTextArea();
selectButton = new javax.swing.JButton();
warningLabel = new javax.swing.JLabel();

setLayout(new java.awt.GridBagLayout());

Expand Down Expand Up @@ -94,13 +97,13 @@ public void focusLost(java.awt.event.FocusEvent evt) {
descTextArea.setOpaque(false);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.gridy = 2;
gridBagConstraints.gridwidth = 3;
gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.gridheight = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
add(descTextArea, gridBagConstraints);

java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/xml/catalog/impl/res/Bundle"); // NOI18N
Expand All @@ -116,6 +119,17 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 0);
add(selectButton, gridBagConstraints);

warningLabel.setForeground(new java.awt.Color(255, 0, 0));
warningLabel.setText(" ");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.insets = new java.awt.Insets(6, 12, 0, 12);
add(warningLabel, gridBagConstraints);
}// </editor-fold>//GEN-END:initComponents

private void selectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectButtonActionPerformed
Expand All @@ -125,6 +139,7 @@ private void selectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
String location = f.toURL().toExternalForm();
locationTextField.setText(location);
model.setSource(location);
updateValidity();
} catch (MalformedURLException ex) {
// ignore
}
Expand All @@ -135,11 +150,13 @@ private void selectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
private void locationTextFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_locationTextFieldFocusLost
//if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug("FocusLost-setting location: " + locationTextField.getText()); // NOI18N
model.setSource(locationTextField.getText());
updateValidity();
}//GEN-LAST:event_locationTextFieldFocusLost

private void locationTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_locationTextFieldActionPerformed
//if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug("ActionPerformed-setting location: " + locationTextField.getText()); // NOI18N
model.setSource(locationTextField.getText());
updateValidity();
}//GEN-LAST:event_locationTextFieldActionPerformed

/**
Expand All @@ -152,19 +169,25 @@ public void setObject(java.lang.Object peer) {

model = (XCatalog) peer;
locationTextField.setText(model.getSource());
updateValidity();
}

public void addPropertyChangeListener(java.beans.PropertyChangeListener p1) {
}

public void removePropertyChangeListener(java.beans.PropertyChangeListener p1) {
}


private void updateValidity() {
warningLabel.setText((model != null && ! model.isValid()) ? TEXT_catalog_not_valid() : " ");
}

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextArea descTextArea;
private javax.swing.JLabel locationLabel;
private javax.swing.JTextField locationTextField;
private javax.swing.JButton selectButton;
private javax.swing.JLabel warningLabel;
// End of variables declaration//GEN-END:variables

}
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,8 @@ public static String XCatalogCustomizer_locationLabel_text() {
public static String DESC_xcatalog_fmts() {
return NbBundle.getMessage(Bundle.class, "DESC_xcatalog_fmts");
}

public static String TEXT_catalog_not_valid() {
return NbBundle.getMessage(Bundle.class, "TEXT_catalog_not_valid");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ XCatalogCustomizer.locationLabel.text=XML Catalog URL:
ACSD_locationTextField=n/a

PROP_choose_file=Browse...

TEXT_catalog_not_valid=Catalog does not seem to be valid.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="1" gridY="-1" gridWidth="0" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="12" insetsBottom="0" insetsRight="11" anchor="18" weightX="0.0" weightY="0.0"/>
<GridBagConstraints gridX="1" gridY="-1" gridWidth="0" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="6" insetsLeft="12" insetsBottom="6" insetsRight="12" anchor="18" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
Expand Down Expand Up @@ -122,7 +122,20 @@
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="0" fill="1" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="1.0"/>
<GridBagConstraints gridX="0" gridY="3" gridWidth="0" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="6" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JLabel" name="warningLabel">
<Properties>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" red="ff" type="rgb"/>
</Property>
<Property name="text" type="java.lang.String" value=" "/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="1" gridY="2" gridWidth="2" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="6" insetsLeft="12" insetsBottom="6" insetsRight="12" anchor="10" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public CatalogCustomizer() {

selectButton.setMnemonic(MNE_file().charAt(0));
selectButton.getAccessibleContext().setAccessibleDescription(ACSD_file());

updateValidity();
}

/** This method is called from within the constructor to
Expand All @@ -69,6 +71,7 @@ private void initComponents() {
selectButton = new javax.swing.JButton();
preferCheckBox = new javax.swing.JCheckBox();
descTextArea = new javax.swing.JTextArea();
warningLabel = new javax.swing.JLabel();

setLayout(new java.awt.GridBagLayout());

Expand Down Expand Up @@ -117,7 +120,7 @@ public void stateChanged(javax.swing.event.ChangeEvent evt) {
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 11);
gridBagConstraints.insets = new java.awt.Insets(6, 12, 6, 12);
add(preferCheckBox, gridBagConstraints);

descTextArea.setEditable(false);
Expand All @@ -132,13 +135,25 @@ public void stateChanged(javax.swing.event.ChangeEvent evt) {
descTextArea.setEnabled(false);
descTextArea.setOpaque(false);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 3;
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
add(descTextArea, gridBagConstraints);

warningLabel.setForeground(new java.awt.Color(255, 0, 0));
warningLabel.setText(" ");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 2;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.insets = new java.awt.Insets(6, 12, 6, 12);
add(warningLabel, gridBagConstraints);
}// </editor-fold>//GEN-END:initComponents

private void selectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectButtonActionPerformed
Expand All @@ -148,6 +163,7 @@ private void selectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
String location = f.toURL().toExternalForm();
locationTextField.setText(location);
model.setLocation(location);
updateValidity();
} catch (MalformedURLException ex) {
// ignore
}
Expand All @@ -162,11 +178,13 @@ private void preferCheckBoxStateChanged(javax.swing.event.ChangeEvent evt) {//GE
private void locationTextFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_locationTextFieldFocusLost
//if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug("FocusLost-setting location: " + locationTextField.getText()); // NOI18N
model.setLocation(locationTextField.getText());
updateValidity();
}//GEN-LAST:event_locationTextFieldFocusLost

private void locationTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_locationTextFieldActionPerformed
//if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug("ActionPerformed-setting location: " + locationTextField.getText()); // NOI18N
model.setLocation(locationTextField.getText());
updateValidity();
}//GEN-LAST:event_locationTextFieldActionPerformed

/**
Expand All @@ -180,20 +198,26 @@ public void setObject(java.lang.Object peer) {
model = (Catalog) peer;
locationTextField.setText(model.getLocation());
preferCheckBox.setSelected(model.isPreferPublic());
updateValidity();
}

public void addPropertyChangeListener(java.beans.PropertyChangeListener p1) {
}

public void removePropertyChangeListener(java.beans.PropertyChangeListener p1) {
}

private void updateValidity() {
warningLabel.setText((model != null && ! model.isValid()) ? TEXT_catalog_not_valid() : " ");
}

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextArea descTextArea;
private javax.swing.JLabel locationLabel;
private javax.swing.JTextField locationTextField;
private javax.swing.JCheckBox preferCheckBox;
private javax.swing.JButton selectButton;
private javax.swing.JLabel warningLabel;
// End of variables declaration//GEN-END:variables

}
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,8 @@ public static String HINT_pp() {
public static String DESC_catalog_fmts() {
return NbBundle.getMessage(Bundle.class, "DESC_catalog_fmts");
}

public static String TEXT_catalog_not_valid() {
return NbBundle.getMessage(Bundle.class, "TEXT_catalog_not_valid");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ PROP_catalog_name_desc=Name that identifies catalog.
PROP_catalog_info=Catalog Info
PROP_catalog_info_desc=Describes actual catalog state.

TEXT_catalog_not_valid=Catalog does not seem to be valid.
Loading
Loading