1 19 20 package org.netbeans.modules.xml.text.completion; 21 22 import java.lang.reflect.Modifier ; 23 import java.util.*; 24 import java.awt.Component ; 25 26 import javax.swing.*; 27 28 import org.netbeans.editor.ext.*; 29 30 import org.netbeans.modules.xml.text.syntax.*; 31 32 39 40 public class XMLCompletion extends Completion { 41 42 public static final String FULLY_VALID = "Fully valid"; public static final String INSERT_END_TAG = "Insert End Tag"; 45 public XMLCompletion(ExtEditorUI extEditorUI) { 46 super(extEditorUI); 47 } 48 49 protected CompletionView createView() { 50 return new ListCompletionView(new DelegatingCellRenderer()); 51 } 52 53 protected CompletionQuery createQuery() { 54 return new XMLCompletionQuery(); 55 } 56 57 64 public synchronized boolean substituteText( boolean flag ) { 65 if( getLastResult() != null ) { 66 int index = getView().getSelectedIndex(); 67 if (index >= 0) { 68 getLastResult().substituteText( index, flag ); 69 } 70 return true; 71 } else { 72 return false; 73 } 74 } 75 76 77 78 public class DelegatingCellRenderer implements ListCellRenderer { 80 ListCellRenderer defaultRenderer = new DefaultListCellRenderer(); 81 82 83 public Component getListCellRendererComponent(JList list, Object value, 84 int index, boolean isSelected, boolean cellHasFocus) { 85 if( value instanceof CompletionQuery.ResultItem ) { 86 return ((CompletionQuery.ResultItem)value).getPaintComponent( list, isSelected, cellHasFocus ); 87 } else { 88 return defaultRenderer.getListCellRendererComponent( list, value, index, isSelected, cellHasFocus); 89 } 90 } 91 } 92 93 } 94 95 | Popular Tags |