From: <el...@us...> - 2010-11-29 18:32:48
|
Revision: 19052 http://jedit.svn.sourceforge.net/jedit/?rev=19052&view=rev Author: elberry Date: 2010-11-29 18:32:42 +0000 (Mon, 29 Nov 2010) Log Message: ----------- Changing plugin announcement to use plugin dependency names instead of the class name. This will help with releases as plugins in PluginManager are shown using their names, not their classnames. Modified Paths: -------------- jEdit/trunk/macros/Properties/Create_Plugin_Announcement.bsh Modified: jEdit/trunk/macros/Properties/Create_Plugin_Announcement.bsh =================================================================== --- jEdit/trunk/macros/Properties/Create_Plugin_Announcement.bsh 2010-11-29 10:08:18 UTC (rev 19051) +++ jEdit/trunk/macros/Properties/Create_Plugin_Announcement.bsh 2010-11-29 18:32:42 UTC (rev 19052) @@ -25,7 +25,43 @@ // import statements import javax.swing.border.*; +import org.gjt.sp.util.Log; +import java.util.Comparator; +public class PluginDependency +{ + public String className; + public String simpleName; + public String version; + + public PluginDependency(String cn, String v) + { + className = cn; + version = v; + simpleName = jEdit.getProperty("plugin." + cn + ".name"); + if(simpleName != null) + { + simpleName = simpleName.trim(); + } + if(simpleName == null || simpleName.length() <= 0) + { + int lastDotIndex = cn.lastIndexOf("."); + simpleName = cn.substring(lastDotIndex + 1); + } + Log.log(Log.DEBUG, this, "new PluginDependency class: " + className + " | name: " + simpleName + " | version: " + version); + } +} + +public class PluginDependencyNameComparator implements Comparator +{ + public int compare(Object o1, Object o2) + { + PluginDependency pd1 = (PluginDependency)o1; + PluginDependency pd2 = (PluginDependency)o2; + return pd1.simpleName.compareTo(pd2.simpleName); + } +} + // main routine void pluginTextDialog( View view, Buffer buffer ) { @@ -92,11 +128,13 @@ } else if( parts[0].equals( "plugin" ) ) { - pluginDependencies.add( parts[1] + " " + parts[2] ); + Log.log(Log.DEBUG, this, "required plugin name - class: " + parts[1] + " | name: " + jEdit.getProperty("plugin." + parts[1] + ".name")); + pluginDependencies.add(new PluginDependency(parts[1], parts[2])); } else if( parts[0].equals( "optional" ) && parts[1].equals( "plugin" ) ) { - optionalPluginDependencies.add( parts[2] + " " + parts[3] ); + Log.log(Log.DEBUG, this, "optional plugin name - class: " + parts[2] + " | name: " + jEdit.getProperty("plugin." + parts[2] + ".name")); + optionalPluginDependencies.add(new PluginDependency(parts[2], parts[3])); } else { @@ -185,15 +223,20 @@ propsPanel.add( new JLabel( jEditDependency ) ); propsPanel.add( new JLabel( "JDK Dependency" ) ); propsPanel.add( new JLabel( javaDependency ) ); + PluginDependencyNameComparator comparator = new PluginDependencyNameComparator(); + Collections.sort(pluginDependencies, comparator); + Collections.sort(optionalPluginDependencies, comparator); for( int i=0; i<pluginDependencies.size(); i++ ) { propsPanel.add( new JLabel( "Depends on" ) ); - propsPanel.add( new JLabel( pluginDependencies.get( i ).toString() ) ); + PluginDependency requiredPlugin = pluginDependencies.get( i ); + propsPanel.add( new JLabel( requiredPlugin.simpleName + " " + requiredPlugin.version ) ); } for( int i=0; i<optionalPluginDependencies.size(); i++ ) { propsPanel.add( new JLabel( "Optional" ) ); - propsPanel.add( new JLabel( optionalPluginDependencies.get( i ).toString() ) ); + PluginDependency optionalPlugin = optionalPluginDependencies.get( i ); + propsPanel.add( new JLabel( optionalPlugin.simpleName + " " + optionalPlugin.version ) ); } content.add( propsPanel, "Center" ); @@ -259,7 +302,73 @@ } dialog.dispose(); } + + void createAnnouncement() + { + announcement = announcementArea.getText(); + shortDescription = shortDescriptionArea.getText(); + longDescription = longDescriptionArea.getText(); + source = sourceArea.getText(); + StringBuffer ret = new StringBuffer(); + ret.append( "Paste the text below into the Plugin Central Submission Tracker at https://sourceforge.net/tracker/?group_id=588&atid=625093\n" ); + ret.append( "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" ); + ret.append( "\n{{{ " ); + ret.append( pluginName ); + ret.append( " " ); + ret.append( version ); + ret.append( "\n Source: " ); + ret.append( source ); + ret.append( "\n Announcement: " + announcement.replaceAll("\n", "\n " ) ); + ret.append( "\n Requires Java " ); + ret.append( javaDependency ); + ret.append( "\n Requires jEdit " ); + ret.append( jEditDependency ); + if( pluginDependencies.size() > 0 ) + { + ret.append( "\n Required plugins: " ); + for( int i=0; i<pluginDependencies.size(); i++ ) + { + ret.append( "\n " ); + PluginDependency plugin = pluginDependencies.get( i ); + ret.append( plugin.simpleName + " " + plugin.version + " (" + plugin.className + ")" ); + } + } + if( optionalPluginDependencies.size() > 0 ) + { + ret.append( "\n Optional plugins: " ); + for( int i=0; i<optionalPluginDependencies.size(); i++ ) + { + ret.append( "\n " ); + PluginDependency plugin = optionalPluginDependencies.get( i ); + ret.append( plugin.simpleName + " " + plugin.version + " (" + plugin.className + ")" ); + } + } + if( shortDescription!=null && !shortDescription.equals( "" ) ) + { + ret.append( "\n \n Short Description: " + shortDescription ); + } + if( longDescription!=null && !longDescription.equals( "" ) ) + { + ret.append( "\n \n Long Description: " + longDescription ); + } + ret.append( " }}}" ); + newbuf = jEdit.newFile( view ); + newbuf.insert( 0, ret.toString() ); + } + boolean pluginIsNotInstalled(PluginDependency dependency, String installed) { + if(installed != null) { + installed = installed.trim(); + if(!installed.equals(dependency.version)) + { + return true; + } + } else { + return true; + } + return false; + } + boolean validateVersions() { boolean valid = true; @@ -280,30 +389,22 @@ // check required plugin dependencies. for( int i = 0; i < pluginDependencies.size(); i++ ) { - String plugin = pluginDependencies.get(i); - String[] pluginParts = plugin.split("\\s+"); - String pluginClass = pluginParts[0]; - String pluginVersion = pluginParts[1]; - String installed = jEdit.getProperty("plugin." + pluginClass + ".version").trim(); - if(!installed.equals(pluginVersion)) - { + PluginDependency plugin = pluginDependencies.get(i); + String installed = jEdit.getProperty("plugin." + plugin.className + ".version"); + if(pluginIsNotInstalled(plugin, installed)) { valid = false; - builder.append(" " + pluginClass + " - Required: " + pluginVersion + " - Running: " + installed + "\n"); + builder.append(" " + plugin.simpleName + " - Required: " + plugin.version + " - Running: " + installed + "\n"); } } // check optional plugin dependencies. for( int i = 0; i < optionalPluginDependencies.size(); i++ ) { - String plugin = optionalPluginDependencies.get(i); - String[] pluginParts = plugin.split("\\s+"); - String pluginClass = pluginParts[0]; - String pluginVersion = pluginParts[1]; - String installed = jEdit.getProperty("plugin." + pluginClass + ".version").trim(); - if(!installed.equals(pluginVersion)) - { + PluginDependency plugin = optionalPluginDependencies.get(i); + String installed = jEdit.getProperty("plugin." + plugin.className + ".version"); + if(pluginIsNotInstalled(plugin, installed)) { valid = false; - builder.append(" " + pluginClass + " - Optional: " + pluginVersion + " - Running: " + installed + "\n"); + builder.append(" " + plugin.simpleName + " - Optional: " + plugin.version + " - Running: " + installed + "\n"); } } @@ -329,57 +430,6 @@ } return valid; } - - void createAnnouncement() - { - announcement = announcementArea.getText(); - shortDescription = shortDescriptionArea.getText(); - longDescription = longDescriptionArea.getText(); - source = sourceArea.getText(); - StringBuffer ret = new StringBuffer(); - ret.append( "Paste the text below into the Plugin Central Submission Tracker at https://sourceforge.net/tracker/?group_id=588&atid=625093\n" ); - ret.append( "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" ); - ret.append( "\n{{{ " ); - ret.append( pluginName ); - ret.append( " " ); - ret.append( version ); - ret.append( "\n Source: " ); - ret.append( source ); - ret.append( "\n Announcement: " + announcement.replaceAll("\n", "\n " ) ); - ret.append( "\n Requires Java " ); - ret.append( javaDependency ); - ret.append( "\n Requires jEdit " ); - ret.append( jEditDependency ); - if( pluginDependencies.size() > 0 ) - { - ret.append( "\n Required plugins: " ); - for( int i=0; i<pluginDependencies.size(); i++ ) - { - ret.append( "\n " ); - ret.append( pluginDependencies.get( i ) ); - } - } - if( optionalPluginDependencies.size() > 0 ) - { - ret.append( "\n Optional plugins: " ); - for( int i=0; i<optionalPluginDependencies.size(); i++ ) - { - ret.append( "\n " ); - ret.append( optionalPluginDependencies.get( i ) ); - } - } - if( shortDescription!=null && !shortDescription.equals( "" ) ) - { - ret.append( "\n \n Short Description: " + shortDescription ); - } - if( longDescription!=null && !longDescription.equals( "" ) ) - { - ret.append( "\n \n Long Description: " + longDescription ); - } - ret.append( " }}}" ); - newbuf = jEdit.newFile( view ); - newbuf.insert( 0, ret.toString() ); - } } // this single line of code is the script's main routine This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |