use of org.eclipse.swt.widgets.Display in project cubrid-manager by CUBRID.
the class CubridBrokerFolderLoader method load.
/**
*
* Load children object for parent
*
* @param parent the parent node
* @param monitor the IProgressMonitor object
*/
public void load(final ICubridNode parent, final IProgressMonitor monitor) {
synchronized (this) {
if (isLoaded()) {
return;
}
//when refresh broker,firstly check whether this broker exist
int ret = checkBrokerExist(parent, monitor);
if (ret == 1 || ret == 2) {
setLoaded(true);
return;
}
if (ret != 0) {
Display display = Display.getDefault();
display.syncExec(new Runnable() {
public void run() {
CommonUITool.openErrorBox(Messages.errBrokerNoExist);
CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
TreeViewer treeViewer = navigatorView == null ? null : navigatorView.getViewer();
if (treeViewer != null) {
CommonUITool.refreshNavigatorTree(treeViewer, parent.getParent());
}
}
});
setLoaded(true);
return;
}
// add sql log folder
String sqlLogFolderId = parent.getId() + NODE_SEPARATOR + SQL_LOG_FOLDER_ID;
ICubridNode sqlLogFolder = parent.getChild(sqlLogFolderId);
if (sqlLogFolder == null) {
sqlLogFolder = new DefaultCubridNode(sqlLogFolderId, SQL_LOG_FOLDER_NAME, "icons/navigator/folder.png");
sqlLogFolder.setType(CubridNodeType.BROKER_SQL_LOG_FOLDER);
sqlLogFolder.setContainer(true);
parent.addChild(sqlLogFolder);
}
//add the children of sql log folder
ServerInfo serverInfo = parent.getServer().getServerInfo();
BrokerLogInfos brokerLogInfos = new BrokerLogInfos();
final CommonQueryTask<BrokerLogInfos> task = new CommonQueryTask<BrokerLogInfos>(serverInfo, CommonSendMsg.getGetBrokerLogFileInfoMSGItems(), brokerLogInfos);
task.setBroker(parent.getLabel());
monitorCancel(monitor, new ITask[] { task });
task.execute();
final String errorMsg = task.getErrorMsg();
if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
sqlLogFolder.removeAllChild();
openErrorBox(errorMsg);
setLoaded(true);
return;
}
if (monitor.isCanceled()) {
setLoaded(true);
return;
}
sqlLogFolder.removeAllChild();
brokerLogInfos = task.getResultModel();
List<LogInfo> logInfoList = brokerLogInfos == null ? null : brokerLogInfos.getBrokerLogInfoList().getLogFileInfoList();
if (logInfoList != null && !logInfoList.isEmpty()) {
for (LogInfo logInfo : logInfoList) {
String id = sqlLogFolder.getId() + NODE_SEPARATOR + logInfo.getName();
ICubridNode logInfoNode = new DefaultCubridNode(id, logInfo.getName(), "icons/navigator/sqllog_item.png");
logInfoNode.setContainer(false);
logInfoNode.setEditorId(LogEditorPart.ID);
logInfoNode.setModelObj(logInfo);
if (LogType.SCRIPT.getText().toLowerCase().equals(logInfo.getType())) {
logInfoNode.setType(CubridNodeType.BROKER_SQL_LOG);
sqlLogFolder.addChild(logInfoNode);
}
}
}
Collections.sort(sqlLogFolder.getChildren());
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
use of org.eclipse.swt.widgets.Display in project bndtools by bndtools.
the class PackageDecorator method updateDecoration.
public static void updateDecoration(IProject project, Project model) throws Exception {
if (!project.isOpen()) {
return;
}
IJavaProject javaProject = JavaCore.create(project);
if (javaProject == null) {
// project is not a java project
return;
}
boolean changed = false;
for (IClasspathEntry cpe : javaProject.getRawClasspath()) {
if (cpe.getEntryKind() != IClasspathEntry.CPE_SOURCE) {
continue;
}
for (IPackageFragmentRoot pkgRoot : javaProject.findPackageFragmentRoots(cpe)) {
assert pkgRoot.getKind() == IPackageFragmentRoot.K_SOURCE;
IResource pkgRootResource = pkgRoot.getCorrespondingResource();
if (pkgRootResource == null) {
continue;
}
File pkgRootFile = pkgRootResource.getLocation().toFile();
boolean pkgInSourcePath = model.getSourcePath().contains(pkgRootFile);
for (IJavaElement child : pkgRoot.getChildren()) {
IPackageFragment pkg = (IPackageFragment) child;
assert pkg.getKind() == IPackageFragmentRoot.K_SOURCE;
IResource pkgResource = pkg.getCorrespondingResource();
if (pkgResource == null) {
continue;
}
String text = pkgResource.getPersistentProperty(packageDecoratorKey);
if (pkgInSourcePath) {
String pkgName = pkg.getElementName();
// Decorate if exported package
Attrs pkgAttrs = model.getExports().getByFQN(pkgName);
if (pkgAttrs != null) {
StringBuilder sb = new StringBuilder(" ").append(Version.parseVersion(pkgAttrs.getVersion()));
pkgAttrs = model.getImports().getByFQN(pkgName);
if (pkgAttrs != null) {
String versionRange = pkgAttrs.getVersion();
if (versionRange != null) {
sb.append('↔').append(versionRange);
}
}
String version = sb.toString();
if (!version.equals(text)) {
pkgResource.setPersistentProperty(packageDecoratorKey, version);
changed = true;
}
continue;
}
// Decorate if non-empty, non-contained package
if (pkg.containsJavaResources() && !model.getContained().containsFQN(pkgName)) {
if (!excluded.equals(text)) {
pkgResource.setPersistentProperty(packageDecoratorKey, excluded);
changed = true;
}
continue;
}
}
// Clear decoration
if (text != null) {
pkgResource.setPersistentProperty(packageDecoratorKey, null);
changed = true;
}
}
}
}
// If decoration change, update display
if (changed) {
Display display = PlatformUI.getWorkbench().getDisplay();
SWTConcurrencyUtil.execForDisplay(display, true, new Runnable() {
@Override
public void run() {
PlatformUI.getWorkbench().getDecoratorManager().update(packageDecoratorId);
}
});
}
}
use of org.eclipse.swt.widgets.Display in project bndtools by bndtools.
the class ResolutionChoiceInteractCallback method processCandidates.
public void processCandidates(final Requirement requirement, Set<Capability> wired, final List<Capability> candidates) {
if (wired.size() > 0 || candidates.size() < 2)
return;
final Display display = PlatformUI.getWorkbench().getDisplay();
final AtomicInteger resultRef = new AtomicInteger();
Runnable runnable = new Runnable() {
public void run() {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
if (!shell.isDisposed()) {
ResolutionChoiceSelectionDialog dialog = new ResolutionChoiceSelectionDialog(shell, requirement, candidates);
resultRef.set(dialog.open());
} else {
resultRef.set(IDialogConstants.CANCEL_ID);
}
}
};
display.syncExec(runnable);
int result = resultRef.get();
if (result == IDialogConstants.CANCEL_ID)
throw new ResolveCancelledException();
}
use of org.eclipse.swt.widgets.Display in project bndtools by bndtools.
the class LaunchStatusHandler method handleStatus.
public Boolean handleStatus(final IStatus status, Object source) throws CoreException {
if (status.isOK())
return true;
final AtomicBoolean result = new AtomicBoolean();
Runnable uitask = new Runnable() {
public void run() {
LaunchStatusDialog dialog = new LaunchStatusDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), status);
int response = dialog.open();
result.set(response == Window.OK);
}
};
Display display = PlatformUI.getWorkbench().getDisplay();
if (display.getThread() == Thread.currentThread())
uitask.run();
else
display.syncExec(uitask);
return result.get();
}
use of org.eclipse.swt.widgets.Display in project bndtools by bndtools.
the class JAREntryPart method loadContent.
protected void loadContent() {
if (displayJob != null && displayJob.getState() != Job.NONE)
displayJob.cancel();
if (zipEntry != null && !zipEntry.isDirectory()) {
IEditorInput input = editor.getEditorInput();
final Display display = text.getDisplay();
final URI uri = URIHelper.retrieveFileURI(input);
if (uri != null) {
displayJob = new Job("Load zip content") {
@Override
protected IStatus run(IProgressMonitor monitor) {
File ioFile = new File(uri);
try (ZipFile zipFile = new ZipFile(ioFile)) {
final StringWriter writer = new StringWriter();
if (showAsText)
readAsText(zipFile, zipEntry, charsets[selectedCharset], writer, 1024 * 20, monitor);
else
readAsHex(zipFile, zipEntry, writer, 1024 * 20, 2, monitor);
display.asyncExec(new Runnable() {
@Override
public void run() {
setContent(writer.toString());
}
});
return Status.OK_STATUS;
} catch (IOException e) {
Status status = new Status(IStatus.ERROR, PluginConstants.PLUGIN_ID, 0, "I/O error reading JAR file contents", e);
// ErrorDialog.openError(getManagedForm().getForm().getShell(), "Error", null, status);
return status;
}
}
};
displayJob.schedule();
}
} else {
setContent("");
}
}
Aggregations