本文整理汇总了Java中org.netbeans.editor.Utilities.getKit方法的典型用法代码示例。如果您正苦于以下问题:Java Utilities.getKit方法的具体用法?Java Utilities.getKit怎么用?Java Utilities.getKit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.editor.Utilities
的用法示例。
在下文中一共展示了Utilities.getKit方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateToolTip
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
/** Update the tooltip by running corresponding action
* {@link ExtKit#buildToolTipAction}. This method gets
* called once the enterTimer fires and it can be overriden
* by children.
*/
protected void updateToolTip() {
EditorUI ui = extEditorUI;
if (ui == null)
return;
JTextComponent comp = ui.getComponent();
if (comp == null)
return;
JComponent oldTooltip = this.toolTip;
if (isGlyphGutterMouseEvent(lastMouseEvent)) {
setToolTipText(extEditorUI.getGlyphGutter().getToolTipText(lastMouseEvent));
} else { // over the text component
BaseKit kit = Utilities.getKit(comp);
if (kit != null) {
Action a = kit.getActionByName(ExtKit.buildToolTipAction);
if (a != null) {
a.actionPerformed(new ActionEvent(comp, 0, "")); // NOI18N
}
}
}
// tooltip has changed, mark it as 'automatic'
if (this.toolTip != oldTooltip) {
tooltipFromView = true;
}
}
示例2: getMimePathBasic
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
private String getMimePathBasic(JTextComponent component) {
final Document doc = component.getDocument();
// original mimeType code
Object mimeTypeObj = doc == null ? null : DocumentUtilities.getMimeType(doc); //NOI18N
String mimeType;
if (mimeTypeObj instanceof String) {
mimeType = (String) mimeTypeObj;
} else {
BaseKit kit = Utilities.getKit(component);
if (kit == null) {
return null;
}
mimeType = kit.getContentType();
}
return mimeType;
}
示例3: addAction
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
private void addAction(JTextComponent target, JMenu menu, String actionName) {
BaseKit kit = Utilities.getKit(target);
if (kit == null) {
return;
}
Action a = kit.getActionByName(actionName);
if (a != null) {
addAction(target, menu, a);
} else { // action-name is null, add the separator
menu.addSeparator();
}
}
示例4: addAction
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
protected void addAction(JTextComponent target, JMenu menu,
String actionName) {
BaseKit kit = Utilities.getKit(target);
if (kit == null) return;
Action a = kit.getActionByName(actionName);
if (a!=null){
addAction(target, menu, a);
} else { // action-name is null, add the separator
menu.addSeparator();
}
}
示例5: actionPerformed
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
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.out.println(\""); // NOI18N
String title = (String)doc.getProperty(Document.TitleProperty);
if (title != null) {
sb.append(title);
sb.append(':');
}
try {
sb.append(Utilities.getLineOffset(doc, target.getCaret().getDot()) + 1);
} catch (BadLocationException e) {
}
sb.append(' ');
BaseKit kit = Utilities.getKit(target);
if (kit == null) return;
Action a = kit.getActionByName(BaseKit.insertContentAction);
if (a != null) {
Utilities.performAction(
a,
new ActionEvent(target, ActionEvent.ACTION_PERFORMED, sb.toString()),
target
);
}
}
}
示例6: getEditorAction
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
private synchronized Action getEditorAction(JTextComponent component) {
if (editorAction == null) {
BaseKit kit = Utilities.getKit(component);
if (kit != null) {
editorAction = kit.getActionByName(editorActionName);
}
}
return editorAction;
}
示例7: performGoto
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
/** Perform the goto operation.
* @return whether the dialog should be made invisible or not
*/
protected boolean performGoto() {
JTextComponent c = EditorRegistry.lastFocusedComponent();
if (c != null) {
try {
int line = Integer.parseInt(getGotoValueText());
//issue 188976
if (line==0)
line = 1;
//end of issue 188976
BaseDocument doc = Utilities.getDocument(c);
if (doc != null) {
int rowCount = Utilities.getRowCount(doc);
if (line > rowCount)
line = rowCount;
// Obtain the offset where to jump
int pos = Utilities.getRowStartFromLineOffset(doc, line - 1);
BaseKit kit = Utilities.getKit(c);
if (kit != null) {
Action a = kit.getActionByName(ExtKit.gotoAction);
if (a instanceof ExtKit.GotoAction) {
pos = ((ExtKit.GotoAction)a).getOffsetFromLine(doc, line - 1);
}
}
if (pos != -1) {
Caret caret = c.getCaret();
caret.setDot(pos);
} else {
c.getToolkit().beep();
return false;
}
}
} catch (NumberFormatException e) {
c.getToolkit().beep();
return false;
}
}
return true;
}
示例8: getKit
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
private BaseKit getKit(){
JTextComponent component = getComponent();
return (component == null) ? BaseKit.getKit(NbEditorKit.class) : Utilities.getKit(component);
}
示例9: getKit
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
/** Gets the editor kit */
private static BaseKit getKit(){
JTextComponent component = getComponent();
return (component == null) ? null : Utilities.getKit(component);
}
示例10: actionPerformed
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent evt, JTextComponent target) {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("actionCommand='" + evt.getActionCommand() //NOI18N
+ "', modifiers=" + evt.getModifiers() //NOI18N
+ ", when=" + evt.getWhen() //NOI18N
+ ", paramString='" + evt.paramString() + "'"); //NOI18N
}
if (target == null) {
return;
}
BaseKit kit = Utilities.getKit(target);
if (kit == null) {
return;
}
BaseDocument doc = Utilities.getDocument(target);
if (doc == null) {
return;
}
// changed as reponse to #250157: other events may get fired during
// the course of key binding processing and if an event is processed
// as nested (i.e. hierarchy change resulting from a component retracting from the screen),
// thie following test would fail.
AWTEvent maybeKeyEvent = EventQueue.getCurrentEvent();
KeyStroke keyStroke = null;
if (maybeKeyEvent instanceof KeyEvent) {
keyStroke = KeyStroke.getKeyStrokeForEvent((KeyEvent) maybeKeyEvent);
}
// try simple keystorkes first
MimePath mimeType = MimePath.parse(NbEditorUtilities.getMimeType(target));
MacroDescription macro = null;
if (keyStroke != null) {
macro = findMacro(mimeType, keyStroke);
} else {
LOG.warning("KeyStroke could not be created for event " + maybeKeyEvent);
}
if (macro == null) {
// if not found, try action command, which should contain complete multi keystroke
KeyStroke[] shortcut = KeyStrokeUtils.getKeyStrokes(evt.getActionCommand());
if (shortcut != null) {
macro = findMacro(mimeType, shortcut);
} else {
LOG.warning("KeyStroke could not be created for action command " + evt.getActionCommand());
}
}
if (macro == null) {
error(target, "macro-not-found", KeyStrokeUtils.getKeyStrokeAsText(keyStroke)); // NOI18N
return;
}
if (!runningActions.add(macro.getName())) { // this macro is already running, beware of loops
error(target, "macro-loop", macro.getName()); // NOI18N
return;
}
try {
runMacro(target, doc, kit, macro);
} finally {
runningActions.remove(macro.getName());
}
}
示例11: getViewFactory
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
/**
* Fetches the factory to be used for building the
* various view fragments that make up the view that
* represents the model. This is what determines
* how the model will be represented. This is implemented
* to fetch the factory provided by the associated
* EditorKit unless that is null, in which case this
* simply returns the BasicTextUI itself which allows
* subclasses to implement a simple factory directly without
* creating extra objects.
*
* @return the factory
*/
public @Override ViewFactory getViewFactory() {
EditorUI editorUI = getEditorUI();
if (editorUI != null) {
BaseKit kit = Utilities.getKit(editorUI.getComponent());
ViewFactory f = kit.getViewFactory();
if (f != null) {
return f;
}
}
return getBaseTextUI();
}