本文整理汇总了Java中org.eclipse.gef.GraphicalViewer类的典型用法代码示例。如果您正苦于以下问题:Java GraphicalViewer类的具体用法?Java GraphicalViewer怎么用?Java GraphicalViewer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GraphicalViewer类属于org.eclipse.gef包,在下文中一共展示了GraphicalViewer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: save
import org.eclipse.gef.GraphicalViewer; //导入依赖的package包/类
public static boolean save(IEditorPart editorPart, GraphicalViewer viewer,
String saveFilePath, int format) {
Assert.isNotNull(editorPart,
"null editorPart passed to ImageSaveUtil::save");
Assert.isNotNull(viewer, "null viewer passed to ImageSaveUtil::save");
Assert.isNotNull(saveFilePath,
"null saveFilePath passed to ImageSaveUtil::save");
if (format != SWT.IMAGE_BMP && format != SWT.IMAGE_JPEG
&& format != SWT.IMAGE_PNG && format != SWT.IMAGE_GIF)
throw new IllegalArgumentException("Save format not supported");
try {
saveEditorContentsAsImage(editorPart, viewer, saveFilePath, format);
} catch (Exception ex) {
MessageDialog.openError(editorPart.getEditorSite().getShell(),
"Save Error", "Could not save editor contents");
return false;
}
return true;
}
示例2: configureGraphicalViewer
import org.eclipse.gef.GraphicalViewer; //导入依赖的package包/类
@Override
protected void configureGraphicalViewer() {
super.configureGraphicalViewer();
getGraphicalViewer().getControl().setBackground(ColorConstants.button);
GraphicalViewer graphicalViewer = getGraphicalViewer();
MainDesignerRootEditPart rootEditPart = new MainDesignerRootEditPart();
graphicalViewer.setRootEditPart(rootEditPart);
// set EditPartFactory
graphicalViewer.setEditPartFactory(new JasperDesignEditPartFactory());
// set rulers providers
RulerProvider provider = new ReportRulerProvider(new ReportRuler(true, RulerProvider.UNIT_PIXELS));
graphicalViewer.setProperty(RulerProvider.PROPERTY_HORIZONTAL_RULER, provider);
provider = new ReportRulerProvider(new ReportRuler(false, RulerProvider.UNIT_PIXELS));
graphicalViewer.setProperty(RulerProvider.PROPERTY_VERTICAL_RULER, provider);
Boolean isRulerVisible = jrContext.getPropertyBoolean(RulersGridPreferencePage.P_PAGE_RULERGRID_SHOWRULER);
graphicalViewer.setProperty(RulerProvider.PROPERTY_RULER_VISIBILITY, isRulerVisible);
createAdditionalActions();
graphicalViewer.setKeyHandler(new JSSGraphicalViewerKeyHandler(graphicalViewer));
}
示例3: save
import org.eclipse.gef.GraphicalViewer; //导入依赖的package包/类
public static boolean save(IEditorPart editorPart, GraphicalViewer viewer) {
Assert.isNotNull(editorPart, "null editorPart passed to ImageSaveUtil::save");
Assert.isNotNull(viewer, "null viewer passed to ImageSaveUtil::save");
String saveFilePath = getSaveFilePath(editorPart, viewer, -1);
if (saveFilePath == null)
return false;
int format = SWT.IMAGE_JPEG;
if (saveFilePath.endsWith(".jpeg"))
format = SWT.IMAGE_JPEG;
else if (saveFilePath.endsWith(".bmp"))
format = SWT.IMAGE_BMP;
// else if (saveFilePath.endsWith(".ico"))
// format = SWT.IMAGE_ICO;
return save(editorPart, viewer, saveFilePath, format);
}
示例4: getSaveFilePath
import org.eclipse.gef.GraphicalViewer; //导入依赖的package包/类
private static String getSaveFilePath(IEditorPart editorPart, GraphicalViewer viewer, int format) {
FileDialog fileDialog = new FileDialog(editorPart.getEditorSite().getShell(), SWT.SAVE);
String[] filterExtensions = new String[] { "*.jpeg",
"*.bmp"/*
* , "*.ico" , "*.png", "*.gif"
*/ };
if (format == SWT.IMAGE_BMP)
filterExtensions = new String[] { "*.bmp" };
else if (format == SWT.IMAGE_JPEG)
filterExtensions = new String[] { "*.jpeg" };
// else if (format == SWT.IMAGE_ICO)
// filterExtensions = new String[] { "*.ico" };
fileDialog.setFilterExtensions(filterExtensions);
return fileDialog.open();
}
示例5: getAdapter
import org.eclipse.gef.GraphicalViewer; //导入依赖的package包/类
public Object getAdapter(Class adapter) {
if (adapter == GraphicalViewer.class || adapter == EditPartViewer.class)
return getGraphicalViewer();
else if (adapter == CommandStack.class)
return getCommandStack();
else if (adapter == EditDomain.class)
return getEditDomain();
else if (adapter == ActionRegistry.class)
return getActionRegistry();
else if (adapter == IPropertySheetPage.class)
return new PropertiesView(true);
else if (adapter == IContentOutlinePage.class) {
return new GW4EOutlinePage();
} else if (adapter == ZoomManager.class)
return ((ScalableRootEditPart) getGraphicalViewer().getRootEditPart()).getZoomManager();
return super.getAdapter(adapter);
}
示例6: checkWatcher
import org.eclipse.gef.GraphicalViewer; //导入依赖的package包/类
/**
* Return true if watch point enable otherwise false
*
* @return boolean
*/
public boolean checkWatcher(Component selectedComponent, String portName) {
ELTGraphicalEditor editor = (ELTGraphicalEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
.getActiveEditor();
GraphicalViewer graphicalViewer = (GraphicalViewer) ((GraphicalEditor) editor).getAdapter(GraphicalViewer.class);
for (Iterator<EditPart> iterator = graphicalViewer.getEditPartRegistry().values().iterator(); iterator.hasNext();) {
EditPart editPart = iterator.next();
if (editPart instanceof ComponentEditPart) {
Component comp = ((ComponentEditPart) editPart).getCastedModel();
if (comp.equals(selectedComponent)) {
List<PortEditPart> portEditParts = editPart.getChildren();
for (AbstractGraphicalEditPart part : portEditParts) {
if (part instanceof PortEditPart) {
String port_Name = ((PortEditPart) part).getCastedModel().getTerminal();
if (port_Name.equals(portName)) {
return ((PortEditPart) part).getPortFigure().isWatched();
}
}
}
}
}
}
return false;
}
示例7: getSubJobList
import org.eclipse.gef.GraphicalViewer; //导入依赖的package包/类
/**
* Collect all subjob file from active editor, also check for nested subjob.
* @return list of subjob.
*/
public List<String> getSubJobList() {
ArrayList<String> subJobList=new ArrayList<>();
ELTGraphicalEditor editor = (ELTGraphicalEditor)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (editor != null && editor instanceof ELTGraphicalEditor) {
GraphicalViewer graphicalViewer = (GraphicalViewer) ((GraphicalEditor) editor)
.getAdapter(GraphicalViewer.class);
for (Iterator<EditPart> ite = graphicalViewer.getEditPartRegistry().values().iterator(); ite.hasNext();) {
EditPart editPart = ite.next();
if (editPart instanceof ComponentEditPart) {
Component component = ((ComponentEditPart) editPart).getCastedModel();
if(Constants.SUBJOB_COMPONENT.equals(component.getComponentName())){
String subJobPath=(String) component.getProperties().get(Constants.PATH_PROPERTY_NAME);
subJobList.add(subJobPath);
checkNestedSubJob(subJobList, subJobPath);
}
}
}
}
return subJobList;
}
示例8: execute
import org.eclipse.gef.GraphicalViewer; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
if (DebugHelper.INSTANCE.hasMoreWatchPoints()) {
ELTGraphicalEditor editor = (ELTGraphicalEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getActivePage().getActiveEditor();
GraphicalViewer graphicalViewer = (GraphicalViewer) ((GraphicalEditor) editor)
.getAdapter(GraphicalViewer.class);
for (Iterator<EditPart> iterator = graphicalViewer.getEditPartRegistry().values().iterator(); iterator
.hasNext();) {
EditPart editPart = (EditPart) iterator.next();
if (editPart instanceof ComponentEditPart) {
Component comp = ((ComponentEditPart) editPart).getCastedModel();
comp.clearWatchers();
} else if (editPart instanceof PortEditPart) {
((PortEditPart) editPart).getPortFigure().removeWatcherColor();
((PortEditPart) editPart).getPortFigure().setWatched(false);
((PortEditPart) editPart).getCastedModel().setWatched(false);
}
}
showMessage(Messages.WATCH_POINT_REMOVED_SUCCESSFULLY);
} else {
showMessage(Messages.NO_WATCH_POINT_AVAILABLE);
}
return null;
}
示例9: getUniqueJobId
import org.eclipse.gef.GraphicalViewer; //导入依赖的package包/类
/**
* Gets the unique job id.
*
* @return the unique job id
*/
private String getUniqueJobId(){
ELTGraphicalEditor editor = (ELTGraphicalEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
.getActiveEditor();
String uniqueJobId = editor.getJobId();
isJobUpdated =false;
GraphicalViewer graphicalViewer = (GraphicalViewer) ((GraphicalEditor) editor).getAdapter(GraphicalViewer.class);
for (Iterator<EditPart> ite = graphicalViewer.getEditPartRegistry().values().iterator();ite.hasNext();){
EditPart editPart = (EditPart) ite.next();
if (editPart instanceof ComponentEditPart){
Component component = ((ComponentEditPart) editPart)
.getCastedModel();
if(component.getStatus()!= ComponentExecutionStatus.BLANK){
isJobUpdated = true;
break;
}
}
}
return uniqueJobId;
}
示例10: clearTrackingStatusForEditor
import org.eclipse.gef.GraphicalViewer; //导入依赖的package包/类
/**
* Clear tracking status for editor.
*
* @param editor
* the editor
*/
public void clearTrackingStatusForEditor(ELTGraphicalEditor editor) {
GraphicalViewer graphicalViewer = (GraphicalViewer) ((GraphicalEditor) editor)
.getAdapter(GraphicalViewer.class);
for (Iterator<EditPart> ite = graphicalViewer.getEditPartRegistry()
.values().iterator(); ite.hasNext();) {
EditPart editPart = ite.next();
if (editPart instanceof ComponentEditPart) {
Component component = ((ComponentEditPart) editPart)
.getCastedModel();
component.updateStatus(ComponentExecutionStatus.BLANK.value());
} else if (editPart instanceof LinkEditPart) {
((LinkEditPart) editPart).clearRecordCountAtPort();
}
}
}
示例11: hasMoreWatchPoints
import org.eclipse.gef.GraphicalViewer; //导入依赖的package包/类
/**
* This function will check watch point in the graph and return true if any watch point exist
*
*/
public boolean hasMoreWatchPoints(){
IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if(activeEditor instanceof ELTGraphicalEditor){
ELTGraphicalEditor editor=(ELTGraphicalEditor) activeEditor;
if(editor!=null){
GraphicalViewer graphicalViewer =(GraphicalViewer) ((GraphicalEditor)editor).getAdapter(GraphicalViewer.class);
for (Object objectEditPart : graphicalViewer.getEditPartRegistry().values()){
if(objectEditPart instanceof ComponentEditPart){
List<PortEditPart> portEditParts = ((EditPart) objectEditPart).getChildren();
for(AbstractGraphicalEditPart part : portEditParts) {
if(part instanceof PortEditPart){
boolean isWatch = ((PortEditPart)part).getPortFigure().isWatched();
if(isWatch){
return isWatch;
}
}
}
}
}
}
}
return false;
}
示例12: showComponentCreationOnCanvas
import org.eclipse.gef.GraphicalViewer; //导入依赖的package包/类
/**
* Creation of content assist
* @param event
* @param viewer
* @param paletteRoot
*/
public void showComponentCreationOnCanvas(KeyEvent event, GraphicalViewer viewer, PaletteRoot paletteRoot) {
this.graphicViewer = viewer;
this.graphicControl = viewer.getControl();
this.triggerChar = event.character;
this.paletteRoot = paletteRoot;
Point cursorRelativePosition = calculatePosition();
if (cursorRelativePosition == null) {
return;
}
disposeAssistText();
createAssistText(cursorRelativePosition);
initializeListneres();
activateAssist(triggerChar);
}
示例13: removeWatch
import org.eclipse.gef.GraphicalViewer; //导入依赖的package包/类
private void removeWatch(Port sourcePort, Component sourceComponent){
ELTGraphicalEditor editor=(ELTGraphicalEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
GraphicalViewer graphicalViewer =(GraphicalViewer) ((GraphicalEditor)editor).getAdapter(GraphicalViewer.class);
for (Object objectEditPart : graphicalViewer.getEditPartRegistry().values())
{
EditPart editPart = (EditPart) objectEditPart;
if(editPart instanceof ComponentEditPart)
{
Component comp = ((ComponentEditPart)editPart).getCastedModel();
if(comp.equals(sourceComponent)){
List<PortEditPart> portEditParts = editPart.getChildren();
for(AbstractGraphicalEditPart part:portEditParts)
{
if(part instanceof PortEditPart){
if(((PortEditPart)part).getCastedModel().getTerminal().equals(sourcePort.getTerminal())){
((PortEditPart)part).getPortFigure().removeWatcherColor();
((PortEditPart)part).getPortFigure().setWatched(false);
}
}
}
}
}
}
}
示例14: removeWatch
import org.eclipse.gef.GraphicalViewer; //导入依赖的package包/类
private void removeWatch(Port sourcePort, Component sourceComponent){
ELTGraphicalEditor editor=(ELTGraphicalEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
GraphicalViewer graphicalViewer =(GraphicalViewer) ((GraphicalEditor)editor).getAdapter(GraphicalViewer.class);
for (Iterator<EditPart> iterator = graphicalViewer.getEditPartRegistry().values().iterator(); iterator.hasNext();)
{
EditPart editPart = (EditPart) iterator.next();
if(editPart instanceof ComponentEditPart)
{
Component comp = ((ComponentEditPart)editPart).getCastedModel();
if(comp.equals(sourceComponent)){
List<PortEditPart> portEditParts = editPart.getChildren();
for(AbstractGraphicalEditPart part:portEditParts)
{
if(part instanceof PortEditPart){
if(((PortEditPart)part).getCastedModel().getTerminal().equals(sourcePort.getTerminal())){
((PortEditPart)part).getPortFigure().removeWatcherColor();
((PortEditPart)part).getPortFigure().setWatched(false);
}
}
}
}
}
}
}
示例15: createEditor
import org.eclipse.gef.GraphicalViewer; //导入依赖的package包/类
/**
* Overrides the underlying editor widget to add the date slider to it.
* @param parent
*/
public void createEditor(Composite parent){
GraphicalViewer viewer = new ScrollingGraphicalViewer();
Control control = viewer.createControl(parent);
if(parent.getLayout() instanceof GridLayout){
GridData gridData = new GridData();
gridData.horizontalSpan = 2;
gridData.horizontalAlignment = SWT.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.verticalAlignment = SWT.FILL;
gridData.grabExcessVerticalSpace = true;
control.setLayoutData(gridData);
}
setGraphicalViewer(viewer);
configureGraphicalViewer();
hookGraphicalViewer();
initializeGraphicalViewer();
}