Skip to content

Commit

Permalink
Do refresh in workspace write lock
Browse files Browse the repository at this point in the history
---
 Signed-off-by: Peter Kriens <[email protected]>

Signed-off-by: Peter Kriens <[email protected]>
  • Loading branch information
pkriens committed Dec 24, 2023
1 parent 7294a89 commit 1eb30dd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
6 changes: 6 additions & 0 deletions biz.aQute.bndlib/src/aQute/bnd/build/Workspace.java
Original file line number Diff line number Diff line change
Expand Up @@ -1527,6 +1527,12 @@ public <T> T writeLocked(Callable<T> callable, long timeoutInMs) throws Exceptio
return workspaceLock.locked(workspaceLock.writeLock(), timeoutInMs, callable, () -> false);
}

public <T> void writeLocked(Runnable runnable) throws Exception {
writeLocked(() -> {
runnable.run();
return null;
});
}
public <T> T writeLocked(Callable<T> callable) throws Exception {
return workspaceLock.locked(workspaceLock.writeLock(), WORKSPACE_LOCK_DEFAULT_TIMEOUTMS, callable, () -> false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
Expand All @@ -40,6 +42,7 @@
import org.eclipse.ui.ide.IDE;

import aQute.bnd.build.Project;
import aQute.bnd.build.Workspace;
import aQute.bnd.build.model.BndEditModel;
import bndtools.Plugin;
import bndtools.central.Central;
Expand Down Expand Up @@ -297,16 +300,25 @@ public boolean performFinish() {
}
}
}

if (serviceApiEditor != null) {
getWorkbench().getActiveWorkbenchWindow()
.getActivePage()
.activate(serviceApiEditor);
}
// refresh whole workspace to update the inter-project relationships
try {
Central.getWorkspace()
.forceRefresh();
} catch (Exception e) {}

Job job = Job.create("refresh workspace", monitor -> {
Workspace workspace;
try {
workspace = Central.getWorkspace();
workspace.writeLocked(workspace::forceRefresh);
} catch (Exception e) {
throw new CoreException(Status.error("failed to refresh the workspace", e));
}
});
job.setRule(ResourcesPlugin.getWorkspace()
.getRoot());
job.schedule();
}
return result;
}
Expand Down

0 comments on commit 1eb30dd

Please sign in to comment.