Skip to content
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

Mass convert #33

Open
wants to merge 26 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e6e2109
mass convert mosv1 mostly working
Goddard Aug 17, 2020
94c6d2c
Working version, but still has bugs
Goddard Aug 20, 2020
580502f
remove checkbox
Goddard Jul 2, 2021
aafb628
fixed imports and newline at end of file
Goddard Jul 4, 2021
89fca90
copy paste header from other files
Goddard Jul 4, 2021
9044e2d
used format for code so it is all the same
Goddard Jul 4, 2021
e1f5b09
added logger
Goddard Jul 4, 2021
625dd01
fixed more imports
Goddard Jul 4, 2021
f73159b
added javadoc block
Goddard Jul 4, 2021
22685ba
added comment and split variables to own line and use equal function
Goddard Jul 4, 2021
dc89796
fix errors to logs and wrong file type
Goddard Jul 4, 2021
353130c
move property to top of class
Goddard Jul 4, 2021
3830798
move int to own line
Goddard Jul 4, 2021
1c59c47
added catch instead of finally to log error
Goddard Jul 4, 2021
ead4b64
added log and removed redundent progress assignment to null
Goddard Jul 4, 2021
60a4921
added log for selecting file
Goddard Jul 4, 2021
f5df564
removed white space
Goddard Jul 4, 2021
2bc5022
added comment for required method even if unused
Goddard Jul 4, 2021
c1a182e
fixed typo
Goddard Jul 4, 2021
e02c8f5
removed commented code
Goddard Jul 4, 2021
6bca663
removed unused code
Goddard Jul 4, 2021
78b74e7
changed to final for count
Goddard Jul 4, 2021
8ed6231
Merge remote-tracking branch 'origin/devel' into mass-convert
Goddard Jul 6, 2021
3698122
fixed old function used
Goddard Jul 6, 2021
0075e22
fixed spacing issue with v2 and shrink bug
Goddard Jul 7, 2021
4c8e5e9
window now fresh after closed and reopened dialog opens in root and s…
Goddard Jul 9, 2021
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ NearInfinity.jar
/bin
/build
/.settings
.idea
NearInfinity.iml
44 changes: 44 additions & 0 deletions src/org/infinity/gui/ProgressCellRenderer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.infinity.gui;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a license header as in the other files


import javax.swing.*;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to avoid wildcard imports. They can unexpectedly stop working in new Java versions, because new classes can be added to the packages.

import javax.swing.table.TableCellRenderer;
import java.awt.*;

public class ProgressCellRenderer extends JProgressBar implements TableCellRenderer {

/**
* Creates a JProgressBar with the range 0,100.
*/
public ProgressCellRenderer(){
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use consistent code style -- space between braces

super(0, 100);
setValue(0);
setString("0%");
setStringPainted(true);
}

public Component getTableCellRendererComponent(
JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column) {

//value is a percentage e.g. 95%
final String sValue = value.toString();
int index = sValue.indexOf('%');
if (index != -1) {
int p = 0;
try{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style again

p = Integer.parseInt(sValue.substring(0, index));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why you need parsing? What type of value parameter expected in this place? May be it will be better to guarantee that it always is an Integer instead of trying parse string with potentially unknown content?

}
catch(NumberFormatException e) {
System.out.println("Number Format Exception");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Logger to log errors and do not suppress exception message and stacktrace. In other words you should log e object if this code ever remains

}

this.setValue(p);
this.setString(sValue);
}
return this;
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There a several files without newline in the end. I think, it is better to have it.

Loading