Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2011-12-16 08:48:48 -0500
committerUwe Stieber2011-12-16 08:48:48 -0500
commit1c7e43c0756bd40b7c5eafc651c8e353cd6efb45 (patch)
tree39dab1d9e4262c0522556fbf5c92a9488f82bd83 /target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views
parentc83143083c3dd734a9d702b63e1d5e1aa6333708 (diff)
downloadorg.eclipse.tcf-1c7e43c0756bd40b7c5eafc651c8e353cd6efb45.tar.gz
org.eclipse.tcf-1c7e43c0756bd40b7c5eafc651c8e353cd6efb45.tar.xz
org.eclipse.tcf-1c7e43c0756bd40b7c5eafc651c8e353cd6efb45.zip
Target Explorer: Add basic line style decoration for comment lines and ignored connect statements
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/ScriptPad.java10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/ScriptPadLineStyleListener.java61
2 files changed, 71 insertions, 0 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/ScriptPad.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/ScriptPad.java
index 54f63cd94..3a0379b28 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/ScriptPad.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/ScriptPad.java
@@ -89,6 +89,8 @@ public class ScriptPad extends ViewPart implements ISelectionProvider, Selection
private Label head;
// Reference to the Text widget
/* default */ StyledText text;
+ // Reference to the line style listener
+ private ScriptPadLineStyleListener lineStyleListener;
// The list of registered selection changed listeners
private final List<ISelectionChangedListener> listeners = new ArrayList<ISelectionChangedListener>();
@@ -125,6 +127,11 @@ public class ScriptPad extends ViewPart implements ISelectionProvider, Selection
public void dispose() {
if (text != null && !text.isDisposed()) {
text.removeSelectionListener(this);
+ if (lineStyleListener != null) {
+ text.removeLineStyleListener(lineStyleListener);
+ lineStyleListener.dispose();
+ lineStyleListener = null;
+ }
}
listeners.clear();
fileLoaded = null;
@@ -164,6 +171,9 @@ public class ScriptPad extends ViewPart implements ISelectionProvider, Selection
}
});
+ lineStyleListener = new ScriptPadLineStyleListener();
+ text.addLineStyleListener(lineStyleListener);
+
// Register ourselves as selection provider
getViewSite().setSelectionProvider(this);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/ScriptPadLineStyleListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/ScriptPadLineStyleListener.java
new file mode 100644
index 000000000..ad019cdf7
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/ScriptPadLineStyleListener.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.ui.views.scriptpad;
+
+import java.util.regex.Pattern;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.LineStyleEvent;
+import org.eclipse.swt.custom.LineStyleListener;
+import org.eclipse.swt.custom.StyleRange;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.tcf.te.runtime.interfaces.IDisposable;
+
+/**
+ * Script Pad line style listener implementation.
+ */
+public class ScriptPadLineStyleListener implements LineStyleListener, IDisposable {
+ private static final Pattern COMMENT_LINE = Pattern.compile("\\s*#.*"); //$NON-NLS-1$
+ private static final Pattern CONNECT_LINE = Pattern.compile("\\s*connect\\s+.*"); //$NON-NLS-1$
+// private static final Pattern COMMAND_LINE = Pattern.compile("\\s*tcf\\s+(\\w+)\\s+(\\w+)(.*)"); //$NON-NLS-1$
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.interfaces.IDisposable#dispose()
+ */
+ @Override
+ public void dispose() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.custom.LineStyleListener#lineGetStyle(org.eclipse.swt.custom.LineStyleEvent)
+ */
+ @Override
+ public void lineGetStyle(LineStyleEvent event) {
+ String text = event.lineText;
+
+ if (text != null && !"".equals(text)) { //$NON-NLS-1$
+
+ if (COMMENT_LINE.matcher(text).matches()) {
+ StyleRange range = new StyleRange(event.lineOffset, text.length(),
+ event.widget.getDisplay().getSystemColor(SWT.COLOR_DARK_GREEN),
+ ((StyledText)event.widget).getBackground());
+ event.styles = new StyleRange[] { range };
+ }
+ else if (CONNECT_LINE.matcher(text).matches()) {
+ StyleRange range = new StyleRange(event.lineOffset, text.length(),
+ event.widget.getDisplay().getSystemColor(SWT.COLOR_GRAY),
+ ((StyledText)event.widget).getBackground(),
+ SWT.ITALIC);
+ event.styles = new StyleRange[] { range };
+ }
+ }
+ }
+
+}

Back to the top