11.3.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit b04aac7a authored by Benedikt Zoennchen's avatar Benedikt Zoennchen

solved issue #36 and find a quick solution for issue #37 which requires further improvements.

parent e1432189
...@@ -89,7 +89,7 @@ public class ScenarioElementView extends JPanel implements ISelectScenarioElemen ...@@ -89,7 +89,7 @@ public class ScenarioElementView extends JPanel implements ISelectScenarioElemen
Theme syntaxTheme = Theme.load(in); Theme syntaxTheme = Theme.load(in);
syntaxTheme.apply(textAreaLocal); syntaxTheme.apply(textAreaLocal);
} catch (IOException e) { } catch (IOException e) {
logger.error(e); logger.error("could not load theme" + e.getMessage());
} }
txtrTextfiletextarea = textAreaLocal; txtrTextfiletextarea = textAreaLocal;
......
...@@ -174,7 +174,7 @@ public class PostvisualizationModel extends SimulationModel<PostvisualizationCon ...@@ -174,7 +174,7 @@ public class PostvisualizationModel extends SimulationModel<PostvisualizationCon
return Optional.ofNullable(potentialContainer.getPotentialField(step.getStepNumber())); return Optional.ofNullable(potentialContainer.getPotentialField(step.getStepNumber()));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
logger.error(e); logger.error("could not load potential field "+ e.getMessage());
return Optional.empty(); return Optional.empty();
} }
} }
...@@ -345,7 +345,7 @@ public class PostvisualizationModel extends SimulationModel<PostvisualizationCon ...@@ -345,7 +345,7 @@ public class PostvisualizationModel extends SimulationModel<PostvisualizationCon
try { try {
potentialContainer.clear(); potentialContainer.clear();
} catch (IOException e) { } catch (IOException e) {
logger.error(e); logger.error("could not clear potential Container: " + e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
} }
......
...@@ -33,7 +33,7 @@ public class ImageGenerator<T extends DefaultSimulationConfig> { ...@@ -33,7 +33,7 @@ public class ImageGenerator<T extends DefaultSimulationConfig> {
bi = renderer.renderImage(ImageGenerator.calculateOptimalWidth(model), bi = renderer.renderImage(ImageGenerator.calculateOptimalWidth(model),
ImageGenerator.calculateOptimalHeight(model)); ImageGenerator.calculateOptimalHeight(model));
} catch (Exception e) { } catch (Exception e) {
logger.error(e); logger.error("could not render image " + e.getMessage());
} finally { } finally {
model.setScale(oldScale); model.setScale(oldScale);
} }
......
...@@ -3,6 +3,7 @@ package org.vadere.gui.projectview; ...@@ -3,6 +3,7 @@ package org.vadere.gui.projectview;
import org.apache.log4j.LogManager; import org.apache.log4j.LogManager;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.vadere.gui.projectview.view.ProjectView; import org.vadere.gui.projectview.view.ProjectView;
import org.vadere.state.attributes.models.AttributesBHM;
import org.vadere.util.io.IOUtils; import org.vadere.util.io.IOUtils;
import java.io.IOException; import java.io.IOException;
...@@ -21,7 +22,7 @@ public class VadereApplication { ...@@ -21,7 +22,7 @@ public class VadereApplication {
public static void main(String[] args) { public static void main(String[] args) {
logger.info("starting Vadere GUI..."); logger.info("starting Vadere GUI...");
// load settings // load settings
loadPreferences(); loadPreferences();
// start main gui // start main gui
......
...@@ -103,7 +103,7 @@ public abstract class ActionAbstractSaveProject extends AbstractAction { ...@@ -103,7 +103,7 @@ public abstract class ActionAbstractSaveProject extends AbstractAction {
Messages.getString("SaveFileErrorMessage.text") + System.lineSeparator() Messages.getString("SaveFileErrorMessage.text") + System.lineSeparator()
+ e.getLocalizedMessage(), + e.getLocalizedMessage(),
Messages.getString("SaveFileErrorMessage.title")); Messages.getString("SaveFileErrorMessage.title"));
logger.error(e); logger.error("could not save project: " + e.getMessage());
throw new IOException(e); throw new IOException(e);
} }
} else { } else {
......
...@@ -99,22 +99,22 @@ public class ActionLoadProject extends AbstractAction { ...@@ -99,22 +99,22 @@ public class ActionLoadProject extends AbstractAction {
public static void loadProjectByPath(ProjectViewModel projectViewModel, String projectFilePath) { public static void loadProjectByPath(ProjectViewModel projectViewModel, String projectFilePath) {
try { try {
VadereProject project = IOVadere. readProjectJson(projectFilePath); VadereProject project = IOVadere.readProjectJson(projectFilePath);
projectViewModel.setCurrentProjectPath(projectFilePath); projectViewModel.setCurrentProjectPath(projectFilePath);
projectViewModel.setProject(project); projectViewModel.setProject(project);
projectViewModel.refreshOutputTable(); projectViewModel.refreshOutputTable();
logger.info("refreshed output table");
// select and load first scenario from list // select and load first scenario from list
projectViewModel.setSelectedRowIndexInScenarioTable(0); projectViewModel.setSelectedRowIndexInScenarioTable(0);
logger.info("selected the first scenario");
// change the default directory for searching files // change the default directory for searching files
Preferences.userNodeForPackage(VadereApplication.class).put("default_directory", Preferences.userNodeForPackage(VadereApplication.class).put("default_directory",
projectViewModel.getCurrentProjectPath()); projectViewModel.getCurrentProjectPath());
addToRecentProjects(projectFilePath); addToRecentProjects(projectFilePath);
ProjectView.getMainWindow().setProjectSpecificActionsEnabled(true); ProjectView.getMainWindow().setProjectSpecificActionsEnabled(true);
logger.info(String.format("project '%s' loaded.", projectViewModel.getProject().getName())); logger.info(String.format("project '%s' loaded.", projectViewModel.getProject().getName()));
// results from migration assistant if he was active // results from migration assistant if he was active
...@@ -159,7 +159,7 @@ public class ActionLoadProject extends AbstractAction { ...@@ -159,7 +159,7 @@ public class ActionLoadProject extends AbstractAction {
} catch (Exception e) { } catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage(), "Migration assistant", JOptionPane.showMessageDialog(null, e.getMessage(), "Migration assistant",
JOptionPane.ERROR_MESSAGE); JOptionPane.ERROR_MESSAGE);
logger.error(e); logger.error("could not load project: " + e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
} }
......
package org.vadere.gui.projectview.utils; package org.vadere.gui.projectview.utils;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.vadere.simulator.models.MainModel; import org.vadere.simulator.models.MainModel;
import org.vadere.simulator.models.Model; import org.vadere.simulator.models.Model;
import org.vadere.simulator.projects.dataprocessing.datakey.DataKey; import org.vadere.simulator.projects.dataprocessing.datakey.DataKey;
import org.vadere.simulator.projects.dataprocessing.outputfile.OutputFile; import org.vadere.simulator.projects.dataprocessing.outputfile.OutputFile;
import org.vadere.simulator.projects.dataprocessing.processor.DataProcessor; import org.vadere.simulator.projects.dataprocessing.processor.DataProcessor;
import org.vadere.state.attributes.Attributes; import org.vadere.state.attributes.Attributes;
import org.vadere.state.attributes.models.AttributesBHM;
import org.vadere.state.attributes.models.AttributesOSM; import org.vadere.state.attributes.models.AttributesOSM;
import java.io.*; import java.io.*;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType; import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.net.JarURLConnection;
import java.net.URL; import java.net.URL;
import java.util.*; import java.util.*;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class ClassFinder { public class ClassFinder {
private static Logger log = LogManager.getLogger(ClassFinder.class);
public static List<String> getAttributesNames() { public static List<String> getAttributesNames() {
// OSM ok for determining package name? use Object.class as tag instead? // OSM ok for determining package name? use Object.class as tag instead?
return getClassNamesWithTagInPackage(AttributesOSM.class.getPackage().getName(), Attributes.class); return getClassNamesWithTagInPackage(AttributesOSM.class.getPackage().getName(), Attributes.class);
...@@ -45,14 +53,14 @@ public class ClassFinder { ...@@ -45,14 +53,14 @@ public class ClassFinder {
public static Map<String, Class> getDataKeysOutputFileRelation() { public static Map<String, Class> getDataKeysOutputFileRelation() {
try { try {
return getClassesStream(DataKey.class.getPackage().getName()) return getClasses(DataKey.class.getPackage().getName())
.stream() .stream()
.filter(c -> !Modifier.isInterface(c.getModifiers())) .filter(c -> !Modifier.isInterface(c.getModifiers()))
.filter(c -> DataKey.class.isAssignableFrom(c)) .filter(c -> DataKey.class.isAssignableFrom(c))
.map(c -> { .map(c -> {
// Find corresponding outputfile class // Find corresponding outputfile class
try { try {
List<Class<?>> opClasses = getClassesStream(OutputFile.class.getPackage().getName()); List<Class<?>> opClasses = getClasses(OutputFile.class.getPackage().getName());
Optional<Class<?>> corrOpClass = opClasses Optional<Class<?>> corrOpClass = opClasses
.stream() .stream()
...@@ -106,7 +114,7 @@ public class ClassFinder { ...@@ -106,7 +114,7 @@ public class ClassFinder {
private static List<Class<?>> findSubclassesInPackage(String packageName, Class<?> baseClassOrInterface) { private static List<Class<?>> findSubclassesInPackage(String packageName, Class<?> baseClassOrInterface) {
try { try {
return getClassesStream(packageName).stream() return getClasses(packageName).stream()
.filter(c -> !c.isInterface() .filter(c -> !c.isInterface()
&& baseClassOrInterface.isAssignableFrom(c) && baseClassOrInterface.isAssignableFrom(c)
&& isNotAnInnerClass(c)) && isNotAnInnerClass(c))
...@@ -139,19 +147,41 @@ public class ClassFinder { ...@@ -139,19 +147,41 @@ public class ClassFinder {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
String path = packageName.replace('.', '/'); String path = packageName.replace('.', '/');
List<File> dirs = new ArrayList<>(); List<File> dirs = new ArrayList<>();
ArrayList<Class<?>> classes = new ArrayList<>();
assert classLoader != null; assert classLoader != null;
//String path = packageName.replace('.', '/');
Enumeration<URL> resources = classLoader.getResources(path); Enumeration<URL> resources = classLoader.getResources(path);
while (resources.hasMoreElements()) { while (resources.hasMoreElements()) {
URL resource = resources.nextElement(); URL url = resources.nextElement();
dirs.add(new File(resource.getFile()));
} /*
ArrayList<Class<?>> classes = new ArrayList<>(); * TODO[Issue #37, Bug]: Find a better solution! The problem is that one can not easily access class-files inside a packed jar!
for (File directory : dirs) { * this code runs if the project is started via a executable jar
classes.addAll(findClasses(directory, packageName)); * it is slow, since the whole .jar will be unpacked.
*/
if(url.getProtocol() == "jar") {
JarURLConnection urlcon = (JarURLConnection) (url.openConnection());
try (JarFile jar = urlcon.getJarFile();) {
Enumeration<JarEntry> entries = jar.entries();
while (entries.hasMoreElements()) {
String entry = entries.nextElement().getName();
if(entry.startsWith(path) && entry.endsWith(".class")) {
String classPath = entry.substring(0, entry.length() - 6).replace('/', '.');
classes.add(ClassFinder.class.forName(classPath));
log.info(classPath);
}
}
}
} // this code is fine but will only be used if the project is started from an IDE!
else {
dirs.add(new File(url.getFile()));
for (File directory : dirs) {
classes.addAll(findClasses(directory, packageName));
}
}
} }
return classes; return classes;
} }
...@@ -175,6 +205,8 @@ public class ClassFinder { ...@@ -175,6 +205,8 @@ public class ClassFinder {
dirs.add(path); dirs.add(path);
log.info(ClassFinder.class.forName(AttributesBHM.class.getName()));
while(!dirs.isEmpty()) { while(!dirs.isEmpty()) {
String currentDir = dirs.removeFirst(); String currentDir = dirs.removeFirst();
String currentPackage = currentDir.replace('/', '.'); String currentPackage = currentDir.replace('/', '.');
......
...@@ -6,6 +6,7 @@ import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; ...@@ -6,6 +6,7 @@ import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
import org.fife.ui.rsyntaxtextarea.SyntaxConstants; import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
import org.fife.ui.rsyntaxtextarea.Theme; import org.fife.ui.rsyntaxtextarea.Theme;
import org.vadere.gui.components.utils.Messages; import org.vadere.gui.components.utils.Messages;
import org.vadere.gui.components.utils.Resources;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
...@@ -34,7 +35,7 @@ public class JSONView extends JPanel { ...@@ -34,7 +35,7 @@ public class JSONView extends JPanel {
Theme syntaxTheme = Theme.load(in); Theme syntaxTheme = Theme.load(in);
syntaxTheme.apply(textAreaLocal); syntaxTheme.apply(textAreaLocal);
} catch (IOException e) { } catch (IOException e) {
logger.error(e); logger.error("could not apply theme: " + e.getMessage());
} }
JPanel panelTop = new JPanel(); JPanel panelTop = new JPanel();
...@@ -46,11 +47,9 @@ public class JSONView extends JPanel { ...@@ -46,11 +47,9 @@ public class JSONView extends JPanel {
add(scrollPane, BorderLayout.CENTER); add(scrollPane, BorderLayout.CENTER);
lbljsoninvalid = new JLabel(Messages.getString("TextView.lbljsoninvalid.text")); lbljsoninvalid = new JLabel(Messages.getString("TextView.lbljsoninvalid.text"));
lbljsoninvalid lbljsoninvalid.setIcon(new ImageIcon(Resources.class.getResource("/icons/Error.gif")));
.setIcon(new ImageIcon(TextView.class.getResource("/com/sun/java/swing/plaf/windows/icons/Error.gif")));
lbljsonvalid = new JLabel(Messages.getString("TextView.lbljsonvalid.text")); lbljsonvalid = new JLabel(Messages.getString("TextView.lbljsonvalid.text"));
lbljsonvalid.setIcon( lbljsonvalid.setIcon(new ImageIcon(Resources.class.getResource("/icons/Inform.gif")));
new ImageIcon(TextView.class.getResource("/com/sun/java/swing/plaf/windows/icons/Inform.gif")));
panelTop.add(lbljsoninvalid); panelTop.add(lbljsoninvalid);
panelTop.add(lbljsonvalid); panelTop.add(lbljsonvalid);
......
...@@ -3,6 +3,7 @@ package org.vadere.gui.projectview.view; ...@@ -3,6 +3,7 @@ package org.vadere.gui.projectview.view;
import javax.swing.*; import javax.swing.*;
import org.vadere.gui.components.utils.Messages; import org.vadere.gui.components.utils.Messages;
import org.vadere.gui.components.utils.Resources;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
...@@ -21,8 +22,7 @@ public class JsonValidIndicator extends JPanel { ...@@ -21,8 +22,7 @@ public class JsonValidIndicator extends JPanel {
labelJsonValid = new JLabel(Messages.getString("TextView.lbljsonvalid.text")); labelJsonValid = new JLabel(Messages.getString("TextView.lbljsonvalid.text"));
add(labelJsonValid); add(labelJsonValid);
labelJsonValid.setIcon(new ImageIcon( labelJsonValid.setIcon(new ImageIcon(Resources.class.getResource("/icons/Inform.gif")));
TextView.class.getResource("/com/sun/java/swing/plaf/windows/icons/Inform.gif")));
// INVALID // INVALID
...@@ -30,8 +30,7 @@ public class JsonValidIndicator extends JPanel { ...@@ -30,8 +30,7 @@ public class JsonValidIndicator extends JPanel {
" <font color=gray size=-1><a href=#>" + Messages.getString("TextView.lbljsoninvalid.showErrorText") " <font color=gray size=-1><a href=#>" + Messages.getString("TextView.lbljsoninvalid.showErrorText")
+ "</a></font></html>"); + "</a></font></html>");
add(labelJsonInvalid); add(labelJsonInvalid);
labelJsonInvalid.setIcon(new ImageIcon(TextView.class labelJsonInvalid.setIcon(new ImageIcon(Resources.class.getResource("/icons/Error.gif")));
.getResource("/com/sun/java/swing/plaf/windows/icons/Error.gif")));
labelJsonInvalid.addMouseListener(new MouseAdapter() { labelJsonInvalid.addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseReleased(MouseEvent e) { public void mouseReleased(MouseEvent e) {
......
...@@ -489,13 +489,14 @@ public class ProjectView extends JFrame implements ProjectFinishedListener, Sing ...@@ -489,13 +489,14 @@ public class ProjectView extends JFrame implements ProjectFinishedListener, Sing
Player.kill(); Player.kill();
ScenarioBundle bundle = model.getSelectedScenarioBundle(); ScenarioBundle bundle = model.getSelectedScenarioBundle();
logger.info(String.format("selected scenario '%s'", bundle.getScenario().getName()));
model.setCurrentScenario(bundle.getScenario()); model.setCurrentScenario(bundle.getScenario());
logger.info(String.format("selected scenario '%s'", bundle.getScenario().getName()));
scenarioJPanel.setScenario(bundle.getScenario(), true); scenarioJPanel.setScenario(bundle.getScenario(), true);
outputTableRenderer.setMarkedOutputFiles(bundle.getOutputDirectories()); outputTableRenderer.setMarkedOutputFiles(bundle.getOutputDirectories());
outputTable.repaint(); // make cell renderer mark associated outputs outputTable.repaint(); // make cell renderer mark associated outputs
logger.info("repainted output table");
} }
}); });
scenarioTable.setDefaultRenderer(Object.class, new ScenarioTableRenderer(model)); scenarioTable.setDefaultRenderer(Object.class, new ScenarioTableRenderer(model));
......
...@@ -91,9 +91,9 @@ public class ScenarioPanel extends JPanel implements IProjectChangeListener, Pro ...@@ -91,9 +91,9 @@ public class ScenarioPanel extends JPanel implements IProjectChangeListener, Pro
setTopography(scenario.getTopography()); setTopography(scenario.getTopography());
} }
}); });
attributesSimulationView = attributesSimulationView =
new TextView("/attributes", "default_directory_attributes", AttributeType.SIMULATION); new TextView("/attributes", "default_directory_attributes", AttributeType.SIMULATION);
tabbedPane.addTab(Messages.getString("Tab.Simulation.title"), attributesSimulationView); tabbedPane.addTab(Messages.getString("Tab.Simulation.title"), attributesSimulationView);
attributesModelView = new TextView("/attributes", "default_directory_attributes", AttributeType.MODEL); attributesModelView = new TextView("/attributes", "default_directory_attributes", AttributeType.MODEL);
...@@ -103,6 +103,7 @@ public class ScenarioPanel extends JPanel implements IProjectChangeListener, Pro ...@@ -103,6 +103,7 @@ public class ScenarioPanel extends JPanel implements IProjectChangeListener, Pro
JMenu mnPresetMenu = new JMenu(Messages.getString("Tab.Model.loadTemplateMenu.title")); JMenu mnPresetMenu = new JMenu(Messages.getString("Tab.Model.loadTemplateMenu.title"));
presetMenuBar.add(mnPresetMenu); presetMenuBar.add(mnPresetMenu);
menusInTabs.add(mnPresetMenu); menusInTabs.add(mnPresetMenu);
ModelPresets.getPresets().forEach( ModelPresets.getPresets().forEach(
modelDefinition -> mnPresetMenu.add(new JMenuItem(new AbstractAction(modelDefinition.getMainModel()) { modelDefinition -> mnPresetMenu.add(new JMenuItem(new AbstractAction(modelDefinition.getMainModel()) {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -150,6 +151,7 @@ public class ScenarioPanel extends JPanel implements IProjectChangeListener, Pro ...@@ -150,6 +151,7 @@ public class ScenarioPanel extends JPanel implements IProjectChangeListener, Pro
attributesModelView.insertAtCursor("\"" + className + "\""); attributesModelView.insertAtCursor("\"" + className + "\"");
} }
}))); })));
logger.info("3");
ClassFinder.getModelNames().stream() ClassFinder.getModelNames().stream()
.sorted() .sorted()
.forEach(className -> mnModelNameMenu.add(new JMenuItem(new AbstractAction(className) { .forEach(className -> mnModelNameMenu.add(new JMenuItem(new AbstractAction(className) {
...@@ -202,6 +204,7 @@ public class ScenarioPanel extends JPanel implements IProjectChangeListener, Pro ...@@ -202,6 +204,7 @@ public class ScenarioPanel extends JPanel implements IProjectChangeListener, Pro
public void setScenario(Scenario scenario, boolean isEditable) { public void setScenario(Scenario scenario, boolean isEditable) {
this.scenario = scenario; this.scenario = scenario;
this.scenarioName.setText(scenario.getDisplayName()); this.scenarioName.setText(scenario.getDisplayName());
if (!initialized) { if (!initialized) {
initialize(); initialize();
} }
......
...@@ -9,6 +9,7 @@ import java.io.IOException; ...@@ -9,6 +9,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.prefs.Preferences; import java.util.prefs.Preferences;
import javax.imageio.ImageIO;
import javax.swing.AbstractButton; import javax.swing.AbstractButton;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import javax.swing.JButton; import javax.swing.JButton;
...@@ -26,6 +27,7 @@ import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; ...@@ -26,6 +27,7 @@ import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
import org.fife.ui.rsyntaxtextarea.SyntaxConstants; import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
import org.fife.ui.rsyntaxtextarea.Theme; import org.fife.ui.rsyntaxtextarea.Theme;
import org.vadere.gui.components.utils.Messages; import org.vadere.gui.components.utils.Messages;
import org.vadere.gui.components.utils.Resources;
import org.vadere.gui.projectview.VadereApplication; import org.vadere.gui.projectview.VadereApplication;
import org.vadere.simulator.projects.Scenario; import org.vadere.simulator.projects.Scenario;
import org.vadere.simulator.projects.dataprocessing.DataProcessingJsonManager; import org.vadere.simulator.projects.dataprocessing.DataProcessingJsonManager;
...@@ -98,7 +100,7 @@ public class TextView extends JPanel implements IJsonView { ...@@ -98,7 +100,7 @@ public class TextView extends JPanel implements IJsonView {
String content = IOUtils.readTextFile(path); String content = IOUtils.readTextFile(path);
txtrTextfiletextarea.setText(content); txtrTextfiletextarea.setText(content);
} catch (IOException e) { } catch (IOException e) {
logger.error(e); logger.error("could not load from file: " + e.getMessage());
} }
} }
}; };
...@@ -107,43 +109,37 @@ public class TextView extends JPanel implements IJsonView { ...@@ -107,43 +109,37 @@ public class TextView extends JPanel implements IJsonView {
* Create the panel. * Create the panel.
*/ */
public TextView(String default_folder, String default_resource, final AttributeType attributeType) { public TextView(String default_folder, String default_resource, final AttributeType attributeType) {
this.default_folder = default_folder; this.default_folder = default_folder;
this.default_resource = default_resource; this.default_resource = default_resource;
this.attributeType = attributeType; this.attributeType = attributeType;
setLayout(new BorderLayout(0, 0)); setLayout(new BorderLayout(0, 0));
logger.info("04");
panelTop = new JPanel(); panelTop = new JPanel();
add(panelTop, BorderLayout.NORTH); add(panelTop, BorderLayout.NORTH);
panelTop.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); panelTop.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
JButton btnSaveToFile = new JButton(Messages.getString("TextFileView.btnSaveToFile.text")); JButton btnSaveToFile = new JButton(Messages.getString("TextFileView.btnSaveToFile.text"));
btnSaveToFile.addActionListener(saveToFileActionListener); btnSaveToFile.addActionListener(saveToFileActionListener);
btnSaveToFile.setIcon(new ImageIcon(TextView.class btnSaveToFile.setIcon(new ImageIcon(Resources.class.getResource("/icons/floppy.gif")));
.getResource("/javax/swing/plaf/metal/icons/ocean/floppy.gif")));
panelTop.add(btnSaveToFile); panelTop.add(btnSaveToFile);
btnLoadFromFile = new JButton(Messages.getString("TextView.btnLoadFromFile.text")); btnLoadFromFile = new JButton(Messages.getString("TextView.btnLoadFromFile.text"));
btnLoadFromFile.addActionListener(loadFromFileActionListener); btnLoadFromFile.setIcon(new ImageIcon(Resources.class.getResource("/icons/floppy.gif")));
btnLoadFromFile.setIcon(new ImageIcon( panelTop.add(btnLoadFromFile);
TextView.class.getResource("/javax/swing/plaf/metal/icons/ocean/floppy.gif")));
panelTop.add(btnLoadFromFile);