/plugins/XSLT/tags/xslt_0_5_2/xslt/XSLTPlugin.java
# · Java · 111 lines · 54 code · 22 blank · 35 comment · 0 complexity · 2ed6b97d410176600b0663690cbe5633 MD5 · raw file
- /*
- * XSLTPlugin.java - XSLT Plugin
- *
- * Copyright (c) 2002 Greg Merrill
- * 2003 Robert McKinnon
- *
- * 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 2
- * of the License, or 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, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
- package xslt;
- import org.gjt.sp.jedit.EditPlugin;
- import org.gjt.sp.jedit.GUIUtilities;
- import org.gjt.sp.jedit.jEdit;
- import org.gjt.sp.jedit.MiscUtilities;
- import org.gjt.sp.util.Log;
- import javax.swing.JOptionPane;
- import java.awt.Component;
- import java.io.PrintWriter;
- import java.io.StringWriter;
- import java.text.MessageFormat;
- import java.util.Vector;
- /**
- * EditPlugin implementation for the XSLT plugin.
- *
- * @author Greg Merrill
- * @author Robert McKinnon - robmckinnon@users.sourceforge.net
- */
- public class XSLTPlugin extends EditPlugin {
- private static XSLTProcessor processor;
- /**
- * Register xerces as the SAX Parser provider
- */
- public void start () {
- String transformerFactory = jEdit.getProperty(XSLTUtilities.TRANSFORMER_FACTORY);
- String saxParserFactory = jEdit.getProperty(XSLTUtilities.SAX_PARSER_FACTORY);
- String saxDriver = jEdit.getProperty(XSLTUtilities.SAX_DRIVER);
- String indentAmount = jEdit.getProperty("xslt.transform.indent-amount");
- XSLTUtilities.setXmlSystemProperties(transformerFactory, saxParserFactory, saxDriver);
- XSLTUtilities.setIndentAmount(indentAmount);
- }
- /**
- * Adds appropriate actions to the plugins menu
- */
- public void createMenuItems (Vector menuItems) {
- menuItems.addElement(GUIUtilities.loadMenu("xslt-menu"));
- }
- /**
- * Displays a user-friendly error message to go with the supplied exception.
- */
- static void processException(Exception e, String message, Component component) {
- StringWriter writer = new StringWriter();
- e.printStackTrace(new PrintWriter(writer));
- Log.log(Log.DEBUG, Thread.currentThread(), writer.toString());
- String msg = MessageFormat.format(jEdit.getProperty("xslt.message.error"),
- new Object[]{message, e.getMessage()});
- JOptionPane.showMessageDialog(component, msg.toString());
- }
- static void showMessageDialog(String property, Component component) {
- String message = jEdit.getProperty(property);
- JOptionPane.showMessageDialog(component, message);
- }
- static void setProcessor(XSLTProcessor processor) {
- XSLTPlugin.processor = processor;
- }
- static void displayOldXalanJarMessage() {
- String message = getOldXalanJarMessage();
- JOptionPane.showMessageDialog(XSLTPlugin.processor, message);
- }
- static String getOldXalanJarMessage() {
- String userPluginsDir = MiscUtilities.constructPath(jEdit.getSettingsDirectory(),"jars");
- String userEndorsedDir = MiscUtilities.constructPath(userPluginsDir, "endorsed");
- String systemPluginsDir = MiscUtilities.constructPath(jEdit.getJEditHome(),"jars");
- String systemEndorsedDir = MiscUtilities.constructPath(systemPluginsDir, "endorsed");
- String[] args = {userPluginsDir, systemPluginsDir, userEndorsedDir, systemEndorsedDir};
- String message = jEdit.getProperty("xslt.old-jar.message", args);
- return message;
- }
- }