Update of /cvsroot/metamorphosis/krysalis-jplugin/src/java/org/krysalis/jplugin/components/sheets/text
In directory sc8-pr-cvs1:/tmp/cvs-serv15221/java/org/krysalis/jplugin/components/sheets/text
Added Files:
NetBeansEditor.java NetBeansHTMLKit.java NetBeansJavaKit.java
NetBeansPlainKit.java TextSheet.java
Log Message:
Move swallowtail.* packages under jplugin.components thus elominating the
package with a confusing name,
--- NEW FILE: NetBeansEditor.java ---
/*****************************************************************************
* Copyright (C) The Krysalis project. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Krysalis Software *
* License version 1.1_01, a copy of which has been included with this *
* distribution in the LICENSE file. *
*****************************************************************************/
package org.krysalis.jplugin.components.sheets.text;
import java.awt.BorderLayout;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.MissingResourceException;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
import java.util.StringTokenizer;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.swing.JComponent;
import javax.swing.JEditorPane;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;
import javax.swing.undo.UndoManager;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.activity.Startable;
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.component.Composable;
import org.krysalis.swingx.resources.ResourceFactory;
import org.krysalis.jplugin.framework.sheets.Sheet;
import org.krysalis.jplugin.framework.storage.StoreEntity;
import org.netbeans.editor.BaseDocument;
import org.netbeans.editor.BaseSettingsInitializer;
import org.netbeans.editor.LocaleSupport;
import org.netbeans.editor.Settings;
import org.netbeans.editor.ext.ExtSettingsInitializer;
/**
*@author <a href="mailto:[email protected]">Nicola Ken Barozzi</a>
*@created 16 settembre 2001
*@version 1.1
*/
public class NetBeansEditor extends JPanel
implements Sheet, Component, Composable, Initializable, Startable {
/**
*/
private final static String SETTINGS =
"netbeans";
/**
* Document property holding String name of associated file
*/
private final static String FILE = "file";
/**
* Document property holding Boolean if document was created or opened
*/
private final static String CREATED = "created";
/**
* Document property holding Boolean modified information
*/
private final static String MODIFIED = "modified";
private DataHandler dh;
private String contentType = "";
private JEditorPane pane;
private JComponent jComponent;
private ResourceBundle settings;
private ResourceFactory resourceFactory;
public NetBeansEditor() {
}
/**
* Sets the commandContext attribute of the NetBeansEditor object
*
*@param s The new commandContext value
*@param dh The new commandContext value
*@exception IOException Description of Exception
*/
public void setCommandContext(String s, DataHandler dh) throws IOException {
this.dh = dh;
}
/**
* Gets the name attribute of the NetBeansEditor object
*
*@return The name value
*/
public String getName() {
return "NetBeansEditor";
}
/**
* Gets the contentType attribute of the NetBeansEditor object
*
*@return The contentType value
*/
public String getContentType() {
return contentType;
}
/**
* Description of the Method
*
*@param cm Description of Parameter
*@exception ComponentException Description of Exception
*/
public void compose(ComponentManager cm) throws ComponentException {
resourceFactory = (ResourceFactory) cm.lookup("ResourceFactory");
}
/**
* Description of the Method
*/
public void initialize() {
try {
settings = new PropertyResourceBundle(resourceFactory.getResource(SETTINGS + ".properties").openStream());
LocaleSupport.addLocalizer(new Localizer("org.netbeans.editor.Bundle"));
//Feed our kits with their default Settings
Settings.addInitializer(new BaseSettingsInitializer(), Settings.CORE_LEVEL);
Settings.addInitializer(new ExtSettingsInitializer(), Settings.CORE_LEVEL);
Settings.reset();
readSettings();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Description of the Method
*
*@exception IOException Description of Exception
*/
public void start() throws IOException {
try {
this.setVisible(false);
DataSource ds = dh.getDataSource();
this.contentType = ds.getContentType();
//FIXME cast
URL dataUrl = ((StoreEntity) ds).getURL();
File file = new File(dataUrl.getFile());
KitInfo info = KitInfo.getKitInfoOrDefault(contentType);
pane = new JEditorPane(contentType, "");
try {
pane.read(
/*
* new FileInputStream( file )
*/
ds.getInputStream(), file.getCanonicalPath());
} catch (IOException exc) {
JOptionPane.showMessageDialog(this, "Can't read.", "Error", JOptionPane.ERROR_MESSAGE);
exc.printStackTrace();
return;
}
Document doc = pane.getDocument();
/*
* doc.addDocumentListener( new MarkingDocumentListener( c ) );
* doc.putProperty( FILE, file );
* doc.putProperty( CREATED, new Boolean( created ) );
*/
UndoManager um = new UndoManager();
doc.addUndoableEditListener(um);
doc.putProperty(BaseDocument.UNDO_MANAGER_PROP, um);
jComponent = new JScrollPane(pane);
this.setLayout(new BorderLayout());
this.add(jComponent, BorderLayout.CENTER);
pane.getCaret().setDot(0);
} catch (Exception e) {
e.printStackTrace();
throw new IOException(e.toString());
}
this.setVisible(true);
}
/**
* Description of the Method
*/
public void stop() { }
/**
* Description of the Method
*
*@exception MissingResourceException Description of Exception
*/
private void readSettings() throws MissingResourceException {
File currentPath = new File(System.getProperty("user.dir")).getAbsoluteFile();
String kits = settings.getString("InstalledEditors");
String defaultKit = settings.getString("DefaultEditor");
StringTokenizer st = new StringTokenizer(kits, ",");
while (st.hasMoreTokens()) {
String kitName = st.nextToken();
// At the first, we have to read ALL info about kit
String contentType = settings.getString(kitName + "_ContentType");
String filterTitle = settings.getString(kitName + "_FileFilterTitle");
String kit = settings.getString(kitName + "_KitClass");
// At the second, we surely need an instance of kitClass
Class kitClass;
try {
kitClass = Class.forName(kit);
} catch (ClassNotFoundException exc) {
// we really need it
throw new MissingResourceException("Missing class", kit, "KitClass");
}
ClassLoader loader = kitClass.getClassLoader();
if (loader == null) {
loader = ClassLoader.getSystemClassLoader();
}
// Actually create the KitInfo from provided informations
KitInfo ki = new KitInfo(contentType, filterTitle, kitClass, loader, defaultKit.equals(kitName));
}
if (KitInfo.getDefault() == null) {
throw new MissingResourceException("Missing default kit definition", defaultKit, "DefaultEditor");
}
}
/**
* Description of the Class
*
*@author Luca Jun Barozzi
*@created 16 settembre 2001
*/
private static class Localizer implements LocaleSupport.Localizer {
ResourceBundle bundle;
/**
* Constructor for the Localizer object
*
*@param bundleName Description of Parameter
*/
public Localizer(String bundleName) {
bundle = ResourceBundle.getBundle(bundleName);
}
/**
* Gets the string attribute of the Localizer object
*
*@param key Description of Parameter
*@return The string value
*/
public String getString(String key) {
return bundle.getString(key);
}
}
/**
* Description of the Class
*
*@author Luca Jun Barozzi
*@created 16 settembre 2001
*/
private final static class KitInfo {
private static List kits = new ArrayList();
private static KitInfo defaultKitInfo;
private String type;
private Class kitClass;
private String description;
/**
* Constructor for the KitInfo object
*
*@param type Description of Parameter
*@param description Description of Parameter
*@param kitClass Description of Parameter
*@param loader Description of Parameter
*@param isDefault Description of Parameter
*/
public KitInfo(String type, String description, Class kitClass, ClassLoader loader, boolean isDefault) {
// Fill in the structure
this.type = type;
this.description = description;
this.kitClass = kitClass;
// Register us
JEditorPane.registerEditorKitForContentType(type, kitClass.getName(), loader);
kits.add(this);
if (isDefault) {
defaultKitInfo = this;
}
}
/**
* Gets the kitList attribute of the KitInfo class
*
*@return The kitList value
*/
public static List getKitList() {
return new ArrayList(kits);
}
/**
* Gets the default attribute of the KitInfo class
*
*@return The default value
*/
public static KitInfo getDefault() {
return defaultKitInfo;
}
/**
* Gets the kitInfoOrDefault attribute of the KitInfo class
*
*@param t Description of Parameter
*@return The kitInfoOrDefault value
*/
public static KitInfo getKitInfoOrDefault(String t) {
KitInfo ki = getKitInfoForType(t);
return ki == null ? defaultKitInfo : ki;
}
/**
* Gets the kitInfoForType attribute of the KitInfo class
*
*@param t Description of Parameter
*@return The kitInfoForType value
*/
public static KitInfo getKitInfoForType(String t) {
for (int i = 0; i < kits.size(); i++) {
if (((KitInfo) kits.get(i)).accept(t)) {
return (KitInfo) kits.get(i);
}
}
return null;
}
/**
* Gets the type attribute of the KitInfo object
*
*@return The type value
*/
public String getType() {
return type;
}
/**
* Gets the kitClass attribute of the KitInfo object
*
*@return The kitClass value
*/
public Class getKitClass() {
return kitClass;
}
/**
* Gets the description attribute of the KitInfo object
*
*@return The description value
*/
public String getDescription() {
return description;
}
/**
* Description of the Method
*
*@param contentType Description of Parameter
*@return Description of the Returned Value
*/
public boolean accept(String contentType) {
if (contentType.equals(type)) {
return true;
} else {
return false;
}
}
}
/**
* Listener listening for document changes on opened documents. There is
* initially one instance per opened document, but this listener is
* one-fire only - as soon as it gets fired, markes changes and removes
* itself from document. On save, new Listener is hooked again.
*
*@author Luca Jun Barozzi
*@created 16 settembre 2001
*/
private class MarkingDocumentListener implements DocumentListener {
private Component comp;
/**
* Constructor for the MarkingDocumentListener object
*
*@param comp Description of Parameter
*/
public MarkingDocumentListener(Component comp) {
this.comp = comp;
}
/**
* Description of the Method
*
*@param e Description of Parameter
*/
public void changedUpdate(DocumentEvent e) { }
/**
* Description of the Method
*
*@param evt Description of Parameter
*/
public void insertUpdate(DocumentEvent evt) {
markChanged(evt);
}
/**
* Description of the Method
*
*@param evt Description of Parameter
*/
public void removeUpdate(DocumentEvent evt) {
markChanged(evt);
}
/**
* Description of the Method
*
*@param evt Description of Parameter
*/
private void markChanged(DocumentEvent evt) {
Document doc = evt.getDocument();
doc.putProperty(MODIFIED, new Boolean(true));
File file = (File) doc.getProperty(FILE);
doc.removeDocumentListener(this);
}
}
}
--- NEW FILE: NetBeansHTMLKit.java ---
/*****************************************************************************
* Copyright (C) The Krysalis project. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Krysalis Software *
* License version 1.1_01, a copy of which has been included with this *
* distribution in the LICENSE file. *
*****************************************************************************/
package org.krysalis.jplugin.components.sheets.text;
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.util.Map;
import javax.swing.Action;
import javax.swing.KeyStroke;
import javax.swing.text.Document;
import javax.swing.text.JTextComponent;
import javax.swing.text.TextAction;
import org.netbeans.editor.BaseAction;
import org.netbeans.editor.BaseDocument;
import org.netbeans.editor.MultiKeyBinding;
import org.netbeans.editor.Settings;
import org.netbeans.editor.SettingsNames;
import org.netbeans.editor.SettingsUtil;
import org.netbeans.editor.Syntax;
import org.netbeans.editor.SyntaxSupport;
import org.netbeans.editor.ext.Completion;
import org.netbeans.editor.ext.ExtEditorUI;
import org.netbeans.editor.ext.ExtKit;
import org.netbeans.editor.ext.ExtUtilities;
import org.netbeans.editor.ext.html.HTMLCompletion;
import org.netbeans.editor.ext.html.HTMLSettingsInitializer;
import org.netbeans.editor.ext.html.HTMLSyntax;
import org.netbeans.editor.ext.html.HTMLSyntaxSupport;
/**
* Editor kit implementation for HTML content type
*
*@author Miloslav Metelka
*@author <a href="mailto:[email protected]">Nicola Ken Barozzi</a>
*@created 16 settembre 2001
*@version 1
*/
public class NetBeansHTMLKit extends ExtKit {
/**
* Description of the Field
*/
public final static String HTML_MIME_TYPE = "text/html";
// NOI18N
/**
* Description of the Field
*/
public final static String shiftInsertBreakAction = "shift-insert-break";
final static long serialVersionUID = -1381945567613910297L;
/**
* Constructor for the NetBeansHTMLKit object
*/
public NetBeansHTMLKit() {
super();
//org.netbeans.editor.ext.html.DTD myDTD = new DTDcreator().createDTD( "My" );
}
/**
* Gets the contentType attribute of the NetBeansHTMLKit object
*
*@return The contentType value
*/
public String getContentType() {
return HTML_MIME_TYPE;
}
/**
* Create new instance of syntax coloring scanner
*
*@param doc document to operate on. It can be null in the cases the
* syntax creation is not related to the particular document
*@return Description of the Returned Value
*/
public Syntax createSyntax(Document doc) {
return new HTMLSyntax();
}
/**
* Create syntax support
*
*@param doc Description of Parameter
*@return Description of the Returned Value
*/
public SyntaxSupport createSyntaxSupport(BaseDocument doc) {
return new HTMLSyntaxSupport(doc);
}
/**
* Description of the Method
*
*@param extEditorUI Description of Parameter
*@return Description of the Returned Value
*/
public Completion createCompletion(ExtEditorUI extEditorUI) {
return new HTMLCompletion(extEditorUI);
}
/**
* Description of the Method
*
*@return Description of the Returned Value
*/
protected Action[] createActions() {
Action[] HTMLActions = new Action[]{
new HTMLShiftBreakAction()
};
return TextAction.augmentList(super.createActions(), HTMLActions);
}
/**
* Description of the Class
*
*@author Luca Jun Barozzi
*@created 16 settembre 2001
*/
public static class HTMLShiftBreakAction extends BaseAction {
final static long serialVersionUID = 4004043376345356061L;
/**
* Constructor for the HTMLShiftBreakAction object
*/
public HTMLShiftBreakAction() {
super(shiftInsertBreakAction, ABBREV_RESET
| MAGIC_POSITION_RESET | UNDO_MERGE_RESET);
}
/**
* Description of the Method
*
*@param evt Description of Parameter
*@param target Description of Parameter
*/
public void actionPerformed(ActionEvent evt, JTextComponent target) {
if (target != null) {
Completion completion = ExtUtilities.getCompletion(target);
if (completion != null && completion.isPaneVisible()) {
if (completion.substituteText(true)) {
// completion.setPaneVisible(false);
} else {
completion.refresh(false);
}
}
}
}
}
/**
* Description of the Class
*
*@author Luca Jun Barozzi
*@created 16 settembre 2001
*/
private static class SaHTMLSettingsInitializer extends Settings.AbstractInitializer {
/**
* Constructor for the SaHTMLSettingsInitializer object
*/
public SaHTMLSettingsInitializer() {
super("sa-html-settings-initializer");
}
/**
* Gets the hTMLKeyBindings attribute of the SaHTMLSettingsInitializer
* object
*
*@return The hTMLKeyBindings value
*/
public MultiKeyBinding[] getHTMLKeyBindings() {
return new MultiKeyBinding[]{
new MultiKeyBinding(
KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_MASK),
NetBeansHTMLKit.shiftInsertBreakAction
)
};
}
/**
* Description of the Method
*
*@param kitClass Description of Parameter
*@param settingsMap Description of Parameter
*/
public void updateSettingsMap(Class kitClass, Map settingsMap) {
if (kitClass == NetBeansHTMLKit.class) {
SettingsUtil.updateListSetting(settingsMap, SettingsNames.KEY_BINDING_LIST, getHTMLKeyBindings());
}
}
}
// NOI18N
static {
Settings.addInitializer(new HTMLSettingsInitializer(NetBeansHTMLKit.class));
Settings.addInitializer(new SaHTMLSettingsInitializer());
Settings.reset();
}
}
--- NEW FILE: NetBeansJavaKit.java ---
/*****************************************************************************
* Copyright (C) The Krysalis project. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Krysalis Software *
* License version 1.1_01, a copy of which has been included with this *
* distribution in the LICENSE file. *
*****************************************************************************/
package org.krysalis.jplugin.components.sheets.text;
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.io.File;
import java.util.Map;
import javax.swing.Action;
import javax.swing.KeyStroke;
import javax.swing.text.BadLocationException;
import javax.swing.text.DefaultEditorKit;
import javax.swing.text.Document;
import javax.swing.text.JTextComponent;
import javax.swing.text.TextAction;
import org.netbeans.editor.BaseAction;
import org.netbeans.editor.BaseDocument;
import org.netbeans.editor.BaseKit;
import org.netbeans.editor.EditorUI;
import org.netbeans.editor.Formatter;
import org.netbeans.editor.MultiKeyBinding;
import org.netbeans.editor.Settings;
import org.netbeans.editor.SettingsNames;
import org.netbeans.editor.SettingsUtil;
import org.netbeans.editor.Syntax;
import org.netbeans.editor.SyntaxSupport;
import org.netbeans.editor.Utilities;
import org.netbeans.editor.ext.Completion;
import org.netbeans.editor.ext.ExtEditorUI;
import org.netbeans.editor.ext.ExtKit;
import org.netbeans.editor.ext.java.JCBaseFinder;
import org.netbeans.editor.ext.java.JCFileProvider;
import org.netbeans.editor.ext.java.JavaCompletion;
import org.netbeans.editor.ext.java.JavaDrawLayerFactory;
import org.netbeans.editor.ext.java.JavaFormatter;
import org.netbeans.editor.ext.java.JavaSettingsInitializer;
import org.netbeans.editor.ext.java.JavaSyntax;
import org.netbeans.editor.ext.java.JavaSyntaxSupport;
/**
* Java editor kit with appropriate document
*
*@author Miloslav Metelka
*@author <a href="mailto:[email protected]">Nicola Ken Barozzi</a>
*@created 16 settembre 2001
*@version 1.00
*/
public class NetBeansJavaKit extends ExtKit {
/**
* Description of the Field
*/
public final static String JAVA_MIME_TYPE = "text/x-java";
/**
* Switch first letter of word to capital and insert 'get' at word
* begining.
*/
public final static String makeGetterAction = "make-getter";
// NOI18N
/**
* Switch first letter of word to capital and insert 'set' at word
* begining.
*/
public final static String makeSetterAction = "make-setter";
// NOI18N
/**
* Switch first letter of word to capital and insert 'is' at word begining.
*/
public final static String makeIsAction = "make-is";
// NOI18N
/**
* Debug source and line number
*/
public final static String abbrevDebugLineAction = "abbrev-debug-line";
// NOI18N
final static long serialVersionUID = -5445829962533684922L;
// NOI18N
private final static String[] getSetIsPrefixes = new String[]{
"get", "set", "is"
};
/**
* Gets the contentType attribute of the NetBeansJavaKit object
*
*@return The contentType value
*/
public String getContentType() {
return JAVA_MIME_TYPE;
}
/**
* Create new instance of syntax coloring scanner
*
*@param doc document to operate on. It can be null in the cases the
* syntax creation is not related to the particular document
*@return Description of the Returned Value
*/
public Syntax createSyntax(Document doc) {
return new JavaSyntax();
}
/**
* Create syntax support
*
*@param doc Description of Parameter
*@return Description of the Returned Value
*/
public SyntaxSupport createSyntaxSupport(BaseDocument doc) {
return new JavaSyntaxSupport(doc);
}
/**
* Description of the Method
*
*@param extEditorUI Description of Parameter
*@return Description of the Returned Value
*/
public Completion createCompletion(ExtEditorUI extEditorUI) {
return new JavaCompletion(extEditorUI);
}
/**
* Create the formatter appropriate for this kit
*
*@return Description of the Returned Value
*/
public Formatter createFormatter() {
return new JavaFormatter(this.getClass());
}
/**
* Description of the Method
*
*@return Description of the Returned Value
*/
protected EditorUI createEditorUI() {
return new ExtEditorUI();
}
/**
* Description of the Method
*
*@param doc Description of Parameter
*/
protected void initDocument(BaseDocument doc) {
doc.addLayer(new JavaDrawLayerFactory.JavaLayer(),
JavaDrawLayerFactory.JAVA_LAYER_VISIBILITY);
doc.addDocumentListener(new JavaDrawLayerFactory.LParenWatcher());
}
/**
* Description of the Method
*
*@return Description of the Returned Value
*/
protected Action[] createActions() {
Action[] javaActions = new Action[]{
new JavaDefaultKeyTypedAction(),
new PrefixMakerAction(makeGetterAction, "get", getSetIsPrefixes),
new PrefixMakerAction(makeSetterAction, "set", getSetIsPrefixes),
new PrefixMakerAction(makeIsAction, "is", getSetIsPrefixes),
new AbbrevDebugLineAction(),
};
return TextAction.augmentList(super.createActions(), javaActions);
}
/**
* Description of the Class
*
*@author Luca Jun Barozzi
*@created 16 settembre 2001
*/
public static class JavaDefaultKeyTypedAction extends ExtDefaultKeyTypedAction {
/**
* Description of the Method
*
*@param target Description of Parameter
*@param typedText Description of Parameter
*/
protected void checkIndentHotChars(JTextComponent target, String typedText) {
boolean reindent = false;
BaseDocument doc = Utilities.getDocument(target);
int dotPos = target.getCaret().getDot();
if (doc != null) {
/*
* Check whether the user has written the ending 'e'
* of the first 'else' on the line.
*/
if ("e".equals(typedText)) {
try {
int fnw = Utilities.getRowFirstNonWhite(doc, dotPos);
if (fnw >= 0 && fnw + 4 == dotPos
&& "else".equals(doc.getText(fnw, 4))
) {
reindent = true;
}
} catch (BadLocationException e) {
}
} else if (":".equals(typedText)) {
try {
int fnw = Utilities.getRowFirstNonWhite(doc, dotPos);
if (fnw >= 0 && fnw + 4 <= doc.getLength()
&& "case".equals(doc.getText(fnw, 4))
) {
reindent = true;
}
} catch (BadLocationException e) {
}
}
// Reindent the line if necessary
if (reindent) {
try {
Utilities.reformatLine(doc, dotPos);
} catch (BadLocationException e) {
}
}
}
super.checkIndentHotChars(target, typedText);
}
}
/**
* Description of the Class
*
*@author Luca Jun Barozzi
*@created 16 settembre 2001
*/
public static class AbbrevDebugLineAction extends BaseAction {
/**
* Constructor for the AbbrevDebugLineAction object
*/
public AbbrevDebugLineAction() {
super(abbrevDebugLineAction);
}
/**
* Description of the Method
*
*@param evt Description of Parameter
*@param target Description of Parameter
*/
public void actionPerformed(ActionEvent evt, JTextComponent target) {
if (target != null) {
if (!target.isEditable() || !target.isEnabled()) {
target.getToolkit().beep();
return;
}
BaseDocument doc = (BaseDocument) target.getDocument();
StringBuffer sb = new StringBuffer("System.err.println(\"");
// NOI18N
File file = (File) doc.getProperty("file");
if (file != null) {
sb.append(file.getAbsolutePath());
sb.append(':');
}
try {
sb.append(Utilities.getLineOffset(doc, target.getCaret().getDot()) + 1);
} catch (BadLocationException e) {
}
sb.append(' ');
BaseKit kit = Utilities.getKit(target);
Action a = kit.getActionByName(DefaultEditorKit.insertContentAction);
if (a != null) {
Utilities.performAction(
a,
new ActionEvent(target, ActionEvent.ACTION_PERFORMED, sb.toString()),
target
);
}
}
}
}
/**
* Description of the Class
*
*@author Luca Jun Barozzi
*@created 16 settembre 2001
*/
private static class SaJavaSettingsInitializer extends Settings.AbstractInitializer {
/**
* Constructor for the SaJavaSettingsInitializer object
*/
public SaJavaSettingsInitializer() {
super("sa-java-settings-initializer");
}
/**
* Gets the javaKeyBindings attribute of the SaJavaSettingsInitializer
* object
*
*@return The javaKeyBindings value
*/
public MultiKeyBinding[] getJavaKeyBindings() {
return new MultiKeyBinding[]{
new MultiKeyBinding(
new KeyStroke[]{
KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.ALT_MASK),
KeyStroke.getKeyStroke(KeyEvent.VK_G, 0)
},
NetBeansJavaKit.makeGetterAction
),
new MultiKeyBinding(
new KeyStroke[]{
KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.ALT_MASK),
KeyStroke.getKeyStroke(KeyEvent.VK_S, 0)
},
NetBeansJavaKit.makeSetterAction
),
new MultiKeyBinding(
new KeyStroke[]{
KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.ALT_MASK),
KeyStroke.getKeyStroke(KeyEvent.VK_I, 0)
},
NetBeansJavaKit.makeIsAction
),
new MultiKeyBinding(
KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.ALT_MASK),
NetBeansJavaKit.abbrevDebugLineAction
)
};
}
/**
* Description of the Method
*
*@param kitClass Description of Parameter
*@param settingsMap Description of Parameter
*/
public void updateSettingsMap(Class kitClass, Map settingsMap) {
if (kitClass == NetBeansJavaKit.class) {
SettingsUtil.updateListSetting(settingsMap, SettingsNames.KEY_BINDING_LIST, getJavaKeyBindings());
}
}
}
static {
Settings.addInitializer(new JavaSettingsInitializer(NetBeansJavaKit.class));
Settings.addInitializer(new SaJavaSettingsInitializer());
Settings.reset();
String jcPath = "D:\\jbprojects\\documentSystem\\resources\\parserDB\\jdk13";
if (jcPath != null) {
JCBaseFinder finder = new JCBaseFinder();
JCFileProvider provider = new JCFileProvider(jcPath);
finder.append(provider);
JavaCompletion.setFinder(finder);
}
}
}
--- NEW FILE: NetBeansPlainKit.java ---
/*****************************************************************************
* Copyright (C) The Krysalis project. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Krysalis Software *
* License version 1.1_01, a copy of which has been included with this *
* distribution in the LICENSE file. *
*****************************************************************************/
package org.krysalis.jplugin.components.sheets.text;
import javax.swing.text.Document;
import org.netbeans.editor.BaseDocument;
import org.netbeans.editor.Syntax;
import org.netbeans.editor.SyntaxSupport;
import org.netbeans.editor.ext.ExtKit;
import org.netbeans.editor.ext.ExtSyntaxSupport;
import org.netbeans.editor.ext.plain.PlainSyntax;
/**
* Editor kit used to edit the plain text.
*
*@author Miloslav Metelka
*@author <a href="mailto:[email protected]">Nicola Ken Barozzi</a>
*@created 16 settembre 2001
*@version 1.00
*/
public class NetBeansPlainKit extends ExtKit {
/**
* Description of the Field
*/
public final static String PLAIN_MIME_TYPE = "text/plain";
// NOI18N
/**
* Gets the contentType attribute of the NetBeansPlainKit object
*
*@return The contentType value
*/
public String getContentType() {
return PLAIN_MIME_TYPE;
}
/**
* Description of the Method
*
*@param doc Description of Parameter
*@return Description of the Returned Value
*/
public Syntax createSyntax(Document doc) {
return new PlainSyntax();
}
/**
* Description of the Method
*
*@param doc Description of Parameter
*@return Description of the Returned Value
*/
public SyntaxSupport createSyntaxSupport(BaseDocument doc) {
return new ExtSyntaxSupport(doc);
}
}
--- NEW FILE: TextSheet.java ---
/*****************************************************************************
* Copyright (C) The Krysalis project. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Krysalis Software *
* License version 1.1_01, a copy of which has been included with this *
* distribution in the LICENSE file. *
*****************************************************************************/
package org.krysalis.jplugin.components.sheets.text;
import java.awt.Component;
import javax.swing.JComponent;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import org.krysalis.jplugin.components.sheets.AbstractSaveableComponentSheet;
/**
*@author <a href="mailto:[email protected]">Nicola Ken Barozzi</a>
*@created June 20, 2001
*@version 1.0
*/
public class TextSheet extends AbstractSaveableComponentSheet {
private JTextArea jTextArea;
private JComponent jComponent;
/**
* Creates a new <code>TextSheet</code>.
*/
public TextSheet() {
jTextArea = new JTextArea();
jComponent = new JScrollPane(jTextArea);
}
/**
* Sets the content attribute of the TextSheet object
*
*@param content The new content value
*@param mimeType The new content value
*/
public void setContent(String content, String mimeType) {
jTextArea.setText(content);
jTextArea.setCaretPosition(0);
}
/**
* Gets the name attribute of the TextSheet object
*
*@return The name value
*/
public String getName() {
return "text";
}
/**
* Gets the component attribute of the TextSheet object
*
*@return The component value
*/
public Component getComponent() {
return jComponent;
}
/**
* Gets the content attribute of the TextSheet object
*
*@return The content value
*/
public String getContent() {
return jTextArea.getText();
}
}
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.