summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bosdonnat <cedricbosdo@openoffice.org>2010-09-14 09:37:27 +0200
committerCédric Bosdonnat <cedricbosdo@openoffice.org>2010-09-14 09:37:27 +0200
commitaf8c7a38282e5b585e79451d2d6615a30ea390fe (patch)
tree51f463659a8a5c97528e97eab385773f218d012a
parente5a7e65ea5675b78124b306d4fd036bdae7c4f42 (diff)
Added the possibility to show anything on the text editors
-rwxr-xr-xcore/source/org/openoffice/ide/eclipse/core/editors/idl/UnoidlEditor.java50
-rwxr-xr-xcore/source/org/openoffice/ide/eclipse/core/editors/registry/RegEditor.java4
-rw-r--r--core/source/org/openoffice/ide/eclipse/core/editors/utils/OOTextEditor.java114
-rw-r--r--core/source/org/openoffice/ide/eclipse/core/editors/utils/SourcePage.java3
4 files changed, 137 insertions, 34 deletions
diff --git a/core/source/org/openoffice/ide/eclipse/core/editors/idl/UnoidlEditor.java b/core/source/org/openoffice/ide/eclipse/core/editors/idl/UnoidlEditor.java
index 0930dc3..d4c3ced 100755
--- a/core/source/org/openoffice/ide/eclipse/core/editors/idl/UnoidlEditor.java
+++ b/core/source/org/openoffice/ide/eclipse/core/editors/idl/UnoidlEditor.java
@@ -41,29 +41,26 @@
*
*
************************************************************************/
-package org.openoffice.ide.eclipse.core.editors.idl;
+package org.openoffice.ide.eclipse.core.editors.idl;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.IVerticalRuler;
-import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.editors.text.TextEditor;
import org.openoffice.ide.eclipse.core.OOEclipsePlugin;
import org.openoffice.ide.eclipse.core.editors.utils.ColorProvider;
-
-/**
+import org.openoffice.ide.eclipse.core.editors.utils.OOTextEditor;
+
+/**
* Class handling the UNO-IDL text to render them in an Eclipse editor. In order
* to fully understand the editor mechanisms, please report to Eclipse plugin
* developer's guide.
*
* @see UnoidlConfiguration for the viewer configuration
- * @see UnoidlDocumentProvider for the document provider
- *
- * @author cedricbosdo
- *
- */
-public class UnoidlEditor extends TextEditor {
+ * @see UnoidlDocumentProvider for the document provider
+ *
+ * @author cedricbosdo
+ *
+ */
+public class UnoidlEditor extends OOTextEditor {
/**
* Member that listens to the preferences property changes.
@@ -77,35 +74,28 @@ public class UnoidlEditor extends TextEditor {
/**
* The color manager providing the colors for the editor.
- */
+ */
private ColorProvider mColorManager;
/**
* Default constructor setting the correct document provider and viewer
* configuration.
- */
- public UnoidlEditor() {
+ */
+ public UnoidlEditor() {
super();
mColorManager = new ColorProvider();
setSourceViewerConfiguration(new UnoidlConfiguration(mColorManager));
setDocumentProvider(new UnoidlDocumentProvider());
- OOEclipsePlugin.getDefault().getPreferenceStore().addPropertyChangeListener(mPropertyListener);
+ OOEclipsePlugin.getDefault().getPreferenceStore().addPropertyChangeListener(mPropertyListener);
}
/**
* {@inheritDoc}
*/
- protected ISourceViewer createSourceViewer(Composite pParent, IVerticalRuler pRuler, int pStyles) {
- return super.createSourceViewer(pParent, pRuler, pStyles);
+ public void dispose() {
+ mColorManager.dispose();
+ OOEclipsePlugin.getDefault().getPreferenceStore().removePropertyChangeListener(mPropertyListener);
+ super.dispose();
}
-
- /**
- * {@inheritDoc}
- */
- public void dispose() {
- mColorManager.dispose();
- OOEclipsePlugin.getDefault().getPreferenceStore().removePropertyChangeListener(mPropertyListener);
- super.dispose();
- }
-}
+}
diff --git a/core/source/org/openoffice/ide/eclipse/core/editors/registry/RegEditor.java b/core/source/org/openoffice/ide/eclipse/core/editors/registry/RegEditor.java
index 52ea1c2..0f20d72 100755
--- a/core/source/org/openoffice/ide/eclipse/core/editors/registry/RegEditor.java
+++ b/core/source/org/openoffice/ide/eclipse/core/editors/registry/RegEditor.java
@@ -46,7 +46,7 @@ package org.openoffice.ide.eclipse.core.editors.registry;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.IVerticalRuler;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.editors.text.TextEditor;
+import org.openoffice.ide.eclipse.core.editors.utils.OOTextEditor;
/**
* Editor class to view the UNO registries, ie <code>.urd</code> and
@@ -55,7 +55,7 @@ import org.eclipse.ui.editors.text.TextEditor;
*
* @author cedricbosdo
*/
-public class RegEditor extends TextEditor {
+public class RegEditor extends OOTextEditor {
/**
* Default constructor, initializing the document provider.
diff --git a/core/source/org/openoffice/ide/eclipse/core/editors/utils/OOTextEditor.java b/core/source/org/openoffice/ide/eclipse/core/editors/utils/OOTextEditor.java
new file mode 100644
index 0000000..46c9d1a
--- /dev/null
+++ b/core/source/org/openoffice/ide/eclipse/core/editors/utils/OOTextEditor.java
@@ -0,0 +1,114 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the GNU Lesser General Public License Version 2.1
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2009 by Novell, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ * The Initial Developer of the Original Code is: Cédric Bosdonnat.
+ *
+ * Copyright: 2010 by Cédric Bosdonnat <cedric.bosdonnat@free.fr>
+ *
+ * All Rights Reserved.
+ *
+ ************************************************************************/
+package org.openoffice.ide.eclipse.core.editors.utils;
+
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.IVerticalRuler;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.editors.text.TextEditor;
+
+/**
+ * Base class for an enhanced text editor to be used in the ooeclipse plugins.
+ *
+ * @author Cédric Bosdonnat <cedric.bosdonnat@free.fr>
+ *
+ */
+public class OOTextEditor extends TextEditor {
+
+ private Composite mMsgComposite;
+ private boolean mMsgVisible = false;
+
+ /**
+ * Hide or Show the message box of the editor.
+ *
+ * @param pVisible <code>true</code> to show it, <code>false</code> to hide.
+ */
+ public void setMessageVisible(boolean pVisible) {
+ mMsgVisible = pVisible;
+ if ( mMsgComposite != null ) {
+ ((GridData) mMsgComposite.getLayoutData()).exclude = !pVisible;
+ mMsgComposite.setVisible(pVisible);
+ mMsgComposite.getParent().layout(true, true);
+ }
+ }
+
+ /**
+ * Override this method to set or change the editor message controls.
+ *
+ * @param pParent the parent composite to use for the creation
+ */
+ protected void createMessageContent(Composite pParent) {
+ // Do nothing here
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected ISourceViewer createSourceViewer(Composite pParent, IVerticalRuler pRuler, int pStyles) {
+ Composite composite = new Composite(pParent, SWT.NONE);
+ GridLayout layout = new GridLayout(1, false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.horizontalSpacing = 0;
+ layout.verticalSpacing = 0;
+ composite.setLayout(layout);
+
+ // Create the warning message
+ mMsgComposite = new Composite(composite, SWT.NONE);
+ GridData data = new GridData(SWT.FILL, SWT.TOP, true, false);
+ mMsgComposite.setLayoutData(data);
+ GridLayout gridLayout = new GridLayout(1, false);
+ gridLayout.marginWidth = 0;
+ gridLayout.marginHeight = 0;
+ gridLayout.verticalSpacing = 0;
+ gridLayout.horizontalSpacing = 0;
+ mMsgComposite.setLayout(gridLayout);
+
+ createMessageContent(mMsgComposite);
+ setMessageVisible( mMsgVisible );
+
+ Composite editorComposite = new Composite(composite, SWT.NONE);
+ editorComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ FillLayout fillLayout = new FillLayout(SWT.VERTICAL);
+ fillLayout.marginHeight = 0;
+ fillLayout.marginWidth = 0;
+ fillLayout.spacing = 0;
+ editorComposite.setLayout(fillLayout);
+
+ ISourceViewer srcViewer = super.createSourceViewer(editorComposite, pRuler, pStyles);
+
+ return srcViewer;
+ }
+}
diff --git a/core/source/org/openoffice/ide/eclipse/core/editors/utils/SourcePage.java b/core/source/org/openoffice/ide/eclipse/core/editors/utils/SourcePage.java
index 46d8971..bfa09f0 100644
--- a/core/source/org/openoffice/ide/eclipse/core/editors/utils/SourcePage.java
+++ b/core/source/org/openoffice/ide/eclipse/core/editors/utils/SourcePage.java
@@ -46,7 +46,6 @@ package org.openoffice.ide.eclipse.core.editors.utils;
import org.eclipse.core.resources.IMarker;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.editors.text.TextEditor;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.editor.IFormPage;
@@ -58,7 +57,7 @@ import org.eclipse.ui.ide.IDE;
* @author cedricbosdo
*
*/
-public class SourcePage extends TextEditor implements IFormPage {
+public class SourcePage extends OOTextEditor implements IFormPage {
private FormEditor mEditor;
private Control mControl;