X-Git-Url: http://git.phpeclipse.com diff --git a/archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/view/PHPSourceConsole.java b/archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/view/PHPSourceConsole.java index 0578019..e4035fb 100644 --- a/archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/view/PHPSourceConsole.java +++ b/archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/view/PHPSourceConsole.java @@ -8,11 +8,9 @@ which accompanies this distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html Contributors: - IBM Corporation - Initial implementation - Klaus Hartlage - www.eclipseproject.de + IBM Corporation - Initial implementation + Klaus Hartlage - www.eclipseproject.de **********************************************************************/ -import net.sourceforge.phpdt.sql.PHPEclipseSQLPlugin; - import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.jface.action.Action; @@ -31,6 +29,9 @@ import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.ViewPart; +import net.sourceforge.phpdt.sql.Messages; +import net.sourceforge.phpdt.sql.PHPEclipseSQLPlugin; + /** * The PHPSourceConsole is used to display the output from the PHP SQL wizards * @see ViewPart @@ -38,9 +39,9 @@ import org.eclipse.ui.part.ViewPart; public class PHPSourceConsole extends ViewPart { public static final String CONSOLE_ID = - "net.sourceforge.phpdt.sql.view.phpsourceconsoleview"; + "net.sourceforge.phpdt.sql.view.phpsourceconsoleview"; - private TextViewer viewer = null; + TextViewer viewer = null; private Document document = null; /** @@ -54,34 +55,34 @@ public class PHPSourceConsole extends ViewPart { * @see ViewPart#createPartControl */ public void createPartControl(Composite parent) { - viewer = new TextViewer(parent, SWT.WRAP | SWT.V_SCROLL | SWT.H_SCROLL); - GridData viewerData = new GridData(GridData.FILL_BOTH); - viewer.getControl().setLayoutData(viewerData); - viewer.setEditable(false); - - StyledText widget = viewer.getTextWidget(); - widget.setFont( - JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT)); - Action cutAction = new Action() { - public void run() { - viewer.getTextWidget().cut(); - } - }; - Action copyAction = new Action() { - public void run() { - viewer.getTextWidget().copy(); - } - }; - Action pasteAction = new Action() { - public void run() { - viewer.getTextWidget().paste(); - } - }; - - IActionBars bars = this.getViewSite().getActionBars(); - bars.setGlobalActionHandler(IWorkbenchActionConstants.CUT, cutAction); - bars.setGlobalActionHandler(IWorkbenchActionConstants.COPY, copyAction); - bars.setGlobalActionHandler(IWorkbenchActionConstants.PASTE, pasteAction); + viewer = new TextViewer(parent, SWT.WRAP | SWT.V_SCROLL | SWT.H_SCROLL); + GridData viewerData = new GridData(GridData.FILL_BOTH); + viewer.getControl().setLayoutData(viewerData); + viewer.setEditable(false); + + StyledText widget = viewer.getTextWidget(); + widget.setFont( + JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT)); + Action cutAction = new Action() { + public void run() { + viewer.getTextWidget().cut(); + } + }; + Action copyAction = new Action() { + public void run() { + viewer.getTextWidget().copy(); + } + }; + Action pasteAction = new Action() { + public void run() { + viewer.getTextWidget().paste(); + } + }; + + IActionBars bars = this.getViewSite().getActionBars(); + bars.setGlobalActionHandler(IWorkbenchActionConstants.CUT, cutAction); + bars.setGlobalActionHandler(IWorkbenchActionConstants.COPY, copyAction); + bars.setGlobalActionHandler(IWorkbenchActionConstants.PASTE, pasteAction); } /** @@ -95,62 +96,62 @@ public class PHPSourceConsole extends ViewPart { * Set the text for the viewer */ private void setOutputText(String text) { - document = new Document(text); - viewer.setDocument(document); + document = new Document(text); + viewer.setDocument(document); } private void appendOutputText(String text) { - try { - if (document == null) { - document = new Document(text); - viewer.setDocument(document); - } - document.replace(document.getLength(), 0, text); - } catch (BadLocationException e) { - } - // viewer.setDocument(document); + try { + if (document == null) { + document = new Document(text); + viewer.setDocument(document); + } + document.replace(document.getLength(), 0, text); + } catch (BadLocationException e) { + } + // viewer.setDocument(document); } public static PHPSourceConsole getInstance() { - IWorkbenchPage page = - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - PHPSourceConsole console = (PHPSourceConsole) page.findView(PHPSourceConsole.CONSOLE_ID); - // if (PHPeclipsePlugin.SHOW_OUTPUT_IN_CONSOLE.getDefault().getPreferenceStore().getBoolean(PHPeclipsePlugin.SHOW_OUTPUT_IN_CONSOLE) == true) { - - try { - page.showView(PHPSourceConsole.CONSOLE_ID); - if (console == null) { - console = (PHPSourceConsole) page.findView(PHPSourceConsole.CONSOLE_ID); - } - } catch (PartInitException e) { - PHPEclipseSQLPlugin.getDefault().getLog().log( - new Status( - IStatus.ERROR, - PHPEclipseSQLPlugin.PLUGIN_ID, - 0, - Messages.getString("sqlconsole.viewopeningproblem"), - e)); - } - - // } - return console; + IWorkbenchPage page = + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + PHPSourceConsole console = (PHPSourceConsole) page.findView(PHPSourceConsole.CONSOLE_ID); + // if (PHPeclipsePlugin.SHOW_OUTPUT_IN_CONSOLE.getDefault().getPreferenceStore().getBoolean(PHPeclipsePlugin.SHOW_OUTPUT_IN_CONSOLE) == true) { + + try { + page.showView(PHPSourceConsole.CONSOLE_ID); + if (console == null) { + console = (PHPSourceConsole) page.findView(PHPSourceConsole.CONSOLE_ID); + } + } catch (PartInitException e) { + PHPEclipseSQLPlugin.getDefault().getLog().log( + new Status( + IStatus.ERROR, + PHPEclipseSQLPlugin.PLUGIN_ID, + 0, + Messages.getString("sqlconsole.viewopeningproblem"), + e)); + } + + // } + return console; } /** * Prints out the string represented by the string buffer */ public synchronized void print(String output) { - appendOutputText(output); + appendOutputText(output); } /** * Prints out the string represented by the string buffer */ public synchronized void println(String output) { - appendOutputText(output+'\n'); + appendOutputText(output+'\n'); } public synchronized void clear() { - setOutputText(""); + setOutputText(""); } }