use of org.eclipse.wst.xsl.jaxp.launching.LaunchAttributes in project webtools.sourceediting by eclipse.
the class LaunchHelper method hydrateAttributes.
private static LaunchAttributes hydrateAttributes(ILaunchConfiguration configuration) throws CoreException {
LaunchAttributes attributes = new LaunchAttributes();
// configuration.getAttribute(JAXPLaunchConfigurationConstants.ATTR_USE_FEATURES_FROM_PREFERENCES,
boolean useDefaultAttributes = false;
// true);
if (useDefaultAttributes) {
IProcessorType pt = getProcessorInstall(configuration).getProcessorType();
Map<String, String> fvals = pt.getAttributeValues();
for (Map.Entry<String, String> entry : fvals.entrySet()) {
String uri = entry.getKey();
getAttribute(pt.getAttributes(), uri);
attributes.addAttribute(new LaunchAttribute(uri, "string", // $NON-NLS-1$
entry.getValue()));
}
} else {
String s = configuration.getAttribute(JAXPLaunchConfigurationConstants.ATTR_ATTRIBUTES, (String) null);
if (s != null && s.length() > 0) {
ByteArrayInputStream inputStream = new ByteArrayInputStream(s.getBytes());
attributes = LaunchAttributes.fromXML(inputStream);
}
}
return attributes;
}
use of org.eclipse.wst.xsl.jaxp.launching.LaunchAttributes in project webtools.sourceediting by eclipse.
the class AttributesBlock method createControl.
public void createControl(Composite parent) {
TabItem item = new TabItem((TabFolder) parent, SWT.NONE);
// $NON-NLS-1$
item.setText(Messages.getString("AttributesBlock.0"));
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
layout.marginBottom = 0;
layout.marginWidth = 0;
composite.setLayout(layout);
item.setControl(composite);
table = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.MULTI);
table.setHeaderVisible(true);
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
table.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent event) {
if (event.character == SWT.DEL && event.stateMask == 0) {
performRemove();
}
}
});
TableColumn tc1 = new TableColumn(table, SWT.NONE);
// $NON-NLS-1$
tc1.setText(Messages.getString("AttributesBlock.2"));
tc1.setWidth(350);
tc1.setResizable(true);
TableColumn tc2 = new TableColumn(table, SWT.NONE);
// $NON-NLS-1$
tc2.setText(Messages.getString("AttributesBlock.7"));
tc2.setWidth(50);
tc2.setResizable(true);
Composite buttonComp = new Composite(composite, SWT.FILL);
buttonComp.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
GridLayout gl = new GridLayout();
gl.marginWidth = 0;
buttonComp.setLayout(gl);
Button addButton = new Button(buttonComp, SWT.PUSH);
// $NON-NLS-1$
addButton.setText(Messages.getString("AttributesBlock.8"));
addButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
addButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
AttributeDialog dialog = new AttributeDialog(getShell(), attributes);
if (dialog.open() == Window.OK) {
List<IAttribute> newAttributes = dialog.getAttributes();
LaunchAttribute first = null;
for (IAttribute attribute : newAttributes) {
// $NON-NLS-1$
LaunchAttribute att = new LaunchAttribute(attribute.getURI(), "string", null);
if (first == null)
first = att;
attributes.addAttribute(att);
}
if (newAttributes.size() > 0) {
tViewer.refresh();
tViewer.setSelection(new StructuredSelection(first), true);
tViewer.editElement(first, 1);
updateLaunchConfigurationDialog();
}
}
}
});
removeButton = new Button(buttonComp, SWT.PUSH);
// $NON-NLS-1$
removeButton.setText(Messages.getString("AttributesBlock.14"));
removeButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
removeButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
performRemove();
}
});
setControl(table);
tViewer = new TableViewer(table);
tViewer.setContentProvider(new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) {
return attributes.getAttributes().toArray(new LaunchAttribute[0]);
}
public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
attributes = (LaunchAttributes) newInput;
}
});
tViewer.setSorter(new ViewerSorter() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
LaunchAttribute a1 = (LaunchAttribute) e1;
LaunchAttribute a2 = (LaunchAttribute) e2;
return a1.uri.compareTo(a2.uri);
}
});
tViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
updateRemoveButton();
}
});
TableViewerColumn tvc1 = new TableViewerColumn(tViewer, tc1);
tvc1.setLabelProvider(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
LaunchAttribute tv = (LaunchAttribute) cell.getElement();
cell.setText(tv.uri);
}
@Override
public int getToolTipTimeDisplayed(Object object) {
return 5000;
}
@Override
public String getToolTipText(Object element) {
LaunchAttribute tv = (LaunchAttribute) element;
return attributeUris.get(tv.uri).getDescription();
}
});
// ColumnViewerToolTipSupport.enableFor(tViewer);
TableViewerColumn tvc2 = new TableViewerColumn(tViewer, tc2);
tvc2.setLabelProvider(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
LaunchAttribute tv = (LaunchAttribute) cell.getElement();
cell.setText(tv.value);
}
});
tvc2.setEditingSupport(new EditingSupport(tViewer) {
@Override
protected boolean canEdit(Object element) {
return true;
}
@Override
protected CellEditor getCellEditor(Object element) {
return new TextCellEditor(table);
}
@Override
protected Object getValue(Object element) {
LaunchAttribute tv = (LaunchAttribute) element;
// $NON-NLS-1$
return tv.value == null ? "" : tv.value;
}
@Override
protected void setValue(Object element, Object value) {
LaunchAttribute tv = (LaunchAttribute) element;
tv.setValue((String) value);
updateLaunchConfigurationDialog();
tViewer.update(tv, null);
}
});
restoreColumnSettings();
}
use of org.eclipse.wst.xsl.jaxp.launching.LaunchAttributes in project webtools.sourceediting by eclipse.
the class AttributesBlock method initializeAttributesFromStorage.
private void initializeAttributesFromStorage(ILaunchConfiguration configuration) throws CoreException {
String s = configuration.getAttribute(JAXPLaunchConfigurationConstants.ATTR_ATTRIBUTES, (String) null);
if (s != null && s.length() > 0) {
attributes = LaunchAttributes.fromXML(new ByteArrayInputStream(s.getBytes()));
} else {
attributes = new LaunchAttributes();
}
tViewer.setInput(attributes);
updateRemoveButton();
}
Aggregations