本文整理汇总了Java中org.openide.text.CloneableEditorSupport类的典型用法代码示例。如果您正苦于以下问题:Java CloneableEditorSupport类的具体用法?Java CloneableEditorSupport怎么用?Java CloneableEditorSupport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CloneableEditorSupport类属于org.openide.text包,在下文中一共展示了CloneableEditorSupport类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getPosition
import org.openide.text.CloneableEditorSupport; //导入依赖的package包/类
@Override
public PositionBounds getPosition() {
try {
DataObject dobj = DataObject.find(getParentFile());
if (dobj != null) {
EditorCookie.Observable obs = (EditorCookie.Observable)dobj.getLookup().lookup(EditorCookie.Observable.class);
if (obs != null && obs instanceof CloneableEditorSupport) {
CloneableEditorSupport supp = (CloneableEditorSupport)obs;
PositionBounds bounds = new PositionBounds(
supp.createPositionRef(loc[0], Position.Bias.Forward),
supp.createPositionRef(Math.max(loc[0], loc[1]), Position.Bias.Forward)
);
return bounds;
}
}
} catch (DataObjectNotFoundException ex) {
LOG.log(Level.INFO, "Can't resolve", ex);//NOI18N
}
return null;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:RelationshipMappingRename.java
示例2: linePart
import org.openide.text.CloneableEditorSupport; //导入依赖的package包/类
public static PositionBounds linePart(FileObject file, int start, int end) {
try {
DataObject od = DataObject.find(file);
if (od == null)
return null;
EditorCookie ec = od.getCookie(EditorCookie.class);
if (!(ec instanceof CloneableEditorSupport)) {
return null;
}
final CloneableEditorSupport ces = (CloneableEditorSupport) ec;
checkOffsetsAndLog(start, end);
return new PositionBounds(ces.createPositionRef(start, Position.Bias.Forward), ces.createPositionRef(end, Position.Bias.Backward));
} catch (IOException e) {
LOG.log(Level.INFO, null, e);
return null;
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:HintsControllerImpl.java
示例3: testSourceViewMarker
import org.openide.text.CloneableEditorSupport; //导入依赖的package包/类
public void testSourceViewMarker() throws Exception {
MVElem elem1 = new MVElem();
MVElem elem2 = new MVElem();
MVElem elem3 = new SourceMVElem();
MultiViewDescription desc1 = new MVDesc("desc1", null, 0, elem1);
MultiViewDescription desc2 = new MVDesc("desc2", null, 0, elem2);
MultiViewDescription desc3 = new SourceMVDesc("desc3", null, 0, elem3);
MultiViewDescription[] descs = new MultiViewDescription[] { desc1, desc2, desc3 };
CloneableTopComponent tc = MultiViewFactory.createCloneableMultiView(descs, desc1);
tc.open();
tc.requestActive();
CloneableEditorSupport.Pane pane = (CloneableEditorSupport.Pane)tc;
JEditorPane editor = pane.getEditorPane();
assertNotNull(editor);
MultiViewHandler hand = MultiViews.findMultiViewHandler(tc);
assertFalse(desc3.equals(Accessor.DEFAULT.extractDescription(hand.getSelectedPerspective())));
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:MultiViewCloneableTopComponentTest.java
示例4: testSerializeAndDeserialize
import org.openide.text.CloneableEditorSupport; //导入依赖的package包/类
public void testSerializeAndDeserialize() throws Exception {
InstanceContent ic = new InstanceContent();
Lookup context = new AbstractLookup(ic);
CloneableEditorSupport ces = createSupport(context);
ic.add(ces);
ic.add(10);
MultiViewEditorElement mvee = new MultiViewEditorElement(context);
assertEquals("ces", ces, mvee.getLookup().lookup(CloneableEditorSupport.class));
assertEquals("ten", Integer.valueOf(10), mvee.getLookup().lookup(Integer.class));
NbMarshalledObject mar = new NbMarshalledObject(mvee);
MultiViewEditorElement deser = (MultiViewEditorElement)mar.get();
assertEquals("ten", Integer.valueOf(10), deser.getLookup().lookup(Integer.class));
assertEquals("ces", ces, deser.getLookup().lookup(CloneableEditorSupport.class));
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:MultiViewEditorElementTest.java
示例5: storeChecksum
import org.openide.text.CloneableEditorSupport; //导入依赖的package包/类
private void storeChecksum(long l) throws IOException {
BackupEntry backup = map.get(l);
if(backup.orig == null) { // Find fileobject for newly created file
backup.orig = FileUtil.toFileObject(backup.origFile);
backup.origFile = null;
}
FileObject fo = backup.orig;
if (!fo.isValid()) {
//deleted
backup.checkSum = new byte[16];
Arrays.fill(backup.checkSum, (byte)0);
return;
}
DataObject dob = DataObject.find(fo);
if (dob != null) {
CloneableEditorSupport ces = dob.getLookup().lookup(CloneableEditorSupport.class);
final BaseDocument doc = (BaseDocument) ces.getDocument();
if (doc !=null && doc.isAtomicLock()) {
//workaround to avoid deadlock
return;
}
}
LOG.log(Level.FINE, "Storing MD5 for {0}", backup.orig);
backup.checkSum = getMD5(getInputStream(backup.orig));
LOG.log(Level.FINE, "MD5 is: {0}", MD5toString(backup.checkSum));
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:BackupFacility2.java
示例6: getPosition
import org.openide.text.CloneableEditorSupport; //导入依赖的package包/类
public PositionBounds getPosition() {
try {
DataObject dobj = DataObject.find(getParentFile());
if (dobj != null) {
EditorCookie.Observable obs = (EditorCookie.Observable)dobj.getCookie(EditorCookie.Observable.class);
if (obs != null && obs instanceof CloneableEditorSupport) {
CloneableEditorSupport supp = (CloneableEditorSupport)obs;
if (loc == null) {
loc = location();
}
PositionBounds bounds = new PositionBounds(
supp.createPositionRef(loc[0], Position.Bias.Forward),
supp.createPositionRef(Math.max(loc[0], loc[1]), Position.Bias.Forward)
);
return bounds;
}
}
} catch (DataObjectNotFoundException ex) {
ex.printStackTrace();
}
return null;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:AbstractRefactoringElement.java
示例7: findCloneableEditorSupport
import org.openide.text.CloneableEditorSupport; //导入依赖的package包/类
/**
* Gets the CloneableEditorSupport for given FileObject
*
* @param fo A FileObject to get the CES for.
* @return Instance of CloneableEditorSupport
*/
public static CloneableEditorSupport findCloneableEditorSupport(FileObject fo) {
try {
DataObject dob = DataObject.find(fo);
Object obj = dob.getCookie(OpenCookie.class);
if (obj instanceof CloneableEditorSupport) {
return (CloneableEditorSupport)obj;
}
obj = dob.getCookie(org.openide.cookies.EditorCookie.class);
if (obj instanceof CloneableEditorSupport) {
return (CloneableEditorSupport)obj;
}
} catch (DataObjectNotFoundException ex) {
Exceptions.printStackTrace(ex);
}
return null;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:GsfUtilities.java
示例8: GsfDataObject
import org.openide.text.CloneableEditorSupport; //导入依赖的package包/类
public GsfDataObject(FileObject pf, MultiFileLoader loader, Language language) throws DataObjectExistsException {
super(pf, loader);
// If the user creates a file with a filename where we can't figure out the language
// (e.g. the PHP New File wizard doesn't enforce a file extension, so if you create
// a file named "pie.class" (issue 124044) the data loader doesn't know which language
// to associate this with since it isn't a GSF file extension or mimetype). However
// during template creation we know the language anyway so we can use it. On subsequent
// IDE restarts the file won't be recognized so the user will have to rename or
// add a new file extension to file type mapping.
if (language == null) {
language = templateLanguage;
}
this.language = language;
getCookieSet().add(new Class[]{
GenericEditorSupport.class, // NOI18N
SaveAsCapable.class, Openable.class, EditorCookie.Observable.class,
PrintCookie.class, CloseCookie.class, Editable.class, LineCookie.class,
DataEditorSupport.class, CloneableEditorSupport.class,
CloneableOpenSupport.class
}, new EditorSupportFactory());
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:GsfDataObject.java
示例9: expand
import org.openide.text.CloneableEditorSupport; //导入依赖的package包/类
private static boolean expand(CodeTemplateManagerOperation op, JTextComponent component, int abbrevStartOffset, CharSequence abbrev) {
op.waitLoaded();
CodeTemplate ct = op.findByAbbreviation(abbrev.toString());
if (ct != null) {
if (accept(ct, CodeTemplateManagerOperation.getTemplateFilters(component, abbrevStartOffset))) {
Document doc = component.getDocument();
sendUndoableEdit(doc, CloneableEditorSupport.BEGIN_COMMIT_GROUP);
try {
// Remove the abbrev text
doc.remove(abbrevStartOffset, abbrev.length());
ct.insert(component);
} catch (BadLocationException ble) {
} finally {
sendUndoableEdit(doc, CloneableEditorSupport.END_COMMIT_GROUP);
}
return true;
}
}
return false;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:AbbrevDetection.java
示例10: QueryBuilderSqlTextArea
import org.openide.text.CloneableEditorSupport; //导入依赖的package包/类
public QueryBuilderSqlTextArea(QueryBuilder queryBuilder) {
super();
_queryBuilder = queryBuilder;
createSqlTextPopup();
// Get Netbeans-registered EditorKit for SQL content
setEditorKit(CloneableEditorSupport.getEditorKit("text/x-sql"));
if ( SYNTAX_HIGHLIGHT ) {
addKeyListener(this);
}
// set the bold attribute
// colors chosen from :
// http://ui.netbeans.org/docs/hi/annotations/index2.html
StyleConstants.setForeground(keyword,new Color(0,0,153));
StyleConstants.setForeground(schema, new Color(0,111,0));
StyleConstants.setForeground(column,new Color(120,0,0));
// Add support for code completion (comment out, breaks syntax highlighting)
// QueryBuilderSqlCompletion doc = new QueryBuilderSqlCompletion( this, sqlReservedWords);
// this.setDocument(doc);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:QueryBuilderSqlTextArea.java
示例11: run
import org.openide.text.CloneableEditorSupport; //导入依赖的package包/类
@Override
public void run() {
if (EventQueue.isDispatchThread()) {
try {
String content = text.getDocument().getText(0, text.getDocument().getLength());
text.setEditorKit(betterXMLKit);
setText(content);
} catch (BadLocationException ex) {
Exceptions.printStackTrace(ex);
}
} else {
betterXMLKit = CloneableEditorSupport.getEditorKit("text/xml");
if (betterXMLKit != null) {
EventQueue.invokeLater(this);
}
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:SubmitPanel.java
示例12: refreshSQL
import org.openide.text.CloneableEditorSupport; //导入依赖的package包/类
public void refreshSQL() {
try {
String sqlText = "";
if (jSplitPane1.getBottomComponent() != null) {
SQLStatementGenerator stmtBldr = dataView.getSQLStatementGenerator();
for (int i = 0; i < insertDataModel.getRowCount(); i++) {
String sql = stmtBldr.generateRawInsertStatement(insertTable, getInsertValues(i));
sqlText = sqlText + sql + "\n";
}
jEditorPane1.setEditorKit(CloneableEditorSupport.getEditorKit("text/x-sql")); // NOI18N
jEditorPane1.setText(sqlText);
jScrollPane2.setViewportView(jEditorPane1);
}
} catch (DBException ex) {
JLabel errorLabel = new JLabel(
"<html><body><font color=\"#FF0000\">" //NOI18N
+ ex.getMessage().replaceAll("\\n", "<br>") //NOI18N
+ "</font></body></html>"); //NOI18N
errorLabel.setBorder(new EmptyBorder(5, 5, 5, 5));
errorLabel.setVerticalAlignment(SwingConstants.TOP);
jScrollPane2.setViewportView(errorLabel);
jScrollPane2.revalidate();
jScrollPane2.repaint();
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:InsertRecordDialog.java
示例13: prepareSpansFor
import org.openide.text.CloneableEditorSupport; //导入依赖的package包/类
public static List<PositionBounds> prepareSpansFor(FileObject file, Iterable<? extends int[]> spans) {
List<PositionBounds> result = new ArrayList<PositionBounds>();
try {
DataObject d = DataObject.find(file);
EditorCookie ec = d.getLookup().lookup(EditorCookie.class);
CloneableEditorSupport ces = (CloneableEditorSupport) ec;
result = new LinkedList<PositionBounds>();
for (int[] span : spans) {
PositionRef start = ces.createPositionRef(span[0], Bias.Forward);
PositionRef end = ces.createPositionRef(span[1], Bias.Forward);
result.add(new PositionBounds(start, end));
}
} catch (DataObjectNotFoundException ex) {
Exceptions.printStackTrace(ex);
}
return result;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:Utilities.java
示例14: refactorElement
import org.openide.text.CloneableEditorSupport; //导入依赖的package包/类
private void refactorElement(ModificationResult modificationResult, CssElementContext.Editor context, CssIndex index) {
//type selector: div
//we do refactor only elements in the current css file, and even this is questionable if makes much sense
Node element = context.getElement();
String elementImage = element.image().toString();
CssFileModel model = CssFileModel.create(context.getParserResult());
List<Difference> diffs = new ArrayList<>();
CloneableEditorSupport editor = GsfUtilities.findCloneableEditorSupport(context.getFileObject());
for (Entry entry : model.getHtmlElements()) {
if (entry.isValidInSourceDocument() && elementImage.equals(entry.getName())) {
diffs.add(new Difference(Difference.Kind.CHANGE,
editor.createPositionRef(entry.getDocumentRange().getStart(), Bias.Forward),
editor.createPositionRef(entry.getDocumentRange().getEnd(), Bias.Backward),
entry.getName(),
refactoring.getNewName(),
NbBundle.getMessage(CssRenameRefactoringPlugin.class, "MSG_Rename_Selector"))); //NOI18N
}
}
if (!diffs.isEmpty()) {
modificationResult.addDifferences(context.getFileObject(), diffs);
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:CssRenameRefactoringPlugin.java
示例15: release
import org.openide.text.CloneableEditorSupport; //导入依赖的package包/类
private synchronized void release() {
if (target == null) {
//already released
return ;
}
sendUndoableEdit(doc, CloneableEditorSupport.END_COMMIT_GROUP);
target.putClientProperty("NetBeansEditor.navigateBoundaries", null); // NOI18N
target.putClientProperty(InstantRenamePerformer.class, null);
if (doc instanceof BaseDocument) {
((BaseDocument) doc).setPostModificationDocumentListener(null);
}
target.removeKeyListener(this);
target = null;
region = null;
attribs = null;
requestRepaint();
doc = null;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:InstantRenamePerformer.java
示例16: testPlainEditorKits
import org.openide.text.CloneableEditorSupport; //导入依赖的package包/类
public void testPlainEditorKits() {
// VIS: JEditorPane when constructed contains javax.swing.JEditorPane$PlainEditorKit
// and calling JEP.setContenetType("text/plain") has no effect. IMO this is probably
// a defect in JDK, becuase JEP should always honour its EditorKit registry.
JEditorPane pane = new JEditorPane();
pane.setEditorKit(new DefaultEditorKit() {
public @Override String getContentType() {
return "text/whatever";
}
});
setContentTypeInAwt(pane, "text/plain");
// Test JDK kit
EditorKit kitFromJdk = pane.getEditorKit();
assertNotNull("Can't find JDK kit for text/plain", kitFromJdk);
assertEquals("The kit for text/plain should not be from JDK",
"org.netbeans.modules.editor.plain.PlainKit", kitFromJdk.getClass().getName());
// Test Netbeans kit
EditorKit kitFromNb = CloneableEditorSupport.getEditorKit("text/plain");
assertNotNull("Can't find Nb kit for text/plain", kitFromNb);
assertEquals("Wrong Nb kit for text/plain",
"org.netbeans.modules.editor.plain.PlainKit", kitFromNb.getClass().getName());
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:EditorSanityTest.java
示例17: refactorElements
import org.openide.text.CloneableEditorSupport; //导入依赖的package包/类
private void refactorElements(ModificationResult modificationResult, RefactoringElementContext context, Collection<RefactoringElement> elementsToRename, String renameMsg) throws IOException, ParseException {
Map<FileObject, List<Difference>> file2diffs = new HashMap<>();
for (RefactoringElement re : elementsToRename) {
CloneableEditorSupport editor = GsfUtilities.findCloneableEditorSupport(re.getFile());
Difference diff = new Difference(Difference.Kind.CHANGE,
editor.createPositionRef(re.getRange().getStart(), Bias.Forward),
editor.createPositionRef(re.getRange().getEnd(), Bias.Backward),
re.getName(),
refactoring.getNewName(),
renameMsg);
List<Difference> diffs = file2diffs.get(re.getFile());
if (diffs == null) {
diffs = new ArrayList<>();
file2diffs.put(re.getFile(), diffs);
}
diffs.add(diff);
}
for (Entry<FileObject, List<Difference>> entry : file2diffs.entrySet()) {
modificationResult.addDifferences(entry.getKey(), entry.getValue());
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:CPRenameRefactoringPlugin.java
示例18: getJavaFieldOccurPlaces
import org.openide.text.CloneableEditorSupport; //导入依赖的package包/类
private static List<OccurrenceItem> getJavaFieldOccurPlaces(FileObject mappingFile, String className, String fieldName) {
List<OccurrenceItem> foundPlaces = new ArrayList<OccurrenceItem>();
try {
// Get the document for this file
DataObject dataObject = DataObject.find(mappingFile);
EditorCookie result = dataObject.getCookie(EditorCookie.class);
if (result == null) {
throw new IllegalStateException("File " + mappingFile + " does not have an EditorCookie.");
}
CloneableEditorSupport editor = (CloneableEditorSupport) result;
Document document = editor.openDocument();
XMLSyntaxSupport syntaxSupport = XMLSyntaxSupport.getSyntaxSupport(document);
if (syntaxSupport == null) {
return foundPlaces;
}
foundPlaces = syntaxSupport.runWithSequence(0,
(TokenSequence ts) -> {
int start = document.getStartPosition().getOffset();
return getJavaFieldOccurPlacesLocked(syntaxSupport, ts, start, editor, className, fieldName);
});
} catch (IOException | BadLocationException ex) {
ErrorManager.getDefault().notify(org.openide.ErrorManager.INFORMATIONAL, ex);
}
return foundPlaces;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:HibernateRefactoringUtil.java
示例19: getMappingResourceOccurPlaces
import org.openide.text.CloneableEditorSupport; //导入依赖的package包/类
private static List<OccurrenceItem> getMappingResourceOccurPlaces(FileObject configFile, String resourceName, boolean searchingPathOnly) {
List<OccurrenceItem> foundPlaces = new ArrayList<OccurrenceItem>();
try {
// Get the document for this file
DataObject dataObject = DataObject.find(configFile);
EditorCookie result = dataObject.getCookie(EditorCookie.class);
if (result == null) {
throw new IllegalStateException("File " + configFile + " does not have an EditorCookie.");
}
CloneableEditorSupport editor = (CloneableEditorSupport) result;
BaseDocument document = (BaseDocument) editor.openDocument();
XMLSyntaxSupport syntaxSupport = XMLSyntaxSupport.getSyntaxSupport(document);
if (syntaxSupport == null) {
return foundPlaces;
}
return syntaxSupport.runWithSequence(0,
(TokenSequence ts) -> {
int start = document.getStartPosition().getOffset();
return getMappingResourceOccurPlacesLocked(syntaxSupport, ts, start, editor, resourceName, searchingPathOnly);
});
} catch (IOException | BadLocationException ex) {
ErrorManager.getDefault().notify(org.openide.ErrorManager.INFORMATIONAL, ex);
}
return foundPlaces;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:HibernateRefactoringUtil.java
示例20: someoneActivated
import org.openide.text.CloneableEditorSupport; //导入依赖的package包/类
private void someoneActivated() {
TopComponent win = TopComponent.getRegistry().getActivated();
if (LOG.isLoggable(Level.FINER)) {
String winId;
if (win == null) {
winId = "<null>";
} else {
String winName = win.getDisplayName();
if (winName == null) {
winName = win.getHtmlDisplayName();
}
if (winName == null) {
winName = win.getName();
}
if (winName != null) {
winName = '"' + winName + '"';
} else {
winName = "<noname>";
}
winId = winName + '(' + win.getClass().getName() + ')';
}
LOG.log(Level.FINER, "someoneActivated ({0})", winId);
}
if ((win == null) || (win instanceof CloneableEditorSupport.Pane)) {
return;
}
Object key = getActionMapKey();
ActionMap actionMap = win.getActionMap();
if ((actionMap.get(key) == null) && activatedOnWindows.add(win)) {
Action ls = getAction();
actionMap.put(key, ls);
win.putClientProperty(getMappedActionKey(),
new WeakReference<Action>(ls));
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:ActionManager.java
注:本文中的org.openide.text.CloneableEditorSupport类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论