Erweiterung

Das Plugin-System von TextCrypt ist denkbar einfach.

TextCrypt wurde mit der Programmiersprache Java entwickelt. So die Plugins ebenfalls mit Java entwickelt werden.

Jedes Plugin muss eine festgeschriebene Struktur haben, die es über PluginInterface implementiert. Der Rest ist fast selbsterklärend. Ein Beispiel-Plugin ist im TextCrypt-Paket enthalten, so dass dieses als Vorlage verwendet werden kann.

package codec.example;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;

import com.enlightware.textcrypt.CodecInterface;
import com.enlightware.textcrypt.GUI;

public class Example01 implements CodecInterface, ActionListener {
   /**
    * Holds the Common GUI-Object.
    */
   private GUI gGUI;

   private JPasswordField password;

   /**
    * Builds GUI for this codec (toolbar).
    */
   public JComponent[] getChild() {
      JButton button=new JButton("Example A");
      button.addActionListener(this);
      password=new JPasswordField();
      password.setColumns(10);
      password.setSize(20,10);
      JComponent[] components={button,new JLabel("Password:"),password};
      return components;
   }

   /**
    * Textcrypt calls this method to set its GUI.
    */
   public void setParent(GUI pGUI) {
      gGUI=pGUI;
   }

   /**
    * Information about the author.
    */
   public String getAuthor() {
      return "Stephan Laukien";
   }

   /**
    * Version of this plugin.
    */
   public String getVersion() {
      return "0.1";
   }

   /**
    * Button-Action
    */
   public void actionPerformed(ActionEvent e) {
      JOptionPane.showMessageDialog(null,"This Codec works!\n"+new String(password.getPassword())+'@'+e.getSource().getClass(),"Example A",JOptionPane.INFORMATION_MESSAGE);
   }
}

Neben Autor-Informationen und der Plugin-Version gibt es eine getChild-Methode, die das Bedienelement in TextCrypt darstellt und eine Methode namens setParent, was dem Plugin eine Instanz des TextCrypt-Fensters liefert.

Hinterlasse eine Antwort

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *

*

Du kannst folgende HTML-Tags benutzen: KEINE!!! :-P