X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.ui%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fui%2Fissues%2FSCLIssuesView.java;h=9f4994eb1ddd42b141d680a370e0b60be1018cbe;hb=1dfeb7d5;hp=adc7def7902191c30158494ab8ba45e4e06ee556;hpb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/issues/SCLIssuesView.java b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/issues/SCLIssuesView.java index adc7def79..9f4994eb1 100644 --- a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/issues/SCLIssuesView.java +++ b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/issues/SCLIssuesView.java @@ -1,5 +1,10 @@ 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; @@ -11,6 +16,9 @@ import org.eclipse.jface.viewers.IStructuredSelection; 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; @@ -23,10 +31,12 @@ import org.eclipse.swt.widgets.Table; 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; +import org.simantics.scl.osgi.issues.SCLIssuesTableEntry; import org.simantics.scl.ui.Activator; -import org.simantics.scl.ui.editor2.OpenSCLDefinition; public class SCLIssuesView extends ViewPart { @@ -40,6 +50,10 @@ public class SCLIssuesView extends ViewPart { ImageRegistry imageRegistry; + SCLIssuesContentProvider issuesContentProvider = new SCLIssuesContentProvider(); + + Clipboard clipboard; + public SCLIssuesView() { super(); imageRegistry = Activator.getInstance().getImageRegistry(); @@ -52,7 +66,8 @@ public class SCLIssuesView extends ViewPart { IAction action = new Action("Refresh") { @Override public void run() { - SCLOsgi.MODULE_REPOSITORY.getSourceRepository().checkUpdates(); + tableViewer.setInput(SCLOsgi.MODULE_REPOSITORY); +// issuesContentProvider.refresh() } }; action.setImageDescriptor(imageRegistry.getDescriptor("arrow_refresh")); @@ -61,12 +76,14 @@ public class SCLIssuesView extends ViewPart { @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(new SCLIssuesContentProvider()); + tableViewer.setContentProvider(issuesContentProvider); Table table = tableViewer.getTable(); table.setHeaderVisible(true); @@ -84,7 +101,12 @@ public class SCLIssuesView extends ViewPart { } @Override public Image getImage(Object element) { - return imageRegistry.get("error"); + SCLIssuesTableEntry entry = (SCLIssuesTableEntry)element; + return entry.error.severity == ErrorSeverity.ERROR + ? imageRegistry.get("error") + : entry.error.severity == ErrorSeverity.IMPORT_ERROR + ? imageRegistry.get("import_error") + : imageRegistry.get("warning"); } }); @@ -136,9 +158,28 @@ public class SCLIssuesView extends ViewPart { public void doubleClick(DoubleClickEvent event) { IStructuredSelection selection = (IStructuredSelection)event.getSelection(); SCLIssuesTableEntry entry = (SCLIssuesTableEntry)selection.getFirstElement(); - OpenSCLDefinition.openDefinition(entry.moduleName, entry.error.location); + 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() { @@ -165,5 +206,15 @@ public class SCLIssuesView extends ViewPart { public void setFocus() { tableViewer.getControl().setFocus(); } + + @Override + public void dispose() { + super.dispose(); + issuesContentProvider.dispose(); + if(clipboard != null) { + clipboard.dispose(); + clipboard = null; + } + } }