package org.simantics.scl.ui.issues;
+import java.util.Iterator;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.part.ViewPart;
import org.simantics.scl.compiler.errors.ErrorSeverity;
import org.simantics.scl.osgi.SCLOsgi;
SCLIssuesContentProvider issuesContentProvider = new SCLIssuesContentProvider();
+ Clipboard clipboard;
+
public SCLIssuesView() {
super();
imageRegistry = Activator.getInstance().getImageRegistry();
@Override
public void createPartControl(Composite parent) {
+ this.clipboard = new Clipboard(parent.getDisplay());
+
this.parent = parent;
parent.setLayout(new FillLayout());
tableViewer = new TableViewer(parent,
- SWT.FULL_SELECTION | SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL);
+ SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
ColumnViewerToolTipSupport.enableFor(tableViewer);
tableViewer.setContentProvider(issuesContentProvider);
entry.openLocation();
}
});
+
+ IHandlerService serv = (IHandlerService) getSite().getService(IHandlerService.class);
+ serv.activateHandler(org.eclipse.ui.IWorkbenchCommandConstants.EDIT_COPY, new CopyHandler());
+ }
+
+ class CopyHandler extends AbstractHandler {
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ IStructuredSelection selection = tableViewer.getStructuredSelection();
+ if(!selection.isEmpty()) {
+ StringBuilder b = new StringBuilder();
+ for(Iterator it=selection.iterator();it.hasNext();) {
+ SCLIssuesTableEntry entry = (SCLIssuesTableEntry)it.next();
+ b.append(entry.moduleName).append('\t').append(entry.error.description).append('\n');
+ }
+ clipboard.setContents(new Object[] { b.toString() }, new Transfer[] { TextTransfer.getInstance() });
+ }
+ return null;
+ }
}
private void resizeColumns() {
public void dispose() {
super.dispose();
issuesContentProvider.dispose();
+ if(clipboard != null) {
+ clipboard.dispose();
+ clipboard = null;
+ }
}
}