From ebffc66e0df6c024af15eeeb5c69dd6c62342371 Mon Sep 17 00:00:00 2001 From: David Inglis Date: Tue, 14 Jun 2005 15:55:15 +0000 Subject: [PATCH] small update to change logging to use the launch plugins plus use its own pixelconverter --- .../internal/CApplicationLaunchShortcut.java | 7 +- .../cdt/launch/internal/ui/LaunchImages.java | 3 +- .../launch/internal/ui/PixelConverter.java | 65 +++++++++++++++++++ .../eclipse/cdt/launch/ui/CDebuggerTab.java | 2 +- 4 files changed, 70 insertions(+), 7 deletions(-) create mode 100644 launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/PixelConverter.java diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CApplicationLaunchShortcut.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CApplicationLaunchShortcut.java index 5ed40a2ee36..0a3e91914e5 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CApplicationLaunchShortcut.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CApplicationLaunchShortcut.java @@ -22,7 +22,6 @@ import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.ICDebugConfiguration; -import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.cdt.launch.AbstractCLaunchDelegate; import org.eclipse.cdt.launch.internal.ui.LaunchMessages; import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; @@ -103,7 +102,7 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut { } } } catch (CoreException e) { - CDebugUIPlugin.log(e); + LaunchUIPlugin.log(e); } // If there are no existing configs associated with the IBinary, create one. @@ -170,7 +169,7 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut { wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, debugConfig.getID()); config = wc.doSave(); } catch (CoreException ce) { - CDebugUIPlugin.log(ce); + LaunchUIPlugin.log(ce); } return config; } @@ -191,7 +190,7 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut { * Convenience method to get the window that owns this action's Shell. */ protected Shell getShell() { - return CDebugUIPlugin.getActiveWorkbenchShell(); + return LaunchUIPlugin.getActiveWorkbenchShell(); } /** diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchImages.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchImages.java index f10de56c31a..ba0bc7d6cfa 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchImages.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchImages.java @@ -13,7 +13,6 @@ package org.eclipse.cdt.launch.internal.ui; import java.net.MalformedURLException; import java.net.URL; -import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.core.runtime.Platform; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageRegistry; @@ -74,7 +73,7 @@ public class LaunchImages { try { return new URL(fgIconBaseURL, buffer.toString()); } catch (MalformedURLException e) { - CUIPlugin.getDefault().log(e); + LaunchUIPlugin.log(e); return null; } } diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/PixelConverter.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/PixelConverter.java new file mode 100644 index 00000000000..fbe060676bb --- /dev/null +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/PixelConverter.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.launch.internal.ui; + + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.swt.graphics.FontMetrics; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.widgets.Control; + +public class PixelConverter { + + private FontMetrics fFontMetrics; + + public PixelConverter( Control control ) { + GC gc = new GC( control ); + gc.setFont( control.getFont() ); + setFontMetrics( gc.getFontMetrics() ); + gc.dispose(); + } + + /** + * @see org.eclipse.jface.dialogs.DialogPage#convertHeightInCharsToPixels(int) + */ + public int convertHeightInCharsToPixels( int chars ) { + return Dialog.convertHeightInCharsToPixels( getFontMetrics(), chars ); + } + + /** + * @see org.eclipse.jface.dialogs.DialogPage#convertHorizontalDLUsToPixels(int) + */ + public int convertHorizontalDLUsToPixels( int dlus ) { + return Dialog.convertHorizontalDLUsToPixels( getFontMetrics(), dlus ); + } + + /** + * @see org.eclipse.jface.dialogs.DialogPage#convertVerticalDLUsToPixels(int) + */ + public int convertVerticalDLUsToPixels( int dlus ) { + return Dialog.convertVerticalDLUsToPixels( getFontMetrics(), dlus ); + } + + /** + * @see org.eclipse.jface.dialogs.DialogPage#convertWidthInCharsToPixels(int) + */ + public int convertWidthInCharsToPixels( int chars ) { + return Dialog.convertWidthInCharsToPixels( getFontMetrics(), chars ); + } + + private FontMetrics getFontMetrics() { + return this.fFontMetrics; + } + + private void setFontMetrics( FontMetrics fontMetrics ) { + this.fFontMetrics = fontMetrics; + } +} diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java index bbb233c1d59..33bdfe401c5 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java @@ -26,10 +26,10 @@ import org.eclipse.cdt.core.IBinaryParser.IBinaryObject; import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.ICDebugConfiguration; -import org.eclipse.cdt.debug.internal.ui.PixelConverter; import org.eclipse.cdt.launch.internal.ui.AbstractCDebuggerTab; import org.eclipse.cdt.launch.internal.ui.LaunchMessages; import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; +import org.eclipse.cdt.launch.internal.ui.PixelConverter; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException;