[jboss-cvs] jbosside/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs ...

Robert Stryker rawblem at gmail.com
Thu Dec 14 14:34:44 EST 2006


  User: rawb    
  Date: 06/12/14 14:34:44

  Modified:    as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs 
                        ConvertNodeToXPathDialog.java
  Log:
  flickering view caused by input being set all over the place. Had to be remedied. It's possible this change breaks something else which depended on that behavior, but if it does I'll find it ;) 
  
  Also, API change which allows removal and addition of items without doing a tree refresh  (more efficient)
  
  Revision  Changes    Path
  1.2       +57 -10    jbosside/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/ConvertNodeToXPathDialog.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ConvertNodeToXPathDialog.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbosside/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/ConvertNodeToXPathDialog.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- ConvertNodeToXPathDialog.java	4 Dec 2006 17:45:30 -0000	1.1
  +++ ConvertNodeToXPathDialog.java	14 Dec 2006 19:34:44 -0000	1.2
  @@ -23,12 +23,16 @@
   
   import java.util.ArrayList;
   
  +import org.eclipse.jface.action.Action;
  +import org.eclipse.jface.action.IMenuManager;
   import org.eclipse.jface.text.DocumentEvent;
   import org.eclipse.jface.text.IDocument;
   import org.eclipse.jface.text.ITextViewer;
   import org.eclipse.jface.text.contentassist.ICompletionProposal;
   import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2;
   import org.eclipse.jface.text.contentassist.IContextInformation;
  +import org.eclipse.jface.viewers.ISelection;
  +import org.eclipse.jface.viewers.IStructuredSelection;
   import org.eclipse.jface.window.Window;
   import org.eclipse.swt.SWT;
   import org.eclipse.swt.events.SelectionEvent;
  @@ -57,6 +61,7 @@
   import org.jboss.ide.eclipse.as.core.util.SimpleTreeItem;
   import org.jboss.ide.eclipse.as.ui.Messages;
   import org.jboss.ide.eclipse.as.ui.dialogs.XPathDialogs.XPathDialog;
  +import org.jboss.ide.eclipse.as.ui.mbeans.editors.proposals.IServiceXMLOutlineActionProvider;
   import org.jboss.ide.eclipse.as.ui.mbeans.editors.proposals.IServiceXMLQuickFixProposalProvider;
   import org.jboss.ide.eclipse.as.ui.views.server.JBossServerView;
   import org.w3c.dom.NamedNodeMap;
  @@ -304,6 +309,31 @@
   		}
   
   		public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
  +			new ConvertNodeRunnable(node, attributeName).run();
  +		}
  +
  +		public void selected(ITextViewer viewer, boolean smartToggle) {
  +		}
  +
  +		public void unselected(ITextViewer viewer) {
  +		}
  +
  +		public boolean validate(IDocument document, int offset, DocumentEvent event) {
  +			return false;
  +		}
  +		
  +	}
  +	
  +	public static class ConvertNodeRunnable implements Runnable {
  +
  +		private String attributeName;
  +		private Node node;
  +		public ConvertNodeRunnable(Node n, String att) {
  +			attributeName = att;
  +			node = n;
  +		}
  +		
  +		public void run() {
   			ConvertNodeToXPathDialog d = new ConvertNodeToXPathDialog(new Shell(), node, attributeName);
   			int result = d.open();
   			if( result == Window.OK) {
  @@ -326,20 +356,37 @@
   				ServerAttributeHelper helper = s.getAttributeHelper();
   				helper.saveXPathPreferenceTree(tree);
   				helper.save();
  -				JBossServerView.getDefault().refreshJBTree(null);
   			}
   		}
   
  -		public void selected(ITextViewer viewer, boolean smartToggle) {
   		}
   
  -		public void unselected(ITextViewer viewer) {
  +	public static class ConvertNodeToXPathDialogOutlineMenuItemProvider implements IServiceXMLOutlineActionProvider {
  +		public void release() {
   		}
   
  -		public boolean validate(IDocument document, int offset, DocumentEvent event) {
  -			return false;
  +		public void menuAboutToShow(IMenuManager manager, ISelection selection) {
  +			Object o = ((IStructuredSelection)selection).getFirstElement();
  +			Node n;
  +			String attName = null;
  +			if( o instanceof Node ) {
  +				n = (Node)o;
  +				if( n instanceof AttrImpl) {
  +					attName = ((AttrImpl)n).getName();
  +					n = ((AttrImpl)n).getOwnerElement();
  +				}
  +				final Node n2 = n;
  +				final String attName2 = attName;
  +				Action temp = new Action() { 
  +					public void run() {
  +						new ConvertNodeRunnable(n2, attName2).run();
  +					}
  +				};
  +				temp.setText("Add to XPaths");
  +				temp.setDescription("Add this element to the list of xpaths you can edit from the properties view.");
  +				manager.add(temp);
  +				System.out.println(o);
  +			}
   		}
  -		
   	}
  -	
   }
  
  
  



More information about the jboss-cvs-commits mailing list