use of org.eclipse.jface.action.IStatusLineManager in project tdi-studio-se by Talend.
the class AbstractFilteredTree method updateStatusLine.
/**
* Updates the status line.
*
* @param selection the selection
*/
public void updateStatusLine(IStructuredSelection selection) {
IStatusLineManager manager = actionBars.getStatusLineManager();
IContributionItem[] items = manager.getItems();
StatusLineContributionItem selfTimeStatusLineItem = null;
for (IContributionItem item : items) {
if (item instanceof StatusLineContributionItem) {
selfTimeStatusLineItem = (StatusLineContributionItem) item;
}
}
// create the status line
if (selfTimeStatusLineItem == null) {
//$NON-NLS-1$
selfTimeStatusLineItem = new StatusLineContributionItem("SelfTimeContributionItem");
manager.add(selfTimeStatusLineItem);
}
// clear the status line
if (selection == null) {
selfTimeStatusLineItem.setText(Util.ZERO_LENGTH_STRING);
return;
}
// set text on status line
double percentage = 0;
double time = 0;
for (Object object : selection.toArray()) {
if (object instanceof IMethodNode) {
percentage += ((IMethodNode) object).getSelfTimeInPercentage();
time += ((IMethodNode) object).getSelfTime();
}
}
String text = Util.ZERO_LENGTH_STRING;
if (percentage != 0) {
//$NON-NLS-1$
text = String.format("Self Time: %.0fms %.1f", time, percentage) + '%';
}
selfTimeStatusLineItem.setText(text);
}
use of org.eclipse.jface.action.IStatusLineManager in project ACS by ACS-Community.
the class ApplicationWorkbenchWindowAdvisor method postWindowOpen.
public void postWindowOpen() {
final IStatusLineManager status = getWindowConfigurer().getActionBarConfigurer().getStatusLineManager();
status.setMessage("Application starting...");
final Display display = getWindowConfigurer().getWindow().getShell().getDisplay();
// Disables the initial view
IViewReference[] views = getWindowConfigurer().getWindow().getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences();
for (int i = 0; i < views.length; i++) {
if (views[i].getId().compareTo(AlarmSystemView.ID) == 0)
((IMyViewPart) views[i].getView(false)).setEnabled(false);
}
boolean authenticated = false;
AuthenticationDialog d = new AuthenticationDialog(ApplicationWorkbenchWindowAdvisor.this.getWindowConfigurer().getWindow().getShell());
UserAuthenticator.Role role = null;
while (!authenticated) {
d.open();
UserAuthenticator userAuth = new UserAuthenticator();
try {
role = userAuth.authenticate(d.getUser(), d.getPassword());
} catch (UserAuthenticatorException e) {
d.setErrorMessage("Authentication unsuccessful");
continue;
} catch (IllegalArgumentException e) {
d.setErrorMessage("Please authenticate yourselve");
continue;
} finally {
status.setMessage("Authentication successful");
}
authenticated = true;
}
final UserAuthenticator.Role finalRole = role;
new Thread(new Runnable() {
@Override
public void run() {
AlarmSystemManager asm = AlarmSystemManager.getInstance(finalRole);
try {
display.asyncExec(new Runnable() {
public void run() {
status.setMessage("Connecting to Manager");
}
});
asm.connectToManager();
display.asyncExec(new Runnable() {
public void run() {
status.setMessage("Connecting to CDB DAL");
}
});
asm.connectToDAL();
display.asyncExec(new Runnable() {
public void run() {
status.setMessage("Loading contents from the CDB");
}
});
asm.loadFromCDB();
final String error = asm.checkCDB();
if (error.compareTo("") != 0) {
display.asyncExec(new Runnable() {
public void run() {
ErrorDialog edialog = new ErrorDialog(getWindowConfigurer().getWindow().getShell(), "CDB Error", "Error while checking CDB integrity", new Status(IStatus.ERROR, "cl.utfsm.acs.acg", error), IStatus.ERROR);
edialog.setBlockOnOpen(true);
edialog.open();
}
});
}
} catch (Exception e) {
e.printStackTrace();
display.asyncExec(new Runnable() {
public void run() {
status.setErrorMessage("Couldn't successfully connect to AS configuation");
}
});
return;
}
/* If everything went OK:
* Show the other views
* Enable the widgets and inform the user */
display.asyncExec(new Runnable() {
public void run() {
IWorkbenchPage page = getWindowConfigurer().getWindow().getActivePage();
try {
if (finalRole == Role.Administrator || finalRole == Role.Operator) {
page.showView(SourcesView.ID, null, IWorkbenchPage.VIEW_VISIBLE);
page.showView(CategoriesView.ID, null, IWorkbenchPage.VIEW_VISIBLE);
page.showView(AlarmsView.ID, null, IWorkbenchPage.VIEW_VISIBLE);
page.showView(ReductionsView.ID, null, IWorkbenchPage.VIEW_VISIBLE);
page.showView("org.eclipse.pde.runtime.LogView", null, IWorkbenchPage.VIEW_VISIBLE);
}
} catch (PartInitException e) {
status.setErrorMessage("Cannot open other views");
}
IViewReference[] views = page.getViewReferences();
for (int i = 0; i < views.length; i++) {
if (views[i].getId().compareTo(AlarmSystemView.ID) == 0)
((IMyViewPart) views[i].getView(false)).setEnabled(true);
if (finalRole == Role.Operator)
if (views[i].getView(false) instanceof IMyViewPart)
((IMyViewPart) views[i].getView(false)).setReadOnly(true);
}
status.setMessage("Application started successfully");
}
});
}
}).start();
}
use of org.eclipse.jface.action.IStatusLineManager in project eclipse.platform.text by eclipse.
the class LockJob method setUp.
@Before
public void setUp() throws Exception {
IFolder folder = ResourceHelper.createFolder("FileDocumentProviderTestProject/test");
file = (File) ResourceHelper.createFile(folder, "file.txt", "");
assertTrue(file.exists());
fsManager = file.getLocalManager();
assertTrue(fsManager.fastIsSynchronized(file));
stopLockingFlag = new AtomicBoolean(false);
stoppedByTest = new AtomicBoolean(false);
fileProvider = new FileDocumentProviderMock();
lockJob = new LockJob("Locking workspace", file, stopLockingFlag, stoppedByTest);
// We need the editor only to get the default editor status line manager
IWorkbench workbench = PlatformUI.getWorkbench();
page = workbench.getActiveWorkbenchWindow().getActivePage();
editor = IDE.openEditor(page, file);
TestUtil.runEventLoop();
IStatusLineManager statusLineManager = editor.getEditorSite().getActionBars().getStatusLineManager();
// This is default monitor which almost all editors are using
IProgressMonitor progressMonitor = statusLineManager.getProgressMonitor();
assertNotNull(progressMonitor);
assertFalse(progressMonitor instanceof NullProgressMonitor);
assertFalse(progressMonitor instanceof EventLoopProgressMonitor);
assertTrue(progressMonitor instanceof IProgressMonitorWithBlocking);
// Because this monitor is not EventLoopProgressMonitor, it will not
// process UI events while waiting on workspace lock
fileProvider.setProgressMonitor(progressMonitor);
TestUtil.waitForJobs(500, 5000);
Job[] jobs = Job.getJobManager().find(null);
String jobsList = Arrays.toString(jobs);
System.out.println("Still running jobs: " + jobsList);
if (!Job.getJobManager().isIdle()) {
jobs = Job.getJobManager().find(null);
for (Job job : jobs) {
System.out.println("Going to cancel: " + job.getName() + " / " + job);
job.cancel();
}
}
}
use of org.eclipse.jface.action.IStatusLineManager in project eclipse.platform.text by eclipse.
the class FindNextAction method statusNotFound.
/**
* Sets the "no matches found" error message to the status line.
*
* @since 3.0
*/
private void statusNotFound() {
fWorkbenchPart.getSite().getShell().getDisplay().beep();
IStatusLineManager manager = getStatusLineManager();
if (manager == null)
return;
manager.setMessage(EditorMessages.FindNext_Status_noMatch_label);
}
use of org.eclipse.jface.action.IStatusLineManager in project yamcs-studio by yamcs.
the class RCPUtils method setStatusMessage.
/**
* Sets a message in the lower left status line. These messages are by
* rcp-design associated with a view.
*
* @param viewId
* the view from which the message originates
*/
public static void setStatusMessage(String viewId, String message) {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IViewSite site = window.getActivePage().findView(viewId).getViewSite();
IStatusLineManager mgr = site.getActionBars().getStatusLineManager();
mgr.setMessage(message);
}
Aggregations