Display d = parent.getDisplay();
LogColors colors = new LogColors();
ImageLoader loader = DdmsPlugin.getImageLoader();
colors.infoColor = new Color(d, 0, 127, 0);
colors.debugColor = new Color(d, 0, 0, 127);
colors.errorColor = new Color(d, 255, 0, 0);
colors.warningColor = new Color(d, 255, 127, 0);
colors.verboseColor = new Color(d, 0, 0, 0);
mCreateFilterAction = new CommonAction("Create Filter") {
@Override
public void run() {
mLogPanel.addFilter();
}
};
mCreateFilterAction.setToolTipText("Create Filter");
mCreateFilterAction.setImageDescriptor(loader
.loadDescriptor("add.png")); // $NON-NLS-1$
mEditFilterAction = new CommonAction("Edit Filter") {
@Override
public void run() {
mLogPanel.editFilter();
}
};
mEditFilterAction.setToolTipText("Edit Filter");
mEditFilterAction.setImageDescriptor(loader
.loadDescriptor("edit.png")); // $NON-NLS-1$
mDeleteFilterAction = new CommonAction("Delete Filter") {
@Override
public void run() {
mLogPanel.deleteFilter();
}
};
mDeleteFilterAction.setToolTipText("Delete Filter");
mDeleteFilterAction.setImageDescriptor(loader
.loadDescriptor("delete.png")); // $NON-NLS-1$
mExportAction = new CommonAction("Export Selection As Text...") {
@Override
public void run() {
mLogPanel.save();
}
};
mExportAction.setToolTipText("Export Selection As Text...");
mExportAction.setImageDescriptor(loader.loadDescriptor("save.png")); // $NON-NLS-1$
LogLevel[] levels = LogLevel.values();
mLogLevelActions = new CommonAction[mLogLevelIcons.length];
for (int i = 0 ; i < mLogLevelActions.length; i++) {
String name = levels[i].getStringValue();
mLogLevelActions[i] = new CommonAction(name, IAction.AS_CHECK_BOX) {
@Override
public void run() {
// disable the other actions and record current index
for (int i = 0 ; i < mLogLevelActions.length; i++) {
Action a = mLogLevelActions[i];
if (a == this) {
a.setChecked(true);
// set the log level
mLogPanel.setCurrentFilterLogLevel(i+2);
} else {
a.setChecked(false);
}
}
}
};
mLogLevelActions[i].setToolTipText(name);
mLogLevelActions[i].setImageDescriptor(loader.loadDescriptor(mLogLevelIcons[i]));
}
mClearAction = new Action("Clear Log") {
@Override
public void run() {
mLogPanel.clear();
}
};
mClearAction.setImageDescriptor(loader
.loadDescriptor("clear.png")); // $NON-NLS-1$
// now create the log view
mLogPanel = new LogPanel(loader, colors, new FilterStorage(), LogPanel.FILTER_MANUAL);
mLogPanel.setActions(mDeleteFilterAction, mEditFilterAction, mLogLevelActions);
// get the font
String fontStr = DdmsPlugin.getDefault().getPreferenceStore().getString(
PreferenceInitializer.ATTR_LOGCAT_FONT);
if (fontStr != null) {
FontData data = new FontData(fontStr);
if (fontStr != null) {
mLogPanel.setFont(new Font(parent.getDisplay(), data));
}
}
mLogPanel.createPanel(parent);
setSelectionDependentPanel(mLogPanel);
// place the actions.
placeActions();
// setup the copy action
mClipboard = new Clipboard(d);
IActionBars actionBars = getViewSite().getActionBars();
actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), new Action("Copy") {
@Override
public void run() {
mLogPanel.copy(mClipboard);
}
});
// setup the select all action
actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(),
new Action("Select All") {
@Override
public void run() {
mLogPanel.selectAll();
}
});