2021-07-01 21:54:10 +00:00
|
|
|
package the.bytecode.club.bytecodeviewer.plugin;
|
|
|
|
|
2021-08-26 21:59:07 +00:00
|
|
|
import java.io.IOException;
|
2021-07-01 21:54:10 +00:00
|
|
|
import org.apache.commons.io.FilenameUtils;
|
2021-07-07 02:51:10 +00:00
|
|
|
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
2021-07-11 14:10:42 +00:00
|
|
|
import the.bytecode.club.bytecodeviewer.resources.IconResources;
|
2021-07-01 21:54:10 +00:00
|
|
|
|
2021-07-24 02:25:51 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
|
|
|
|
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *
|
|
|
|
* *
|
|
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
2021-07-01 21:54:10 +00:00
|
|
|
/**
|
|
|
|
* @author Konloch
|
|
|
|
* @since 7/1/2021
|
|
|
|
*/
|
|
|
|
public enum PluginTemplate
|
|
|
|
{
|
2021-07-05 03:23:40 +00:00
|
|
|
JAVA("/templates/Template_Plugin.java"),
|
|
|
|
JAVASCRIPT("/templates/Template_Plugin.js"),
|
2021-07-01 21:54:10 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
private final String resourcePath;
|
|
|
|
private final String extension;
|
|
|
|
private String contents;
|
|
|
|
|
|
|
|
PluginTemplate(String resourcePath)
|
|
|
|
{
|
|
|
|
this.resourcePath = resourcePath;
|
|
|
|
this.extension = FilenameUtils.getExtension(resourcePath);
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getContents() throws IOException
|
|
|
|
{
|
|
|
|
if(contents == null)
|
2021-07-11 14:10:42 +00:00
|
|
|
contents = IconResources.loadResourceAsString(resourcePath);
|
2021-07-01 21:54:10 +00:00
|
|
|
|
|
|
|
return contents;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getExtension()
|
|
|
|
{
|
|
|
|
return extension;
|
|
|
|
}
|
|
|
|
|
|
|
|
public PluginWriter openEditorExceptionHandled()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
return openEditor();
|
|
|
|
}
|
|
|
|
catch (IOException e)
|
|
|
|
{
|
2021-07-07 02:51:10 +00:00
|
|
|
BytecodeViewer.handleException(e);
|
2021-07-01 21:54:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public PluginWriter openEditor() throws IOException
|
|
|
|
{
|
|
|
|
PluginWriter writer = new PluginWriter(this);
|
|
|
|
writer.setVisible(true);
|
|
|
|
return writer;
|
|
|
|
}
|
|
|
|
}
|