diff options
Diffstat (limited to 'org.tizen.common.connection')
8 files changed, 417 insertions, 230 deletions
diff --git a/org.tizen.common.connection/META-INF/MANIFEST.MF b/org.tizen.common.connection/META-INF/MANIFEST.MF index c4e0d3928..3aa5a4cd4 100644 --- a/org.tizen.common.connection/META-INF/MANIFEST.MF +++ b/org.tizen.common.connection/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Tizen Common Connection Bundle-SymbolicName: org.tizen.common.connection;singleton:=true -Bundle-Version: 1.17.0.qualifier +Bundle-Version: 1.0.0.qualifier Bundle-Activator: org.tizen.common.connection.ConnectionPlugin Bundle-Vendor: Samsung Require-Bundle: org.eclipse.ui, diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/debugtools/ToolsInstall.java b/org.tizen.common.connection/src/org/tizen/common/connection/debugtools/ToolsInstall.java index 144e688f8..c62827865 100644 --- a/org.tizen.common.connection/src/org/tizen/common/connection/debugtools/ToolsInstall.java +++ b/org.tizen.common.connection/src/org/tizen/common/connection/debugtools/ToolsInstall.java @@ -204,10 +204,13 @@ class InstallProgress implements IRunnableWithProgress { monitor.worked(5); if (isCopied) { try { - device.executeShellCommand("rm -rf " + DebugTool.TOOLS_TARGET_PATH + "/" + tool.getPackagename() + ";" - + "cd " + DebugTool.TOOLS_TARGET_PATH + " && tar -xzf " + tool.getBinaryname() + ";" - + "echo 'version:" + tool.getVersion() + "' >" + DebugTool.TOOLS_TARGET_PATH + "/" + tool.getControlFile() + ";" - + "cd " + DebugTool.TOOLS_TARGET_PATH + " && rm " + tool.getBinaryname()); + //make one string command for sequential executing + device.executeShellCommand( + "rm -rf " + DebugTool.TOOLS_TARGET_PATH + "/" + tool.getPackagename() + ";" + + "cd " + DebugTool.TOOLS_TARGET_PATH + " && tar -xzf " + tool.getBinaryname() + ";" + + "echo 'version:" + tool.getVersion() + "' >" + DebugTool.TOOLS_TARGET_PATH + "/" + tool.getControlFile() + ";" + + "cd " + DebugTool.TOOLS_TARGET_PATH + " && rm " + tool.getBinaryname()); + } catch (IOException e) { Logger.error("Error after copied " + tool.getPackagename() , e); } @@ -318,4 +321,4 @@ public class ToolsInstall { }); } -}
\ No newline at end of file +} diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/log/AddViewDialog.java b/org.tizen.common.connection/src/org/tizen/common/connection/log/AddViewDialog.java index be746c826..2d6ccd340 100644 --- a/org.tizen.common.connection/src/org/tizen/common/connection/log/AddViewDialog.java +++ b/org.tizen.common.connection/src/org/tizen/common/connection/log/AddViewDialog.java @@ -3,10 +3,10 @@ * * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * -* Contact: +* Contact: * Hoon Kang <h245.kang@samsung.com> * Hyunsik Noh <hyunsik.noh@samsung.com> -* +* * 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 @@ -44,7 +44,6 @@ import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.tizen.common.connection.ddmuilib.FileDialogUtils; - import org.tizen.sdblib.IDevice; import org.tizen.sdblib.SmartDevelopmentBridge; @@ -59,13 +58,13 @@ public class AddViewDialog extends Dialog { private Shell parent; private Shell shell; - + private String dialogName = null; private boolean bOk = false; private LogTab oldTab = null; - + private static final String TEMPNAME = "LogTab-#"; private static int cnt = 0; @@ -99,11 +98,11 @@ public class AddViewDialog extends Dialog { if (tab.getFilterDeviceName() == null) return; device = tab.getFilterDeviceName(); - + pidKeyword = tab.getPidFilter(); tagKeyword = tab.getTagFilter(); msgKeyword = tab.getMsgFilter(); - + oldTab = tab; } } @@ -111,7 +110,7 @@ public class AddViewDialog extends Dialog { /** * Opens the dialog. The method will return when the user closes the dialog * somehow. - * + * * @return true if ok was pressed, false if cancelled. */ public boolean open() { @@ -149,6 +148,7 @@ public class AddViewDialog extends Dialog { shell.setLayout(new GridLayout(1, false)); shell.addListener(SWT.Close, new Listener() { + @Override public void handleEvent(Event event) { } }); @@ -198,7 +198,7 @@ public class AddViewDialog extends Dialog { mid.setText("Search Keywords"); mid.setLayoutData(new GridData(GridData.FILL_BOTH)); mid.setLayout(new GridLayout(2, false)); - + l = new Label(mid, SWT.NONE); l.setText("Tag : "); @@ -208,7 +208,7 @@ public class AddViewDialog extends Dialog { tagText.setMessage("Separated by a space/comma"); tagText.setToolTipText("Search Tag Keywords are separated by a space as well as a comma"); tagText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - + l = new Label(mid, SWT.NONE); l.setText("Pid : "); @@ -218,7 +218,7 @@ public class AddViewDialog extends Dialog { pidText.setMessage("Separated by a space/comma"); pidText.setToolTipText("Search Pid Keywords are separated by a space as well as a comma"); pidText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - + l = new Label(mid, SWT.NONE); l.setText("Message : "); @@ -242,39 +242,39 @@ public class AddViewDialog extends Dialog { public void widgetSelected(SelectionEvent e) { String newName = tabNameText.getText(); for (LogTab tab : LogPanel.tabs) { - if (tab.getFilterName().equals(newName)) { + if (tab.getFilterName().equals(newName)) { if (oldTab != null && oldTab == tab) - continue; + continue; int ret = FileDialogUtils.getInstance().checkTabName(newName); if (ret == IDialogConstants.OK_ID) return; } } - + bOk = true; - + if (tabNameText.getText().length() != 0) tabName = tabNameText.getText(); else tabName = TEMPNAME + cnt++; - + if (tagText.getText().length() != 0) tagKeyword = tagText.getText(); else tagKeyword = null; - + if (pidText.getText().length() != 0) pidKeyword = pidText.getText(); else pidKeyword = null; - + if (msgText.getText().length() != 0) msgKeyword = msgText.getText(); else msgKeyword = null; - + device = dCombo.getItem(dCombo.getSelectionIndex()); - + shell.close(); } }); @@ -298,15 +298,15 @@ public class AddViewDialog extends Dialog { public String getDevice() { return device; } - + public String getPidKeyword() { return pidKeyword; } - + public String getTagKeyword() { return tagKeyword; } - + public String getMsgKeyword() { return msgKeyword; } diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/log/LogPanel.java b/org.tizen.common.connection/src/org/tizen/common/connection/log/LogPanel.java index b0b10e9b9..12b45b632 100644 --- a/org.tizen.common.connection/src/org/tizen/common/connection/log/LogPanel.java +++ b/org.tizen.common.connection/src/org/tizen/common/connection/log/LogPanel.java @@ -3,10 +3,10 @@ * * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * -* Contact: +* Contact: * Hoon Kang <h245.kang@samsung.com> * Hyunsik Noh <hyunsik.noh@samsung.com> -* +* * 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 @@ -63,9 +63,11 @@ import org.eclipse.swt.widgets.TableItem; import org.eclipse.swt.widgets.Text; import org.tizen.common.connection.ddmuilib.FileDialogUtils; import org.tizen.common.connection.ddmuilib.ITableFocusListener; -import org.tizen.common.connection.ddmuilib.Panel; import org.tizen.common.connection.ddmuilib.ITableFocusListener.IFocusedTableActivator; - +import org.tizen.common.connection.ddmuilib.Panel; +import org.tizen.common.util.DialogUtil; +import org.tizen.common.util.NotificationType; +import org.tizen.common.util.NotifierDialog; import org.tizen.sdblib.IDevice; import org.tizen.sdblib.Log.LogLevel; import org.tizen.sdblib.SmartDevelopmentBridge; @@ -73,22 +75,27 @@ import org.tizen.sdblib.SmartDevelopmentBridge.IDeviceChangeListener; public class LogPanel extends Panel implements IDeviceChangeListener { - public static final int ENABLE_NOTHING = 0; - public static final int ENABLE_DEFAULT = 1; - public static final int ENABLE_ALL = 2; + public static final int ACTION_NOTHING = 0; + public static final int ACTION_DEVICE_TAB = 1; + public static final int ACTION_ADDITIONAL_TAB = 2; public static ArrayList<LogTab> tabs = new ArrayList<LogTab>(); - + private String defaultLogSave; private static int tabCnt = 0; + private Composite parent; private TabFolder folders; - private Text filterText; + private Table table; + + private Combo panelFilterIndex; + private Text panelFilterKeyword; + + private final LogColors colors; - private LogColors colors; - private LogTab currentTab; + private Action[] levelActions; private Action addAction; private Action removeAction; @@ -96,6 +103,8 @@ public class LogPanel extends Panel implements IDeviceChangeListener { private Action exportAction; private Action clearAction; + private Control control; + /** message data, separated from content for multi line messages */ protected static class LogMessageInfo { public LogLevel logLevel; @@ -119,7 +128,7 @@ public class LogPanel extends Panel implements IDeviceChangeListener { /** * Create the log panel with some default parameters - * + * * @param colors * The display color object */ @@ -152,31 +161,43 @@ public class LogPanel extends Panel implements IDeviceChangeListener { folders.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - - currentTab = getCurrentLogTab(); - if (currentTab == null) - return; - currentTab.initTab(); - currentTab.setLevelIcon(levelActions); - - if (currentTab.isDefault()) { - setActionEnabled(LogPanel.ENABLE_DEFAULT); - } else { - setActionEnabled(LogPanel.ENABLE_ALL); - } + selectLogTab(); } }); + control = getTabControl(folders); SmartDevelopmentBridge.addDeviceChangeListener(this); + //Create default device tab if device(s) is connectied createDefaultTabs(); - + selectLogTab(); return null; } + private void selectLogTab() + { + //1.get selected tabitem's logtab + //2.set previous logtab view filter and get selected logtab view filter + initViewFilter(getCurrentLogTab()); + if (currentTab == null) + return; + //remove all message and re-fill message into table from selected logtab msg buffer + currentTab.initTab(); + + //set icon selection from selected logtab object + currentTab.setLevelIcon(levelActions); + + //Set action enabled state from selected tab(LotTab object) + if (currentTab.isDefault()) { + setActionEnabled(LogPanel.ACTION_DEVICE_TAB); + } else { + setActionEnabled(LogPanel.ACTION_ADDITIONAL_TAB); + } + } + /** - * + * * Create the LogFilters with default devicesd - * + * */ private void createDefaultTabs() { SmartDevelopmentBridge sdbBridge = SmartDevelopmentBridge.getBridge(); @@ -198,7 +219,7 @@ public class LogPanel extends Panel implements IDeviceChangeListener { private LogTab createDefaultTab(IDevice device, String tabName) { LogTab tab = createTab(device, null); tab.setDefault(); - setActionEnabled(LogPanel.ENABLE_DEFAULT); + setActionEnabled(LogPanel.ACTION_DEVICE_TAB); return tab; } @@ -226,23 +247,40 @@ public class LogPanel extends Panel implements IDeviceChangeListener { TabItem item = new TabItem(folders, SWT.NONE, tabCnt++); item.setText(tab.getFilterName()); - - item.setControl(getTabControl(folders, tab)); + tab.setTable(table); + item.setControl(control); tab.setTab(item); folders.setSelection(item); tabs.add(tab); if (tab.isDefault()) { - setActionEnabled(LogPanel.ENABLE_DEFAULT); + setActionEnabled(LogPanel.ACTION_DEVICE_TAB); } else { - setActionEnabled(LogPanel.ENABLE_ALL); + setActionEnabled(LogPanel.ACTION_ADDITIONAL_TAB); } tab.setLevelIcon(levelActions); return tab; } - private Control getTabControl(TabFolder tabFolder, final LogTab tab) { + private void initViewFilter(LogTab tab) + { + if(currentTab != null) + { + currentTab.setFilterIndexFromPanel(panelFilterIndex.getSelectionIndex()); + currentTab.setFilterKeywordFromPanel(panelFilterKeyword.getText()); + } + + currentTab = tab; + + if(tab != null) + { + panelFilterIndex.select(tab.getFilterIndexFromPanel()); + panelFilterKeyword.setText(tab.getFilterKeywordFromPanel()); + } + } + + private Control getTabControl(TabFolder tabFolder) { // Create a composite and add four buttons to it Composite composite = new Composite(tabFolder, SWT.NONE); @@ -253,7 +291,7 @@ public class LogPanel extends Panel implements IDeviceChangeListener { mid.setLayoutData(new GridData(GridData.FILL_BOTH)); mid.setLayout(new FillLayout()); - final Table table = new Table(mid, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.BORDER_SOLID); + table = new Table(mid, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL); table.setHeaderVisible(true); table.setLinesVisible(true); @@ -264,10 +302,12 @@ public class LogPanel extends Panel implements IDeviceChangeListener { ControlListener listener = null; listener = new ControlListener() { + @Override public void controlMoved(ControlEvent e) { } + @Override public void controlResized(ControlEvent e) { Rectangle r = table.getClientArea(); @@ -276,7 +316,7 @@ public class LogPanel extends Panel implements IDeviceChangeListener { total += table.getColumn(1).getWidth(); total += table.getColumn(2).getWidth(); total += table.getColumn(3).getWidth(); - +// if (r.width > total) { table.getColumn(4).setWidth(r.width - total); } @@ -301,47 +341,55 @@ public class LogPanel extends Panel implements IDeviceChangeListener { col = createTableColumn(table, "Message", SWT.LEFT, "abcdefghijklmnopqrstuvwxyz0123456789"); - col.setResizable(false); +// col.setResizable(false); Composite bottom = new Composite(composite, SWT.NONE); bottom.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); bottom.setLayout(new GridLayout(3, false)); - final Combo combo = new Combo(bottom, SWT.READ_ONLY); + panelFilterIndex = new Combo(bottom, SWT.READ_ONLY); String[] comboItems = {"Pid", "Tag", "Message"}; - combo.setItems(comboItems); - combo.select(2); - combo.setToolTipText("Keyword Search: Pid or Tag, Message"); - combo.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - if (filterText.getText() != null) { - int index = combo.getSelectionIndex(); - if (index != -1) - tab.tableRefill(index, filterText.getText()); - } + panelFilterIndex.setItems(comboItems); + panelFilterIndex.select(2); + panelFilterIndex.setToolTipText(LogUIMessages.Log_Tooltip_View_Filter_Combo); + panelFilterIndex.addSelectionListener(new SelectionListener() { + @Override + public void widgetSelected(SelectionEvent e) { + if(currentTab != null) + { + int index = panelFilterIndex.getSelectionIndex(); + if (panelFilterKeyword.getText() != null) { + currentTab.tableRefill(index, panelFilterKeyword.getText()); + } + } } - public void widgetDefaultSelected(SelectionEvent e) { + @Override + public void widgetDefaultSelected(SelectionEvent e) { } }); - filterText = new Text(bottom, SWT.SINGLE | SWT.BORDER); - filterText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - filterText.setMessage("Search Keywords from this table are separated by a space as well as a comma"); - filterText.addModifyListener(new ModifyListener() { + panelFilterKeyword = new Text(bottom, SWT.SINGLE | SWT.BORDER); + panelFilterKeyword.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + panelFilterKeyword.setMessage(LogUIMessages.Log_Message_View_Filter_Text); + panelFilterKeyword.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { - if (filterText.getText() != null) { - int index = combo.getSelectionIndex(); - if (index != -1) { - tab.tableRefill(index, filterText.getText()); - } - } + if(currentTab != null) + { + String keyword = panelFilterKeyword.getText(); + int index = currentTab.getFilterIndexFromPanel(); + panelFilterIndex.select(index); + if (keyword != null) { + if (index != -1) { + currentTab.tableRefill(index, keyword); + } + } + } } }); - tab.setTable(table); return composite; } @@ -359,7 +407,7 @@ public class LogPanel extends Panel implements IDeviceChangeListener { /** * Copies the current selection of the current filter as multiline text. - * + * * @param clipboard * The clipboard to place the copied content. */ @@ -378,7 +426,7 @@ public class LogPanel extends Panel implements IDeviceChangeListener { /** * Sets a TableFocusListener which will be notified when one of the tables * gets or loses focus. - * + * * @param listener */ public void setTableFocusListener(ITableFocusListener listener) { @@ -394,17 +442,19 @@ public class LogPanel extends Panel implements IDeviceChangeListener { /** * Sets up a Table object to notify the global Table Focus listener when it * gets or loses the focus. - * + * * @param table * the Table object. */ private void addTableToFocusListener(final Table table) { // create the activator for this table final IFocusedTableActivator activator = new IFocusedTableActivator() { + @Override public void copy(Clipboard clipboard) { copyTable(clipboard, table); } + @Override public void selectAll() { table.selectAll(); } @@ -413,10 +463,12 @@ public class LogPanel extends Panel implements IDeviceChangeListener { // add the focus listener on the table to notify the global // listener table.addFocusListener(new FocusListener() { + @Override public void focusGained(FocusEvent e) { globalListener.focusGained(activator); } + @Override public void focusLost(FocusEvent e) { globalListener.focusLost(activator); } @@ -426,7 +478,7 @@ public class LogPanel extends Panel implements IDeviceChangeListener { /** * Copies the current selection of a Table into the provided Clipboard, as * multi-line text. - * + * * @param clipboard * The clipboard to place the copied content. * @param table @@ -458,24 +510,24 @@ public class LogPanel extends Panel implements IDeviceChangeListener { /** * saves the current selection in a text file. - * + * * @return false if the saving failed. */ public boolean save() { if (getCurrentLogTab() == null) return false; FileDialog dlg = new FileDialog(parent.getShell(), SWT.SAVE); - String fileName; - dlg.setText("Export Log"); - dlg.setFileName(getCurrentLogTab().getFilterName() + "-log.txt"); + dlg.setText(LogUIMessages.Log_Title_Tab_Export); + String fileName = String.format(LogUIMessages.Log_File_Tab_Export_Postfix, getCurrentLogTab().getFilterName()); + dlg.setFileName(fileName); String defaultPath = defaultLogSave; if (defaultPath == null) { defaultPath = System.getProperty("user.home"); //$NON-NLS-1$ } dlg.setFilterPath(defaultPath); - dlg.setFilterNames(new String[] { "Text Files (*.txt)" }); - dlg.setFilterExtensions(new String[] { "*.txt" }); + dlg.setFilterNames(new String[] { LogUIMessages.Log_File_Tab_Export_Filter }); + dlg.setFilterExtensions(new String[] { LogUIMessages.Log_File_Tab_Export_Filter_Extensions }); File check; boolean again; do { @@ -519,19 +571,41 @@ public class LogPanel extends Panel implements IDeviceChangeListener { this.getCurrentLogTab().clear(); } + private boolean checkTabConnection(LogTab tab, String title) + { + String deviceName = tab.getFilterDeviceName(); + if(deviceName == null) + { + String tabName = tab.getFilterName(); + String message = String.format(LogUIMessages.Log_Message_Tab_Device_Disconnected, tabName); + DialogUtil.openErrorDialog(parent.getShell(), title, message); + return false; + } + return true; + } + public void addTab() { - if (getCurrentLogTab() == null) + LogTab tab = getCurrentLogTab(); + if (tab == null) return; - AddViewDialog dlg = new AddViewDialog(parent.getShell(), - getCurrentLogTab().getFilterDeviceName()); - + if(!checkTabConnection(tab, LogUIMessages.Log_Title_Tab_AddTab_Error)) + { + return ; + } + + AddViewDialog dlg = new AddViewDialog(parent.getShell(), tab.getFilterDeviceName()); + //if base device is already disconnected, + if(dlg.getDevice() == null) + return ; + if (dlg.open()) { for (IDevice device : SmartDevelopmentBridge.getBridge() .getDevices()) { if (device.getSerialNumber().equals(dlg.getDevice())) { LogTab newTab = createTab(device, dlg.getName()); - + setTabRefresh(newTab); + initViewFilter(newTab); newTab.setPidFilter(dlg.getPidKeyword()); newTab.setTagFilter(dlg.getTagKeyword()); newTab.setMsgFilter(dlg.getMsgKeyword()); @@ -555,11 +629,13 @@ public class LogPanel extends Panel implements IDeviceChangeListener { return; } tab.stopLogTab(true); +// tab.dispose(); + folders.getItem(index).dispose(); tabs.remove(index); tabCnt--; - tab.dispose(); if (!tabs.isEmpty()) - folders.setSelection(0); + folders.setSelection(folders.getItemCount()); + selectLogTab(); } @@ -571,7 +647,12 @@ public class LogPanel extends Panel implements IDeviceChangeListener { if (oldTab.isDefault()) { return; } - + + if(!checkTabConnection(oldTab, LogUIMessages.Log_Title_Tab_EditTab_Error)) + { + return ; + } + AddViewDialog dlg = new AddViewDialog(parent.getShell(), oldTab); if (dlg.open()) { for (IDevice device : SmartDevelopmentBridge.getBridge() @@ -595,11 +676,17 @@ public class LogPanel extends Panel implements IDeviceChangeListener { oldTab.setPidFilter(dlg.getPidKeyword()); oldTab.setTagFilter(dlg.getTagKeyword()); oldTab.setMsgFilter(dlg.getMsgKeyword()); - + if (bRestart) + { oldTab.startLogTab(); + setTabRefresh(oldTab); + initViewFilter(oldTab); + } else + { oldTab.refill(); + } break; } } @@ -625,11 +712,22 @@ public class LogPanel extends Panel implements IDeviceChangeListener { public LogTab getCurrentLogTab() { if (tabs.size() != 0) { int index = folders.getSelectionIndex(); - return tabs.get(index); + LogTab tab = tabs.get(index); + setTabRefresh(tab); + return tab; } else return null; } + private void setTabRefresh(LogTab tab) + { + for(LogTab anytab : tabs) + { + anytab.setPendingAsyncRefresh(false); + } + tab.setPendingAsyncRefresh(true); + } + public void stopAll() { for (LogTab tab : tabs) { tab.stopLogTab(true); @@ -647,7 +745,22 @@ public class LogPanel extends Panel implements IDeviceChangeListener { } @Override - public void deviceDisconnected(IDevice device) { + public void deviceDisconnected(final IDevice device) { + if (parent.isDisposed() == false) { + Display display = parent.getDisplay(); + display.asyncExec(new Runnable() { + @Override + public void run() { + if (parent.isDisposed() == false) { + String deviceSN = device.getSerialNumber(); + String title = LogUIMessages.Log_Title_View_Device_Disconnected; + String message = String.format(LogUIMessages.Log_Message_View_Device_Disconnected, deviceSN, deviceSN); + NotifierDialog.notify(title, message, NotificationType.DISCONNECTED); + } + } + }); + } + } @Override @@ -656,9 +769,11 @@ public class LogPanel extends Panel implements IDeviceChangeListener { if (parent.isDisposed() == false) { Display display = parent.getDisplay(); display.asyncExec(new Runnable() { + @Override public void run() { if (folders.isDisposed() == false) { LogTab tab = createDefaultTab(device, null); + selectLogTab(); tab.startLogTab(); } else { SmartDevelopmentBridge @@ -672,7 +787,7 @@ public class LogPanel extends Panel implements IDeviceChangeListener { public void setActionEnabled(int enable) { - if (enable == ENABLE_NOTHING) { + if (enable == ACTION_NOTHING) { addAction.setEnabled(false); removeAction.setEnabled(false); @@ -682,7 +797,7 @@ public class LogPanel extends Panel implements IDeviceChangeListener { for (Action a : levelActions) { a.setEnabled(false); } - } else if (enable == ENABLE_DEFAULT) { + } else if (enable == ACTION_DEVICE_TAB) { addAction.setEnabled(true); removeAction.setEnabled(false); editAction.setEnabled(false); @@ -691,7 +806,7 @@ public class LogPanel extends Panel implements IDeviceChangeListener { for (Action a : levelActions) { a.setEnabled(true); } - } else if (enable == ENABLE_ALL) { + } else if (enable == ACTION_ADDITIONAL_TAB) { addAction.setEnabled(true); removeAction.setEnabled(true); editAction.setEnabled(true); diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/log/LogTab.java b/org.tizen.common.connection/src/org/tizen/common/connection/log/LogTab.java index 5e49a7cfc..9c6f57432 100644 --- a/org.tizen.common.connection/src/org/tizen/common/connection/log/LogTab.java +++ b/org.tizen.common.connection/src/org/tizen/common/connection/log/LogTab.java @@ -3,10 +3,10 @@ * * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * -* Contact: +* Contact: * Hoon Kang <h245.kang@samsung.com> * Hyunsik Noh <hyunsik.noh@samsung.com> -* +* * 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 @@ -40,7 +40,6 @@ import org.eclipse.swt.widgets.TableItem; import org.tizen.common.connection.log.LogPanel.LogMessage; import org.tizen.common.connection.log.LogPanel.LogMessageInfo; import org.tizen.common.console.AnsicodeAdapter; - import org.tizen.sdblib.IDevice; import org.tizen.sdblib.Log; import org.tizen.sdblib.Log.LogLevel; @@ -54,7 +53,6 @@ public class LogTab { public static final int FILTER_PID = 0x0; public static final int FILTER_TAG = 0x1; public static final int FILTER_MSG = 0x2; - private int filterMode = FILTER_NONE; public static final int LEVEL_ALL = 0x1F; public static final int LEVEL_VERBOSE = 0x1; @@ -72,11 +70,14 @@ public class LogTab { private String[] pidFilter = null; private String[] tagFilter = null; private String[] msgFilter = null; - + private String pidFilterString = null; private String tagFilterString = null; private String msgFilterString = null; - private String tableFilter = null; + + private int filterIndexFromPanel = FILTER_MSG; + private String filterKeywordFromPanel = ""; + private String filterName = null; private IDevice filterDevice = null; private LogTabOuputReceiver logger = null; @@ -87,11 +88,11 @@ public class LogTab { private static Pattern logPattern = Pattern .compile("^\\[\\s(\\d\\d-\\d\\d\\s\\d\\d:\\d\\d:\\d\\d\\.\\d+)" + //$NON-NLS-1$ - "\\s+(\\d*):\\s*(\\d+)\\s([VDIWE])/(.+)\\s+\\]$"); + "\\s+(\\d*):\\s*(\\d+)\\s([VDIWE])/(.+)\\s+\\]$"); - private ArrayList<LogMessage> tableMessages = new ArrayList<LogMessage>(); - private ArrayList<LogMessage> newMessages = new ArrayList<LogMessage>(); - private LogMessage[] buffer = new LogMessage[STRING_BUFFER_LENGTH]; + private final ArrayList<LogMessage> tableMessages = new ArrayList<LogMessage>(); + private final ArrayList<LogMessage> newMessages = new ArrayList<LogMessage>(); + private final LogMessage[] buffer = new LogMessage[STRING_BUFFER_LENGTH]; private LogMessageInfo lastMessageInfo = null; private boolean pendingAsyncRefresh = false; @@ -137,9 +138,9 @@ public class LogTab { if (msg != null) msgFilter = setFilter(msg.split("[\\s\t,]")); else - msgFilter = null; + msgFilter = null; } - + private String[] setFilter(String[] array) { ArrayList<String> result = new ArrayList<String>(); for (String s : array) { @@ -149,7 +150,7 @@ public class LogTab { } return result.toArray(new String[(result.size())]); } - + public String getFilterName() { return filterName; } @@ -171,7 +172,10 @@ public class LogTab { } public String getFilterDeviceName() { - return filterDevice.getSerialNumber(); + if(filterDevice != null) + return filterDevice.getSerialNumber(); + else + return null; } public void setTab(TabItem pTabItem) { @@ -188,7 +192,7 @@ public class LogTab { /** * Returns the UI table object. - * + * * @return */ public Table getTable() { @@ -196,8 +200,16 @@ public class LogTab { } public void dispose() { - table.dispose(); - tabItem.dispose(); + Display d = tabItem.getDisplay(); + + d.syncExec(new Runnable() { + @Override + public void run() { + if (tabItem.isDisposed() == false) { + tabItem.dispose(); + } + } + }); table = null; tabItem = null; } @@ -239,6 +251,7 @@ public class LogTab { } finally { logger = null; filterDevice = null; + stopLogTab(false); } } } .start(); @@ -258,6 +271,7 @@ public class LogTab { } } + //add message to tableMessages(filtered message) and replace old message to new message public boolean addMessage(LogMessage newMessage, LogMessage oldMessage) { synchronized (tableMessages) { if (oldMessage != null) { @@ -396,7 +410,7 @@ public class LogTab { /** * Add a TableItem for the index-th item of the buffer - * + * * @param filter * The index of the table in which to insert the item. */ @@ -451,6 +465,7 @@ public class LogTab { } } + @Override public boolean isCancelled() { return isCancelled; } @@ -458,9 +473,8 @@ public class LogTab { /** * Process new Log lines coming from {@link LogCatOuputReceiver}. - * - * @param lines - * the new lines + * + * @param lines the new lines */ protected void processLogLines(String[] lines) { // WARNING: this will not work if the string contains more line @@ -483,8 +497,7 @@ public class LogTab { // check for header lines. Matcher matcher = logPattern.matcher(line); if (matcher.matches()) { - // this is a header line, parse the - // header and keep it around. + // this is a header line, parse the header and keep it around. lastMessageInfo = new LogMessageInfo(); lastMessageInfo.time = matcher.group(1); @@ -493,27 +506,21 @@ public class LogTab { .getByLetterString(matcher.group(4)); lastMessageInfo.tag = matcher.group(5).trim(); } else { - // This is not a header line. - // Create a new LogMessage and process - // it. - LogMessage mc = new LogMessage(); if (lastMessageInfo == null) { return; } - // If someone printed a log message - // with - // embedded '\n' characters, there - // will - // one header line followed by - // multiple text lines. + // This is not a header line. + // Create a new LogMessage and process it. + LogMessage mc = new LogMessage(); + + // If someone printed a log message with embedded '\n' characters, + //there will one header line followed by multiple text lines. // Use the last header that we saw. mc.data = lastMessageInfo; - // tabs seem to display as only 1 tab - // so we replace the leading tabs - // by 4 spaces. + // tabs seem to display as only 1 tab so we replace the leading tabs by 4 spaces. mc.msg = line.replaceAll("\t", " "); //$NON-NLS-1$ //$NON-NLS-2$ // process the new LogMessage. @@ -525,12 +532,8 @@ public class LogTab { } } - // if we don't have a pending Runnable that will do the - // refresh, we - // ask the Display - // to run one in the UI thread. - if (pendingAsyncRefresh == false) { - pendingAsyncRefresh = true; + if (pendingAsyncRefresh) { +// pendingAsyncRefresh = true; try { Display display = table.getDisplay(); @@ -538,13 +541,12 @@ public class LogTab { // run in sync because this will update the // buffer start/end indices display.asyncExec(new Runnable() { + @Override public void run() { asyncRefresh(); } }); } catch (SWTException e) { - // display is disposed, we're probably - // quitting. Let's stop. stopLogTab(false); } } @@ -556,12 +558,10 @@ public class LogTab { * <p/> * This adds the new message to the buffer, and gives it to the existing * filters. - * + * * @param newMessage */ private void processNewMessage(LogMessage newMessage) { - // // if we are in auto filtering mode, make sure we have - // // a filter for this // compute the index where the message goes. // was the buffer empty? @@ -592,29 +592,7 @@ public class LogTab { // then add the new one buffer[messageIndex] = newMessage; - synchronized (tableMessages) { - if (oldMessage != null) { - if (tableMessages.size() > STRING_BUFFER_LENGTH) { - int index = tableMessages.indexOf(oldMessage); - if (index != -1) { - // TODO check that index will always - // be -1 or 0, as only the oldest - // message is ever removed. - tableMessages.remove(index); - removedMessageCount++; - } - } - } - } - - boolean filter = accept(newMessage); - if (filter) { - // at this point the message is accepted, we add it to the - // list - tableMessages.add(newMessage); - newMessages.add(newMessage); - } - + addMessage(newMessage, oldMessage); } /** @@ -623,16 +601,17 @@ public class LogTab { private void asyncRefresh() { if (table.isDisposed() == false) { synchronized (buffer) { - try { - // the circular buffer has been updated, let - // have the filter flush - // their display with the new messages. - flush(); - - } finally { - // the pending refresh is done. - pendingAsyncRefresh = false; - } + flush(); +// try { +// // the circular buffer has been updated, let +// // have the filter flush +// // their display with the new messages. +// flush(); +// +// } finally { +// // the pending refresh is done. +// pendingAsyncRefresh = false; +// } } } else { stopLogTab(true); @@ -650,6 +629,7 @@ public class LogTab { // run sync as we need to update right now. d.syncExec(new Runnable() { + @Override public void run() { if (table.isDisposed() == false) { table.removeAll(); @@ -685,9 +665,7 @@ public class LogTab { for (int i = indexStart; i < max; i++) { int realItemIndex = i % STRING_BUFFER_LENGTH; - addMessage(buffer[realItemIndex], null /* - * old message - */); + addMessage(buffer[realItemIndex], null /** old message*/); } } @@ -700,46 +678,61 @@ public class LogTab { synchronized (buffer) { for (LogMessage logMsg : buffer) { if (accept(logMsg)) { - tableMessages.add(logMsg); - newMessages.add(logMsg); + addMessage(logMsg, null); } } } flush(); } - + public void tableRefill(int index, String filter) { - - tableFilter = filter; - filterMode = index; - - newMessages.clear(); - lastMessageInfo = null; - if (table.isDisposed() == false) - table.removeAll(); + filterKeywordFromPanel = filter; + filterIndexFromPanel = index; - synchronized (tableMessages) { - for (LogMessage logMsg : tableMessages) { - if (tableAccept(logMsg)) { - newMessages.add(logMsg); + msgClear(); + + synchronized (buffer) { + for (LogMessage logMsg : buffer) { + if (accept(logMsg) && tableAccept(logMsg)) { + addMessage(logMsg, null); } } } flush(); } - + + public int getFilterIndexFromPanel() + { + return filterIndexFromPanel; + } + + public void setFilterIndexFromPanel(int index) + { + filterIndexFromPanel = index; + } + + public String getFilterKeywordFromPanel() + { + return filterKeywordFromPanel; + } + + public void setFilterKeywordFromPanel(String keyword) + { + filterKeywordFromPanel = keyword; + } + boolean tableAccept(LogMessage logMessage) { if (logMessage == null) return false; - - if (tableFilter == null || tableFilter.length() == 0) + + if (filterKeywordFromPanel == null || filterKeywordFromPanel.length() == 0) return true; - - switch(filterMode) { + + switch(filterIndexFromPanel) { case 0: { - String[] filter = tableFilter.split("[\\s\t,]"); + String[] filter = filterKeywordFromPanel.split("[\\s\t,]"); for (int i = 0; i < filter.length; i++) { if (logMessage.data.pidString.contains( filter[i])) @@ -747,10 +740,10 @@ public class LogTab { } } break; - + case 1: { - String[] filter = tableFilter.split("[\\s\t,]"); + String[] filter = filterKeywordFromPanel.split("[\\s\t,]"); for (int i = 0; i < filter.length; i++) { if (logMessage.data.tag.toLowerCase().contains( filter[i].toLowerCase())) @@ -758,10 +751,10 @@ public class LogTab { } } break; - + case 2: { - String[] filter = tableFilter.split("[\\s\t,]"); + String[] filter = filterKeywordFromPanel.split("[\\s\t,]"); for (int i = 0; i < filter.length; i++) { if (logMessage.msg.toLowerCase().contains( filter[i].toLowerCase())) @@ -769,7 +762,7 @@ public class LogTab { } } break; - + default: return false; @@ -785,6 +778,7 @@ public class LogTab { levelMode &= (~level); } + //remove all filtered messages and tableMessages for refill or init tab public void msgClear() { removedMessageCount = 0; newMessages.clear(); @@ -794,6 +788,7 @@ public class LogTab { table.removeAll(); } + //buffer clear public void clear() { for (int i = 0; i < STRING_BUFFER_LENGTH; i++) { buffer[i] = null; @@ -817,4 +812,9 @@ public class LogTab { return isDefault; } + public void setPendingAsyncRefresh(boolean b) + { + pendingAsyncRefresh = b; + } + }
\ No newline at end of file diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/log/LogUIMessages.java b/org.tizen.common.connection/src/org/tizen/common/connection/log/LogUIMessages.java new file mode 100644 index 000000000..656ee5f80 --- /dev/null +++ b/org.tizen.common.connection/src/org/tizen/common/connection/log/LogUIMessages.java @@ -0,0 +1,53 @@ +/* +* Common +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Contact: +* Kangho Kim <kh5225.kim@samsung.com> +* Hyunsik Noh <hyunsik.noh@samsung.com> +* + * 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. +* +* Contributors: +* - S-Core Co., Ltd +* +*/ +package org.tizen.common.connection.log; + +import org.eclipse.osgi.util.NLS; + +public class LogUIMessages extends NLS { + private static final String BUNDLE_NAME = LogUIMessages.class.getPackage().getName() + ".LogUIMessages"; //$NON-NLS-1$ + + public static String Log; + public static String Log_Title_Tab_AddTab_Error; + public static String Log_Title_Tab_EditTab_Error; + public static String Log_Title_View_Device_Disconnected; + public static String Log_Message_Tab_Device_Disconnected; + public static String Log_Message_View_Device_Disconnected; + public static String Log_Message_View_Filter_Text; + public static String Log_Tooltip_View_Filter_Combo; + public static String Log_Title_Tab_Export; + public static String Log_File_Tab_Export_Postfix; + public static String Log_File_Tab_Export_Filter; + public static String Log_File_Tab_Export_Filter_Extensions; + + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, LogUIMessages.class); + } + + private LogUIMessages() { + } +} diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/log/LogUIMessages.properties b/org.tizen.common.connection/src/org/tizen/common/connection/log/LogUIMessages.properties new file mode 100644 index 000000000..6f0ab47fa --- /dev/null +++ b/org.tizen.common.connection/src/org/tizen/common/connection/log/LogUIMessages.properties @@ -0,0 +1,17 @@ +Log = Log + +Log_Title_Tab_AddTab_Error = Add tab error +Log_Title_Tab_EditTab_Error = Edit tab error +Log_Title_View_Device_Disconnected = Device is disconnected + +Log_Message_Tab_Device_Disconnected = %s tab's device is already disconnected. +Log_Message_View_Device_Disconnected = %s is disconnected.\nThe tabs for %s do not work. +Log_Message_View_Filter_Text = Search Keywords from this table are separated by a space as well as a comma + +Log_Tooltip_View_Filter_Combo = Keyword Search: Pid or Tag, Message + +Log_Title_Tab_Export = Export Log + +Log_File_Tab_Export_Postfix = %s-log.txt +Log_File_Tab_Export_Filter = Text Files (*.txt) +Log_File_Tab_Export_Filter_Extensions = *.txt
\ No newline at end of file diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/ui/LogView.java b/org.tizen.common.connection/src/org/tizen/common/connection/ui/LogView.java index 6c73dad2f..a48f3923c 100644 --- a/org.tizen.common.connection/src/org/tizen/common/connection/ui/LogView.java +++ b/org.tizen.common.connection/src/org/tizen/common/connection/ui/LogView.java @@ -3,10 +3,10 @@ * * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * -* Contact: +* Contact: * Hoon Kang <h245.kang@samsung.com> * Hyunsik Noh <hyunsik.noh@samsung.com> -* +* * 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 @@ -40,12 +40,11 @@ import org.eclipse.ui.part.ViewPart; import org.tizen.common.connection.ConnectionPlugin; import org.tizen.common.connection.log.LogColors; import org.tizen.common.connection.log.LogPanel; - import org.tizen.sdblib.Log.LogLevel; /** * The log cat view displays log output from the current device selection. - * + * */ public final class LogView extends ViewPart { @@ -60,7 +59,7 @@ public final class LogView extends ViewPart { private Action clearAction; private Action[] logLevelActions; - private String[] logLevelIcons = { "icons/log/v.png", //$NON-NLS-1S + private final String[] logLevelIcons = { "icons/log/v.png", //$NON-NLS-1S "icons/log/d.png", //$NON-NLS-1S "icons/log/i.png", //$NON-NLS-1S "icons/log/w.png", //$NON-NLS-1S @@ -88,7 +87,7 @@ public final class LogView extends ViewPart { }; addAction.setToolTipText("Add LogTab"); addAction.setImageDescriptor(ConnectionPlugin.getImageDescriptorFromPlugin("icons/log/Add tab.png")); - + removeAction = new Action("Remove Tab") { @Override public void run() { @@ -97,7 +96,7 @@ public final class LogView extends ViewPart { }; removeAction.setToolTipText("Remove LogTab"); removeAction.setImageDescriptor(ConnectionPlugin.getImageDescriptorFromPlugin("icons/log/Remove tab.png")); - + editAction = new Action("Edit Tab") { @Override public void run() { @@ -156,10 +155,10 @@ public final class LogView extends ViewPart { // now create the log view logPanel = new LogPanel(colors); - + logPanel.setActions(logLevelActions, addAction, removeAction, editAction, exportAction, clearAction); placeActions(); - logPanel.setActionEnabled(LogPanel.ENABLE_NOTHING); + logPanel.setActionEnabled(LogPanel.ACTION_NOTHING); logPanel.createPanel(parent); // setup the copy action |