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();
public void init(IViewSite site, IMemento memento)
throws PartInitException {
super.init(site, memento);
- IAction action = new Action("Refresh") {
+ IAction action = new Action(Messages.SCLIssuesView_Refresh) {
@Override
public void run() {
tableViewer.setInput(SCLOsgi.MODULE_REPOSITORY);
// issuesContentProvider.refresh()
}
};
- action.setImageDescriptor(imageRegistry.getDescriptor("arrow_refresh"));
+ action.setImageDescriptor(imageRegistry.getDescriptor("arrow_refresh")); //$NON-NLS-1$
site.getActionBars().getToolBarManager().add(action);
}
@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);
table.setLinesVisible(true);
column1 = new TableViewerColumn(tableViewer, SWT.NONE);
- column1.getColumn().setText("Module");
+ column1.getColumn().setText(Messages.SCLIssuesView_Module);
column1.getColumn().setWidth(COLUMN1_DEFAULT_WIDTH);
column1.getColumn().setResizable(true);
column1.setLabelProvider(new ColumnLabelProvider() {
public Image getImage(Object element) {
SCLIssuesTableEntry entry = (SCLIssuesTableEntry)element;
return entry.error.severity == ErrorSeverity.ERROR
- ? imageRegistry.get("error")
+ ? imageRegistry.get("error") //$NON-NLS-1$
: entry.error.severity == ErrorSeverity.IMPORT_ERROR
- ? imageRegistry.get("import_error")
- : imageRegistry.get("warning");
+ ? imageRegistry.get("import_error") //$NON-NLS-1$
+ : imageRegistry.get("warning"); //$NON-NLS-1$
}
});
column2 = new TableViewerColumn(tableViewer, SWT.NONE);
- column2.getColumn().setText("Description");
+ column2.getColumn().setText(Messages.SCLIssuesView_Description);
column2.getColumn().setResizable(false);
column2.setLabelProvider(new ColumnLabelProvider() {
@Override
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;
+ }
}
}