use of org.eclipse.jst.jsp.core.taglib.TaglibIndexDelta in project webtools.sourceediting by eclipse.
the class TaglibIndexDeltaTraceView method createPartControl.
public void createPartControl(final Composite parent) {
fViewer = new TableViewer(parent, SWT.SINGLE | SWT.FULL_SELECTION);
fViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
showSelectionDetail(parent);
}
});
fViewer.setContentProvider(new ArrayContentProvider());
fViewer.setLabelProvider(new ITableLabelProvider() {
public void removeListener(ILabelProviderListener listener) {
}
public boolean isLabelProperty(Object element, String property) {
return false;
}
public void dispose() {
}
public void addListener(ILabelProviderListener listener) {
}
public String getColumnText(Object element, int columnIndex) {
switch(columnIndex) {
case 0:
{
return Long.toString(((TaglibIndexDelta) element).getTime());
}
case 1:
{
String kind = null;
switch(((ITaglibIndexDelta) element).getKind()) {
case ITaglibIndexDelta.ADDED:
kind = "added";
break;
case ITaglibIndexDelta.REMOVED:
kind = "removed";
break;
case ITaglibIndexDelta.CHANGED:
kind = "changed";
break;
}
return kind;
}
case 2:
return ((ITaglibIndexDelta) element).getProject().getName();
case 3:
return ((TaglibIndexDelta) element).getTrigger().toString();
}
return "";
}
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
});
String[] columnProperties = new String[] { "time", "Kind", "Project", "Trigger" };
TableLayout tlayout = new TableLayout();
CellEditor[] cellEditors = new CellEditor[columnProperties.length];
int[] columnWidths = new int[] { Display.getCurrent().getBounds().width / 14, Display.getCurrent().getBounds().width / 7, Display.getCurrent().getBounds().width / 7, Display.getCurrent().getBounds().width / 14, Display.getCurrent().getBounds().width / 7 };
for (int i = 0; i < columnProperties.length; i++) {
tlayout.addColumnData(new ColumnWeightData(1));
TableColumn tc = new TableColumn(fViewer.getTable(), SWT.NONE);
tc.setText(columnProperties[i]);
tc.setResizable(true);
tc.setWidth(columnWidths[i]);
}
fViewer.setCellEditors(cellEditors);
fViewer.setColumnProperties(columnProperties);
fViewer.getTable().setHeaderVisible(true);
fViewer.getTable().setLinesVisible(true);
fViewer.setColumnProperties(columnProperties);
MenuManager contextMenuManager = new MenuManager();
contextMenuManager.setRemoveAllWhenShown(false);
contextMenuManager.add(new Action() {
public void run() {
super.run();
showSelectionDetail(parent);
}
public String getText() {
return "Details...";
}
public boolean isEnabled() {
return !fViewer.getSelection().isEmpty();
}
});
Menu contextMenu = contextMenuManager.createContextMenu(fViewer.getControl());
getControl().setMenu(contextMenu);
fViewer.setInput(fInput);
}
use of org.eclipse.jst.jsp.core.taglib.TaglibIndexDelta in project webtools.sourceediting by eclipse.
the class TaglibIndexDeltaTraceView method showSelectionDetail.
void showSelectionDetail(final Composite composite) {
IStructuredSelection selection = (IStructuredSelection) fViewer.getSelection();
if (!selection.isEmpty()) {
final TaglibIndexDelta selectedDelta = (TaglibIndexDelta) selection.getFirstElement();
final ITableLabelProvider tableLabelProvider = ((ITableLabelProvider) fViewer.getLabelProvider());
String columnText = tableLabelProvider.getColumnText(selectedDelta, 1);
columnText = columnText + ":" + tableLabelProvider.getColumnText(selectedDelta, 2);
new Dialog(composite.getShell()) {
public void create() {
setShellStyle(getShellStyle() | SWT.RESIZE);
super.create();
}
protected Control createDialogArea(final Composite parent) {
final Composite inner = new Composite(parent, SWT.NONE);
inner.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
final Sash sash = new Sash(inner, SWT.HORIZONTAL);
final TreeViewer treeViewer = new TreeViewer(inner);
treeViewer.setContentProvider(new ITreeContentProvider() {
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
public void dispose() {
}
public Object[] getElements(Object inputElement) {
return getChildren(inputElement);
}
public boolean hasChildren(Object element) {
return getChildren(element).length > 0;
}
public Object getParent(Object element) {
return selectedDelta;
}
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof TaglibIndexDelta) {
TaglibIndexDelta taglibIndexDelta = ((TaglibIndexDelta) parentElement);
if (taglibIndexDelta.getTrigger() != null) {
List combined = new ArrayList();
combined.add(taglibIndexDelta.getTrigger());
combined.addAll(Arrays.asList(taglibIndexDelta.getAffectedChildren()));
return combined.toArray();
}
return taglibIndexDelta.getAffectedChildren();
}
return new Object[0];
}
});
treeViewer.setLabelProvider(new LabelProvider() {
public String getText(Object element) {
if (element instanceof ITaglibIndexDelta) {
ITaglibIndexDelta taglibIndexDelta = ((ITaglibIndexDelta) element);
if (taglibIndexDelta.getTaglibRecord() != null)
return taglibIndexDelta.toString();
String text = tableLabelProvider.getColumnText(selectedDelta, 1);
text = text + ":" + tableLabelProvider.getColumnText(selectedDelta, 2);
return text;
}
return StringUtils.firstLineOf(super.getText(element));
}
});
treeViewer.setInput(selectedDelta);
final Text text = new Text(inner, SWT.MULTI);
treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection2 = (IStructuredSelection) treeViewer.getSelection();
if (!selection2.isEmpty())
text.setText("" + (selection2).getFirstElement());
else
text.setText("");
}
});
final FormLayout form = new FormLayout();
inner.setLayout(form);
FormData firstData = new FormData();
firstData.top = new FormAttachment(0, 0);
firstData.bottom = new FormAttachment(sash, 2);
firstData.left = new FormAttachment(0, 0);
firstData.right = new FormAttachment(100, 0);
treeViewer.getControl().setLayoutData(firstData);
FormData secondData = new FormData();
secondData.top = new FormAttachment(sash, 2);
secondData.left = new FormAttachment(0, 0);
secondData.right = new FormAttachment(100, 0);
secondData.bottom = new FormAttachment(100, 0);
text.setLayoutData(secondData);
final FormData sashData = new FormData();
sashData.top = new FormAttachment(60, 0);
sashData.left = new FormAttachment(0, 0);
sashData.right = new FormAttachment(100, 0);
sash.setLayoutData(sashData);
sash.addListener(SWT.Selection, new org.eclipse.swt.widgets.Listener() {
public void handleEvent(Event e) {
sashData.top = new FormAttachment(0, e.y);
inner.layout();
}
});
return sash;
}
}.open();
}
}
Aggregations