public void setupDirectoriesPage() { final List<?> selectedResources = mainPage.getSelectedResources(); final List<String> filesAndDirs = new ArrayList<String>(selectedResources.size()); final FileSystemStructureProvider provider = FileSystemStructureProvider.INSTANCE; for (final Object o : selectedResources) { final FileSystemElement fse = (FileSystemElement) o; final Object fso = fse.getFileSystemObject(); final String s = provider.getFullPath(fso); filesAndDirs.add(s); } final String projectPath = mainPage.getProjectPath().toString(); final ErlProjectImport epi = ErlideImport.importProject( BackendCore.getBackendManager().getIdeBackend(), projectPath, filesAndDirs); final IPath beamDir = new Path(epi.getBeamDir()); importIncludeAndSourceDirsPage.setup( projectPath, epi.getDirectories(), epi.getIncludeDirs(), epi.getSourceDirs(), beamDir); resources = epi.getResources(); final List<Object> fileSystemObjects = new ArrayList<Object>(); for (final Object o : selectedResources) { final FileSystemElement fse = (FileSystemElement) o; final Object fso = fse.getFileSystemObject(); final String s = provider.getFullPath(fso); if (epi.getResources().contains(s)) { fileSystemObjects.add(((FileSystemElement) o).getFileSystemObject()); } } }
public IBackend getBackend() { final IStructuredSelection sel = (IStructuredSelection) backends.getSelection(); if (sel.getFirstElement() != null) { final IBackend b = (IBackend) sel.getFirstElement(); return b; } final IBackend b = BackendCore.getBackendManager().getIdeBackend(); if (b != null) { backends.setSelection(new StructuredSelection(b)); return b; } return null; }
private IBackend createBackend() { final RuntimeInfo info = RuntimeInfo.copy(BackendCore.getRuntimeInfoManager().getErlideRuntime(), false); final String nodeName = Activator.getDefault().getPreferenceStore().getString(PreferenceNames.NODE_NAME); if (info != null) { try { info.setNodeName(nodeName); info.setStartShell(false); final EnumSet<BackendOptions> options = EnumSet.of(BackendOptions.AUTOSTART, BackendOptions.NO_CONSOLE); final ILaunchConfiguration launchConfig = getLaunchConfiguration(info, options); final IBackend b = BackendCore.getBackendFactory() .createBackend(new BackendData(launchConfig, ILaunchManager.RUN_MODE)); return b; } catch (final Exception e) { ErlLogger.error(e); } } return null; }
/** This is a callback that will allow us to create the viewer and initialize it. */ @Override public void createPartControl(final Composite parent) { final Composite container = new Composite(parent, SWT.NONE); final GridLayout thisLayout = new GridLayout(2, false); container.setLayout(thisLayout); thisLayout.marginWidth = 5; thisLayout.marginHeight = 5; thisLayout.makeColumnsEqualWidth = false; thisLayout.verticalSpacing = 1; final Label label = new Label(container, SWT.SHADOW_NONE); label.setText("Erlang backend node"); backends = new ComboViewer(container, SWT.SINGLE | SWT.V_SCROLL); final Combo combo = backends.getCombo(); combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); backends.getControl().setSize(new org.eclipse.swt.graphics.Point(319, 18)); backends.setContentProvider(new BackendContentProvider()); backends.setLabelProvider(new BackendLabelProvider()); backends.setInput(BackendCore.getBackendManager()); viewer = new TableViewer(container, SWT.SINGLE | SWT.V_SCROLL | SWT.FULL_SELECTION); final Table table = viewer.getTable(); final GridData layoutData = new GridData(SWT.FILL, SWT.FILL, false, true, 2, 1); table.setLayoutData(layoutData); final Table t = (Table) viewer.getControl(); final TableColumn colPid = new TableColumn(t, SWT.LEAD); colPid.setText("Pid/Name"); colPid.setWidth(150); final TableColumn colStart = new TableColumn(t, SWT.LEAD); colStart.setText("Initial call"); colStart.setWidth(300); final TableColumn colReds = new TableColumn(t, SWT.LEAD); colReds.setText("Reds"); colReds.setWidth(80); final TableColumn colMsgs = new TableColumn(t, SWT.LEAD); colMsgs.setText("Msgs"); colMsgs.setWidth(60); viewer.setContentProvider(new ViewContentProvider()); viewer.setLabelProvider(new ViewLabelProvider()); // viewer.setSorter(new NameSorter()); viewer.setInput(getViewSite()); viewer.addDoubleClickListener( new IDoubleClickListener() { public void doubleClick(final DoubleClickEvent event) { doubleClickAction.run(); } }); t.setLinesVisible(true); t.setHeaderVisible(true); // TODO this is wrong - all backends should be inited final IRpcCallSite ideBackend = BackendCore.getBackendManager().getIdeBackend(); if (ideBackend != null) { ErlideProclist.processListInit(ideBackend); } BackendCore.getBackendManager() .forEachBackend( new IErlideBackendVisitor() { public void visit(final IBackend b) { ErlideProclist.processListInit(b); } }); makeActions(); hookContextMenu(); hookDoubleClickAction(); contributeToActionBars(); }
@Override protected IProject[] build( final int kind, @SuppressWarnings("rawtypes") final Map args, final IProgressMonitor monitor) throws CoreException { final IProject project = getProject(); if (project == null || !project.isAccessible()) { return new IProject[0]; } if (BuilderHelper.isDebugging()) { ErlLogger.debug( "Starting build " + helper.buildKind(kind) + " of " + project.getName() + " @ " + new Date(System.currentTimeMillis())); } try { MarkerUtils.deleteMarkers(project); initializeBuilder(monitor); final OtpErlangList compilerOptions = CompilerPreferences.get(project); ErlLogger.debug("******** building %s: %s", getProject().getName(), compilerOptions); final Set<String> resourcesToBuild = getResourcesToBuild(kind, args, project); final int n = resourcesToBuild.size(); if (n > 0) { final IBackend backend = BackendCore.getBackendManager().getBuildBackend(project); if (backend == null) { final String message = "No backend with the required " + "version could be found. Can't build."; MarkerUtils.addProblemMarker(project, null, null, message, 0, IMarker.SEVERITY_ERROR); throw new BackendException(message); } notifier.setProgressPerCompilationUnit(1.0f / n); final IPath projectPath = project.getLocation(); final IErlProject erlProject = CoreScope.getModel().getErlangProject(project); final String outputDir = projectPath.append(erlProject.getOutputLocation()).toString(); helper.ensureDirExists(outputDir); final Collection<IPath> includeDirs = helper.getAllIncludeDirs(project); final RpcEventProcessor processor = new RpcEventProcessor(new BuildHandler(), backend.createMbox()); final OtpErlangPid watcher = processor.getPid(); final OtpErlangPid builder = (OtpErlangPid) backend.call( "erlide_builder", "build_resources", "lsslsxp", resourcesToBuild, outputDir, includeDirs, compilerOptions, watcher); processor.setStarter(builder); processor.run(); } } catch (final Exception e) { ErlLogger.error(e); final String msg = NLS.bind(BuilderMessages.build_inconsistentProject, e.getLocalizedMessage()); MarkerUtils.addProblemMarker(project, null, null, msg, 0, IMarker.SEVERITY_ERROR); } finally { cleanup(); if (BuilderHelper.isDebugging()) { ErlLogger.debug( "Finished build of " + project.getName() // $NON-NLS-1$ + " @ " + new Date(System.currentTimeMillis())); } } return null; }