new Status(IStatus.ERROR,
DesignerPlugin.getDefault().toString(),
IStatus.ERROR,
"Parse error or internal Designer error.",
rootCause);
ErrorDialog dialog =
new ErrorDialog(
DesignerPlugin.getShell(),
"Exception happened",
"Designer error occurred.\nSelect Details>> for more information.\nSee the Error Log for more information.",
status, IStatus.ERROR) {
private Clipboard clipboard;
@Override
protected org.eclipse.swt.widgets.List createDropDownList(Composite parent) {
final org.eclipse.swt.widgets.List list = super.createDropDownList(parent);
list.removeAll();
// populate list using custom PrintWriter
list.add("Plug-in Provider: Google");
list.add("Plug-in Name: " + BrandingUtils.getBranding().getProductName());
list.add("Plug-in ID: org.eclipse");
//list.add("Plug-in Version: " + String.valueOf(product.getVersion()));
list.add("");
final PrintWriter printWriter = new PrintWriter(new Writer() {
@Override
public void write(char[] cbuf, int off, int len) throws IOException {
if (len != 2 && !(cbuf[0] == '\r' || cbuf[0] == '\n')) {
list.add(StringUtils.replace(new String(cbuf, off, len), "\t", " "));
}
}
@Override
public void flush() throws IOException {
}
@Override
public void close() throws IOException {
}
});
if (rootCause != null) {
rootCause.printStackTrace(printWriter);
list.add("");
list.add("Full stack trace (to see full context):");
}
exception.printStackTrace(printWriter);
// print config
list.add("");
// install own context menu
Menu menu = list.getMenu();
menu.dispose();
Menu copyMenu = new Menu(list);
MenuItem copyItem = new MenuItem(copyMenu, SWT.NONE);
copyItem.setText(JFaceResources.getString("copy")); //$NON-NLS-1$
copyItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
copyList(list);
}
public void widgetDefaultSelected(SelectionEvent e) {
copyList(list);
}
});
list.setMenu(copyMenu);
return list;
}
private void copyList(org.eclipse.swt.widgets.List list) {
if (clipboard != null) {
clipboard.dispose();
}
StringBuffer statusBuffer = new StringBuffer();
for (int i = 0; i < list.getItemCount(); ++i) {
statusBuffer.append(list.getItem(i));
statusBuffer.append("\r\n");
}
clipboard = new Clipboard(list.getDisplay());
clipboard.setContents(
new Object[]{statusBuffer.toString()},
new Transfer[]{TextTransfer.getInstance()});
}
@Override
public boolean close() {
if (clipboard != null) {
clipboard.dispose();
}
return super.close();
}
};
dialog.open();
}
}