Commit 3c2739c4 authored by Robert Smith's avatar Robert Smith
Browse files

Fixed Nek5000 bugs



Fixed various bugs with Nek5000
Signed-off-by: Robert Smith's avatarRobert Smith <SmithRW@ornl.gov>
parent 2b25e1f7
......@@ -38,11 +38,10 @@ import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
......@@ -128,7 +127,7 @@ public class ICEResourcePage extends ICEFormPage implements ISelectionListener,
}
// Create the list of text file extensions
String[] extensions = { "txt", "sh", "i", "csv" };
String[] extensions = { "txt", "sh", "i" };
textFileExtensions = new ArrayList<String>(Arrays.asList(extensions));
ResourcesPlugin.getWorkspace().addResourceChangeListener(this,
......@@ -181,6 +180,15 @@ public class ICEResourcePage extends ICEFormPage implements ISelectionListener,
// Create the browser.
browser = createBrowser(pageComposite, toolkit);
stackLayout.topControl = browser;
// Set an error message if no brwoser was detected.
if (browser == null) {
Label label = new Label(pageComposite, SWT.CENTER);
label.setText(
"No browser detected. You must install or configure a web browser for your operating system, if availabe, to view some resources. Some resources may be openable and appear in text editors in new tabs.");
stackLayout.topControl = label;
}
pageComposite.layout();
// Create the grid of plots.
......@@ -211,7 +219,7 @@ public class ICEResourcePage extends ICEFormPage implements ISelectionListener,
// It is possible that constructing the Browser throws an SWTError.
// Thus, to create the browser, we must use a try-catch block.
try {
// Initialize the browser and apply the layout.
// Initialize the browser and apply the layout.
browser = new Browser(parent, SWT.NONE);
toolkit.adapt(browser);
browser.layout(true);
......@@ -221,12 +229,12 @@ public class ICEResourcePage extends ICEFormPage implements ISelectionListener,
if (!resourceComponent.isEmpty()) {
browser.setText("<html><body>"
+ "<p style=\"font-family:Tahoma;font-size:x-small\" "
+ "align=\"center\">Select a resource to view</p>"
+ "align=\"center\">Select a resource to view. Some text files may open in new tabs and unreadable files may be downloaded instead of displayed.</p>"
+ "</body></html>");
} else {
browser.setText("<html><body>"
+ "<p style=\"font-family:Tahoma;font-size:x-small\" "
+ "align=\"center\">No resources available</p>"
+ "align=\"center\">No resources available. Some text files may open in new tabs and unreadable files may be downloaded instead of displayed.</p>"
+ "</body></html>");
}
} catch (SWTError e) {
......@@ -259,13 +267,21 @@ public class ICEResourcePage extends ICEFormPage implements ISelectionListener,
if (resource == null) {
Control topControl = stackLayout.topControl;
if (topControl != browser) {
// Update the browser.
browser.setText("<html><body>"
+ "<p style=\"font-family:Tahoma;font-size:x-small\" "
+ "align=\"center\">Select a resource to view</p>"
+ "</body></html>");
stackLayout.topControl = browser;
pageComposite.layout();
if (browser != null && !browser.isDisposed()) {
// Update the browser.
browser.setText("<html><body>"
+ "<p style=\"font-family:Tahoma;font-size:x-small\" "
+ "align=\"center\">Select a resource to view. Some text files may open in new tabs and unreadable files may be downloaded instead of displayed.</p>"
+ "</body></html>");
stackLayout.topControl = browser;
pageComposite.layout();
} else {
Label label = new Label(pageComposite, SWT.CENTER);
label.setText(
"No browser detected. You must install or configure a web browser for your operating system, if availabe, to view some resources. Some resources may be openable and appear in text editors in new tabs.");
stackLayout.topControl = label;
}
// Dispose of the previous Control occupying the
// ResourcePage.
......@@ -413,7 +429,7 @@ public class ICEResourcePage extends ICEFormPage implements ISelectionListener,
// Clear the browser and make it the top widget.
browser.setText("<html><body>"
+ "<p style=\"font-family:Tahoma;font-size:x-small\" "
+ "align=\"center\">No resources available</p>"
+ "align=\"center\">No resources available. Some text files may open in new tabs and unreadable files may be downloaded instead of displayed.</p>"
+ "</body></html>");
stackLayout.topControl = browser;
pageComposite.layout();
......@@ -524,6 +540,7 @@ public class ICEResourcePage extends ICEFormPage implements ISelectionListener,
if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
try {
event.getDelta().accept(new IResourceDeltaVisitor() {
@Override
public boolean visit(IResourceDelta delta)
throws CoreException {
for (ICEResource r : ICEResourcePage.this.resourceComponent
......
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.ice.datastructures.internal.VizServiceFactoryHolder">
<implementation class="org.eclipse.ice.datastructures.internal.VizServiceFactoryHolder"/>
<reference bind="setVizServiceFactory" cardinality="1..1" interface="org.eclipse.eavp.viz.service.IVizServiceFactory" name="IVizServiceFactory" policy="static" unbind="unsetVizServiceFactory"/>
</scr:component>
/*******************************************************************************
* Copyright (c) 2014 UT-Battelle, LLC.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Initial API and implementation and/or initial documentation -
* Robert Smith
*******************************************************************************/
package org.eclipse.ice.datastructures.internal;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
import org.eclipse.eavp.viz.service.IVizServiceFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Holder class for a VizServiceFactory.
*
* @author Robert Smith
*
*/
public class VizServiceFactoryHolder {
// The VizServiceFactory held by the VizServiceFactory
private static IVizServiceFactory factory;
/**
* Getter for the held VizServiceFactory.
*
* @return the held VizServiceFactory
*/
public static IVizServiceFactory getFactory() {
return factory;
}
/**
* Setter for the VizServiceFactory.
*
* @param input
* the VizServiceFactory to hold
*/
public static void setVizServiceFactory(IVizServiceFactory input) {
VizServiceFactoryHolder.factory = input;
Logger staticLogger = LoggerFactory
.getLogger(VizServiceFactoryHolder.class);
IConfigurationElement[] elements = Platform.getExtensionRegistry()
.getConfigurationElementsFor(
"org.eclipse.eavp.viz.service.IVizServiceFactory");
staticLogger.info("Available configuration elements");
for (IConfigurationElement element : elements) {
staticLogger.info(element.getName());
}
return;
}
/**
* Remove the given VizServiceFactory if it is held by the
* VizServiceFactoryHolder.
*
* @input A VizServiceFactory to remove.
*/
public static void unsetVizServiceFactory(IVizServiceFactory input) {
if (input == factory) {
factory = null;
}
return;
}
}
......@@ -17,6 +17,8 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import org.eclipse.eavp.viz.service.IVizServiceFactory;
import org.eclipse.ice.datastructures.internal.VizServiceFactoryHolder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -69,12 +71,6 @@ public class ResourceHandler {
// already
if (vizFileExtensions == null) {
vizFileExtensions = new ArrayList<String>(3);
// Add entries to the list; make sure they are lowercase!
vizFileExtensions.add("csv");
vizFileExtensions.add("e");
vizFileExtensions.add("silo");
vizFileExtensions.add("h5m");
}
return;
......@@ -101,6 +97,16 @@ public class ResourceHandler {
*/
public ICEResource getResource(String filePath) throws IOException {
// Populate the list with all the file extensions which can be handled
// by any viz service
if (vizFileExtensions.size() == 0) {
IVizServiceFactory factory = VizServiceFactoryHolder.getFactory();
for (String service : factory.getServiceNames()) {
vizFileExtensions
.addAll(factory.get(service).getSupportedExtensions());
}
}
// Local declarations
ICEResource resource = null;
File file = null;
......@@ -110,8 +116,8 @@ public class ResourceHandler {
file = new File(filePath);
} else {
// If the file path is empty, complain and exit
logger.info("ResourceHandler Message: The file path was "
+ "empty!");
logger.info(
"ResourceHandler Message: The file path was " + "empty!");
return resource;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment