use of org.eclipse.gef.editparts.ZoomManager in project jbosstools-hibernate by jbosstools.
the class DiagramViewer method getFitPageZoomValue.
public double getFitPageZoomValue() {
double res = 1.0;
ZoomManager manager = (ZoomManager) getGraphicalViewer().getProperty(ZoomManager.class.toString());
Method m = null;
try {
// $NON-NLS-1$
m = manager.getClass().getDeclaredMethod("getFitPageZoomLevel");
m.setAccessible(true);
res = (Double) m.invoke(manager);
} catch (SecurityException e) {
} catch (NoSuchMethodException e) {
} catch (IllegalArgumentException e) {
} catch (IllegalAccessException e) {
} catch (InvocationTargetException e) {
}
return res;
}
use of org.eclipse.gef.editparts.ZoomManager in project jbosstools-hibernate by jbosstools.
the class DiagramViewer method loadProperties.
protected boolean loadProperties() {
if (getOrmDiagram() == null || getGraphicalViewer() == null) {
return false;
}
// Ruler properties
DiagramRuler ruler = getOrmDiagram().getRuler(PositionConstants.WEST);
RulerProvider provider = null;
if (ruler != null) {
provider = new DiagramRulerProvider(ruler);
}
getGraphicalViewer().setProperty(RulerProvider.PROPERTY_VERTICAL_RULER, provider);
ruler = getOrmDiagram().getRuler(PositionConstants.NORTH);
provider = null;
if (ruler != null) {
provider = new DiagramRulerProvider(ruler);
}
getGraphicalViewer().setProperty(RulerProvider.PROPERTY_HORIZONTAL_RULER, provider);
getGraphicalViewer().setProperty(RulerProvider.PROPERTY_RULER_VISIBILITY, new Boolean(getOrmDiagram().getRulerVisibility()));
// Snap to Geometry property
getGraphicalViewer().setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, new Boolean(getOrmDiagram().isSnapToGeometryEnabled()));
// Grid properties
getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, new Boolean(getOrmDiagram().isGridEnabled()));
// We keep grid visibility and enablement in sync
getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, new Boolean(getOrmDiagram().isGridEnabled()));
// Zoom
ZoomManager manager = (ZoomManager) getGraphicalViewer().getProperty(ZoomManager.class.toString());
if (manager != null) {
manager.setZoom(getOrmDiagram().getZoom());
}
return true;
}
use of org.eclipse.gef.editparts.ZoomManager in project statecharts by Yakindu.
the class XtextDirectEditManager method getZoomLevelFont.
/**
* This method obtains the fonts that are being used by the figure at its
* zoom level.
*
* @param gep
* the associated <code>GraphicalEditPart</code> of the figure
* @param actualFont
* font being used by the figure
* @param display
* @return <code>actualFont</code> if zoom level is 1.0 (or when there's an
* error), new Font otherwise.
*/
private Font getZoomLevelFont(Font actualFont, Display display) {
Object zoom = getEditPart().getViewer().getProperty(ZoomManager.class.toString());
if (zoom != null) {
double zoomLevel = ((ZoomManager) zoom).getZoom();
if (zoomLevel == 1.0f)
return actualFont;
FontData[] fd = new FontData[actualFont.getFontData().length];
FontData tempFD = null;
for (int i = 0; i < fd.length; i++) {
tempFD = actualFont.getFontData()[i];
fd[i] = new FontData(tempFD.getName(), (int) (zoomLevel * tempFD.getHeight()), tempFD.getStyle());
}
try {
FontDescriptor fontDescriptor = FontDescriptor.createFrom(fd);
cachedFontDescriptors.add(fontDescriptor);
return getResourceManager().createFont(fontDescriptor);
} catch (DeviceResourceException e) {
Trace.catching(DiagramUIPlugin.getInstance(), DiagramUIDebugOptions.EXCEPTIONS_CATCHING, getClass(), "getZoomLevelFonts", // $NON-NLS-1$
e);
Log.error(DiagramUIPlugin.getInstance(), DiagramUIStatusCodes.IGNORED_EXCEPTION_WARNING, "getZoomLevelFonts", // $NON-NLS-1$
e);
return actualFont;
}
} else
return actualFont;
}
use of org.eclipse.gef.editparts.ZoomManager in project dbeaver by serge-rider.
the class ERDEditorPart method fillDefaultEditorContributions.
protected void fillDefaultEditorContributions(IContributionManager toolBarManager) {
ZoomManager zoomManager = rootPart.getZoomManager();
String[] zoomStrings = new String[] { ZoomManager.FIT_ALL, ZoomManager.FIT_HEIGHT, ZoomManager.FIT_WIDTH };
// Init zoom combo with dummy part service
// to prevent zoom disable on part change - as it is standalone zoom control, not global one
zoomCombo = new ZoomComboContributionItem(new IPartService() {
@Override
public void addPartListener(IPartListener listener) {
}
@Override
public void addPartListener(IPartListener2 listener) {
}
@Override
public IWorkbenchPart getActivePart() {
return ERDEditorPart.this;
}
@Override
public IWorkbenchPartReference getActivePartReference() {
return null;
}
@Override
public void removePartListener(IPartListener listener) {
}
@Override
public void removePartListener(IPartListener2 listener) {
}
}, zoomStrings);
zoomCombo.setZoomManager(zoomManager);
toolBarManager.add(zoomCombo);
// toolBarManager.add(new UndoAction(ERDEditorPart.this));
// toolBarManager.add(new RedoAction(ERDEditorPart.this));
// toolBarManager.add(new PrintAction(ERDEditorPart.this));
ZoomInAction zoomInAction = new ZoomInAction(zoomManager);
zoomInAction.setImageDescriptor(DBeaverIcons.getImageDescriptor(UIIcon.ZOOM_IN));
ZoomOutAction zoomOutAction = new ZoomOutAction(zoomManager);
zoomOutAction.setImageDescriptor(DBeaverIcons.getImageDescriptor(UIIcon.ZOOM_OUT));
toolBarManager.add(zoomInAction);
toolBarManager.add(zoomOutAction);
toolBarManager.add(new Separator());
// toolBarManager.add(createAttributeVisibilityMenu());
toolBarManager.add(new DiagramLayoutAction(ERDEditorPart.this));
toolBarManager.add(new DiagramToggleGridAction());
toolBarManager.add(new DiagramRefreshAction(ERDEditorPart.this));
toolBarManager.add(new Separator());
{
toolBarManager.add(ActionUtils.makeCommandContribution(getSite(), IWorkbenchCommandConstants.FILE_PRINT, ERDUIMessages.erd_editor_control_action_print_diagram, UIIcon.PRINT));
toolBarManager.add(ActionUtils.makeCommandContribution(getSite(), IWorkbenchCommandConstants.FILE_SAVE_AS, ERDUIMessages.erd_editor_control_action_save_external_format, UIIcon.PICTURE_SAVE));
toolBarManager.add(ActionUtils.makeCommandContribution(getSite(), IWorkbenchCommandConstants.FILE_SAVE, null, UIIcon.SAVE));
}
toolBarManager.add(new Separator());
{
Action configAction = new Action(ERDUIMessages.erd_editor_control_action_configuration) {
@Override
public void run() {
UIUtils.showPreferencesFor(getSite().getShell(), ERDEditorPart.this, ERDPreferencePage.PAGE_ID);
}
};
configAction.setImageDescriptor(DBeaverIcons.getImageDescriptor(UIIcon.CONFIGURATION));
toolBarManager.add(configAction);
}
}
use of org.eclipse.gef.editparts.ZoomManager in project yamcs-studio by yamcs.
the class TextEditManager method initCellEditor.
@Override
protected void initCellEditor() {
// update text
var textFigure = getEditPart().getAdapter(ITextFigure.class);
// var labelModel = (AbstractWidgetModel) getEditPart().getModel();
getCellEditor().setValue(textFigure.getText());
if (textFigure.isOpaque() || textFigure.getBorder() instanceof AbstractBackground) {
getCellEditor().getControl().setBackground(textFigure.getBackgroundColor());
} else {
getCellEditor().getControl().setBackground(textFigure.getParent().getBackgroundColor());
}
getCellEditor().getControl().setForeground(textFigure.getForegroundColor());
// update font
var zoomMgr = (ZoomManager) getEditPart().getViewer().getProperty(ZoomManager.class.toString());
if (zoomMgr != null) {
// this will force the font to be set
cachedZoom = -1.0;
updateScaledFont(zoomMgr.getZoom());
zoomMgr.addZoomListener(zoomListener);
} else {
getCellEditor().getControl().setFont(textFigure.getFont());
}
// Hook the cell editor's copy/paste actions to the actionBars so that they can
// be invoked via keyboard shortcuts.
var activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (activeEditor != null) {
actionBars = activeEditor.getEditorSite().getActionBars();
saveCurrentActions(actionBars);
actionHandler = new CellEditorActionHandler(actionBars);
actionHandler.addCellEditor(getCellEditor());
actionBars.updateActionBars();
}
}
Aggregations