Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* uDig - User Friendly Desktop Internet GIS client
/** uDig - User Friendly Desktop Internet GIS client
* http://udig.refractions.net
* (C) 2004, Refractions Research Inc.
*
Expand All @@ -15,73 +15,82 @@
import org.eclipse.swt.browser.LocationListener;

/**
* TODO Purpose of
* <p>
* TODO Purpose of this class
*
* </p>
* @author mleslie
* @since 1.0.0
*/
public class ExternalCatalogueImportURLDescriptor
implements ExternalCatalogueImportDescriptor {
public class ExternalCatalogueImportURLDescriptor implements ExternalCatalogueImportDescriptor {
private URL url;

private String description;

private ImageDescriptor descImage;

private ImageDescriptor icon;

private String label;

private String id;

private LocationListener listener;

private String viewName;

/**
* @param url1
*
* @param url1
*
*/
public ExternalCatalogueImportURLDescriptor(URL url1) {
super();
this.url = url1;
}

/**
*
* @return URL of the catalog
*/
public URL getUrl() {
return this.url;
}


@Override
public String getID() {
return this.id;
}

/**
*
* @param id
*/
public void setID(String id) {
this.id = id;
}


@Override
public String getLabel() {
return (this.label == null) ? "" : this.label; //$NON-NLS-1$
}

/**
*
* @param label
*/
public void setLabel(String label) {
this.label = label;
}


@Override
public ImageDescriptor getIcon() {
return icon;
}

@Override
public String getDescription() {
return (this.description == null) ? "" : this.description; //$NON-NLS-1$
}

@Override
public ImageDescriptor getDescriptionImage() {
return this.descImage;
}
Expand All @@ -90,62 +99,61 @@ public ImageDescriptor getDescriptionImage() {
*
* @param attribute
*/
public void setDescription( String attribute ) {
public void setDescription(String attribute) {
this.description = attribute;
}

/**
*
* @param descriptor
*/
public void setDescriptionImage( ImageDescriptor descriptor ) {
public void setDescriptionImage(ImageDescriptor descriptor) {
this.descImage = descriptor;
}

/**
*
* @param descriptor
*/
public void setIcon( ImageDescriptor descriptor ) {
public void setIcon(ImageDescriptor descriptor) {
this.icon = descriptor;
}

/**
*
* @param name
*/
public void setListener(String name) {
LocationListener blah = null;
if(name != null) {
if (name != null) {
try {
blah = (LocationListener)Class.forName(name).newInstance();
} catch (InstantiationException e) {
//
} catch (IllegalAccessException e) {
//
} catch (ClassNotFoundException e) {
//
blah = (LocationListener) Class.forName(name).getDeclaredConstructor()
.newInstance();
} catch (Exception e) {
// do nothing
}
}
this.listener = blah;
}

/**
*
* @param listener
*/
public void setListener(LocationListener listener) {
this.listener = listener;
}


@Override
public LocationListener getListener() {
return this.listener;
}
}

public void setViewName(String viewName) {
this.viewName = viewName;
}

@Override
public String getViewName() {
return this.viewName;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* uDig - User Friendly Desktop Internet GIS client
/**
* uDig - User Friendly Desktop Internet GIS client
* http://udig.refractions.net
* (C) 2004, Refractions Research Inc.
*
Expand Down Expand Up @@ -65,9 +66,6 @@

/**
* Provides a tabbed browser view using the native web browser.
* <p>
*
* </p>
*
* @author mleslie
* @since 1.0.0
Expand Down Expand Up @@ -244,21 +242,14 @@ public LocationListener getListener() {
if (this.listener == null || this.listener.equals("DEFAULT")) //$NON-NLS-1$
return null;
try {
return (LocationListener) Class.forName(this.listener).newInstance();
} catch (InstantiationException e) {
//
} catch (IllegalAccessException e) {
//
} catch (ClassNotFoundException e) {
//
return (LocationListener) Class.forName(this.listener).getDeclaredConstructor()
.newInstance();
} catch (Exception e) {
return null;
}
return null;
}
}

/**
*
*/
public BrowserContainerView() {
super();
}
Expand Down Expand Up @@ -299,7 +290,7 @@ public void createPartControl(Composite parent) {
this.browserData = null;
} else {
String initialBrowserURL = System.getProperty(BROWSER_INITIAL_URL_PROPERTY,
"http://udig.github.io/data/");
"http://udig.github.io/data/"); //$NON-NLS-1$
addTab(Messages.BrowserContainerView_tabTitle, initialBrowserURL, (Image) null,
getListener()); // $NON-NLS-1$
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* uDig - User Friendly Desktop Internet GIS client
/**
* uDig - User Friendly Desktop Internet GIS client
* http://udig.refractions.net
* (C) 2010, Refractions Research Inc.
*
Expand All @@ -14,42 +15,41 @@
import org.locationtech.udig.catalog.internal.wmt.WMTService;

public class WMTSourceFactory {
// todo: make every WMTSource class singleton, so that the cache is reused!
public static WMTSource createSource(WMTService service, URL url,
String resourceId) throws Throwable {

// TODO: make every WMTSource class singleton, so that the cache is reused!
public static WMTSource createSource(WMTService service, URL url, String resourceId)
throws Throwable {
WMTSource source;

String className = getClassFromUrl(url);
source = (WMTSource) Class.forName(className).newInstance();
source = (WMTSource) Class.forName(className).getDeclaredConstructor().newInstance();

source.init(resourceId);
source.setWmtService(service);

return source;
}

/**
* Strip out the start of the url:
*
* wmt://localhost/wmt/org.locationtech.udig.catalog.internal.wmt.wmtsource.OSMSource
* -->
* org.locationtech.udig.catalog.internal.wmt.wmtsource.OSMSource
* Strip out the start of the URL:
*
* wmt://localhost/wmt/org.locationtech.udig.catalog.internal.wmt.wmtsource.OSMSource -->
* org.locationtech.udig.catalog.internal.wmt.wmtsource.OSMSource
*
* @param url
* @return
*/
public static String getClassFromUrl(URL url) {
String withoutId = url.toString().replace(WMTService.ID, ""); //$NON-NLS-1$

int posSlash = withoutId.indexOf("/"); //$NON-NLS-1$
if (posSlash >= 0) {
return withoutId.substring(0, posSlash);
} else {
return withoutId;
}
}

/**
* Should be used only when testing!
*
Expand All @@ -59,16 +59,16 @@ public static String getClassFromUrl(URL url) {
* @param noException
* @return
*/
public static WMTSource createSource(WMTService service, URL url,
String resourceId, boolean noException) {
public static WMTSource createSource(WMTService service, URL url, String resourceId,
boolean noException) {
WMTSource source;
try{

try {
source = createSource(service, url, resourceId);
} catch (Throwable exc) {
source = null;
}

return source;
}
}
Loading