Skip to content

Commit

Permalink
[NETBEANS-3695] - not proper to use a static variable through a refer…
Browse files Browse the repository at this point in the history
…ence (apache#1872)

This PR fixes some compiler warnings. Submitter BradWalker says: "It's really not proper to use a static variable through a reference because they can't be derived. The proper thing to do is use them with a Class name."
  • Loading branch information
BradWalker authored and eirikbakke committed Jan 16, 2020
1 parent 9899e6c commit 820a688
Show file tree
Hide file tree
Showing 24 changed files with 51 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -614,9 +614,9 @@ public Enumeration enabled(GrammarEnvironment ctx) {
Enumeration en = ctx.getDocumentChildren();
while (en.hasMoreElements()) {
Node next = (Node) en.nextElement();
if (next.getNodeType() == next.DOCUMENT_TYPE_NODE) {
if (next.getNodeType() == Node.DOCUMENT_TYPE_NODE) {
return null; // null for web.xml specified by DTD
} else if (next.getNodeType() == next.ELEMENT_NODE) {
} else if (next.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element) next;
String tag = element.getTagName();
if (EJB_JAR_TAG.equals(tag)) { // NOI18N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -591,9 +591,9 @@ public Enumeration enabled(GrammarEnvironment ctx) {
Enumeration en = ctx.getDocumentChildren();
while (en.hasMoreElements()) {
Node next = (Node) en.nextElement();
if (next.getNodeType() == next.DOCUMENT_TYPE_NODE) {
if (next.getNodeType() == Node.DOCUMENT_TYPE_NODE) {
return null; // null for web.xml specified by DTD
} else if (next.getNodeType() == next.ELEMENT_NODE) {
} else if (next.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element) next;
String tag = element.getTagName();
if (EJB_JAR_TAG.equals(tag)) { // NOI18N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public void keyTyped(KeyEvent ke) {

@Override
public void keyPressed(KeyEvent ke) {
if (ke.getKeyCode() == ke.VK_ENTER || ke.getKeyCode() == ke.VK_ESCAPE) {
if (ke.getKeyCode() == KeyEvent.VK_ENTER || ke.getKeyCode() == KeyEvent.VK_ESCAPE) {
confirm(ke);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public void setSSHKeyFile(String filename) throws IllegalArgumentException {
throw new IllegalArgumentException("Invalid ssh key file " + filename); // NOI18N
}

type = type.SSH_KEY;
type = Type.SSH_KEY;
sshKeyFile = filename;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected static RenderedImage transformImage(RenderedImage image,
throws IllegalArgumentException {
try{
AffineTransform af = new AffineTransform();
if( pf.getOrientation() == pf.LANDSCAPE ){
if( pf.getOrientation() == PageFormat.LANDSCAPE ){
}else{
af.translate(pf.getImageableX(), pf.getImageableY());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ private void layoutTapPanel (TapPanel tp) {
if ( c.length > 0 ) {
Dimension d2 = c[ 0 ].getPreferredSize ();
if ( tp.isExpanded () ) {
int top = tp.getOrientation () == tp.UP ? 0 : tp.getMinimumHeight ();
int top = tp.getOrientation () == TapPanel.UP ? 0 : tp.getMinimumHeight ();
int height = Math.min ( tp.getHeight () - tp.getMinimumHeight (), d2.height );
c[ 0 ].setBounds ( 0, top, tp.getWidth (), height );
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ public LinkButton() {
}

public void setColors(Color linkColor, Color linkInFocusColor, Color mouseOverLinkColor, Color visitedLinkColor) {
this.linkInFocusColor = linkInFocusColor;
this.linkColor = linkColor;
this.mouseOverLinkColor = mouseOverLinkColor;
this.visitedLinkColor = visitedLinkColor;
LinkButton.linkInFocusColor = linkInFocusColor;
LinkButton.linkColor = linkColor;
LinkButton.mouseOverLinkColor = mouseOverLinkColor;
LinkButton.visitedLinkColor = visitedLinkColor;
}

private void init() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {

org.openide.awt.Mnemonics.setLocalizedText(fontSizeLabel, org.openide.util.NbBundle.getMessage(TermOptionsPanel.class, "TermOptionsPanel.fontSizeLabel.text")); // NOI18N

fontSizeSpinner.setModel(new SpinnerNumberModel(12, termOptions.MIN_FONT_SIZE, termOptions.MAX_FONT_SIZE, 1));
fontSizeSpinner.setModel(new SpinnerNumberModel(12, TermOptions.MIN_FONT_SIZE, TermOptions.MAX_FONT_SIZE, 1));
fontSizeSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
fontSizeSpinnerStateChanged(evt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public GrammarQuery getGrammar(GrammarEnvironment ctx) {
GrammarQuery query = g.getGrammar(ctx);
if (query == null) {
ErrorManager err = ErrorManager.getDefault();
err.log(err.WARNING, "Broken contract: " + g.getClass());
err.log(ErrorManager.WARNING, "Broken contract: " + g.getClass());
}
return query;
} else {
Expand All @@ -136,7 +136,7 @@ public GrammarQuery getGrammar(GrammarEnvironment ctx) {
PrintWriter writer = new PrintWriter(stringWriter);
ex.printStackTrace(writer);
writer.flush();
err.log(err.WARNING, stringWriter.getBuffer().toString());
err.log(ErrorManager.WARNING, stringWriter.getBuffer().toString());
return null;
}
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public Enumeration enabled(GrammarEnvironment ctx) {
Enumeration en = ctx.getDocumentChildren();
while (en.hasMoreElements()) {
Node next = (Node) en.nextElement();
if (next.getNodeType() == next.ELEMENT_NODE) {
if (next.getNodeType() == Node.ELEMENT_NODE) {
boolean xslt = false;
boolean version1x = false;
NamedNodeMap attrs = next.getAttributes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public Enumeration enabled(GrammarEnvironment ctx) {
Enumeration en = ctx.getDocumentChildren();
while (en.hasMoreElements()) {
Node next = (Node) en.nextElement();
if (next.getNodeType() == next.ELEMENT_NODE) {
if (next.getNodeType() == Node.ELEMENT_NODE) {
Element root = (Element) next;
if ("project".equals(root.getNodeName())) { // NOI18N
return Enumerations.singleton (next);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public void keyTyped(KeyEvent ke) {

@Override
public void keyPressed(KeyEvent ke) {
if (ke.getKeyCode() == ke.VK_ENTER || ke.getKeyCode() == ke.VK_ESCAPE) {
if (ke.getKeyCode() == KeyEvent.VK_ENTER || ke.getKeyCode() == KeyEvent.VK_ESCAPE) {
confirm(ke);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,11 +471,11 @@ private void updateTextWidth() {
if (e.isPopupTrigger()) {
// Show a popup allowing to configure the various options
showPopup(e.getX(), e.getY());
} else if (e.getID() == e.MOUSE_ENTERED) {
} else if (e.getID() == MouseEvent.MOUSE_ENTERED) {
containsMouse = true;
cachedBorderVaild = false;
repaint();
} else if (e.getID() == e.MOUSE_EXITED) {
} else if (e.getID() == MouseEvent.MOUSE_EXITED) {
containsMouse = false;
cachedBorderVaild = false;
repaint();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ public void performActionAt(int index, ActionEvent ev) {
} else {
// is action
Action a = (Action) arr[index];
a.actionPerformed(new ActionEvent(a, ActionEvent.ACTION_PERFORMED, a.NAME));
a.actionPerformed(new ActionEvent(a, ActionEvent.ACTION_PERFORMED, Action.NAME));

return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ public void processFocusEvent(FocusEvent fe) {
}

if (!isAncestorOf(fe.getOppositeComponent()) || (fe.getOppositeComponent() == null)) {
if (isEditing() && (fe.getID() == fe.FOCUS_LOST)) {
if (isEditing() && (fe.getID() == FocusEvent.FOCUS_LOST)) {
if (PropUtils.isLoggable(BaseTable.class)) {
PropUtils.log(
BaseTable.class, "ProcessFocusEvent got focus lost to unknown component, removing editor"
Expand All @@ -791,7 +791,7 @@ public void processFocusEvent(FocusEvent fe) {

if (!inEditorRemoveRequest() && !inEditRequest()) { //XXX inEditRequest probably shouldn't be here

if ((fe.getOppositeComponent() == null) && (fe.getID() == fe.FOCUS_LOST)) {
if ((fe.getOppositeComponent() == null) && (fe.getID() == FocusEvent.FOCUS_LOST)) {
//ignore the strange focus to null stuff NetBeans does
return;
}
Expand Down Expand Up @@ -842,7 +842,7 @@ public void processKeyEvent(KeyEvent e) {

//Manually hook in the bindings for tab - does not seem to get called
//automatically
if (e.getKeyCode() != e.VK_TAB) {
if (e.getKeyCode() != KeyEvent.VK_TAB) {
if (!suppressDefaultHandling) {
//Either the search field or the table should handle up/down, not both
super.processKeyEvent(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ private void prepareEditor() {
* by the look and feel */
@Override
public void processFocusEvent(FocusEvent fe) {
if ((fe.getID() == fe.FOCUS_LOST) &&
if ((fe.getID() == FocusEvent.FOCUS_LOST) &&
fe.getOppositeComponent() == getEditor().getEditorComponent() &&
isPopupVisible()) {

Expand All @@ -471,7 +471,7 @@ public void processFocusEvent(FocusEvent fe) {

Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();

if (isDisplayable() && (fe.getID() == fe.FOCUS_GAINED) && (focusOwner == this) && !isPopupVisible()) {
if (isDisplayable() && (fe.getID() == FocusEvent.FOCUS_GAINED) && (focusOwner == this) && !isPopupVisible()) {
if (isEditable()) {
prepareEditor();

Expand All @@ -489,7 +489,7 @@ public void processFocusEvent(FocusEvent fe) {
}

repaint();
} else if ((fe.getID() == fe.FOCUS_LOST) && isPopupVisible() && !isDisplayable()) {
} else if ((fe.getID() == FocusEvent.FOCUS_LOST) && isPopupVisible() && !isDisplayable()) {
if (!PropUtils.psCommitOnFocusLoss) {
setActionCommand(COMMAND_FAILURE);
fireActionEvent();
Expand Down Expand Up @@ -603,7 +603,7 @@ public void firePopupMenuCanceled() {
public void processKeyEvent(KeyEvent ke) {
super.processKeyEvent(ke);

if ((ke.getID() == ke.KEY_PRESSED) && (ke.getKeyCode() == ke.VK_ESCAPE)) {
if ((ke.getID() == KeyEvent.KEY_PRESSED) && (ke.getKeyCode() == KeyEvent.VK_ESCAPE)) {
setActionCommand(COMMAND_FAILURE);
fireActionEvent();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private void updateIcon() {
Icon ic = null;
FeatureDescriptor fd = env.getFeatureDescriptor();

if (env.getState() == env.STATE_INVALID) {
if (env.getState() == PropertyEnv.STATE_INVALID) {
ic = ImageUtilities.loadImageIcon("org/openide/resources/propertysheet/invalid.gif", false); //NOI18N
} else if (fd != null) {
ic = (Icon) fd.getValue("valueIcon"); //NOI18N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ private void updateDisplayerFromClientProps() {
protected void processFocusEvent(FocusEvent fe) {
super.processFocusEvent(fe);

if (fe.getID() == fe.FOCUS_GAINED) {
if (fe.getID() == FocusEvent.FOCUS_GAINED) {
if ((inner != null) && inner.isEnabled() && inner.isFocusTraversable()) {
inner.requestFocus();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.awt.event.KeyEvent;

import java.beans.PropertyEditor;

Expand Down Expand Up @@ -478,17 +479,17 @@ public String getName() {
return "InvRadioButton - " + getText(); //NOI18N
}

public void processKeyEvent(java.awt.event.KeyEvent ke) {
public void processKeyEvent(KeyEvent ke) {
super.processKeyEvent(ke);

if (
((ke.getKeyCode() == ke.VK_ENTER) || (ke.getKeyCode() == ke.VK_ESCAPE)) &&
(ke.getID() == ke.KEY_PRESSED)
((ke.getKeyCode() == KeyEvent.VK_ENTER) || (ke.getKeyCode() == KeyEvent.VK_ESCAPE)) &&
(ke.getID() == KeyEvent.KEY_PRESSED)
) {
RadioInplaceEditor.this.fireActionPerformed(
new ActionEvent(
this, ActionEvent.ACTION_PERFORMED,
(ke.getKeyCode() == ke.VK_ENTER) ? COMMAND_SUCCESS : COMMAND_FAILURE
(ke.getKeyCode() == KeyEvent.VK_ENTER) ? COMMAND_SUCCESS : COMMAND_FAILURE
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public JComponent getRenderer(Property prop) {

if (
!(result instanceof JLabel) &&
((env.getState() == env.STATE_INVALID) || (prop.getValue("valueIcon") != null))
((env.getState() == ReusablePropertyEnv.STATE_INVALID) || (prop.getValue("valueIcon") != null))
) { //NOI18N
result = prepareIconPanel(editor, env, (InplaceEditor) result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,13 @@ public void applySettings(ProfilerIDESettings pis) {
Object oomeSelected = oomeCombo.getSelectedItem();

if (Bundle.ProfilerOptionsPanel_OomeNothingText().equals(oomeSelected)) {
pis.setOOMDetectionMode(pis.OOME_DETECTION_NONE);
pis.setOOMDetectionMode(ProfilerIDESettings.OOME_DETECTION_NONE);
} else if (Bundle.ProfilerOptionsPanel_OomeProjectText().equals(oomeSelected)) {
pis.setOOMDetectionMode(pis.OOME_DETECTION_PROJECTDIR);
pis.setOOMDetectionMode(ProfilerIDESettings.OOME_DETECTION_PROJECTDIR);
} else if (Bundle.ProfilerOptionsPanel_OomeTempText().equals(oomeSelected)) {
pis.setOOMDetectionMode(pis.OOME_DETECTION_TEMPDIR);
pis.setOOMDetectionMode(ProfilerIDESettings.OOME_DETECTION_TEMPDIR);
} else if (Bundle.ProfilerOptionsPanel_OomeCustomText().equals(oomeSelected)) {
pis.setOOMDetectionMode(pis.OOME_DETECTION_CUSTOMDIR);
pis.setOOMDetectionMode(ProfilerIDESettings.OOME_DETECTION_CUSTOMDIR);
}

pis.setCustomHeapdumpPath(oomeDetectionDirTextField.getText());
Expand Down Expand Up @@ -301,22 +301,22 @@ public boolean currentSettingsEquals(ProfilerIDESettings settings) {
return false;
}

if ((settings.getOOMDetectionMode() == settings.OOME_DETECTION_NONE)
if ((settings.getOOMDetectionMode() == ProfilerIDESettings.OOME_DETECTION_NONE)
&& (!Bundle.ProfilerOptionsPanel_OomeNothingText().equals(oomeCombo.getSelectedItem()))) {
return false;
}

if ((settings.getOOMDetectionMode() == settings.OOME_DETECTION_PROJECTDIR)
if ((settings.getOOMDetectionMode() == ProfilerIDESettings.OOME_DETECTION_PROJECTDIR)
&& (!Bundle.ProfilerOptionsPanel_OomeProjectText().equals(oomeCombo.getSelectedItem()))) {
return false;
}

if ((settings.getOOMDetectionMode() == settings.OOME_DETECTION_TEMPDIR)
if ((settings.getOOMDetectionMode() == ProfilerIDESettings.OOME_DETECTION_TEMPDIR)
&& (!Bundle.ProfilerOptionsPanel_OomeTempText().equals(oomeCombo.getSelectedItem()))) {
return false;
}

if ((settings.getOOMDetectionMode() == settings.OOME_DETECTION_CUSTOMDIR)
if ((settings.getOOMDetectionMode() == ProfilerIDESettings.OOME_DETECTION_CUSTOMDIR)
&& (!Bundle.ProfilerOptionsPanel_OomeCustomText().equals(oomeCombo.getSelectedItem()))) {
return false;
}
Expand Down Expand Up @@ -411,13 +411,13 @@ public void init(ProfilerIDESettings pis) {
takingSnapshotCombo.setSelectedItem(Bundle.ProfilerOptionsPanel_SaveSnapshotRadioText());
}

if (pis.getOOMDetectionMode() == pis.OOME_DETECTION_NONE) {
if (pis.getOOMDetectionMode() == ProfilerIDESettings.OOME_DETECTION_NONE) {
oomeCombo.setSelectedItem(Bundle.ProfilerOptionsPanel_OomeNothingText());
} else if (pis.getOOMDetectionMode() == pis.OOME_DETECTION_PROJECTDIR) {
} else if (pis.getOOMDetectionMode() == ProfilerIDESettings.OOME_DETECTION_PROJECTDIR) {
oomeCombo.setSelectedItem(Bundle.ProfilerOptionsPanel_OomeProjectText());
} else if (pis.getOOMDetectionMode() == pis.OOME_DETECTION_TEMPDIR) {
} else if (pis.getOOMDetectionMode() == ProfilerIDESettings.OOME_DETECTION_TEMPDIR) {
oomeCombo.setSelectedItem(Bundle.ProfilerOptionsPanel_OomeTempText());
} else if (pis.getOOMDetectionMode() == pis.OOME_DETECTION_CUSTOMDIR) {
} else if (pis.getOOMDetectionMode() == ProfilerIDESettings.OOME_DETECTION_CUSTOMDIR) {
oomeCombo.setSelectedItem(Bundle.ProfilerOptionsPanel_OomeCustomText());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static Collection<org.netbeans.modules.cordova.platforms.spi.Device> pars
@Override
public void openUrl(String url) {
try {
if (browser == browser.DEFAULT) {
if (browser == Browser.DEFAULT) {
ProcessUtilities.callProcess(
((AndroidPlatform) getPlatform()).getAdbCommand(),
true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static JsonLexer create(LexerRestartInfo<JsTokenId> info) {
public Token<JsTokenId> nextToken() {
org.antlr.v4.runtime.Token nextToken = scanner.nextToken();
Token<JsTokenId> token = null;
if (nextToken.getType() != scanner.EOF) {
if (nextToken.getType() != org.netbeans.modules.javascript2.json.parser.JsonLexer.EOF) {
token = tokenFactory.createToken(tokenId(nextToken.getType()));
LOGGER.log(Level.FINEST, "Lexed token is {0}", token.id());
return token;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private String getDataMainValue(TokenSequence<HTMLTokenId> ts, int offset) {
HTMLTokenId tokenId = token.id();
if (tokenId == HTMLTokenId.VALUE) {
String value = token.text().toString();
token = LexerUtils.followsToken(ts, Arrays.asList(HTMLTokenId.ARGUMENT), true, false, HTMLTokenId.OPERATOR, HTMLTokenId.ARGUMENT.WS, HTMLTokenId.BLOCK_COMMENT);
token = LexerUtils.followsToken(ts, Arrays.asList(HTMLTokenId.ARGUMENT), true, false, HTMLTokenId.OPERATOR, HTMLTokenId.WS, HTMLTokenId.BLOCK_COMMENT);
if (token != null && token.id() == HTMLTokenId.ARGUMENT && DATAMAIN.equals(token.text().toString())) {
return value.substring(1, value.length() - 1);
}
Expand Down

0 comments on commit 820a688

Please sign in to comment.