Merge "Issue #1638 Created AWIPSWorkbenchAdvisor which sends MenuCreation request to run so core cave applications will not depend on uf.edex.menus being deployed in EDEX. Changed DbQuery to use DbQueryRequest under the hood to remove dependency on ScriptCreator." into development
Former-commit-id:44f8ba8943
[formerly 805fae0df3b82e1e16a931741d22bf7637e6aa06] Former-commit-id:e4c1e86d55
This commit is contained in:
commit
5728a3e5b6
9 changed files with 110 additions and 324 deletions
|
@ -20,6 +20,20 @@
|
||||||
|
|
||||||
package com.raytheon.uf.viz.core.catalog;
|
package com.raytheon.uf.viz.core.catalog;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.raytheon.uf.common.dataquery.db.OrderField.ResultOrder;
|
||||||
|
import com.raytheon.uf.common.dataquery.requests.DbQueryRequest;
|
||||||
|
import com.raytheon.uf.common.dataquery.requests.DbQueryRequest.OrderMode;
|
||||||
|
import com.raytheon.uf.common.dataquery.requests.DbQueryRequest.RequestField;
|
||||||
|
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||||
|
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
|
||||||
|
import com.raytheon.uf.common.dataquery.responses.DbQueryResponse;
|
||||||
|
import com.raytheon.uf.viz.core.exception.VizException;
|
||||||
|
import com.raytheon.uf.viz.core.requests.ThriftClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a database query.
|
* Performs a database query.
|
||||||
*
|
*
|
||||||
|
@ -30,71 +44,25 @@ package com.raytheon.uf.viz.core.catalog;
|
||||||
* 06/05/08 #875 bphillip Initial Creation.
|
* 06/05/08 #875 bphillip Initial Creation.
|
||||||
* 06/12/08 M. Duff Added ordering and convenience methods.
|
* 06/12/08 M. Duff Added ordering and convenience methods.
|
||||||
* 10/13/08 chammack Improve error handling on server-side exceptions
|
* 10/13/08 chammack Improve error handling on server-side exceptions
|
||||||
|
* Mar 20, 2013 #1638 mschenke Rewrote to use DbQueryRequest under the hood to remove use of ScriptCreator
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author bphillip
|
* @author bphillip
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.raytheon.uf.common.dataquery.db.JoinField;
|
|
||||||
import com.raytheon.uf.common.dataquery.db.OrderField;
|
|
||||||
import com.raytheon.uf.common.dataquery.db.OrderField.ResultOrder;
|
|
||||||
import com.raytheon.uf.common.dataquery.db.ReturnedField;
|
|
||||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
|
||||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
|
|
||||||
import com.raytheon.uf.common.message.Message;
|
|
||||||
import com.raytheon.uf.common.message.response.AbstractResponseMessage;
|
|
||||||
import com.raytheon.uf.common.message.response.ResponseMessageError;
|
|
||||||
import com.raytheon.uf.common.message.response.ResponseMessageGeneric;
|
|
||||||
import com.raytheon.uf.viz.core.RecordFactory;
|
|
||||||
import com.raytheon.uf.viz.core.comm.Connector;
|
|
||||||
import com.raytheon.uf.viz.core.exception.VizException;
|
|
||||||
import com.raytheon.uf.viz.core.exception.VizServerSideException;
|
|
||||||
|
|
||||||
public class DbQuery {
|
public class DbQuery {
|
||||||
|
|
||||||
/** The database to query */
|
private DbQueryRequest request = new DbQueryRequest();
|
||||||
protected String dbName;
|
|
||||||
|
|
||||||
/** The class to query against */
|
private ResultOrder ascending = ResultOrder.ASC;
|
||||||
protected String className;
|
|
||||||
|
|
||||||
protected String plugin = "satellite";
|
|
||||||
|
|
||||||
protected ReturnedField distinctField;
|
|
||||||
|
|
||||||
protected String distinctClass;
|
|
||||||
|
|
||||||
protected List<ReturnedField> columns = new ArrayList<ReturnedField>();
|
|
||||||
|
|
||||||
protected List<OrderField> orderBy = new ArrayList<OrderField>();
|
|
||||||
|
|
||||||
protected List<JoinField> joinFields = new ArrayList<JoinField>();
|
|
||||||
|
|
||||||
protected ResultOrder ascending = ResultOrder.ASC;
|
|
||||||
|
|
||||||
protected Map<String, RequestConstraint> constraints = new HashMap<String, RequestConstraint>();
|
|
||||||
|
|
||||||
protected Integer maxResults;
|
|
||||||
|
|
||||||
public DbQuery(Class<?> clazz, String databaseName) {
|
public DbQuery(Class<?> clazz, String databaseName) {
|
||||||
this.className = clazz.getName();
|
request.setEntityClass(clazz);
|
||||||
this.dbName = databaseName;
|
request.setDatabase(databaseName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DbQuery(String pluginName) {
|
public DbQuery(String pluginName) {
|
||||||
try {
|
setPlugin(pluginName);
|
||||||
this.className = RecordFactory.getInstance()
|
|
||||||
.getPluginClass(pluginName).getName();
|
|
||||||
this.dbName = "metadata";
|
|
||||||
this.plugin = pluginName;
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -103,164 +71,30 @@ public class DbQuery {
|
||||||
* @return The response
|
* @return The response
|
||||||
* @throws VizException
|
* @throws VizException
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public List<Object[]> performQuery() throws VizException {
|
public List<Object[]> performQuery() throws VizException {
|
||||||
String query = assembleQuery();
|
DbQueryResponse response = (DbQueryResponse) ThriftClient
|
||||||
// System.out.println("[" + query + "]");
|
.sendRequest(request);
|
||||||
|
List<RequestField> fields = request.getFields();
|
||||||
Message message = Connector.getInstance().connectMessage(query, null,
|
if (fields == null || fields.size() == 0) {
|
||||||
60000);
|
fields = new ArrayList<RequestField>();
|
||||||
AbstractResponseMessage[] absresponses = message.getBody()
|
RequestField entity = new RequestField();
|
||||||
.getResponses();
|
entity.setField(DbQueryResponse.ENTITY_RESULT_KEY);
|
||||||
|
fields.add(entity);
|
||||||
List<Object[]> retVal = new ArrayList<Object[]>();
|
|
||||||
for (AbstractResponseMessage response : absresponses) {
|
|
||||||
|
|
||||||
if (response instanceof ResponseMessageGeneric) {
|
|
||||||
if (((ResponseMessageGeneric) response).getContents() instanceof List) {
|
|
||||||
ArrayList<?> list = (ArrayList) ((ResponseMessageGeneric) response)
|
|
||||||
.getContents();
|
|
||||||
Object[] vals = new Object[list.size()];
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
vals[i] = list.get(i);
|
|
||||||
}
|
|
||||||
retVal.add(vals);
|
|
||||||
} else {
|
|
||||||
Object obj = ((ResponseMessageGeneric) response)
|
|
||||||
.getContents();
|
|
||||||
Object[] vals = new Object[1];
|
|
||||||
vals[0] = obj;
|
|
||||||
retVal.add(vals);
|
|
||||||
}
|
|
||||||
} else if (response instanceof ResponseMessageError) {
|
|
||||||
ResponseMessageError rme = (ResponseMessageError) response;
|
|
||||||
VizServerSideException innerException = new VizServerSideException(
|
|
||||||
rme.toString());
|
|
||||||
throw new VizServerSideException(rme.getErrorMsg(),
|
|
||||||
innerException);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return retVal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Object[]> performQuery(boolean bool) throws VizException {
|
List<Map<String, Object>> results = response.getResults();
|
||||||
String query = assembleQuery();
|
List<Object[]> rval = new ArrayList<Object[]>(results.size());
|
||||||
System.out.println("[" + query + "]");
|
|
||||||
|
|
||||||
Message message = Connector.getInstance().connectMessage(query, null,
|
for (Map<String, Object> result : results) {
|
||||||
60000);
|
Object[] objs = new Object[fields.size()];
|
||||||
AbstractResponseMessage[] absresponses = message.getBody()
|
int i = 0;
|
||||||
.getResponses();
|
for (RequestField field : fields) {
|
||||||
|
objs[i++] = result.get(field.field);
|
||||||
List<Object[]> retVal = new ArrayList<Object[]>();
|
|
||||||
for (AbstractResponseMessage response : absresponses) {
|
|
||||||
|
|
||||||
if (response instanceof ResponseMessageGeneric) {
|
|
||||||
if (((ResponseMessageGeneric) response).getContents() instanceof List) {
|
|
||||||
ArrayList<?> list = (ArrayList<?>) ((ResponseMessageGeneric) response)
|
|
||||||
.getContents();
|
|
||||||
Object[] vals = new Object[list.size()];
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
vals[i] = list.get(i);
|
|
||||||
}
|
}
|
||||||
retVal.add(vals);
|
rval.add(objs);
|
||||||
} else {
|
|
||||||
Object obj = ((ResponseMessageGeneric) response)
|
|
||||||
.getContents();
|
|
||||||
Object[] vals = new Object[1];
|
|
||||||
vals[0] = obj;
|
|
||||||
retVal.add(vals);
|
|
||||||
}
|
|
||||||
} else if (response instanceof ResponseMessageError) {
|
|
||||||
ResponseMessageError rme = (ResponseMessageError) response;
|
|
||||||
VizServerSideException innerException = new VizServerSideException(
|
|
||||||
rme.toString());
|
|
||||||
throw new VizServerSideException(rme.getErrorMsg(),
|
|
||||||
innerException);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return retVal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
return rval;
|
||||||
* Assembles the database query
|
|
||||||
*
|
|
||||||
* @param dbName
|
|
||||||
* The database name
|
|
||||||
* @param className
|
|
||||||
* The class name to query for
|
|
||||||
* @param distinctField
|
|
||||||
* The distinct field (optional)
|
|
||||||
* @param columns
|
|
||||||
* The fields to be returned (required)
|
|
||||||
* @param constraints
|
|
||||||
* The constraints to apply to the query
|
|
||||||
* @return
|
|
||||||
* @throws VizException
|
|
||||||
*/
|
|
||||||
private String assembleQuery() throws VizException {
|
|
||||||
|
|
||||||
addConstraint("pluginName", plugin);
|
|
||||||
addConstraint("dbName", dbName);
|
|
||||||
addConstraint("className", className);
|
|
||||||
|
|
||||||
if (distinctField != null) {
|
|
||||||
addConstraint("distinctField",
|
|
||||||
new RequestConstraint(distinctField.getField()));
|
|
||||||
addConstraint("distinctClass", new RequestConstraint(distinctClass));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!columns.isEmpty()) {
|
|
||||||
StringBuffer fieldList = new StringBuffer();
|
|
||||||
for (int i = 0; i < columns.size(); i++) {
|
|
||||||
fieldList.append(columns.get(i).getField() + "---"
|
|
||||||
+ columns.get(i).getClassName());
|
|
||||||
if (i != columns.size() - 1) {
|
|
||||||
fieldList.append(",");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
addConstraint("columns", fieldList);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!joinFields.isEmpty()) {
|
|
||||||
StringBuffer joinFieldList = new StringBuffer();
|
|
||||||
for (int i = 0; i < joinFields.size(); i++) {
|
|
||||||
joinFieldList.append(joinFields.get(i).getJoinClassOne())
|
|
||||||
.append("---");
|
|
||||||
joinFieldList.append(joinFields.get(i).getJoinClassTwo())
|
|
||||||
.append("---");
|
|
||||||
joinFieldList.append(joinFields.get(i).getJoinFieldOne());
|
|
||||||
if (joinFields.get(i).getJoinFieldTwo() != null) {
|
|
||||||
joinFieldList.append("---");
|
|
||||||
joinFieldList.append(joinFields.get(i).getJoinFieldTwo());
|
|
||||||
}
|
|
||||||
if (i != joinFields.size() - 1) {
|
|
||||||
joinFieldList.append(",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
addConstraint("joinFields", joinFieldList);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!orderBy.isEmpty()) {
|
|
||||||
StringBuffer orderList = new StringBuffer();
|
|
||||||
for (int i = 0; i < orderBy.size(); i++) {
|
|
||||||
orderList.append(orderBy.get(i).getField() + "---"
|
|
||||||
+ orderBy.get(i).getClassName() + "---"
|
|
||||||
+ orderBy.get(i).getOrder());
|
|
||||||
if (i != orderBy.size() - 1) {
|
|
||||||
orderList.append(",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
addConstraint("orderBy", orderList);
|
|
||||||
addConstraint("sortOrder", String.valueOf(ascending));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (maxResults != null) {
|
|
||||||
addConstraint("maxResults", maxResults);
|
|
||||||
}
|
|
||||||
return ScriptCreator.createScript(constraints, Integer.MAX_VALUE,
|
|
||||||
"dbquery");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -268,12 +102,7 @@ public class DbQuery {
|
||||||
* the plugin to set
|
* the plugin to set
|
||||||
*/
|
*/
|
||||||
public void setPlugin(String plugin) {
|
public void setPlugin(String plugin) {
|
||||||
this.plugin = plugin;
|
request.addConstraint("pluginName", new RequestConstraint(plugin));
|
||||||
}
|
|
||||||
|
|
||||||
public void setDistinctField(String distinctField, String className) {
|
|
||||||
distinctClass = className;
|
|
||||||
this.distinctField = new ReturnedField(distinctField, className);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -281,14 +110,11 @@ public class DbQuery {
|
||||||
* the distinctField to set
|
* the distinctField to set
|
||||||
*/
|
*/
|
||||||
public void setDistinctField(String distinctField) {
|
public void setDistinctField(String distinctField) {
|
||||||
setDistinctField(distinctField, className);
|
request.setDistinct(true);
|
||||||
|
addColumn(distinctField);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addConstraint(String key, ConstraintType operator,
|
public void addConstraint(String key, ConstraintType operator, Object value) {
|
||||||
Object value, String className) {
|
|
||||||
if (constraints == null) {
|
|
||||||
constraints = new HashMap<String, RequestConstraint>();
|
|
||||||
}
|
|
||||||
RequestConstraint constraint = new RequestConstraint();
|
RequestConstraint constraint = new RequestConstraint();
|
||||||
|
|
||||||
switch (operator) {
|
switch (operator) {
|
||||||
|
@ -307,24 +133,16 @@ public class DbQuery {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
constraint.setConstraintType(operator);
|
constraint.setConstraintType(operator);
|
||||||
constraints.put(key, constraint);
|
request.addConstraint(key, constraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addConstraint(String key, RequestConstraint constraint) {
|
public void addConstraint(String key, RequestConstraint constraint) {
|
||||||
addConstraint(key, constraint.getConstraintType(),
|
addConstraint(key, constraint.getConstraintType(),
|
||||||
constraint.getConstraintValue(), className);
|
constraint.getConstraintValue());
|
||||||
}
|
|
||||||
|
|
||||||
public void addConstraint(String key, ConstraintType operator, Object value) {
|
|
||||||
addConstraint(key, operator, value, className);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addConstraint(String key, Object value) {
|
public void addConstraint(String key, Object value) {
|
||||||
addConstraint(key, ConstraintType.EQUALS, value, className);
|
addConstraint(key, ConstraintType.EQUALS, value);
|
||||||
}
|
|
||||||
|
|
||||||
public void addColumn(String columnName, String className) {
|
|
||||||
columns.add(new ReturnedField(columnName, className));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -334,12 +152,18 @@ public class DbQuery {
|
||||||
* A column name
|
* A column name
|
||||||
*/
|
*/
|
||||||
public void addColumn(String columnName) {
|
public void addColumn(String columnName) {
|
||||||
addColumn(columnName, className);
|
request.addRequestField(columnName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addOrderBy(String columnName, ResultOrder order) {
|
||||||
|
request.setOrderByField(columnName,
|
||||||
|
order == ResultOrder.ASC ? OrderMode.ASC : OrderMode.DESC);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void addOrderBy(String columnName, ResultOrder order,
|
public void addOrderBy(String columnName, ResultOrder order,
|
||||||
String className) {
|
String className) {
|
||||||
orderBy.add(new OrderField(columnName, className, order));
|
addOrderBy(columnName, order);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -349,7 +173,7 @@ public class DbQuery {
|
||||||
* A column name
|
* A column name
|
||||||
*/
|
*/
|
||||||
public void addOrderBy(String columnName) {
|
public void addOrderBy(String columnName) {
|
||||||
addOrderBy(columnName, ascending, className);
|
addOrderBy(columnName, ascending, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -369,16 +193,7 @@ public class DbQuery {
|
||||||
* - the maximum number of rows to return use -999 for all rows
|
* - the maximum number of rows to return use -999 for all rows
|
||||||
*/
|
*/
|
||||||
public void setMaxResults(Integer maxResults) {
|
public void setMaxResults(Integer maxResults) {
|
||||||
this.maxResults = maxResults;
|
request.setLimit(maxResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addJoinField(Class<?> class1, Class<?> class2, String field1,
|
|
||||||
String field2) {
|
|
||||||
joinFields.add(new JoinField(field1, field2, class1.getName(), class2
|
|
||||||
.getName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addJoinField(Class<?> class1, Class<?> class2, String field) {
|
|
||||||
addJoinField(class1, class2, field, field);
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -22,8 +22,6 @@ package com.raytheon.uf.viz.thinclient.cave;
|
||||||
import org.eclipse.jface.preference.IPreferencePage;
|
import org.eclipse.jface.preference.IPreferencePage;
|
||||||
import org.eclipse.jface.preference.PreferenceManager;
|
import org.eclipse.jface.preference.PreferenceManager;
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
|
|
||||||
import org.eclipse.ui.application.WorkbenchWindowAdvisor;
|
|
||||||
|
|
||||||
import com.raytheon.uf.viz.thinclient.cave.preferences.DynamicPreferenceNode;
|
import com.raytheon.uf.viz.thinclient.cave.preferences.DynamicPreferenceNode;
|
||||||
import com.raytheon.uf.viz.thinclient.cave.preferences.DynamicPreferenceNode.IPreferencePageFactory;
|
import com.raytheon.uf.viz.thinclient.cave.preferences.DynamicPreferenceNode.IPreferencePageFactory;
|
||||||
|
@ -32,7 +30,6 @@ import com.raytheon.uf.viz.thinclient.cave.preferences.ThinClientConnectionPrefe
|
||||||
import com.raytheon.uf.viz.thinclient.cave.preferences.ThinClientPreferencePage;
|
import com.raytheon.uf.viz.thinclient.cave.preferences.ThinClientPreferencePage;
|
||||||
import com.raytheon.uf.viz.thinclient.cave.preferences.ThinClientServerPreferences;
|
import com.raytheon.uf.viz.thinclient.cave.preferences.ThinClientServerPreferences;
|
||||||
import com.raytheon.viz.ui.personalities.awips.VizWorkbenchAdvisor;
|
import com.raytheon.viz.ui.personalities.awips.VizWorkbenchAdvisor;
|
||||||
import com.raytheon.viz.ui.personalities.awips.VizWorkbenchWindowAdvisor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thin Client workbench advisor, adds the thin client preference page
|
* Thin Client workbench advisor, adds the thin client preference page
|
||||||
|
@ -44,6 +41,7 @@ import com.raytheon.viz.ui.personalities.awips.VizWorkbenchWindowAdvisor;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Oct 21, 2011 mschenke Initial creation
|
* Oct 21, 2011 mschenke Initial creation
|
||||||
|
* Mar 20, 2013 1638 mschenke Removed overriding of createWorkbenchWindowAdvisor as not needed
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -53,13 +51,6 @@ import com.raytheon.viz.ui.personalities.awips.VizWorkbenchWindowAdvisor;
|
||||||
|
|
||||||
public class ThinClientWorkbenchAdvisor extends VizWorkbenchAdvisor {
|
public class ThinClientWorkbenchAdvisor extends VizWorkbenchAdvisor {
|
||||||
|
|
||||||
@Override
|
|
||||||
public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
|
|
||||||
IWorkbenchWindowConfigurer configurer) {
|
|
||||||
return new VizWorkbenchWindowAdvisor(configurer, singlePerspective,
|
|
||||||
false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
|
|
@ -54,7 +54,6 @@ import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||||
import com.raytheon.uf.common.status.UFStatus;
|
import com.raytheon.uf.common.status.UFStatus;
|
||||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||||
import com.raytheon.uf.viz.core.exception.VizException;
|
import com.raytheon.uf.viz.core.exception.VizException;
|
||||||
import com.raytheon.uf.viz.core.localization.LocalizationManager;
|
|
||||||
import com.raytheon.uf.viz.ui.menus.xml.IncludeMenuItem;
|
import com.raytheon.uf.viz.ui.menus.xml.IncludeMenuItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,6 +77,7 @@ import com.raytheon.uf.viz.ui.menus.xml.IncludeMenuItem;
|
||||||
* Apr 27, 2012 #562 dgilling Ensure call to MenuCreationJob
|
* Apr 27, 2012 #562 dgilling Ensure call to MenuCreationJob
|
||||||
* uses proper method to retrieve
|
* uses proper method to retrieve
|
||||||
* localized site.
|
* localized site.
|
||||||
|
* Mar 20, 2013 1638 mschenke Removed menu creation job use
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -94,36 +94,15 @@ public class DiscoverMenuContributions {
|
||||||
public static Schema schema;
|
public static Schema schema;
|
||||||
|
|
||||||
public static void discoverContributions() {
|
public static void discoverContributions() {
|
||||||
discoverContributions(new String[] { "menus" }, true);
|
discoverContributions(new String[] { "menus" });
|
||||||
}
|
|
||||||
|
|
||||||
public static void discoverContributions(boolean scheduleJob) {
|
|
||||||
discoverContributions(new String[] { "menus" }, scheduleJob);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void discoverContributions(final String[] menuArray) {
|
|
||||||
discoverContributions(menuArray, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized void discoverContributions(
|
public static synchronized void discoverContributions(
|
||||||
final String[] menuArray, boolean scheduleJob) {
|
final String[] menuArray) {
|
||||||
if (ran) {
|
if (ran) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scheduleJob) {
|
|
||||||
MenuCreationJob job = new MenuCreationJob(LocalizationManager
|
|
||||||
.getInstance().getSite());
|
|
||||||
|
|
||||||
job.schedule();
|
|
||||||
try {
|
|
||||||
job.join();
|
|
||||||
} catch (InterruptedException e2) {
|
|
||||||
statusHandler.handle(Priority.PROBLEM,
|
|
||||||
e2.getLocalizedMessage(), e2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ran = true;
|
ran = true;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ Require-Bundle: org.eclipse.ui,
|
||||||
com.raytheon.uf.common.serialization.comm;bundle-version="1.0.0",
|
com.raytheon.uf.common.serialization.comm;bundle-version="1.0.0",
|
||||||
org.eclipse.core.resources;bundle-version="3.6.0",
|
org.eclipse.core.resources;bundle-version="3.6.0",
|
||||||
com.raytheon.uf.viz.ui.menus;bundle-version="1.12.1174",
|
com.raytheon.uf.viz.ui.menus;bundle-version="1.12.1174",
|
||||||
|
com.raytheon.uf.common.menus;bundle-version="1.12.1174",
|
||||||
com.raytheon.uf.viz.application;bundle-version="1.0.0",
|
com.raytheon.uf.viz.application;bundle-version="1.0.0",
|
||||||
com.raytheon.viz.alerts;bundle-version="1.12.1174",
|
com.raytheon.viz.alerts;bundle-version="1.12.1174",
|
||||||
com.raytheon.uf.common.comm;bundle-version="1.12.1174"
|
com.raytheon.uf.common.comm;bundle-version="1.12.1174"
|
||||||
|
|
|
@ -17,22 +17,18 @@
|
||||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||||
* further licensing information.
|
* further licensing information.
|
||||||
**/
|
**/
|
||||||
package com.raytheon.uf.viz.ui.menus;
|
package com.raytheon.viz.ui.personalities.awips;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
|
||||||
import org.eclipse.core.runtime.IStatus;
|
|
||||||
import org.eclipse.core.runtime.Status;
|
|
||||||
import org.eclipse.core.runtime.jobs.Job;
|
|
||||||
|
|
||||||
import com.raytheon.uf.common.menus.MenuCreationRequest;
|
import com.raytheon.uf.common.menus.MenuCreationRequest;
|
||||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
|
||||||
import com.raytheon.uf.common.status.UFStatus;
|
import com.raytheon.uf.common.status.UFStatus;
|
||||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||||
import com.raytheon.uf.viz.core.exception.VizException;
|
import com.raytheon.uf.viz.core.exception.VizException;
|
||||||
|
import com.raytheon.uf.viz.core.localization.LocalizationManager;
|
||||||
import com.raytheon.uf.viz.core.requests.ThriftClient;
|
import com.raytheon.uf.viz.core.requests.ThriftClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Job to create the menus on demand in CAVE
|
* AWIPS {@link VizWorkbenchAdvisor} that reqeusts menu creation service to run
|
||||||
|
* before discovering dynamic menus
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
*
|
*
|
||||||
|
@ -40,43 +36,28 @@ import com.raytheon.uf.viz.core.requests.ThriftClient;
|
||||||
*
|
*
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Jun 23, 2011 mnash Initial creation
|
* Mar 20, 2013 mschenke Initial creation
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author mnash
|
* @author mschenke
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class MenuCreationJob extends Job {
|
public class AWIPSWorkbenchAdvisor extends VizWorkbenchAdvisor {
|
||||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
|
||||||
.getHandler(MenuCreationJob.class);
|
|
||||||
|
|
||||||
private String site = "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public MenuCreationJob(String site) {
|
|
||||||
super("Building CAVE menus for " + site + "...");
|
|
||||||
this.site = site;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run the menu generation code
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
protected void createDynamicMenus() {
|
||||||
// create the request to send to EDEX to generate the menus
|
// create the request to send to EDEX to generate the menus
|
||||||
MenuCreationRequest request = new MenuCreationRequest();
|
MenuCreationRequest request = new MenuCreationRequest();
|
||||||
request.setSite(site);
|
request.setSite(LocalizationManager.getInstance().getSite());
|
||||||
try {
|
try {
|
||||||
ThriftClient.sendRequest(request);
|
ThriftClient.sendRequest(request);
|
||||||
} catch (VizException e1) {
|
} catch (VizException e) {
|
||||||
statusHandler
|
UFStatus.getHandler(AWIPSWorkbenchAdvisor.class).handle(
|
||||||
.handle(Priority.PROBLEM, e1.getLocalizedMessage(), e1);
|
Priority.PROBLEM, e.getLocalizedMessage(), e);
|
||||||
return Status.CANCEL_STATUS;
|
|
||||||
}
|
}
|
||||||
return Status.OK_STATUS;
|
super.createDynamicMenus();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -255,7 +255,7 @@ public abstract class AbstractCAVEComponent implements IStandaloneComponent {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected WorkbenchAdvisor getWorkbenchAdvisor() {
|
protected WorkbenchAdvisor getWorkbenchAdvisor() {
|
||||||
return new VizWorkbenchAdvisor();
|
return new AWIPSWorkbenchAdvisor();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -45,6 +45,7 @@ import org.eclipse.ui.contexts.IContextService;
|
||||||
import com.raytheon.uf.viz.application.ProgramArguments;
|
import com.raytheon.uf.viz.application.ProgramArguments;
|
||||||
import com.raytheon.uf.viz.core.Activator;
|
import com.raytheon.uf.viz.core.Activator;
|
||||||
import com.raytheon.uf.viz.core.preferences.PreferenceConstants;
|
import com.raytheon.uf.viz.core.preferences.PreferenceConstants;
|
||||||
|
import com.raytheon.uf.viz.ui.menus.DiscoverMenuContributions;
|
||||||
import com.raytheon.viz.ui.VizWorkbenchManager;
|
import com.raytheon.viz.ui.VizWorkbenchManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,6 +57,7 @@ import com.raytheon.viz.ui.VizWorkbenchManager;
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* 7/1/06 chammack Initial Creation.
|
* 7/1/06 chammack Initial Creation.
|
||||||
* Mar 5, 2013 1753 njensen Added shutdown printout
|
* Mar 5, 2013 1753 njensen Added shutdown printout
|
||||||
|
* Mar 20, 2013 1638 mschenke Added overrideable method for dynamic menu creation
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -74,6 +76,8 @@ public class VizWorkbenchAdvisor extends WorkbenchAdvisor {
|
||||||
|
|
||||||
protected boolean singlePerspective;
|
protected boolean singlePerspective;
|
||||||
|
|
||||||
|
private boolean createdMenus = false;
|
||||||
|
|
||||||
public VizWorkbenchAdvisor() {
|
public VizWorkbenchAdvisor() {
|
||||||
performanceListener = CaveCommandExecutionListener.getInstance();
|
performanceListener = CaveCommandExecutionListener.getInstance();
|
||||||
jobChangeListener = CaveJobChangeListener.getInstance();
|
jobChangeListener = CaveJobChangeListener.getInstance();
|
||||||
|
@ -292,8 +296,11 @@ public class VizWorkbenchAdvisor extends WorkbenchAdvisor {
|
||||||
@Override
|
@Override
|
||||||
public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
|
public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
|
||||||
IWorkbenchWindowConfigurer configurer) {
|
IWorkbenchWindowConfigurer configurer) {
|
||||||
return new VizWorkbenchWindowAdvisor(configurer, singlePerspective,
|
if (createdMenus == false) {
|
||||||
true);
|
createdMenus = true;
|
||||||
|
createDynamicMenus();
|
||||||
|
}
|
||||||
|
return new VizWorkbenchWindowAdvisor(configurer, singlePerspective);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -330,6 +337,8 @@ public class VizWorkbenchAdvisor extends WorkbenchAdvisor {
|
||||||
public void postStartup() {
|
public void postStartup() {
|
||||||
super.postStartup();
|
super.postStartup();
|
||||||
|
|
||||||
|
// createDynamicMenus();
|
||||||
|
|
||||||
Boolean log = Activator.getDefault().getPreferenceStore()
|
Boolean log = Activator.getDefault().getPreferenceStore()
|
||||||
.getBoolean(PreferenceConstants.P_LOG_PERF);
|
.getBoolean(PreferenceConstants.P_LOG_PERF);
|
||||||
|
|
||||||
|
@ -341,6 +350,14 @@ public class VizWorkbenchAdvisor extends WorkbenchAdvisor {
|
||||||
service.activateContext("com.raytheon.uf.viz.application.awips");
|
service.activateContext("com.raytheon.uf.viz.application.awips");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uses {@link DiscoverMenuContributions} to create dynamic menu
|
||||||
|
* contributions
|
||||||
|
*/
|
||||||
|
protected void createDynamicMenus() {
|
||||||
|
DiscoverMenuContributions.discoverContributions();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggle whether we are logging or not
|
* Toggle whether we are logging or not
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -32,7 +32,6 @@ import org.eclipse.ui.application.IActionBarConfigurer;
|
||||||
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
|
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
|
||||||
import org.eclipse.ui.application.WorkbenchWindowAdvisor;
|
import org.eclipse.ui.application.WorkbenchWindowAdvisor;
|
||||||
|
|
||||||
import com.raytheon.uf.viz.ui.menus.DiscoverMenuContributions;
|
|
||||||
import com.raytheon.uf.viz.ui.menus.widgets.tearoff.TearOffMenuListener;
|
import com.raytheon.uf.viz.ui.menus.widgets.tearoff.TearOffMenuListener;
|
||||||
import com.raytheon.viz.ui.dialogs.ModeListener;
|
import com.raytheon.viz.ui.dialogs.ModeListener;
|
||||||
import com.raytheon.viz.ui.perspectives.AbstractVizPerspectiveManager;
|
import com.raytheon.viz.ui.perspectives.AbstractVizPerspectiveManager;
|
||||||
|
@ -48,6 +47,7 @@ import com.raytheon.viz.ui.statusline.VizActionBarAdvisor;
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* 7/1/06 chammack Initial Creation.
|
* 7/1/06 chammack Initial Creation.
|
||||||
* Oct 21, 2008 #1450 randerso Fixed to support multipane editors
|
* Oct 21, 2008 #1450 randerso Fixed to support multipane editors
|
||||||
|
* Mar 20, 2013 1638 mschenke Removed call to DiscoverMenuContributions as now handled in VizWorkbenchAdvisor
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -68,10 +68,9 @@ public class VizWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
|
||||||
* @param configurer
|
* @param configurer
|
||||||
*/
|
*/
|
||||||
public VizWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer,
|
public VizWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer,
|
||||||
boolean singlePerspective, boolean createMenuJob) {
|
boolean singlePerspective) {
|
||||||
super(configurer);
|
super(configurer);
|
||||||
this.singlePerspective = singlePerspective;
|
this.singlePerspective = singlePerspective;
|
||||||
DiscoverMenuContributions.discoverContributions(createMenuJob);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -78,7 +78,6 @@ import com.raytheon.viz.ui.tools.ModalToolManager;
|
||||||
* @author randerso
|
* @author randerso
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public abstract class AbstractVizPerspectiveManager implements
|
public abstract class AbstractVizPerspectiveManager implements
|
||||||
IBackgroundColorChangedListener {
|
IBackgroundColorChangedListener {
|
||||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||||
|
@ -139,6 +138,9 @@ public abstract class AbstractVizPerspectiveManager implements
|
||||||
// update editor on last selected modal tool
|
// update editor on last selected modal tool
|
||||||
if (part instanceof IEditorPart
|
if (part instanceof IEditorPart
|
||||||
&& part instanceof IDisplayPaneContainer) {
|
&& part instanceof IDisplayPaneContainer) {
|
||||||
|
IWorkbenchPart newPart = part.getSite().getPage()
|
||||||
|
.getActivePart();
|
||||||
|
if (newPart instanceof IEditorPart) {
|
||||||
AbstractVizPerspectiveManager mgr = VizPerspectiveListener
|
AbstractVizPerspectiveManager mgr = VizPerspectiveListener
|
||||||
.getCurrentPerspectiveManager();
|
.getCurrentPerspectiveManager();
|
||||||
if (mgr != null) {
|
if (mgr != null) {
|
||||||
|
@ -151,6 +153,7 @@ public abstract class AbstractVizPerspectiveManager implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void partOpened(IWorkbenchPart part) {
|
public void partOpened(IWorkbenchPart part) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue