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

adm43 and ler24 #12

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
14 changes: 10 additions & 4 deletions src/BrowserModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,45 +30,51 @@ public class BrowserModel {
/**
* Creates an empty model.
*/
public BrowserModel () {
public BrowserModel (String language) {
myHome = null;
myCurrentURL = null;
myCurrentIndex = -1;
myHistory = new ArrayList<>();
myFavorites = new HashMap<>();

// use resources for errors
myResources = ResourceBundle.getBundle(DEFAULT_RESOURCES);
}

/**
* Returns the first page in next history, null if next history is empty.
*/
public URL next () {
public URL next() throws BrowserException {
if (hasNext()) {
myCurrentIndex++;
return myHistory.get(myCurrentIndex);
}

else {
throw new BrowserException(myResources.getString("NoNext"));
}
}

/**
* Returns the first page in back history, null if back history is empty.
* @throws BrowserException
*/
public URL back () {
public URL back() throws BrowserException {
if (hasPrevious()) {
myCurrentIndex--;
return myHistory.get(myCurrentIndex);
}

else {
throw new BrowserException(myResources.getString("NoPrevious"));
}
}

/**
* Changes current page to given URL, removing next history.
* @throws BrowserException
*/

public URL go (String url) {
try {
URL tmp = completeURL(url);
Expand Down Expand Up @@ -132,7 +138,7 @@ public void addFavorite (String name) {
/**
* Returns URL from favorites associated with given name, null if none set.
*/
public URL getFavorite (String name) {
public URL getFavorite (String name) throws BrowserException {
if (name != null && !name.equals("") && myFavorites.containsKey(name)) {
return myFavorites.get(name);
}
Expand Down
2 changes: 1 addition & 1 deletion src/BrowserView.java
Original file line number Diff line number Diff line change
Expand Up @@ -306,4 +306,4 @@ public void changed (ObservableValue<? extends State> ov, State oldState, State
}
}
};
}
}
10 changes: 7 additions & 3 deletions src/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,23 @@
* @author Robert C. Duvall
*/
public class Main extends Application {
// convenience constants
private static final String ENGLISH = "English";
// convenience constants
public static final String TITLE = "NanoBrowser";
public static final String DEFAULT_START_PAGE = "http://www.cs.duke.edu/rcd";


@Override
public void start (Stage stage) {
String language = ENGLISH;

// create program specific components
BrowserModel model = new BrowserModel();
BrowserView display = new BrowserView(model, "English");
BrowserModel model = new BrowserModel(language);
BrowserView display = new BrowserView(model, language);
// give the window a title
stage.setTitle(TITLE);
// add our user interface components to Frame and show it
setUserAgentStylesheet(STYLESHEET_MODENA);
stage.setScene(display.getScene());
stage.show();
// start somewhere, less typing for debugging
Expand Down
1 change: 1 addition & 0 deletions src/resources/English.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ ErrorTitle=Browser Error
FavoritePromptTitle=Add Favorite
FavoriteFirstItem=All Favorites
SetHomeCommand=Set Home
ShowFavorites=Favorites
4 changes: 4 additions & 0 deletions src/resources/English_Errors.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
EmptyNext=Can't go forward
EmptyBack=Can't go backward
EmptyFavorite=Can't get favorite
MalformedURL=Bad URL: %s
8 changes: 4 additions & 4 deletions src/resources/default.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
.root {
-fx-font-size: 14pt;
-fx-font-family: "Courier New";
-fx-font-size: 11pt;
-fx-font-family: "Papyrus";
-fx-base: rgb(132, 145, 47);
-fx-background: rgb(225, 228, 203);
}

.button {
-fx-text-fill: #006464;
-fx-background-color: #DFB951;
-fx-background-color: #550011;
-fx-border-radius: 20;
-fx-background-radius: 20;
-fx-padding: 8;
Expand All @@ -28,7 +28,7 @@
}

.label {
-fx-font-size: 11pt;
-fx-font-size: 9pt;
-fx-font-family: "Segoe UI Semibold";
-fx-text-fill: #006464;
-fx-opacity: 0.6;
Expand Down