本文整理汇总了Java中org.openide.text.ActiveEditorDrop类的典型用法代码示例。如果您正苦于以下问题:Java ActiveEditorDrop类的具体用法?Java ActiveEditorDrop怎么用?Java ActiveEditorDrop使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ActiveEditorDrop类属于org.openide.text包,在下文中一共展示了ActiveEditorDrop类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testFindItem
import org.openide.text.ActiveEditorDrop; //导入依赖的package包/类
public void testFindItem() throws Exception {
FileObject itemFile = createItemFileWithActiveEditorDrop();
assertNotNull(itemFile);
//create palette
PaletteController pc = PaletteFactory.createPalette(PALETTE_ROOT, new DummyActions());
//find node with ActiveEditorDrop impl in its lookup
Node root = (Node)pc.getRoot().lookup(Node.class);
Node[] cats = root.getChildren().getNodes(true);
Node foundNode = null;
Node foundCat = null;
assertEquals("Too many categories", 1, cats.length);
Node[] items = cats[0].getChildren().getNodes(true);
assertEquals("Too many items", 1, items.length);
assertTrue("Item not found.",
DataObject.find(itemFile).getNodeDelegate().getLookup().lookup(ActiveEditorDrop.class) ==
items[0].getLookup().lookup(ActiveEditorDrop.class)
);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:PaletteItemTest.java
示例2: testSelectItem
import org.openide.text.ActiveEditorDrop; //导入依赖的package包/类
public void testSelectItem() throws Exception {
FileObject itemFile = createItemFileWithActiveEditorDrop();
assertNotNull(itemFile);
//create palette
PaletteController pc = PaletteFactory.createPalette(PALETTE_ROOT, new DummyActions());
pc.addPropertyChangeListener(new PaletteListener(pc));
//simulate node selection
Category modelCat = pc.getModel().getCategories()[0];
Item modelItem = modelCat.getItems()[0];
pc.getModel().setSelectedItem(modelCat.getLookup(), modelItem.getLookup());
assertNotNull("Selected item does not contain ActiveEditorDrop implementation",
selectedNode.lookup(ActiveEditorDrop.class));
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:PaletteItemTest.java
示例3: clipboardCopy
import org.openide.text.ActiveEditorDrop; //导入依赖的package包/类
@Override
public Transferable clipboardCopy() throws IOException {
ExTransferable t = ExTransferable.create( super.clipboardCopy() );
Lookup lookup = getLookup();
ActiveEditorDrop drop = (ActiveEditorDrop) lookup.lookup(ActiveEditorDrop.class);
ActiveEditorDropTransferable s = new ActiveEditorDropTransferable(drop);
t.put(s);
//do not allow external DnD flavors otherwise some items may get interpreted
//as an external file dropped into the editor window
return new NoExternalDndTransferable( t );
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:PaletteItemNode.java
示例4: verifyPaletteItem
import org.openide.text.ActiveEditorDrop; //导入依赖的package包/类
private void verifyPaletteItem(FileObject itemFile) throws Exception {
assertNotNull(itemFile);
Node itemNode = DataObject.find(itemFile).getNodeDelegate();
assertEquals("Item loaded with a wrong display name.", NbBundle.getBundle(BUNDLE_NAME).getString(NAME_KEY), itemNode.getDisplayName());
assertEquals("Item loaded with a wrong description.", NbBundle.getBundle(BUNDLE_NAME).getString(TOOLTIP_KEY), itemNode.getShortDescription());
assertNotNull("Item loaded with no small icon.", itemNode.getIcon(BeanInfo.ICON_COLOR_16x16));
assertNotNull("Item loaded with no big icon.", itemNode.getIcon(BeanInfo.ICON_COLOR_32x32));
Object o = itemNode.getLookup().lookup(ActiveEditorDrop.class);
assertNotNull("Item does not contain ActiveEditorDrop implementation in its lookup.", o);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:PaletteItemTest.java
示例5: actionPerformed
import org.openide.text.ActiveEditorDrop; //导入依赖的package包/类
public void actionPerformed(ActionEvent e) {
ActiveEditorDrop drop = (ActiveEditorDrop) item.lookup(ActiveEditorDrop.class);
JTextComponent target = Utilities.getFocusedComponent();
if (target == null) {
String msg = NbBundle.getMessage(HtmlPaletteActions.class, "MSG_ErrorNoFocusedDocument"); //NOI18N
DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(msg, NotifyDescriptor.ERROR_MESSAGE));
return;
}
try {
drop.handleTransfer(target);
}
finally {
Utilities.requestFocus(target);
}
try {
FileObject fo = DataLoadersBridge.getDefault().getFileObject(target);
if(fo != null) {
PaletteController pc = HtmlPaletteFactory.getPalette(fo.getMIMEType());
pc.clearSelection();
}
}
catch (IOException ignored) {
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:HtmlPaletteActions.java
示例6: ActiveEditorDropTransferable
import org.openide.text.ActiveEditorDrop; //导入依赖的package包/类
ActiveEditorDropTransferable(ActiveEditorDrop drop) {
super(ActiveEditorDrop.FLAVOR);
this.drop = drop;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:6,代码来源:PaletteItemNode.java
示例7: type
import org.openide.text.ActiveEditorDrop; //导入依赖的package包/类
public Class<? extends ActiveEditorDrop> type(String obj) {
//able to convert String instances only
return ActiveEditorDrop.class;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:ActiveEditorDropDefaultProvider.java
示例8: convert
import org.openide.text.ActiveEditorDrop; //导入依赖的package包/类
public ActiveEditorDrop convert(String obj) {
return getActiveEditorDrop(obj);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:ActiveEditorDropDefaultProvider.java
示例9: process
import org.openide.text.ActiveEditorDrop; //导入依赖的package包/类
private void process(Element e, PaletteItemRegistration pir) throws LayerGenerationException {
LayerBuilder builder = layer(e);
TypeMirror activeEditorDrop = type(ActiveEditorDrop.class);
LayerBuilder.File f = builder.file(pir.paletteid() + "/" + pir.category() + "/" + pir.itemid() + ".xml");
StringBuilder paletteFile = new StringBuilder();
paletteFile.append("<!DOCTYPE editor_palette_item PUBLIC '-//NetBeans//Editor Palette Item 1.1//EN' 'http://www.netbeans.org/dtds/editor-palette-item-1_1.dtd'>\n");
paletteFile.append("<editor_palette_item version=\"1.1\">\n");
if (pir.body().isEmpty()) {
// body empty we need a activeEditorDrop
if (e.getKind() == ElementKind.CLASS && isAssignable(e.asType(), activeEditorDrop)) {
String className = processingEnv.getElementUtils().getBinaryName((TypeElement) e).toString();
paletteFile.append(" <class name=\"").append(className).append("\"/>\n");
} else {
throw new LayerGenerationException("Class annotated with @PaletteItemRegistration has to implements ActiveEditorDrop", e);
}
} else {
// body not empty put info
paletteFile.append("<body> <![CDATA[");
paletteFile.append(pir.body());
paletteFile.append("]]> </body>\n");
}
// icon shoud be in classpath
if (!pir.icon16().isEmpty()) {
builder.validateResource(pir.icon16(), e, pir, "icon16", true);
paletteFile.append("<icon16 urlvalue=\"").append(pir.icon16()).append("\" />\n");
} else {
throw new LayerGenerationException("Icon 16 must be set ", e);
}
if (!pir.icon32().isEmpty()) {
builder.validateResource(pir.icon32(), e, pir, "icon32", true);
paletteFile.append("<icon32 urlvalue=\"").append(pir.icon32()).append("\" />\n");
} else {
throw new LayerGenerationException("Icon 32 must be set ", e);
}
paletteFile.append("<inline-description>");
paletteFile.append("<display-name>");
paletteFile.append(pir.name());
paletteFile.append("</display-name>");
paletteFile.append("<tooltip> <![CDATA[ ");
paletteFile.append(pir.tooltip());
paletteFile.append("]]></tooltip>");
paletteFile.append("</inline-description>");
paletteFile.append("</editor_palette_item>");
f.contents(paletteFile.toString());
f.write();
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:54,代码来源:PaletteItemRegistrationProcessor.java
示例10: getActiveEditorDrop
import org.openide.text.ActiveEditorDrop; //导入依赖的package包/类
private ActiveEditorDrop getActiveEditorDrop(String body) {
return new ActiveEditorDropDefault(body);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:ActiveEditorDropDefaultProvider.java
注:本文中的org.openide.text.ActiveEditorDrop类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论