use of org.eclipse.jface.action.StatusLineContributionItem 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.StatusLineContributionItem in project GT by Tencent.
the class StatusBar method init.
@SuppressWarnings("restriction")
public void init() {
WorkbenchWindow curworkbenchWindow = (WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow();
curworkbenchWindow.setStatusLineVisible(true);
lineManager = curworkbenchWindow.getStatusLineManager();
statusItem = new StatusLineContributionItem("APT", 100);
lineManager.add(statusItem);
}
use of org.eclipse.jface.action.StatusLineContributionItem in project cubrid-manager by CUBRID.
the class CubridStatusLineContrItem method updateStatusLine.
/**
*
* Update the status line information
*
* @param statusLineManager StatusLineManager
* @param cubridNode The selected ICubridNode object
*/
protected void updateStatusLine(StatusLineManager statusLineManager, ICubridNode cubridNode) {
clearStatusLine();
updateStatusLineForRestoreQueryEditor();
if (!(cubridNode instanceof ISchemaNode)) {
return;
}
StringBuffer dbInfoStrBuffer = new StringBuffer();
ISchemaNode schemaNode = (ISchemaNode) cubridNode;
CubridDatabase database = schemaNode.getDatabase();
if (database == null || database.getDatabaseInfo() == null) {
return;
}
DatabaseInfo dbInfo = database.getDatabaseInfo();
DbUserInfo dbUserInfo = dbInfo.getAuthLoginedDbUserInfo();
if (dbUserInfo == null || dbUserInfo.getName() == null || dbUserInfo.getName().trim().length() == 0) {
dbInfoStrBuffer.append(dbInfo.getDbName());
} else {
dbInfoStrBuffer.append(dbUserInfo.getName() + "@" + dbInfo.getDbName());
}
String brokerPort = database.getDatabaseInfo().getBrokerPort();
if (brokerPort != null && brokerPort.trim().length() > 0) {
dbInfoStrBuffer.append(":").append(brokerPort);
}
String charset = database.getDatabaseInfo().getCharSet();
if (charset != null && charset.trim().length() > 0) {
dbInfoStrBuffer.append(":charset=").append(charset);
}
String numberStr = getChilderenNumStr(cubridNode);
int addWidth = 30;
if (numberStr != null && numberStr.length() > 0) {
StatusLineContributionItem item = new StatusLineContributionItem(OBJ_NUM_INFO_CONTR_ID, numberStr.length() + 3);
statusLineManager.add(item);
item.setText(numberStr);
addWidth = 10;
}
StatusLineContributionItem item = new StatusLineContributionItem(DB_INFO_CONTR_ID, dbInfoStrBuffer.length() + addWidth);
statusLineManager.add(item);
item.setText(dbInfoStrBuffer.toString());
}
use of org.eclipse.jface.action.StatusLineContributionItem in project cubrid-manager by CUBRID.
the class CubridStatusLineContrItem method updateStatusLine.
/**
*
* Update the status line information
*
* @param statusLineManager StatusLineManager
* @param cubridNode The selected ICubridNode object
*/
protected void updateStatusLine(StatusLineManager statusLineManager, ICubridNode cubridNode) {
clearStatusLine();
updateStatusLineForRestoreQueryEditor();
if (cubridNode == null || cubridNode.getServer() == null || cubridNode.getServer().getServerInfo() == null) {
return;
}
String serverInfoStr = cubridNode.getServer().getLabel();
if (!DatabaseNavigatorMenu.SELF_DATABASE_ID.equals(cubridNode.getId())) {
ServerUserInfo userInfo = cubridNode.getServer().getServerInfo().getLoginedUserInfo();
if (userInfo != null && userInfo.getUserName() != null && userInfo.getUserName().trim().length() > 0) {
serverInfoStr = userInfo.getUserName() + "@" + serverInfoStr;
}
String monPort = cubridNode.getServer().getMonPort();
if (monPort != null && monPort.trim().length() > 0) {
serverInfoStr = serverInfoStr + ":" + monPort;
}
}
StringBuffer dbInfoStrBuffer = new StringBuffer();
if (cubridNode instanceof ISchemaNode) {
ISchemaNode schemaNode = (ISchemaNode) cubridNode;
CubridDatabase database = schemaNode.getDatabase();
dbInfoStrBuffer.append(database.getDatabaseInfo().getDbName());
DbUserInfo dbUserInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
if (database.isLogined() && dbUserInfo != null && dbUserInfo.getName() != null && dbUserInfo.getName().trim().length() > 0) {
dbInfoStrBuffer = new StringBuffer(dbUserInfo.getName() + "@" + dbInfoStrBuffer.toString());
}
String brokerPort = QueryOptions.getBrokerPort(database.getDatabaseInfo());
BrokerInfos brokerInfos = database.getServer().getServerInfo().getBrokerInfos();
List<BrokerInfo> brokerInfoList = brokerInfos == null || brokerInfos.getBorkerInfoList() == null ? null : brokerInfos.getBorkerInfoList().getBrokerInfoList();
boolean isExist = false;
for (int i = 0; brokerInfoList != null && i < brokerInfoList.size(); i++) {
BrokerInfo brokerInfo = brokerInfoList.get(i);
if (brokerPort == null || brokerInfo.getPort() == null || brokerInfo.getPort().trim().length() == 0 || !brokerPort.equals(brokerInfo.getPort())) {
continue;
}
if (brokerPort.equals(brokerInfo.getPort())) {
isExist = true;
String status = brokerInfo.getState() == null || brokerInfo.getState().trim().equalsIgnoreCase("OFF") ? "OFF" : "ON";
String text = brokerInfo.getName() + "[" + brokerInfo.getPort() + "/" + status + "]";
dbInfoStrBuffer.append(":").append(text);
break;
}
}
if (!isExist && brokerPort != null && brokerPort.trim().length() > 0) {
dbInfoStrBuffer.append(":").append(brokerPort);
}
String charset = database.getDatabaseInfo().getCharSet();
if (charset != null && charset.trim().length() > 0) {
dbInfoStrBuffer.append(":charset=").append(charset);
}
}
String numberStr = getChilderenNumStr(cubridNode);
if (numberStr != null && numberStr.length() > 0) {
StatusLineContributionItem item = new StatusLineContributionItem(OBJ_NUM_INFO_CONTR_ID, numberStr.length() + 4);
statusLineManager.add(item);
item.setText(numberStr);
}
int addedWidth = 3;
if (dbInfoStrBuffer == null || dbInfoStrBuffer.length() == 0) {
addedWidth = 30;
}
StatusLineContributionItem item = new StatusLineContributionItem(SERVER_INFO_CONTR_ID, serverInfoStr.length() + addedWidth);
statusLineManager.add(item);
item.setText(serverInfoStr);
if (dbInfoStrBuffer != null && dbInfoStrBuffer.length() > 0) {
item = new StatusLineContributionItem(DB_INFO_CONTR_ID, dbInfoStrBuffer.length() + 3);
statusLineManager.add(item);
item.setText(dbInfoStrBuffer.toString());
}
}
use of org.eclipse.jface.action.StatusLineContributionItem in project tdi-studio-se by Talend.
the class SWTResourceFilteredTree method updateStatusLine.
/**
* Updates the status line.
*
* @param resourceElements The SWT resource elements
*/
public void updateStatusLine(ISWTResourceElement[] resourceElements) {
IStatusLineManager manager = actionBars.getStatusLineManager();
IContributionItem[] items = manager.getItems();
StatusLineContributionItem resourceCountContributionItem = null;
for (IContributionItem item : items) {
if (item instanceof StatusLineContributionItem) {
resourceCountContributionItem = (StatusLineContributionItem) item;
}
}
// create the status line
if (resourceCountContributionItem == null) {
//$NON-NLS-1$
resourceCountContributionItem = new StatusLineContributionItem("ResourceCountContributionItem");
manager.add(resourceCountContributionItem);
}
if (resourceElements == null) {
resourceCountContributionItem.setText(Util.ZERO_LENGTH_STRING);
return;
}
Map<String, Integer> resources = new HashMap<String, Integer>();
for (ISWTResourceElement resourceElement : resourceElements) {
//$NON-NLS-1$
String name = resourceElement.getName().split(" ")[0];
Integer count = resources.get(name);
resources.put(name, count == null ? 1 : ++count);
}
// set text on status line
List<String> list = new ArrayList<String>(resources.keySet());
Collections.sort(list);
StringBuffer buffer = new StringBuffer();
//$NON-NLS-1$
buffer.append("Total: ").append(resourceElements.length);
for (String name : list) {
//$NON-NLS-1$
buffer.append(", ").append(name);
//$NON-NLS-1$
buffer.append(": ").append(resources.get(name));
}
resourceCountContributionItem.setText(buffer.toString());
}
Aggregations