Skip to content
This repository has been archived by the owner on Jul 10, 2018. It is now read-only.

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
Reformatting
Address Lint warnings
Switch to Java 8 lambdas
  • Loading branch information
kirill-grouchnikov committed Dec 17, 2016
1 parent 3291f30 commit d9bb0e4
Show file tree
Hide file tree
Showing 211 changed files with 4,029 additions and 2,027 deletions.
Expand Up @@ -32,7 +32,9 @@
*/
package org.pushingpixels.flamingo.api.bcb;

import java.util.*;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

import javax.swing.event.EventListenerList;

Expand Down
8 changes: 6 additions & 2 deletions src/org/pushingpixels/flamingo/api/bcb/JBreadcrumbBar.java
Expand Up @@ -32,9 +32,13 @@
*/
package org.pushingpixels.flamingo.api.bcb;

import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import javax.swing.*;
import javax.swing.JComponent;
import javax.swing.UIDefaults;
import javax.swing.UIManager;

import org.pushingpixels.flamingo.internal.ui.bcb.BasicBreadcrumbBarUI;
import org.pushingpixels.flamingo.internal.ui.bcb.BreadcrumbBarUI;
Expand Down
Expand Up @@ -29,12 +29,21 @@
*/
package org.pushingpixels.flamingo.api.bcb.core;

import java.io.*;
import java.util.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;

import javax.swing.filechooser.FileSystemView;

import org.pushingpixels.flamingo.api.bcb.*;
import org.pushingpixels.flamingo.api.bcb.BreadcrumbBarCallBack;
import org.pushingpixels.flamingo.api.bcb.BreadcrumbItem;
import org.pushingpixels.flamingo.api.bcb.JBreadcrumbBar;
import org.pushingpixels.flamingo.api.common.StringValuePair;

/**
Expand Down
Expand Up @@ -37,7 +37,12 @@
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;

import org.pushingpixels.flamingo.api.bcb.*;
import org.pushingpixels.flamingo.api.bcb.BreadcrumbBarCallBack;
import org.pushingpixels.flamingo.api.bcb.BreadcrumbBarException;
import org.pushingpixels.flamingo.api.bcb.BreadcrumbBarExceptionHandler;
import org.pushingpixels.flamingo.api.bcb.BreadcrumbItem;
import org.pushingpixels.flamingo.api.bcb.BreadcrumbPathEvent;
import org.pushingpixels.flamingo.api.bcb.JBreadcrumbBar;
import org.pushingpixels.flamingo.api.common.StringValuePair;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
Expand All @@ -51,10 +56,10 @@

/**
* Breadcrumb bar that allows browsing multiple local and remote SVN
* repositories. The implementation uses <a
* href="http://www.svnkit.com">SVNKit</a> library. Make sure to read the <a
* href="http://www.svnkit.com/licensing/index.html">licensing terms</a> before
* using this component in your application.
* repositories. The implementation uses
* <a href="http://www.svnkit.com">SVNKit</a> library. Make sure to read the
* <a href="http://www.svnkit.com/licensing/index.html">licensing terms</a>
* before using this component in your application.
*
* @author Kirill Grouchnikov
*/
Expand Down Expand Up @@ -97,8 +102,7 @@ public static class SvnRepositoryInfo {
* @param password
* Password.
*/
public SvnRepositoryInfo(String name, String url, String user,
String password) {
public SvnRepositoryInfo(String name, String url, String user, String password) {
this.name = name;
this.url = url;
this.user = user;
Expand Down Expand Up @@ -157,79 +161,68 @@ protected class PathCallback extends BreadcrumbBarCallBack<String> {
* @param repoList
* List of all SVN repositories.
*/
public PathCallback(
BreadcrumbMultiSvnSelector.SvnRepositoryInfo... repoList) {
public PathCallback(BreadcrumbMultiSvnSelector.SvnRepositoryInfo... repoList) {
this.repositories = new ArrayList<SvnRepositoryInfo>();
if (repoList != null) {
for (BreadcrumbMultiSvnSelector.SvnRepositoryInfo repository : repoList) {
this.addSvnRepositoryInfo(repository);
}
}

getModel().addPathListener(new BreadcrumbPathListener() {
@Override
public void breadcrumbPathEvent(BreadcrumbPathEvent event) {
final List<BreadcrumbItem<String>> newPath = getModel()
.getItems();
// If one element - an SVN repository has been
// selected. Need to connect to it and update the
// currRepository field.
if (newPath.size() == 1)
connectionLatch = new CountDownLatch(1);
getModel().addPathListener((BreadcrumbPathEvent event) -> {
final List<BreadcrumbItem<String>> newPath = getModel().getItems();
// If one element - an SVN repository has been
// selected. Need to connect to it and update the
// currRepository field.
if (newPath.size() == 1)
connectionLatch = new CountDownLatch(1);

SwingUtilities.invokeLater(new Runnable() {
public void run() {
// If one element - an SVN repository has been
// selected. Need to connect to it and update
// the currRepository field.
if (newPath.size() != 1)
return;
final String newSvnName = newPath.get(0).getData();
// System.out.println("Connecting to " +
// newSvnName);
// find the connection params
for (final SvnRepositoryInfo repoInfo : repositories) {
if (newSvnName.equals(repoInfo.name)) {
// connect
SwingWorker<SVNRepository, Void> worker = new SwingWorker<SVNRepository, Void>() {
@Override
protected SVNRepository doInBackground()
throws Exception {
try {
SVNRepository repository = SVNRepositoryFactory
.create(SVNURL
.parseURIEncoded(repoInfo.url));
ISVNAuthenticationManager authManager = SVNWCUtil
.createDefaultAuthenticationManager(
repoInfo.user,
repoInfo.password);
repository
.setAuthenticationManager(authManager);
return repository;
} catch (SVNException svne) {
List<BreadcrumbBarExceptionHandler> handlers = getExceptionHandlers();
for (BreadcrumbBarExceptionHandler handler : handlers) {
handler.onException(svne);
}
return null;
}
SwingUtilities.invokeLater(() -> {
// If one element - an SVN repository has been
// selected. Need to connect to it and update
// the currRepository field.
if (newPath.size() != 1)
return;
final String newSvnName = newPath.get(0).getData();
// System.out.println("Connecting to " +
// newSvnName);
// find the connection params
for (final SvnRepositoryInfo repoInfo : repositories) {
if (newSvnName.equals(repoInfo.name)) {
// connect
SwingWorker<SVNRepository, Void> worker = new SwingWorker<SVNRepository, Void>() {
@Override
protected SVNRepository doInBackground() throws Exception {
try {
SVNRepository repository = SVNRepositoryFactory
.create(SVNURL.parseURIEncoded(repoInfo.url));
ISVNAuthenticationManager authManager = SVNWCUtil
.createDefaultAuthenticationManager(repoInfo.user,
repoInfo.password);
repository.setAuthenticationManager(authManager);
return repository;
} catch (SVNException svne) {
List<BreadcrumbBarExceptionHandler> handlers = getExceptionHandlers();
for (BreadcrumbBarExceptionHandler handler : handlers) {
handler.onException(svne);
}
return null;
}
}

@Override
protected void done() {
try {
currRepository = get();
connectionLatch.countDown();
} catch (Exception exc) {
}
}
};
worker.execute();
@Override
protected void done() {
try {
currRepository = get();
connectionLatch.countDown();
} catch (Exception exc) {
}
}
}
};
worker.execute();
}
});
}
}
});
});
}

Expand Down Expand Up @@ -262,8 +255,7 @@ public void setup() {
* util.List)
*/
@Override
public List<StringValuePair<String>> getPathChoices(
List<BreadcrumbItem<String>> path)
public List<StringValuePair<String>> getPathChoices(List<BreadcrumbItem<String>> path)
throws BreadcrumbBarException {
try {
if (connectionLatch != null)
Expand All @@ -275,20 +267,18 @@ public List<StringValuePair<String>> getPathChoices(
// root - list all the repositories.
List<StringValuePair<String>> result = new ArrayList<StringValuePair<String>>();
for (SvnRepositoryInfo repoInfo : repositories) {
StringValuePair<String> toAdd = new StringValuePair<String>(
repoInfo.name, repoInfo.name);
StringValuePair<String> toAdd = new StringValuePair<String>(repoInfo.name,
repoInfo.name);
result.add(toAdd);
}
return result;
}

String lastPath = (path.size() == 1) ? "" : path.get(
path.size() - 1).getData();
String lastPath = (path.size() == 1) ? "" : path.get(path.size() - 1).getData();
// System.out.println("Last path is " + lastPath + ", repo "
// + this.currRepository);
try {
return BreadcrumbSvnSelector.getPathChoices(
this.currRepository, lastPath);
return BreadcrumbSvnSelector.getPathChoices(this.currRepository, lastPath);
} catch (SVNException svne) {
if (this.throwsExceptions) {
throw new BreadcrumbBarException(svne);
Expand All @@ -304,8 +294,7 @@ public List<StringValuePair<String>> getPathChoices(
* org.jvnet.flamingo.bcb.BreadcrumbBarCallBack#getLeafs(java.util.List)
*/
@Override
public List<StringValuePair<String>> getLeafs(
List<BreadcrumbItem<String>> path)
public List<StringValuePair<String>> getLeafs(List<BreadcrumbItem<String>> path)
throws BreadcrumbBarException {
if (path == null) {
// root - no leafs, only repositories.
Expand All @@ -317,11 +306,9 @@ public List<StringValuePair<String>> getLeafs(
connectionLatch.await();
} catch (InterruptedException ie) {
}
String lastPath = (path.size() == 1) ? "" : path.get(
path.size() - 1).getData();
String lastPath = (path.size() == 1) ? "" : path.get(path.size() - 1).getData();
try {
return BreadcrumbSvnSelector.getLeafs(this.currRepository,
lastPath);
return BreadcrumbSvnSelector.getLeafs(this.currRepository, lastPath);
} catch (SVNException svne) {
if (this.throwsExceptions) {
throw new BreadcrumbBarException(svne);
Expand All @@ -338,11 +325,9 @@ public List<StringValuePair<String>> getLeafs(
* lang.Object)
*/
@Override
public InputStream getLeafContent(String leaf)
throws BreadcrumbBarException {
public InputStream getLeafContent(String leaf) throws BreadcrumbBarException {
try {
return BreadcrumbSvnSelector.getLeafContent(
this.currRepository, leaf);
return BreadcrumbSvnSelector.getLeafContent(this.currRepository, leaf);
} catch (SVNException svne) {
if (this.throwsExceptions) {
throw new BreadcrumbBarException(svne);
Expand Down
Expand Up @@ -29,12 +29,29 @@
*/
package org.pushingpixels.flamingo.api.bcb.core;

import java.io.*;
import java.util.*;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import org.pushingpixels.flamingo.api.bcb.*;
import org.pushingpixels.flamingo.api.bcb.BreadcrumbBarCallBack;
import org.pushingpixels.flamingo.api.bcb.BreadcrumbBarException;
import org.pushingpixels.flamingo.api.bcb.BreadcrumbItem;
import org.pushingpixels.flamingo.api.bcb.JBreadcrumbBar;
import org.pushingpixels.flamingo.api.common.StringValuePair;
import org.tmatesoft.svn.core.*;
import org.tmatesoft.svn.core.SVNDirEntry;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNNodeKind;
import org.tmatesoft.svn.core.SVNProperties;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
import org.tmatesoft.svn.core.internal.io.fs.FSRepositoryFactory;
Expand Down
Expand Up @@ -34,10 +34,14 @@
import java.util.LinkedList;
import java.util.List;

import javax.swing.*;
import javax.swing.Icon;
import javax.swing.JLabel;
import javax.swing.JTree;
import javax.swing.tree.TreeModel;

import org.pushingpixels.flamingo.api.bcb.*;
import org.pushingpixels.flamingo.api.bcb.BreadcrumbBarCallBack;
import org.pushingpixels.flamingo.api.bcb.BreadcrumbItem;
import org.pushingpixels.flamingo.api.bcb.JBreadcrumbBar;
import org.pushingpixels.flamingo.api.common.StringValuePair;

/**
Expand Down
Expand Up @@ -31,12 +31,16 @@

import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.event.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;

import javax.accessibility.AccessibleContext;
import javax.swing.ButtonModel;
import javax.swing.SwingConstants;
import javax.swing.event.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.EventListenerList;

import org.pushingpixels.flamingo.api.common.icon.ResizableIcon;
import org.pushingpixels.flamingo.api.common.model.ActionButtonModel;
Expand Down
Expand Up @@ -31,7 +31,12 @@

import java.awt.Dimension;
import java.io.InputStream;
import java.util.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
Expand Down
Expand Up @@ -29,7 +29,11 @@
*/
package org.pushingpixels.flamingo.api.common;

import org.pushingpixels.flamingo.internal.ui.common.*;
import org.pushingpixels.flamingo.internal.ui.common.CommandButtonLayoutManagerBig;
import org.pushingpixels.flamingo.internal.ui.common.CommandButtonLayoutManagerCustom;
import org.pushingpixels.flamingo.internal.ui.common.CommandButtonLayoutManagerMedium;
import org.pushingpixels.flamingo.internal.ui.common.CommandButtonLayoutManagerSmall;
import org.pushingpixels.flamingo.internal.ui.common.CommandButtonLayoutManagerTile;

/**
* Display state for command buttons. This class provides a number of core
Expand Down

0 comments on commit d9bb0e4

Please sign in to comment.