package de.taliis.plugins.dbc;
import java.io.InvalidClassException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Vector;
import javax.swing.ImageIcon;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import starlight.taliis.core.chunks.ChunkNotFoundException;
import starlight.taliis.core.files.dbc;
import starlight.taliis.core.files.wowfile;
import starlight.taliis.helpers.fileLoader;
import de.taliis.editor.configMananger;
import de.taliis.editor.fileMananger;
import de.taliis.editor.plugin.Plugin;
import de.taliis.editor.plugin.PluginView;
import de.taliis.editor.plugin.eventServer;
import de.taliis.plugins.dbc.mixeditor.*;
/**
* The dbc mixed editor.
*
* Besides the std dbc features this plugins is created
* to be _the_ dbc editor!
* - until i loose interest into it of course.
*
* @author ganku
*
*/
public class dbcMixEditor implements Plugin, PluginView {
ImageIcon viewIcon = null;
fileMananger fm;
configMananger cm;
Vector<Plugin> pp;
String dep[] = {
"starlight.taliis.core.files.wowfile",
"starlight.taliis.core.files.dbc"
};
public boolean checkDependencies() {
String now = "";
try {
for(String s : dep) {
now = s;
Class.forName(s);
}
return true;
} catch(Exception e) {
System.err.println("Class \"" + now + "\" not found.");
return false;
}
}
public ImageIcon getIcon() {
return viewIcon;
}
public int getPluginType() {
return PLUGIN_TYPE_VIEW;
}
public String[] getSupportedDataTypes() {
return new String[] {"dbc"};
}
public String[] neededDependencies() {
return dep;
}
public void setClassLoaderRef(URLClassLoader ref) {
fileLoader.cl = ref;
try {
URL u = ref.getResource("icons/table_gear.png");
viewIcon = new ImageIcon( u );
} catch (Exception e) {};/**/
}
public void setConfigManangerRef(configMananger ref) {
cm = ref;
}
public void setEventServer(eventServer ref) {
}
public void setFileManangerRef(fileMananger ref) {
fm = ref;
}
public void setMenuRef(JMenuBar ref) {
}
public void setPluginPool(Vector<Plugin> ref) {
pp = ref;
}
public JPanel createView() throws InvalidClassException, ChunkNotFoundException {
wowfile f = (wowfile)fm.getActiveFile().obj;
if(f instanceof dbc) {
MixDataSet data = new MixDataSet();
data.dbcFile = (dbc)f;
data.config = cm.requestConfig( fm.getActiveFile().f.getName() + ".conf");
for(Plugin p : pp) {
if(p.getClass().toString().endsWith("mpqFileRequest"))
return new MixEditor(data, fm, p);
}
return new MixEditor(data, fm, null);
}
return null;
}
public String toString() {
return "Table";
}
public void unload() {};
}