Issue #1018 change product browser to handle no editor conditions better.
Change-Id: I3235ebb6d50eee26c75d31ce91e2a01c2d49b300 Former-commit-id:4d20aa0e82
[formerly4d20aa0e82
[formerly 7cb30aa5c00eea5b95b6c4b39653fabeaccdd872]] Former-commit-id:7559065a1d
Former-commit-id:850203f715
This commit is contained in:
parent
79f15e475e
commit
7f5bd99b0c
4 changed files with 84 additions and 48 deletions
|
@ -27,11 +27,15 @@ import java.util.Map;
|
|||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.viz.core.DescriptorMap;
|
||||
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
|
||||
import com.raytheon.uf.viz.core.catalog.CatalogQuery;
|
||||
import com.raytheon.uf.viz.core.catalog.DbQuery;
|
||||
|
@ -39,6 +43,7 @@ import com.raytheon.uf.viz.core.drawables.AbstractRenderableDisplay;
|
|||
import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
||||
import com.raytheon.uf.viz.core.drawables.ResourcePair;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.map.MapDescriptor;
|
||||
import com.raytheon.uf.viz.core.procedures.Bundle;
|
||||
import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData;
|
||||
import com.raytheon.uf.viz.core.rsc.ResourceProperties;
|
||||
|
@ -46,7 +51,10 @@ import com.raytheon.uf.viz.core.rsc.ResourceType;
|
|||
import com.raytheon.uf.viz.productbrowser.ProductBrowserPreference.PreferenceType;
|
||||
import com.raytheon.viz.ui.EditorUtil;
|
||||
import com.raytheon.viz.ui.MenuLoader;
|
||||
import com.raytheon.viz.ui.VizWorkbenchManager;
|
||||
import com.raytheon.viz.ui.editor.AbstractEditor;
|
||||
import com.raytheon.viz.ui.perspectives.AbstractVizPerspectiveManager;
|
||||
import com.raytheon.viz.ui.perspectives.VizPerspectiveListener;
|
||||
|
||||
/**
|
||||
* Product browser abstract requestable implementation
|
||||
|
@ -134,11 +142,11 @@ public abstract class AbstractRequestableProductBrowserDataDefinition<T extends
|
|||
|
||||
String[] temp = queryData(param, queryList);
|
||||
if (temp != null) {
|
||||
if ((Boolean) getPreference(FORMAT_DATA).getValue()) {
|
||||
parameters = formatData(param, temp);
|
||||
} else {
|
||||
parameters = super.formatData(param, temp);
|
||||
}
|
||||
if ((Boolean) getPreference(FORMAT_DATA).getValue()) {
|
||||
parameters = formatData(param, temp);
|
||||
} else {
|
||||
parameters = super.formatData(param, temp);
|
||||
}
|
||||
}
|
||||
|
||||
if (parameters != null) {
|
||||
|
@ -194,7 +202,10 @@ public abstract class AbstractRequestableProductBrowserDataDefinition<T extends
|
|||
IDescriptor currDesc = null;
|
||||
// retrieves the correct editor
|
||||
getEditor();
|
||||
IDisplayPaneContainer container = EditorUtil.getActiveVizContainer();
|
||||
IDisplayPaneContainer container = getEditor();
|
||||
if (container == null) {
|
||||
return;
|
||||
}
|
||||
AbstractRenderableDisplay display = (AbstractRenderableDisplay) container
|
||||
.getActiveDisplayPane().getRenderableDisplay();
|
||||
display = (AbstractRenderableDisplay) display.createNewDisplay();
|
||||
|
@ -265,8 +276,39 @@ public abstract class AbstractRequestableProductBrowserDataDefinition<T extends
|
|||
return null;
|
||||
}
|
||||
|
||||
public void getEditor() {
|
||||
// do nothing, if user wants a certain editor then overwrite this method
|
||||
protected IDisplayPaneContainer getEditor() {
|
||||
String id = DescriptorMap.getEditorId(getDescriptorClass().getName());
|
||||
IEditorPart editorPart = EditorUtil.getActiveEditor();
|
||||
if (editorPart != null && id.equals(editorPart.getEditorSite().getId())) {
|
||||
return (AbstractEditor) editorPart;
|
||||
}
|
||||
editorPart = EditorUtil.findEditor(id);
|
||||
if (editorPart != null) {
|
||||
return (AbstractEditor) editorPart;
|
||||
}
|
||||
return openNewEditor(id);
|
||||
}
|
||||
|
||||
protected IDisplayPaneContainer openNewEditor(String editorId) {
|
||||
IWorkbenchWindow window = VizWorkbenchManager.getInstance()
|
||||
.getCurrentWindow();
|
||||
AbstractVizPerspectiveManager mgr = VizPerspectiveListener.getInstance(
|
||||
window).getActivePerspectiveManager();
|
||||
if (mgr != null) {
|
||||
AbstractEditor editor = mgr.openNewEditor();
|
||||
if (editor == null) {
|
||||
return null;
|
||||
} else if (editorId.equals(editor.getEditorSite().getId())) {
|
||||
return editor;
|
||||
} else {
|
||||
window.getActivePage().closeEditor(editor, false);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Class<? extends IDescriptor> getDescriptorClass() {
|
||||
return MapDescriptor.class;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -27,15 +27,13 @@ import java.util.Collections;
|
|||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.ui.PartInitException;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.radar.util.RadarInfoDict;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
|
||||
import com.raytheon.uf.viz.core.DescriptorMap;
|
||||
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
|
||||
import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
||||
import com.raytheon.uf.viz.core.rsc.DisplayType;
|
||||
import com.raytheon.uf.viz.core.rsc.LoadProperties;
|
||||
import com.raytheon.uf.viz.core.rsc.ResourceType;
|
||||
|
@ -44,9 +42,11 @@ import com.raytheon.uf.viz.productbrowser.AbstractRequestableProductBrowserDataD
|
|||
import com.raytheon.uf.viz.productbrowser.ProductBrowserLabel;
|
||||
import com.raytheon.uf.viz.productbrowser.ProductBrowserPreference;
|
||||
import com.raytheon.viz.radar.rsc.RadarResourceData;
|
||||
import com.raytheon.viz.radar.ui.xy.RadarGraphDescriptor;
|
||||
import com.raytheon.viz.radar.ui.xy.RadarGraphDisplay;
|
||||
import com.raytheon.viz.radar.ui.xy.RadarXYDescriptor;
|
||||
import com.raytheon.viz.radar.ui.xy.RadarXYDisplay;
|
||||
import com.raytheon.viz.ui.editor.EditorInput;
|
||||
import com.raytheon.viz.ui.UiUtil;
|
||||
|
||||
/**
|
||||
* Product browser implementation for radar
|
||||
|
@ -174,40 +174,30 @@ public class RadarProductBrowserDataDefinition extends
|
|||
return new RadarResourceData();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.productbrowser.AbstractProductBrowserDataDefinition
|
||||
* #getEditor()
|
||||
*/
|
||||
@Override
|
||||
public void getEditor() {
|
||||
protected IDisplayPaneContainer openNewEditor(String editorId) {
|
||||
if (editorId.equals(DescriptorMap.getEditorId(RadarXYDescriptor.class
|
||||
.getName()))) {
|
||||
return UiUtil.createEditor(editorId, new RadarXYDisplay());
|
||||
} else if (editorId.equals(DescriptorMap
|
||||
.getEditorId(RadarGraphDescriptor.class.getName()))) {
|
||||
return UiUtil.createEditor(editorId, new RadarGraphDisplay());
|
||||
} else {
|
||||
return super.openNewEditor(editorId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends IDescriptor> getDescriptorClass() {
|
||||
int prodCode = Integer.parseInt((resourceData).getMetadataMap()
|
||||
.get("productCode").getConstraintValue());
|
||||
String format = infoDict.getInfo(prodCode).getFormat();
|
||||
if ("XY".equals(format)) {
|
||||
String editor = "com.raytheon.viz.radar.ui.xy.RadarXYEditor";
|
||||
EditorInput cont = new EditorInput(
|
||||
(IRenderableDisplay) new RadarXYDisplay());
|
||||
try {
|
||||
PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getActivePage().openEditor(cont, editor, true);
|
||||
} catch (PartInitException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to open editor : " + editor, e);
|
||||
}
|
||||
return RadarXYDescriptor.class;
|
||||
} else if ("Graph".equals(format)) {
|
||||
String editor = "com.raytheon.viz.radar.ui.xy.RadarGraphEditor";
|
||||
EditorInput cont = new EditorInput(
|
||||
(IRenderableDisplay) new RadarGraphDisplay());
|
||||
try {
|
||||
PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getActivePage().openEditor(cont, editor, true);
|
||||
} catch (PartInitException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to open editor : " + editor, e);
|
||||
}
|
||||
return RadarGraphDescriptor.class;
|
||||
} else {
|
||||
return super.getDescriptorClass();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -102,9 +102,11 @@ public class RadarGraphDisplay extends AbstractNonMapDisplay {
|
|||
GraphProperties graphProps) throws VizException {
|
||||
// Plot the resource data on the graph
|
||||
for (ResourcePair rp : getDescriptor().getResourceList()) {
|
||||
graphProps = (GraphProperties) calcPaintDataTime(graphProps,
|
||||
rp.getResource());
|
||||
rp.getResource().paint(target, graphProps);
|
||||
if (rp.getResource() != null) {
|
||||
graphProps = (GraphProperties) calcPaintDataTime(graphProps,
|
||||
rp.getResource());
|
||||
rp.getResource().paint(target, graphProps);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -80,9 +80,11 @@ public class RadarXYDisplay extends AbstractNonMapDisplay {
|
|||
|
||||
// Plot the resource data on the graph
|
||||
for (ResourcePair rp : getDescriptor().getResourceList()) {
|
||||
graphProps = (GraphProperties) calcPaintDataTime(graphProps,
|
||||
rp.getResource());
|
||||
rp.getResource().paint(target, graphProps);
|
||||
if (rp.getResource() != null) {
|
||||
graphProps = (GraphProperties) calcPaintDataTime(graphProps,
|
||||
rp.getResource());
|
||||
rp.getResource().paint(target, graphProps);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue