aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java116
-rw-r--r--eclipse/dictionary.txt1
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidXmlEditor.java30
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/ActivityPage.java20
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectWizard.java2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplatePage.java40
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplateWizard.java6
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplateWizardState.java14
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/Parameter.java36
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateHandler.java37
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateMetadata.java145
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/templates/BlankActivity/template.xml25
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/templates/MasterDetailFlow/template.xml7
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/templates/NewAndroidApplication/template.xml7
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.ddms/plugin.xml6
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/preferences/LogCatColorsPage.java65
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/preferences/LogCatPreferencePage.java18
17 files changed, 439 insertions, 136 deletions
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java
index c2942d0..233c7c1 100644
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java
+++ b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java
@@ -41,6 +41,8 @@ import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.ModifyEvent;
@@ -52,6 +54,7 @@ import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -92,6 +95,15 @@ public final class LogCatPanel extends SelectionDependentPanel
/** Preference key to use for storing font settings. */
public static final String LOGCAT_VIEW_FONT_PREFKEY = "logcat.view.font";
+ // Preference keys for message colors based on severity level
+ private static final String MSG_COLOR_PREFKEY_PREFIX = "logcat.msg.color.";
+ public static final String VERBOSE_COLOR_PREFKEY = MSG_COLOR_PREFKEY_PREFIX + "verbose"; //$NON-NLS-1$
+ public static final String DEBUG_COLOR_PREFKEY = MSG_COLOR_PREFKEY_PREFIX + "debug"; //$NON-NLS-1$
+ public static final String INFO_COLOR_PREFKEY = MSG_COLOR_PREFKEY_PREFIX + "info"; //$NON-NLS-1$
+ public static final String WARN_COLOR_PREFKEY = MSG_COLOR_PREFKEY_PREFIX + "warn"; //$NON-NLS-1$
+ public static final String ERROR_COLOR_PREFKEY = MSG_COLOR_PREFKEY_PREFIX + "error"; //$NON-NLS-1$
+ public static final String ASSERT_COLOR_PREFKEY = MSG_COLOR_PREFKEY_PREFIX + "assert"; //$NON-NLS-1$
+
// Use a monospace font family
private static final String FONT_FAMILY =
DdmConstants.CURRENT_PLATFORM == DdmConstants.PLATFORM_DARWIN ? "Monaco":"Courier New";
@@ -163,6 +175,13 @@ public final class LogCatPanel extends SelectionDependentPanel
private Font mFont;
private int mWrapWidthInChars;
+ private Color mVerboseColor;
+ private Color mDebugColor;
+ private Color mInfoColor;
+ private Color mWarnColor;
+ private Color mErrorColor;
+ private Color mAssertColor;
+
private SashForm mSash;
// messages added since last refresh, synchronized on mLogBuffer
@@ -185,6 +204,20 @@ public final class LogCatPanel extends SelectionDependentPanel
initializePreferenceUpdateListeners();
mFont = getFontFromPrefStore();
+ loadMessageColorPreferences();
+ }
+
+ private void loadMessageColorPreferences() {
+ if (mVerboseColor != null) {
+ disposeMessageColors();
+ }
+
+ mVerboseColor = getColorFromPrefStore(VERBOSE_COLOR_PREFKEY);
+ mDebugColor = getColorFromPrefStore(DEBUG_COLOR_PREFKEY);
+ mInfoColor = getColorFromPrefStore(INFO_COLOR_PREFKEY);
+ mWarnColor = getColorFromPrefStore(WARN_COLOR_PREFKEY);
+ mErrorColor = getColorFromPrefStore(ERROR_COLOR_PREFKEY);
+ mAssertColor = getColorFromPrefStore(ASSERT_COLOR_PREFKEY);
}
private void initializeFilters() {
@@ -209,6 +242,20 @@ public final class LogCatPanel extends SelectionDependentPanel
mPrefStore.setDefault(LogCatMessageList.MAX_MESSAGES_PREFKEY,
LogCatMessageList.MAX_MESSAGES_DEFAULT);
mPrefStore.setDefault(DISPLAY_FILTERS_COLUMN_PREFKEY, true);
+
+ /* Default Colors for different log levels. */
+ PreferenceConverter.setDefault(mPrefStore, LogCatPanel.VERBOSE_COLOR_PREFKEY,
+ new RGB(0, 0, 0));
+ PreferenceConverter.setDefault(mPrefStore, LogCatPanel.DEBUG_COLOR_PREFKEY,
+ new RGB(0, 0, 127));
+ PreferenceConverter.setDefault(mPrefStore, LogCatPanel.INFO_COLOR_PREFKEY,
+ new RGB(0, 127, 0));
+ PreferenceConverter.setDefault(mPrefStore, LogCatPanel.WARN_COLOR_PREFKEY,
+ new RGB(255, 127, 0));
+ PreferenceConverter.setDefault(mPrefStore, LogCatPanel.ERROR_COLOR_PREFKEY,
+ new RGB(255, 0, 0));
+ PreferenceConverter.setDefault(mPrefStore, LogCatPanel.ASSERT_COLOR_PREFKEY,
+ new RGB(255, 0, 0));
}
private void initializePreferenceUpdateListeners() {
@@ -230,6 +277,21 @@ public final class LogCatPanel extends SelectionDependentPanel
}
}
});
+ } else if (changedProperty.startsWith(MSG_COLOR_PREFKEY_PREFIX)) {
+ loadMessageColorPreferences();
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ Color c = mVerboseColor;
+ for (TableItem it: mTable.getItems()) {
+ Object data = it.getData();
+ if (data instanceof LogCatMessage) {
+ c = getForegroundColor((LogCatMessage) data);
+ }
+ it.setForeground(c);
+ }
+ }
+ });
} else if (changedProperty.equals(LogCatMessageList.MAX_MESSAGES_PREFKEY)) {
mReceiver.resizeFifo(mPrefStore.getInt(
LogCatMessageList.MAX_MESSAGES_PREFKEY));
@@ -834,6 +896,13 @@ public final class LogCatPanel extends SelectionDependentPanel
addRightClickMenu(mTable);
initDoubleClickListener();
recomputeWrapWidth();
+
+ mTable.addDisposeListener(new DisposeListener() {
+ @Override
+ public void widgetDisposed(DisposeEvent arg0) {
+ dispose();
+ }
+ });
}
/** Setup menu to be displayed when right clicking a log message. */
@@ -914,6 +983,11 @@ public final class LogCatPanel extends SelectionDependentPanel
return new Font(Display.getDefault(), fd);
}
+ private Color getColorFromPrefStore(String key) {
+ RGB rgb = PreferenceConverter.getColor(mPrefStore, key);
+ return new Color(Display.getDefault(), rgb);
+ }
+
private void setupDefaults() {
int defaultFilterIndex = 0;
mFiltersTableViewer.getTable().setSelection(defaultFilterIndex);
@@ -1239,29 +1313,24 @@ public final class LogCatPanel extends SelectionDependentPanel
return wrappedMessages;
}
- /* Default Colors for different log levels. */
- private static final Color INFO_MSG_COLOR = new Color(null, 0, 127, 0);
- private static final Color DEBUG_MSG_COLOR = new Color(null, 0, 0, 127);
- private static final Color ERROR_MSG_COLOR = new Color(null, 255, 0, 0);
- private static final Color WARN_MSG_COLOR = new Color(null, 255, 127, 0);
- private static final Color VERBOSE_MSG_COLOR = new Color(null, 0, 0, 0);
-
- private static Color getForegroundColor(LogCatMessage m) {
+ private Color getForegroundColor(LogCatMessage m) {
LogLevel l = m.getLogLevel();
if (l.equals(LogLevel.VERBOSE)) {
- return VERBOSE_MSG_COLOR;
+ return mVerboseColor;
} else if (l.equals(LogLevel.INFO)) {
- return INFO_MSG_COLOR;
+ return mInfoColor;
} else if (l.equals(LogLevel.DEBUG)) {
- return DEBUG_MSG_COLOR;
+ return mDebugColor;
} else if (l.equals(LogLevel.ERROR)) {
- return ERROR_MSG_COLOR;
+ return mErrorColor;
} else if (l.equals(LogLevel.WARN)) {
- return WARN_MSG_COLOR;
+ return mWarnColor;
+ } else if (l.equals(LogLevel.ASSERT)) {
+ return mAssertColor;
}
- return null;
+ return mVerboseColor;
}
private List<ILogCatMessageSelectionListener> mMessageSelectionListeners;
@@ -1344,4 +1413,23 @@ public final class LogCatPanel extends SelectionDependentPanel
public void selectAll() {
mTable.selectAll();
}
+
+ private void dispose() {
+ if (mFont != null && !mFont.isDisposed()) {
+ mFont.dispose();
+ }
+
+ if (mVerboseColor != null && !mVerboseColor.isDisposed()) {
+ disposeMessageColors();
+ }
+ }
+
+ private void disposeMessageColors() {
+ mVerboseColor.dispose();
+ mDebugColor.dispose();
+ mInfoColor.dispose();
+ mWarnColor.dispose();
+ mErrorColor.dispose();
+ mAssertColor.dispose();
+ }
}
diff --git a/eclipse/dictionary.txt b/eclipse/dictionary.txt
index 5ac89f5..dbb51e5 100644
--- a/eclipse/dictionary.txt
+++ b/eclipse/dictionary.txt
@@ -292,6 +292,7 @@ textfields
thematically
themed
thumbnail
+thumbnails
timestamp
timestamps
tmp
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidXmlEditor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidXmlEditor.java
index 803478b..396e172 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidXmlEditor.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidXmlEditor.java
@@ -1018,23 +1018,21 @@ public abstract class AndroidXmlEditor extends FormEditor implements IResourceCh
model.changedModel();
if (AdtPrefs.getPrefs().getFormatGuiXml() && mFormatNode != null) {
- if (!mFormatNode.hasError()) {
- if (mFormatNode == getUiRootNode()) {
- reformatDocument();
- } else {
- Node node = mFormatNode.getXmlNode();
- if (node instanceof IndexedRegion) {
- IndexedRegion region = (IndexedRegion) node;
- int begin = region.getStartOffset();
- int end = region.getEndOffset();
-
- if (!mFormatChildren) {
- // This will format just the attribute list
- end = begin + 1;
- }
-
- reformatRegion(begin, end);
+ if (mFormatNode == getUiRootNode()) {
+ reformatDocument();
+ } else {
+ Node node = mFormatNode.getXmlNode();
+ if (node instanceof IndexedRegion) {
+ IndexedRegion region = (IndexedRegion) node;
+ int begin = region.getStartOffset();
+ int end = region.getEndOffset();
+
+ if (!mFormatChildren) {
+ // This will format just the attribute list
+ end = begin + 1;
}
+
+ reformatRegion(begin, end);
}
}
mFormatNode = null;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/ActivityPage.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/ActivityPage.java
index 22eb81a..9a61b4f 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/ActivityPage.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/ActivityPage.java
@@ -16,9 +16,6 @@
package com.android.ide.eclipse.adt.internal.wizards.templates;
import static com.android.ide.eclipse.adt.internal.wizards.templates.NewTemplateWizard.ACTIVITY_TEMPLATES;
-import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.ATTR_DESCRIPTION;
-import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.ATTR_NAME;
-import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.ATTR_THUMB;
import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.PREVIEW_PADDING;
import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.PREVIEW_WIDTH;
@@ -41,8 +38,6 @@ import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
import java.io.InputStream;
@@ -121,18 +116,17 @@ class ActivityPage extends WizardPage implements SelectionListener {
setPreview(mValues.activityValues.getTemplateName());
}
- private void setPreview(String template) {
+ private void setPreview(String templateName) {
Image oldImage = mPreviewImage;
mPreviewImage = null;
String title = "";
String description = "";
- Document doc = TemplateHandler.getMetadataDocument(template);
- if (doc != null) {
- Element root = doc.getDocumentElement();
- String thumb = root.getAttribute(ATTR_THUMB);
+ TemplateMetadata template = TemplateHandler.getTemplate(templateName);
+ if (template != null) {
+ String thumb = template.getThumbnailPath();
if (thumb != null && !thumb.isEmpty()) {
- String filePath = TemplateHandler.getTemplatePath(template) + '/' + thumb;
+ String filePath = TemplateHandler.getTemplatePath(templateName) + '/' + thumb;
InputStream input = AdtPlugin.readEmbeddedFileAsStream(filePath);
if (input != null) {
try {
@@ -143,8 +137,8 @@ class ActivityPage extends WizardPage implements SelectionListener {
}
}
}
- title = root.getAttribute(ATTR_NAME);
- description = root.getAttribute(ATTR_DESCRIPTION);
+ title = template.getTitle();
+ description = template.getDescription();
}
mHeading.setText(title);
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectWizard.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectWizard.java
index 9df974f..60f7a9e 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectWizard.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectWizard.java
@@ -317,7 +317,7 @@ public class NewProjectWizard extends Wizard implements INewWizard {
parameters.put(ATTR_TARGET_API, paramMap.get(ATTR_TARGET_API));
- TemplateHandler activityTemplate = activityValues.getTemplate();
+ TemplateHandler activityTemplate = activityValues.getTemplateHandler();
activityTemplate.setBackupMergedFiles(false);
activityTemplate.render(outputPath, parameters);
List<String> filesToOpen = activityTemplate.getFilesToOpen();
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplatePage.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplatePage.java
index f89fd11..a6fdf48 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplatePage.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplatePage.java
@@ -16,10 +16,8 @@
package com.android.ide.eclipse.adt.internal.wizards.templates;
import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.ATTR_DEFAULT;
-import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.ATTR_DESCRIPTION;
import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.ATTR_ID;
import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.ATTR_NAME;
-import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.ATTR_THUMB;
import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.PREVIEW_PADDING;
import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.PREVIEW_WIDTH;
@@ -57,7 +55,6 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -160,16 +157,15 @@ public class NewTemplatePage extends WizardPage
// Add parameters
mFirst = null;
- Document doc = mValues.getTemplate().getMetadataDocument();
+ TemplateMetadata template = mValues.getTemplateHandler().getTemplate();
String thumb = null;
- if (doc != null) {
- Element root = doc.getDocumentElement();
- thumb = root.getAttribute(ATTR_THUMB);
- String title = root.getAttribute(ATTR_NAME);
+ if (template != null) {
+ thumb = template.getThumbnailPath();
+ String title = template.getTitle();
if (!title.isEmpty()) {
setTitle(title);
}
- String description = root.getAttribute(ATTR_DESCRIPTION);
+ String description = template.getDescription();
if (!description.isEmpty()) {
setDescription(description);
}
@@ -180,8 +176,7 @@ public class NewTemplatePage extends WizardPage
seen = new HashSet<String>();
}
-
- List<Parameter> parameters = Parameter.getParameters(doc);
+ List<Parameter> parameters = template.getParameters();
mParameters = new ArrayList<Parameter>(parameters.size());
for (Parameter parameter : parameters) {
Parameter.Type type = parameter.type;
@@ -288,19 +283,14 @@ public class NewTemplatePage extends WizardPage
int selected = 0;
List<String> ids = Lists.newArrayList();
List<String> labels = Lists.newArrayList();
- List<String> thumbs = Lists.newArrayList();
for (int i = 0, n = options.size(); i < n; i++) {
Element option = options.get(i);
String optionId = option.getAttribute(ATTR_ID);
assert optionId != null && !optionId.isEmpty() : ATTR_ID;
- String optionThumb = option.getAttribute(ATTR_THUMB);
String isDefault = option.getAttribute(ATTR_DEFAULT);
if (isDefault != null && !isDefault.isEmpty() &&
Boolean.valueOf(isDefault)) {
selected = i;
- if (optionThumb != null && !optionThumb.isEmpty()) {
- thumb = optionThumb;
- }
}
NodeList childNodes = option.getChildNodes();
assert childNodes.getLength() == 1 &&
@@ -308,11 +298,9 @@ public class NewTemplatePage extends WizardPage
String optionLabel = childNodes.item(0).getNodeValue().trim();
ids.add(optionId);
labels.add(optionLabel);
- thumbs.add(optionThumb);
}
combo.setData(parameter);
parameter.control = combo;
- combo.setData(ATTR_THUMB, thumbs.toArray(new String[thumbs.size()]));
combo.setData(ATTR_ID, ids.toArray(new String[ids.size()]));
assert labels.size() > 0;
combo.setItems(labels.toArray(new String[labels.size()]));
@@ -371,10 +359,14 @@ public class NewTemplatePage extends WizardPage
}
private void setPreview(String thumb) {
+ if (thumb == null) {
+ return;
+ }
+
Image oldImage = mPreviewImage;
mPreviewImage = null;
- byte[] data = mValues.getTemplate().readTemplateResource(thumb);
+ byte[] data = mValues.getTemplateHandler().readTemplateResource(thumb);
if (data != null) {
try {
mPreviewImage = new Image(getControl().getDisplay(),
@@ -546,15 +538,15 @@ public class NewTemplatePage extends WizardPage
if (index != -1 && index < optionIds.length) {
String optionId = optionIds[index];
editParameter(combo, optionId);
- String[] thumbs = (String[]) combo.getData(ATTR_THUMB);
- String thumb = thumbs[index];
- if (thumb != null && !thumb.isEmpty()) {
- setPreview(thumb);
- }
+ TemplateMetadata template = mValues.getTemplateHandler().getTemplate();
+ setPreview(template.getThumbnailPath());
}
} else if (source instanceof Button) {
Button button = (Button) source;
editParameter(button, button.getSelection());
+
+ TemplateMetadata template = mValues.getTemplateHandler().getTemplate();
+ setPreview(template.getThumbnailPath());
}
validatePage();
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplateWizard.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplateWizard.java
index 5fe91c5..b7ad998 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplateWizard.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplateWizard.java
@@ -119,8 +119,8 @@ public class NewTemplateWizard extends Wizard implements INewWizard {
parameters.put(ATTR_TARGET_API, manifest.getTargetSdkVersion());
File outputPath = AdtUtils.getAbsolutePath(project).toFile();
- TemplateHandler template = mValues.getTemplate();
- template.render(outputPath, parameters);
+ TemplateHandler handler = mValues.getTemplateHandler();
+ handler.render(outputPath, parameters);
try {
project.refreshLocal(DEPTH_INFINITE, new NullProgressMonitor());
@@ -128,7 +128,7 @@ public class NewTemplateWizard extends Wizard implements INewWizard {
AdtPlugin.log(e, null);
}
- List<String> filesToOpen = template.getFilesToOpen();
+ List<String> filesToOpen = handler.getFilesToOpen();
NewTemplateWizard.openFiles(project, filesToOpen, mWorkbench);
return true;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplateWizardState.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplateWizardState.java
index cb32a4f..dc75a71 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplateWizardState.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplateWizardState.java
@@ -37,7 +37,7 @@ public class NewTemplateWizardState {
private String mTemplateName = BLANK_ACTIVITY;
/** Template handler responsible for instantiating templates and reading resources */
- private TemplateHandler mTemplate;
+ private TemplateHandler mTemplateHandler;
/** Configured parameters, by id */
public final Map<String, Object> parameters = new HashMap<String, Object>();
@@ -78,23 +78,23 @@ public class NewTemplateWizardState {
if (!templateName.equals(mTemplateName)) {
mTemplateName = templateName;
mTemplateLocation = null;
- mTemplate = null;
+ mTemplateHandler = null;
}
}
@NonNull
- TemplateHandler getTemplate() {
- if (mTemplate == null) {
+ TemplateHandler getTemplateHandler() {
+ if (mTemplateHandler == null) {
File inputPath;
if (mTemplateLocation != null) {
inputPath = mTemplateLocation;
} else {
inputPath = new File(TemplateHandler.getTemplatePath(mTemplateName));
}
- mTemplate = TemplateHandler.createFromPath(inputPath);
+ mTemplateHandler = TemplateHandler.createFromPath(inputPath);
}
- return mTemplate;
+ return mTemplateHandler;
}
// For template development/testing only
@@ -102,7 +102,7 @@ public class NewTemplateWizardState {
if (!file.equals(mTemplateLocation)) {
mTemplateLocation = file;
mTemplateName = null;
- mTemplate = null;
+ mTemplateHandler = null;
}
}
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/Parameter.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/Parameter.java
index 1fad0e1..0b8b952 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/Parameter.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/Parameter.java
@@ -21,7 +21,6 @@ import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHan
import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.ATTR_ID;
import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.ATTR_NAME;
import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.ATTR_SUGGEST;
-import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.TAG_PARAMETER;
import com.android.annotations.NonNull;
import com.android.annotations.Nullable;
@@ -37,13 +36,9 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.fieldassist.ControlDecoration;
import org.eclipse.swt.widgets.Control;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import java.util.ArrayList;
import java.util.EnumSet;
-import java.util.List;
import java.util.Locale;
/**
@@ -142,24 +137,7 @@ class Parameter {
}
}
- /** The type of parameter. Must be one of
- * <ul>
- * <li> string
- * <li> id
- * <li> class
- * <li> boolean
- * <li> package
- * <li> apiLevel
- * <li> enum (must contain option children)
- * <li> Resource types:
- * <ul>
- * <li> layout
- * <li> <i>more to come</i>
- * </ul>
- * </ul>
- * <p>
- * TODO: Switch to an enum
- */
+ /** The type of parameter */
@NonNull
public final Type type;
@@ -346,16 +324,4 @@ class Parameter {
return mValidator;
}
-
- @NonNull
- static List<Parameter> getParameters(@NonNull Document document) {
- NodeList parameters = document.getElementsByTagName(TAG_PARAMETER);
- List<Parameter> list = new ArrayList<Parameter>(parameters.getLength());
- for (int index = 0, max = parameters.getLength(); index < max; index++) {
- Element element = (Element) parameters.item(index);
- list.add(new Parameter(element));
- }
-
- return list;
- }
} \ No newline at end of file
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateHandler.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateHandler.java
index 8864502..dc0c898 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateHandler.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateHandler.java
@@ -117,6 +117,8 @@ class TemplateHandler {
static final String TAG_COPY = "copy"; //$NON-NLS-1$
static final String TAG_INSTANTIATE = "instantiate"; //$NON-NLS-1$
static final String TAG_OPEN = "open"; //$NON-NLS-1$
+ static final String TAG_THUMB = "thumb"; //$NON-NLS-1$
+ static final String TAG_THUMBS = "thumbs"; //$NON-NLS-1$
static final String ATTR_VALUE = "value"; //$NON-NLS-1$
static final String ATTR_DEFAULT = "default"; //$NON-NLS-1$
static final String ATTR_SUGGEST = "suggest"; //$NON-NLS-1$
@@ -129,7 +131,6 @@ class TemplateHandler {
static final String ATTR_TO = "to"; //$NON-NLS-1$
static final String ATTR_FROM = "from"; //$NON-NLS-1$
static final String ATTR_CONSTRAINTS = "constraints";//$NON-NLS-1$
- static final String ATTR_THUMB = "thumb"; //$NON-NLS-1$
/** Default padding to apply in wizards around the thumbnail preview images */
static final int PREVIEW_PADDING = 10;
@@ -161,6 +162,11 @@ class TemplateHandler {
*/
private boolean mBackupMergedFiles = true;
+ /**
+ * Template metadata
+ */
+ private TemplateMetadata mTemplate;
+
/** Creates a new {@link TemplateHandler} for the given root path */
static TemplateHandler createFromPath(File rootPath) {
return new TemplateHandler(rootPath);
@@ -222,25 +228,38 @@ class TemplateHandler {
}
@Nullable
- public Document getMetadataDocument() {
- String xml = readTemplateTextResource(TEMPLATE_XML);
- if (xml != null) {
- return DomUtilities.parseDocument(xml, true);
- } else {
- return null;
+ public TemplateMetadata getTemplate() {
+ if (mTemplate == null) {
+ String xml = readTemplateTextResource(TEMPLATE_XML);
+ if (xml != null) {
+ Document doc = DomUtilities.parseDocument(xml, true);
+ if (doc != null && doc.getDocumentElement() != null) {
+ mTemplate = new TemplateMetadata(doc);
+ }
+ }
}
+
+ return mTemplate;
}
- public static Document getMetadataDocument(String templateName) {
+ @Nullable
+ public static TemplateMetadata getTemplate(String templateName) {
String relative = getTemplatePath(templateName) + '/' +TEMPLATE_XML;
String xml = AdtPlugin.readEmbeddedTextFile(relative);
- return DomUtilities.parseDocument(xml, true);
+ Document doc = DomUtilities.parseDocument(xml, true);
+ if (doc != null && doc.getDocumentElement() != null) {
+ return new TemplateMetadata(doc);
+ }
+
+ return null;
}
+ @NonNull
public static String getTemplatePath(String templateName) {
return TEMPLATE_PREFIX + templateName;
}
+ @NonNull
public String getResourcePath(String templateName) {
return new File(mRootPath.getPath(), templateName).getPath();
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateMetadata.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateMetadata.java
new file mode 100644
index 0000000..eac818a
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateMetadata.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/org/documents/epl-v10.php
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.ide.eclipse.adt.internal.wizards.templates;
+
+import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.ATTR_DESCRIPTION;
+import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.ATTR_NAME;
+import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.TAG_PARAMETER;
+import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.TAG_THUMB;
+
+import com.android.annotations.NonNull;
+import com.android.annotations.Nullable;
+import com.android.ide.eclipse.adt.AdtPlugin;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/** An ADT template along with metadata */
+class TemplateMetadata {
+ private final Document mDocument;
+ private final List<Parameter> mParameters;
+ private final Map<String, Parameter> mParameterMap;
+
+ TemplateMetadata(@NonNull Document document) {
+ mDocument = document;
+
+ NodeList parameters = mDocument.getElementsByTagName(TAG_PARAMETER);
+ mParameters = new ArrayList<Parameter>(parameters.getLength());
+ mParameterMap = new HashMap<String, Parameter>(parameters.getLength());
+ for (int index = 0, max = parameters.getLength(); index < max; index++) {
+ Element element = (Element) parameters.item(index);
+ Parameter parameter = new Parameter(element);
+ mParameters.add(parameter);
+ if (parameter.id != null) {
+ mParameterMap.put(parameter.id, parameter);
+ }
+ }
+ }
+
+ @Nullable
+ String getTitle() {
+ String name = mDocument.getDocumentElement().getAttribute(ATTR_NAME);
+ if (name != null && !name.isEmpty()) {
+ return name;
+ }
+
+ return null;
+ }
+
+ @Nullable
+ String getDescription() {
+ String description = mDocument.getDocumentElement().getAttribute(ATTR_DESCRIPTION);
+ if (description != null && !description.isEmpty()) {
+ return description;
+ }
+
+ return null;
+ }
+
+ @Nullable
+ String getThumbnailPath() {
+ // Apply selector logic. Pick the thumb first thumb that satisfies the largest number
+ // of conditions.
+ NodeList thumbs = mDocument.getElementsByTagName(TAG_THUMB);
+ if (thumbs.getLength() == 0) {
+ return null;
+ }
+
+
+ int bestMatchCount = 0;
+ Element bestMatch = null;
+
+ for (int i = 0, n = thumbs.getLength(); i < n; i++) {
+ Element thumb = (Element) thumbs.item(i);
+
+ NamedNodeMap attributes = thumb.getAttributes();
+ if (bestMatch == null && attributes.getLength() == 0) {
+ bestMatch = thumb;
+ } else if (attributes.getLength() <= bestMatchCount) {
+ // Already have a match with this number of attributes, no point checking
+ continue;
+ } else {
+ boolean match = true;
+ for (int j = 0, max = attributes.getLength(); j < max; j++) {
+ Attr attribute = (Attr) attributes.item(j);
+ Parameter parameter = mParameterMap.get(attribute.getName());
+ if (parameter == null) {
+ AdtPlugin.log(null, "Unexpected parameter in template thumbnail: %1$s",
+ attribute.getName());
+ continue;
+ }
+ String thumbNailValue = attribute.getValue();
+ String editedValue = parameter.value != null ? parameter.value.toString() : "";
+ if (!thumbNailValue.equals(editedValue)) {
+ match = false;
+ break;
+ }
+ }
+ if (match) {
+ bestMatch = thumb;
+ bestMatchCount = attributes.getLength();
+ }
+ }
+ }
+
+ if (bestMatch != null) {
+ NodeList children = bestMatch.getChildNodes();
+ for (int i = 0, n = children.getLength(); i < n; i++) {
+ Node child = children.item(i);
+ if (child.getNodeType() == Node.TEXT_NODE) {
+ return child.getNodeValue().trim();
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /** Returns the list of available parameters */
+ @NonNull
+ List<Parameter> getParameters() {
+ return mParameters;
+ }
+}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/templates/BlankActivity/template.xml b/eclipse/plugins/com.android.ide.eclipse.adt/templates/BlankActivity/template.xml
index 6294592..302e2cc 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/templates/BlankActivity/template.xml
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/templates/BlankActivity/template.xml
@@ -1,8 +1,7 @@
<?xml version="1.0"?>
<template
name="New Blank Activity"
- description="Creates a new blank activity, with optional inner navigation."
- thumb="template_blank_activity.png">
+ description="Creates a new blank activity, with optional inner navigation.">
<category value="Activities" />
@@ -30,11 +29,11 @@
type="enum"
default="none"
help="The type of navigation to use for the activity" >
- <option id="none" default="true" thumb="template_blank_activity.png">None</option>
- <option id="tabs" thumb="template_blank_activity_tabs.png">Tabs</option>
- <option id="tabs_pager" thumb="template_blank_activity_tabs_pager.png">Tabs + Swipe</option>
- <option id="pager_strip" thumb="template_blank_activity_pager.png">Swipe Views + Title Strip</option>
- <option id="dropdown" thumb="template_blank_activity_dropdown.png">Dropdown</option>
+ <option id="none" default="true">None</option>
+ <option id="tabs">Tabs</option>
+ <option id="tabs_pager">Tabs + Swipe</option>
+ <option id="pager_strip">Swipe Views + Title Strip</option>
+ <option id="dropdown">Dropdown</option>
</parameter>
<parameter
@@ -52,6 +51,18 @@
constraints="package"
default="com.mycompany.myapp" />
+ <!-- 128x128 thumbnails relative to template.xml -->
+ <thumbs>
+ <!-- default thumbnail is required -->
+ <thumb>template_blank_activity.png</thumb>
+ <!-- attributes act as selectors based on chosen parameters -->
+ <thumb navType="none">template_blank_activity.png</thumb>
+ <thumb navType="tabs">template_blank_activity_tabs.png</thumb>
+ <thumb navType="tabs_pager">template_blank_activity_tabs_pager.png</thumb>
+ <thumb navType="pager_strip">template_blank_activity_pager.png</thumb>
+ <thumb navType="dropdown">template_blank_activity_dropdown.png</thumb>
+ </thumbs>
+
<globals file="globals.xml.ftl" />
<execute file="recipe.xml.ftl" />
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/templates/MasterDetailFlow/template.xml b/eclipse/plugins/com.android.ide.eclipse.adt/templates/MasterDetailFlow/template.xml
index bc01747..0eed682 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/templates/MasterDetailFlow/template.xml
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/templates/MasterDetailFlow/template.xml
@@ -1,8 +1,11 @@
<?xml version="1.0"?>
<template
name="New Master/Detail Flow"
- description="Creates a new master/detail flow, which is two columns on tablets, and one column on smaller screens. This creates a master fragment, detail fragment, and two activities."
- thumb="template_master_detail.png">
+ description="Creates a new master/detail flow, which is two columns on tablets, and one column on smaller screens. This creates a master fragment, detail fragment, and two activities.">
+
+ <thumbs>
+ <thumb>template_master_detail.png</thumb>
+ </thumbs>
<category value="Flows" />
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/templates/NewAndroidApplication/template.xml b/eclipse/plugins/com.android.ide.eclipse.adt/templates/NewAndroidApplication/template.xml
index 60f5363..84ba6c7 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/templates/NewAndroidApplication/template.xml
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/templates/NewAndroidApplication/template.xml
@@ -1,8 +1,11 @@
<?xml version="1.0"?>
<template
name="New Android Application"
- description="Creates a new Android application with an activity."
- thumb="template_new_project.png">>
+ description="Creates a new Android application with an activity.">
+
+ <thumbs>
+ <thumb>template_new_project.png</thumb>
+ </thumbs>
<category value="Applications" />
diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/plugin.xml b/eclipse/plugins/com.android.ide.eclipse.ddms/plugin.xml
index c1d43ae..f5a809f 100644
--- a/eclipse/plugins/com.android.ide.eclipse.ddms/plugin.xml
+++ b/eclipse/plugins/com.android.ide.eclipse.ddms/plugin.xml
@@ -127,5 +127,11 @@
class="com.android.ide.eclipse.ddms.preferences.LogCatPreferencePage"
id="com.android.ide.eclipse.ddms.preferences.LogCatPreferencePage"
name="%page.name.LogCat"/>
+ <page
+ category="com.android.ide.eclipse.ddms.preferences.LogCatPreferencePage"
+ class="com.android.ide.eclipse.ddms.preferences.LogCatColorsPage"
+ id="com.android.ide.eclipse.ddms.preferences.LogCatColorsPage"
+ name="Colors">
+ </page>
</extension>
</plugin>
diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/preferences/LogCatColorsPage.java b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/preferences/LogCatColorsPage.java
new file mode 100644
index 0000000..675a51c
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/preferences/LogCatColorsPage.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.ide.eclipse.ddms.preferences;
+
+import com.android.ddmuilib.logcat.LogCatPanel;
+import com.android.ide.eclipse.ddms.DdmsPlugin;
+
+import org.eclipse.jface.preference.ColorFieldEditor;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+public class LogCatColorsPage extends FieldEditorPreferencePage
+ implements IWorkbenchPreferencePage {
+ public LogCatColorsPage() {
+ super(GRID);
+ setPreferenceStore(DdmsPlugin.getDefault().getPreferenceStore());
+ }
+
+ @Override
+ public void init(IWorkbench workbench) {
+ }
+
+ @Override
+ protected void createFieldEditors() {
+ // colors preference for different log levels
+ ColorFieldEditor cfe = new ColorFieldEditor(LogCatPanel.VERBOSE_COLOR_PREFKEY,
+ "Verbose Log Message Color", getFieldEditorParent());
+ addField(cfe);
+
+ cfe = new ColorFieldEditor(LogCatPanel.DEBUG_COLOR_PREFKEY, "Debug Log Message Color",
+ getFieldEditorParent());
+ addField(cfe);
+
+ cfe = new ColorFieldEditor(LogCatPanel.INFO_COLOR_PREFKEY, "Info Log Message Color",
+ getFieldEditorParent());
+ addField(cfe);
+
+ cfe = new ColorFieldEditor(LogCatPanel.WARN_COLOR_PREFKEY, "Warning Log Message Color",
+ getFieldEditorParent());
+ addField(cfe);
+
+ cfe = new ColorFieldEditor(LogCatPanel.ERROR_COLOR_PREFKEY, "Error Log Message Color",
+ getFieldEditorParent());
+ addField(cfe);
+
+ cfe = new ColorFieldEditor(LogCatPanel.ASSERT_COLOR_PREFKEY, "Assert Log Message Color",
+ getFieldEditorParent());
+ addField(cfe);
+ }
+}
diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/preferences/LogCatPreferencePage.java b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/preferences/LogCatPreferencePage.java
index 9971e18..a0c5450 100644
--- a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/preferences/LogCatPreferencePage.java
+++ b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/preferences/LogCatPreferencePage.java
@@ -30,6 +30,9 @@ import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.FontFieldEditor;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IPerspectiveDescriptor;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
@@ -62,18 +65,27 @@ public class LogCatPreferencePage extends FieldEditorPreferencePage implements
Messages.LogCatPreferencePage_MaxMessages, getFieldEditorParent());
addField(mMaxMessages);
+ createHorizontalSeparator();
+
if (InstallDetails.isAdtInstalled()) {
createAdtSpecificFieldEditors();
}
}
+ private void createHorizontalSeparator() {
+ Label l = new Label(getFieldEditorParent(), SWT.SEPARATOR | SWT.HORIZONTAL);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 3;
+ l.setLayoutData(gd);
+ }
+
private void createAdtSpecificFieldEditors() {
mSwitchPerspective = new BooleanFieldEditor(PreferenceInitializer.ATTR_SWITCH_PERSPECTIVE,
Messages.LogCatPreferencePage_Switch_Perspective, getFieldEditorParent());
addField(mSwitchPerspective);
IPerspectiveDescriptor[] perspectiveDescriptors =
PlatformUI.getWorkbench().getPerspectiveRegistry().getPerspectives();
- String[][] perspectives;
+ String[][] perspectives = new String[0][0];
if (perspectiveDescriptors.length > 0) {
perspectives = new String[perspectiveDescriptors.length][2];
for (int i = 0; i < perspectiveDescriptors.length; i++) {
@@ -81,8 +93,6 @@ public class LogCatPreferencePage extends FieldEditorPreferencePage implements
perspectives[i][0] = perspective.getLabel();
perspectives[i][1] = perspective.getId();
}
- } else {
- perspectives = new String[0][0];
}
mWhichPerspective = new ComboFieldEditor(PreferenceInitializer.ATTR_PERSPECTIVE_ID,
Messages.LogCatPreferencePage_Switch_To, perspectives, getFieldEditorParent());
@@ -90,6 +100,8 @@ public class LogCatPreferencePage extends FieldEditorPreferencePage implements
.getBoolean(PreferenceInitializer.ATTR_SWITCH_PERSPECTIVE), getFieldEditorParent());
addField(mWhichPerspective);
+ createHorizontalSeparator();
+
mAutoMonitorLogcat = new BooleanFieldEditor(LogCatMonitor.AUTO_MONITOR_PREFKEY,
Messages.LogCatPreferencePage_AutoMonitorLogcat,
getFieldEditorParent());