Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » Add text field to XPath View(I want them horizontally)
Add text field to XPath View [message #723270] Thu, 08 September 2011 04:28 Go to next message
MarcoGT  is currently offline MarcoGT
Messages: 77
Registered: May 2011
Member
Hi all,

I want to add a couple of text field to the XPath View but every item I add is place vertically...I want them horizontally....but I did not succeded.
This is the method drawing UI.

public void createPartControl(Composite parent) {
		
		Composite parentComp = new Composite(parent, SWT.NONE);
		GridLayout gl = new GridLayout(1, false);
		gl.horizontalSpacing = 0;
		gl.verticalSpacing = 0;
		gl.marginHeight = 0;
		gl.marginWidth = 0;
		parentComp.setLayout(gl);
		GridData gd = new GridData(SWT.FILL, SWT.NONE, true, false, 2, 1);
		parentComp.setLayoutData(gd);

		Composite comp = new Composite(parentComp, SWT.NONE);
		comp.setLayout(new GridLayout(1, false));
		comp.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
		
		String key = null;
		
		Properties props = config.getProperties();
		
		for(Object propKey : props.keySet()) {
			key = (String) propKey;
		
			if(key.startsWith("XPathView")) {
				xPathMap.put(key, config.getPropertyValue(key));
			}
		}
		
		String[] expressions = new String[xPathMap.size()];
		Iterator<String> it = xPathMap.keySet().iterator();
		
		int j = 0;
		
		while(it.hasNext()) {
			String k = it.next();
			expressions[j] = k.replace("XPathView.", "");
			j++;
		}
		
		Arrays.sort(expressions, String.CASE_INSENSITIVE_ORDER);
		
		Label comboLabel = new Label(comp, SWT.NONE);
		comboLabel.setText(Messages.XPathView_3);
		
		final Combo expressionCombo = new Combo(comp, SWT.DROP_DOWN | SWT.READ_ONLY);
		expressionCombo.setItems(expressions);
		
		final Combo expressionCombo2 = new Combo(comp, SWT.DROP_DOWN | SWT.READ_ONLY);
		expressionCombo2.setItems(expressions);
		
		expressionCombo.addSelectionListener(new SelectionListener() {
			
			public void widgetSelected(SelectionEvent arg0) {
				String xPathString = xPathMap.get("XPathView." + expressionCombo.getText());
				text.setText(xPathString);
			}
			
			public void widgetDefaultSelected(SelectionEvent arg0) {
			
			}
		});
		
		//chapter = new Text(parent, SWT.SINGLE);
		
		
		Label label = new Label(comp, SWT.NONE);
		label.setText(Messages.XPathView_1);
		
		this.text = new Text(comp, SWT.BORDER);
		
		gd = new GridData(SWT.FILL, SWT.NONE, true, false);
		text.setLayoutData(gd);
		text.addModifyListener(new ModifyListener() {
			public void modifyText(ModifyEvent e) {
				recomputeXPath();
			}
		});

		this.locationText = new Text(comp, SWT.READ_ONLY | SWT.FULL_SELECTION);
		gd = new GridData(SWT.FILL, SWT.NONE, true, false);
		locationText.setLayoutData(gd);

		this.treeViewer = new TreeViewer(parentComp, SWT.NONE);
		gd = new GridData(SWT.FILL, SWT.FILL, true, true);
		gd.horizontalSpan = 2;
		treeViewer.getControl().setLayoutData(gd);
		treeViewer.setLabelProvider(new JFaceNodeLabelProviderXPath());
		treeViewer.setContentProvider(new JFaceNodeContentProviderXPath());
		treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

			public void selectionChanged(SelectionChangedEvent event) {
				if (getSite().getPage().getActivePart() == XPathView.this) {
					handleTreeSelection((IStructuredSelection) event
							.getSelection(), false);
				}
			}
		});
		treeViewer.addDoubleClickListener(new IDoubleClickListener() {

			public void doubleClick(DoubleClickEvent event) {
				handleTreeSelection(
						(IStructuredSelection) event.getSelection(), true);
			}

		});

		final CTabFolder folder = new CTabFolder(parentComp, SWT.BOTTOM
				| SWT.FLAT);
		gd = new GridData(SWT.FILL, SWT.NONE, true, false);
		gd.heightHint = 0;
		folder.setLayoutData(gd);
		folder.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				CTabItem item = (CTabItem) e.item;
				sheetMap.put(currentSheet, text.getText());
				pageChange(folder.indexOf(item));
			}
		});

		for (int i = 0; i < 5; i++) {
			CTabItem item = new CTabItem(folder, SWT.NONE, i);
			// item.setControl(comp);
			item.setText(Messages.XPathView_2 + (i + 1));
		}
		folder.setSelection(currentSheet);
		pageChange(currentSheet);

		this.xpathComputer = new XPathComputer(this);
		createMenu();
		createToolbar();
		createContextMenu();

		getSite().setSelectionProvider(selectionProvider);

		initEditorListener();
	}

Re: Add text field to XPath View [message #723439 is a reply to message #723270] Thu, 08 September 2011 10:49 Go to previous message
Nitin Dahyabhai is currently offline Nitin Dahyabhai
Messages: 2236
Registered: July 2009
Senior Member
Your GridLayout is specified to only have one column.

---
Nitin Dahyabhai
Eclipse WTP, IBM
Previous Topic:Extending content assistance of WTP's XML editor
Next Topic:Keyboard shortcut problems with Html editor
Goto Forum:
  


Current Time: Mon Jul 28 12:44:48 EDT 2014

Powered by FUDForum. Page generated in 0.04145 seconds