From cd3930beed05dd0a0d02e4cef44d6fdd72d3c371 Mon Sep 17 00:00:00 2001 From: "hyunsik.noh" Date: Wed, 18 Jan 2012 10:58:31 +0900 Subject: [PATCH] [Title] remove useless comment, and fix null point exception ocurred when dnd works Change-Id: I8c1e8f9aa0bad550ede73c36aa4ec99d5a25a5d8 --- .../tizen/common/connection/ConnectionPlugin.java | 48 ++- .../ConnectionExplorerContentProvider.java | 41 +-- .../explorer/ConnectionExplorerLabelProvider.java | 81 ++--- .../explorer/ConnectionExplorerPanel.java | 358 +++++---------------- .../tizen/common/connection/explorer/Messages.java | 2 - .../tizen/common/connection/log/AddViewDialog.java | 193 +---------- .../tizen/common/connection/log/LogPanel.java | 55 +--- .../tizen/common/connection/log/LogTab.java | 171 +--------- .../ConnectionExplorerInfoPropertyPages.java | 1 - .../sdblib/dnd/FileEntryDropAdapter.java | 2 + .../tizen/common/connection/ui/LogView.java | 5 +- 11 files changed, 162 insertions(+), 795 deletions(-) diff --git a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/ConnectionPlugin.java b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/ConnectionPlugin.java index 3253a55..ec00a62 100644 --- a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/ConnectionPlugin.java +++ b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/ConnectionPlugin.java @@ -61,25 +61,25 @@ public class ConnectionPlugin extends AbstractUIPlugin { // The shared instance private static ConnectionPlugin plugin; - private IDevice mCurrentDevice; - private final ArrayList mListeners = new ArrayList(); + private IDevice currentDevice; + private final ArrayList listeners = new ArrayList(); public int OS; public final int LINUX = 0; public final int WINDOWS = 1; /** - * Classes which implement this interface provide methods that deals - * with {@link IDevice} and {@link Client} selectionchanges. + * Implements for FileEntry changed status. */ public interface ISelectionListener { /** - * Sent when a new {@link IDevice} is selected. - * @param selectedDevice the selected device. If null, no devices are selected. + * Sent when a FileEntry is selected. + * @param selectedEntry the selected FileEntry. If null, no FileEntry are selected. */ public void selectionChanged(FileEntry selectedEntry); } + /** * The constructor */ @@ -91,6 +91,7 @@ public class ConnectionPlugin extends AbstractUIPlugin { * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) */ public void start(BundleContext context) throws Exception { + super.start(context); plugin = this; @@ -101,22 +102,10 @@ public class ConnectionPlugin extends AbstractUIPlugin { else this.OS = this.LINUX; -// AndroidDebugBridge.init(false); -// AndroidDebugBridge.createBridge("/home/mustafa/mywork/source/sdb/bin/adb",true); - - // get the eclipse store -// final IPreferenceStore eclipseStore = getPreferenceStore(); - - //AndroidDebugBridge.addDeviceChangeListener(this); - -// DdmUiPreferences.setStore(eclipseStore); - -// DeviceMonitor monitor = new DeviceMonitor(); -// monitor.processDeviceData(); - - } + public static synchronized List getDebugTools(IDevice device) { + List toolLists = new ArrayList(); IExtensionRegistry x = RegistryFactory.getRegistry(); @@ -169,6 +158,7 @@ public class ConnectionPlugin extends AbstractUIPlugin { } return toolLists; } + /* * (non-Javadoc) * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) @@ -190,33 +180,30 @@ public class ConnectionPlugin extends AbstractUIPlugin { public void setCurrentDevice( IDevice device ) { - mCurrentDevice = device; + currentDevice = device; } public IDevice getCurrentDevice() { - return mCurrentDevice; + return currentDevice; } public void addSelectionListener(ISelectionListener listener) { - mListeners.add(listener); + listeners.add(listener); } public void removeSelectionListener(ISelectionListener listener) { - mListeners.remove(listener); + listeners.remove(listener); } public void notifySelectionListeners(FileEntry file) { - ISelectionListener[] mlistenersCopy = mListeners.toArray( - new ISelectionListener[mListeners.size()]); + ISelectionListener[] listenersCopy = listeners.toArray( + new ISelectionListener[listeners.size()]); - for (ISelectionListener listener : mlistenersCopy) + for (ISelectionListener listener : listenersCopy) { - // notify the listener with a try/catch-all to make sure this thread won't die - // because of an uncaught exception before all the listeners were notified. - try { listener.selectionChanged( file ); @@ -227,6 +214,7 @@ public class ConnectionPlugin extends AbstractUIPlugin { } } } + /** * Returns an image descriptor for the image file at the given * plug-in relative path diff --git a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/explorer/ConnectionExplorerContentProvider.java b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/explorer/ConnectionExplorerContentProvider.java index 7258920..cf26281 100644 --- a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/explorer/ConnectionExplorerContentProvider.java +++ b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/explorer/ConnectionExplorerContentProvider.java @@ -39,13 +39,12 @@ import com.samsung.tizen.sdblib.SmartDevelopmentBridge; public class ConnectionExplorerContentProvider implements ITreeContentProvider { - private TreeViewer mViewer; -// private FileListingService mFileListingService; - private FileEntry mRootEntry; + private TreeViewer viewer; + private FileEntry rootEntry; - private IListingReceiver sListingReceiver = new IListingReceiver() { + private IListingReceiver listingReceiver = new IListingReceiver() { public void setChildren(final FileEntry entry, FileEntry[] children) { - final Tree t = mViewer.getTree(); + final Tree t = viewer.getTree(); if (t != null && t.isDisposed() == false) { Display display = t.getDisplay(); if (display.isDisposed() == false) { @@ -53,12 +52,8 @@ public class ConnectionExplorerContentProvider implements ITreeContentProvider public void run() { if (t.isDisposed() == false) { // refresh the entry. - mViewer.refresh(entry); - - // force it open, since on linux and windows - // when getChildren() returns null, the node is - // not considered expanded. - mViewer.setExpandedState(entry, true); + viewer.refresh(entry); + viewer.setExpandedState(entry, true); } } }); @@ -67,7 +62,7 @@ public class ConnectionExplorerContentProvider implements ITreeContentProvider } public void refreshEntry(final FileEntry entry) { - final Tree t = mViewer.getTree(); + final Tree t = viewer.getTree(); if (t != null && t.isDisposed() == false) { Display display = t.getDisplay(); if (display.isDisposed() == false) { @@ -75,7 +70,7 @@ public class ConnectionExplorerContentProvider implements ITreeContentProvider public void run() { if (t.isDisposed() == false) { // refresh the entry. - mViewer.refresh(entry); + viewer.refresh(entry); } } }); @@ -87,17 +82,15 @@ public class ConnectionExplorerContentProvider implements ITreeContentProvider @Override public void dispose() { - // TODO Auto-generated method stub - } @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { if (viewer instanceof TreeViewer) { - mViewer = (TreeViewer)viewer; + this.viewer = (TreeViewer)viewer; } if (newInput instanceof FileEntry) { - mRootEntry = (FileEntry)newInput; + rootEntry = (FileEntry)newInput; } } @@ -108,14 +101,11 @@ public class ConnectionExplorerContentProvider implements ITreeContentProvider Object[] oldEntries = parentEntry.getCachedChildren(); Object[] newEntries = parentEntry.getFileListingService().getChildren(parentEntry, - true, sListingReceiver); + true, listingReceiver); if (newEntries != null) { return newEntries; } else { - // if null was returned, this means the cache was not valid, - // and a thread was launched for ls. sListingReceiver will be - // notified with the new entries. return oldEntries; } } @@ -128,16 +118,7 @@ public class ConnectionExplorerContentProvider implements ITreeContentProvider FileEntry[] entries = new FileEntry[ devices.length ]; for( int i = 0; i < devices.length ; i++) { -// setListingService(devices[i].getFileListingService()); -// if (devices[i].isEmulator()) -// { -// entries[i] = new FileEntry( null, devices[i].getSerialNumber(), FileListingService.TYPE_ROOT_EMULATOR, true, devices[i].getFileListingService()); -// } -// else -// entries[i] = new FileEntry( null, devices[i].getSerialNumber(), FileListingService.TYPE_ROOT_DEVICE, true, devices[i].getFileListingService()); entries[i] = devices[i].getFileListingService().getRoot(); - - } return entries; } diff --git a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/explorer/ConnectionExplorerLabelProvider.java b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/explorer/ConnectionExplorerLabelProvider.java index 6bc3014..25b3533 100644 --- a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/explorer/ConnectionExplorerLabelProvider.java +++ b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/explorer/ConnectionExplorerLabelProvider.java @@ -37,37 +37,25 @@ import com.samsung.tizen.sdblib.IDevice; public class ConnectionExplorerLabelProvider implements ITableLabelProvider { - private Image mFileImage; - private Image mFolderImage; - private Image mFileLinkImage; - private Image mFolderLinkImage; - private Image mOtherImage; - private Image mEmulatorImage; - private Image mDeviceImage; + private Image fileImage; + private Image folderImage; + private Image fileLinkImage; + private Image folderLinkImage; + private Image otherImage; + private Image emulatorImage; + private Image deviceImage; public static int index; - /** - * Creates Label provider with custom images. - * - * @param fileImage - * the Image to represent a file - * @param folderImage - * the Image to represent a folder - * @param packageImage - * the Image to represent a .apk file. If null, fileImage - * is used instead. - * @param otherImage - * the Image to represent all other entry type. - */ + public ConnectionExplorerLabelProvider(Display display) { ImageLoader loader = ImageLoader.getDdmUiLibLoader(); - mFileImage = loader.loadImage("file.gif", display); - mFolderImage = loader.loadImage("directory.gif", display); - mFileLinkImage = loader.loadImage("file_link.gif", display); - mFolderLinkImage = loader.loadImage("directory_link.gif", display); - mOtherImage = loader.loadImage("file.gif", display); - mEmulatorImage = loader.loadImage("emulator.gif", display); - mDeviceImage = loader.loadImage("device.gif", display); + fileImage = loader.loadImage("file.gif", display); + folderImage = loader.loadImage("directory.gif", display); + fileLinkImage = loader.loadImage("file_link.gif", display); + folderLinkImage = loader.loadImage("directory_link.gif", display); + otherImage = loader.loadImage("file.gif", display); + emulatorImage = loader.loadImage("emulator.gif", display); + deviceImage = loader.loadImage("device.gif", display); } @Override @@ -77,21 +65,21 @@ public class ConnectionExplorerLabelProvider implements ITableLabelProvider { FileEntry entry = (FileEntry) element; switch (entry.getType()) { case FileListingService.TYPE_FILE: - return mFileImage; + return fileImage; case FileListingService.TYPE_LINK: - return mFileLinkImage; + return fileLinkImage; case FileListingService.TYPE_DIRECTORY: - return mFolderImage; + return folderImage; case FileListingService.TYPE_DIRECTORY_LINK: - return mFolderLinkImage; + return folderLinkImage; case FileListingService.TYPE_ROOT_EMULATOR: - return mEmulatorImage; + return emulatorImage; case FileListingService.TYPE_ROOT_DEVICE: - return mDeviceImage; + return deviceImage; } } - // default case return a different image. - return mOtherImage; + + return otherImage; } return null; } @@ -104,22 +92,6 @@ public class ConnectionExplorerLabelProvider implements ITableLabelProvider { switch (columnIndex) { case 0: return entry.getName(); - case 1: - { - switch(index) - { - case 0: - return entry.getSize(); - case 1: - return entry.getDate(); - case 2: - return entry.getTime(); - case 3: - return entry.getPermissions(); - case 4: - return entry.getInfo(); - } - } } } else if (element instanceof IDevice) { IDevice device = (IDevice) element; @@ -130,26 +102,19 @@ public class ConnectionExplorerLabelProvider implements ITableLabelProvider { @Override public void addListener(ILabelProviderListener listener) { - // TODO Auto-generated method stub - } @Override public void dispose() { - // TODO Auto-generated method stub - } @Override public boolean isLabelProperty(Object element, String property) { - // TODO Auto-generated method stub return false; } @Override public void removeListener(ILabelProviderListener listener) { - // TODO Auto-generated method stub - } } diff --git a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/explorer/ConnectionExplorerPanel.java b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/explorer/ConnectionExplorerPanel.java index c9b65a4..b07a6d7 100644 --- a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/explorer/ConnectionExplorerPanel.java +++ b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/explorer/ConnectionExplorerPanel.java @@ -75,6 +75,7 @@ import com.samsung.tizen.common.connection.ddmuilib.TableHelper; import com.samsung.tizen.common.connection.ddmuilib.console.DdmConsole; import com.samsung.tizen.common.connection.debugtools.ToolsInstall; import com.samsung.tizen.common.connection.sdblib.dnd.FileEntryTransfer; +import com.samsung.tizen.common.log.Logger; import com.samsung.tizen.sdblib.FileListingService; import com.samsung.tizen.sdblib.FileListingService.FileEntry; import com.samsung.tizen.sdblib.IDevice; @@ -92,21 +93,14 @@ public class ConnectionExplorerPanel extends Panel IDebugBridgeChangeListener, ISelectionListener { - private final static String TRACE_KEY_EXT = ".key"; // $NON-NLS-1S - private final static String TRACE_DATA_EXT = ".data"; // $NON-NLS-1S private final static String DRAGACTIONID = "com.samsung.tizen.common.connection.filedrop"; private String INVALID_FOR_FILENAME = ";"; - private static Pattern mKeyFilePattern = Pattern.compile("(.+)\\" - + TRACE_KEY_EXT); // $NON-NLS-1S - private static Pattern mDataFilePattern = Pattern.compile("(.+)\\" - + TRACE_DATA_EXT); // $NON-NLS-1S - public static String COLUMN_NAME = "name"; //$NON-NLS-1S private Composite mParent; - private TreeViewer mTreeViewer; - private Tree mTree; + private TreeViewer treeViewer; + private Tree tree; private ConnectionExplorerContentProvider mContentProvider; private ToolItem pushToolItem; @@ -123,106 +117,47 @@ public class ConnectionExplorerPanel extends Panel private IDevice mCurrentDevice; - private String mDefaultSave; + private String defaultSave; // only use on linux system private String PATH_SEPARATOR = "/"; - private final ArrayList mDevicesToExpand = new ArrayList(); - private final ArrayList mDevicesList = new ArrayList(); + private final ArrayList devicesToExpand = new ArrayList(); + private final ArrayList devicesList = new ArrayList(); private FileEntry currentFileEntry; public ConnectionExplorerPanel() { } - /** - * Creates a control capable of displaying some information. This is called - * once, when the application is initializing, from the UI thread. - */ + @Override protected Control createControl(Composite parent) { mParent = parent; parent.setLayout(new FillLayout()); - mTree = new Tree(parent, SWT.MULTI | SWT.FULL_SELECTION ); - mTree.setHeaderVisible(true); + tree = new Tree(parent, SWT.MULTI | SWT.FULL_SELECTION ); + tree.setHeaderVisible(true); IPreferenceStore store = DdmUiPreferences.getStore(); - // create columns - TableHelper.createTreeColumn(mTree, "FileEntry", SWT.LEFT, + TableHelper.createTreeColumn(tree, "FileEntry", SWT.LEFT, "abcdefghijklmnopqrstuvwz", COLUMN_NAME, store); //$NON-NLS-1$ - mTree.setHeaderVisible(false); + tree.setHeaderVisible(true); - mTreeViewer = new TreeViewer(mTree); - // setup data provider + treeViewer = new TreeViewer(tree); mContentProvider = new ConnectionExplorerContentProvider(); - mTreeViewer.setContentProvider(mContentProvider); - mTreeViewer.setLabelProvider(new ConnectionExplorerLabelProvider( + treeViewer.setContentProvider(mContentProvider); + treeViewer.setLabelProvider(new ConnectionExplorerLabelProvider( mParent.getDisplay())); - mTree.addSelectionListener(new SelectionAdapter() { + tree.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { notifyListeners(); } }); - // add support for double click -// mTreeViewer.addDoubleClickListener(new IDoubleClickListener() { -// public void doubleClick(DoubleClickEvent event) { -// ISelection sel = event.getSelection(); -// -// if (sel instanceof IStructuredSelection) { -// IStructuredSelection selection = (IStructuredSelection) sel; -// -// if (selection.size() == 1) { -// FileEntry entry = (FileEntry) selection -// .getFirstElement(); -// String name = entry.getName(); -// -// FileEntry parentEntry = entry.getParent(); -// -// // can't really do anything with no parent -// if (parentEntry == null) { -// return; -// } -// -// // check this is a file like we want. -// Matcher m = mKeyFilePattern.matcher(name); -// if (m.matches()) { -// // get the name w/o the extension -// String baseName = m.group(1); -// -// // add the data extension -// String dataName = baseName + TRACE_DATA_EXT; -// -// FileEntry dataEntry = parentEntry -// .findChild(dataName); -// -// handleTraceDoubleClick(baseName, entry, dataEntry); -// -// } else { -// m = mDataFilePattern.matcher(name); -// if (m.matches()) { -// // get the name w/o the extension -// String baseName = m.group(1); -// -// // add the key extension -// String keyName = baseName + TRACE_KEY_EXT; -// -// FileEntry keyEntry = parentEntry -// .findChild(keyName); -// -// handleTraceDoubleClick(baseName, keyEntry, -// entry); -// } -// } -// } -// } -// } -// }); // setup drag listener - mTreeViewer.addDragSupport( + treeViewer.addDragSupport( DND.DROP_MOVE | DND.DROP_COPY, new Transfer[]{PluginTransfer.getInstance(), FileEntryTransfer.getInstance()}, @@ -231,7 +166,7 @@ public class ConnectionExplorerPanel extends Panel @Override public void dragStart(DragSourceEvent e) { - TreeItem[] items = mTree.getSelection(); + TreeItem[] items = tree.getSelection(); for (int i = 0; i < items.length; i++) { Object data = items[i].getData(); @@ -253,7 +188,7 @@ public class ConnectionExplorerPanel extends Panel @Override public void dragSetData(DragSourceEvent e) { // get the selection - TreeItem[] items = mTree.getSelection(); + TreeItem[] items = tree.getSelection(); FileEntry[] entries = new FileEntry[items.length]; for (int i = 0; i < items.length; i++) { @@ -275,10 +210,11 @@ public class ConnectionExplorerPanel extends Panel } }); + // setup drop listener - mTreeViewer.addDropSupport(DND.DROP_COPY | DND.DROP_MOVE, + treeViewer.addDropSupport(DND.DROP_COPY | DND.DROP_MOVE, new Transfer[]{FileTransfer.getInstance()}, - new ViewerDropAdapter(mTreeViewer) { + new ViewerDropAdapter(treeViewer) { @Override public boolean performDrop(Object data) { // get the item on which we dropped the item(s) @@ -335,7 +271,7 @@ public class ConnectionExplorerPanel extends Panel } }); - return mTree; + return tree; } public void setToolItems(ToolItem push, ToolItem pull, ToolItem start ) { @@ -348,8 +284,6 @@ public class ConnectionExplorerPanel extends Panel Action actionPush, Action actionPull, Action actionRefresh, Action actionRename, Action actionProperty, Action actionDelete) { this.subMenu = subMenu; -// this.actionAddFolder = actionAddFolder; -// this.actionAddFile = actionAddFile; this.actionPush = actionPush; this.actionPull = actionPull; this.actionRefresh = actionRefresh; @@ -381,114 +315,9 @@ public class ConnectionExplorerPanel extends Panel */ @Override public void setFocus() { - mTree.setFocus(); + tree.setFocus(); } -// /** -// * Processes a double click on a trace file -// * -// * @param baseName -// * the base name of the 2 files. -// * @param keyEntry -// * The FileEntry for the .key file. -// * @param dataEntry -// * The FileEntry for the .data file. -// */ -// private void handleTraceDoubleClick(String baseName, FileEntry keyEntry, -// FileEntry dataEntry) { -// // first we need to download the files. -// File keyFile; -// File dataFile; -// String path; -// try { -// // create a temp file for keyFile -// File f = File.createTempFile(baseName, ".trace"); -// f.delete(); -// f.mkdir(); -// -// path = f.getAbsolutePath(); -// -// keyFile = new File(path + PATH_SEPARATOR + keyEntry.getName()); -// dataFile = new File(path + PATH_SEPARATOR + dataEntry.getName()); -// } catch (IOException e) { -// return; -// } -// -// // download the files -// try { -// SyncService sync = mCurrentDevice.getSyncService(); -// if (sync != null) { -// ISyncProgressMonitor monitor = SyncService -// .getNullProgressMonitor(); -// SyncResult result = sync.pullFile(keyEntry, -// keyFile.getAbsolutePath(), monitor); -// if (result.getCode() != SyncService.RESULT_OK) { -// DdmConsole.printErrorToConsole(String.format( -// "Failed to pull %1$s: %2$s", keyEntry.getName(), -// result.getMessage())); -// return; -// } -// -// result = sync.pullFile(dataEntry, dataFile.getAbsolutePath(), -// monitor); -// if (result.getCode() != SyncService.RESULT_OK) { -// DdmConsole.printErrorToConsole(String.format( -// "Failed to pull %1$s: %2$s", dataEntry.getName(), -// result.getMessage())); -// return; -// } -// -// // now that we have the file, we need to launch traceview -// String[] command = new String[2]; -// command[0] = DdmUiPreferences.getTraceview(); -// command[1] = path + PATH_SEPARATOR + baseName; -// -// try { -// final Process p = Runtime.getRuntime().exec(command); -// -// // create a thread for the output -// new Thread("Traceview output") { -// @Override -// public void run() { -// // create a buffer to read the stderr output -// InputStreamReader is = new InputStreamReader( -// p.getErrorStream()); -// BufferedReader resultReader = new BufferedReader(is); -// -// // read the lines as they come. if null is returned, -// // it's -// // because the process finished -// try { -// while (true) { -// String line = resultReader.readLine(); -// if (line != null) { -// DdmConsole -// .printErrorToConsole("Traceview: " -// + line); -// } else { -// break; -// } -// } -// // get the return code from the process -// p.waitFor(); -// } catch (IOException e) { -// } catch (InterruptedException e) { -// -// } -// } -// }.start(); -// -// } catch (IOException e) { -// } -// } -// } catch (IOException e) { -// DdmConsole.printErrorToConsole(String.format( -// "Failed to pull %1$s: %2$s", keyEntry.getName(), -// e.getMessage())); -// return; -// } -// } - /** * Pull the current selection on the local drive. This method displays a * dialog box to let the user select where to store the file(s) and @@ -496,14 +325,14 @@ public class ConnectionExplorerPanel extends Panel */ public void pullSelection() { // get the selection - TreeItem[] items = mTree.getSelection(); + TreeItem[] items = tree.getSelection(); // name of the single file pull, or null if we're pulling a directory // or more than one object. String filePullName = null; FileEntry singleEntry = null; - // are we pulling a single file? + //Pull the single file if (items.length == 1) { singleEntry = (FileEntry) items[0].getData(); if (singleEntry.getType() == FileListingService.TYPE_FILE) { @@ -512,7 +341,7 @@ public class ConnectionExplorerPanel extends Panel } // where do we save by default? - String defaultPath = mDefaultSave; + String defaultPath = defaultSave; if (defaultPath == null) { defaultPath = System.getProperty("user.home"); //$NON-NLS-1$ } @@ -526,7 +355,7 @@ public class ConnectionExplorerPanel extends Panel String fileName = fileDialog.open(); if (fileName != null) { - mDefaultSave = fileDialog.getFilterPath(); + defaultSave = fileDialog.getFilterPath(); pullFile(singleEntry, fileName); } @@ -552,7 +381,7 @@ public class ConnectionExplorerPanel extends Panel */ public void pushIntoSelection() { // get the name of the object we're going to pull - TreeItem[] items = mTree.getSelection(); + TreeItem[] items = tree.getSelection(); if (items.length == 0) { return; @@ -565,9 +394,8 @@ public class ConnectionExplorerPanel extends Panel // There should be only one. FileEntry entry = (FileEntry) items[0].getData(); - // dlg.setFileName(entry.getName()); - String defaultPath = mDefaultSave; + String defaultPath = defaultSave; if (defaultPath == null) { defaultPath = System.getProperty("user.home"); //$NON-NLS-1$ } @@ -575,7 +403,7 @@ public class ConnectionExplorerPanel extends Panel fileName = dlg.open(); if (fileName != null) { - mDefaultSave = dlg.getFilterPath(); + defaultSave = dlg.getFilterPath(); // we need to figure out the remote path based on the current // selection type. @@ -589,7 +417,7 @@ public class ConnectionExplorerPanel extends Panel } pushFile(fileName, remotePath); - mTreeViewer.refresh(toRefresh); + treeViewer.refresh(toRefresh); } } @@ -602,7 +430,7 @@ public class ConnectionExplorerPanel extends Panel String fullPath = currentFileEntry.getFullPath(); - TreeItem[] items = mTree.getSelection(); + TreeItem[] items = tree.getSelection(); if (items.length != 1) { return; @@ -621,7 +449,7 @@ public class ConnectionExplorerPanel extends Panel } public void flush() { - mTreeViewer.refresh(parentEntry); + treeViewer.refresh(parentEntry); } public boolean isCancelled() { @@ -629,9 +457,8 @@ public class ConnectionExplorerPanel extends Panel } }); } catch (IOException e) { - // adb failed somehow, we do nothing. We should be displaying the - // error from the output - // of the shell command. + Logger.error("failed to do add new file", e); + throw new RuntimeException(e); } refresh(parentEntry); } @@ -644,7 +471,7 @@ public class ConnectionExplorerPanel extends Panel return; String fullPath = currentFileEntry.getFullPath(); - TreeItem[] items = mTree.getSelection(); + TreeItem[] items = tree.getSelection(); if (items.length != 1) { return; @@ -663,7 +490,7 @@ public class ConnectionExplorerPanel extends Panel } public void flush() { - mTreeViewer.refresh(parentEntry); + treeViewer.refresh(parentEntry); } public boolean isCancelled() { @@ -671,9 +498,8 @@ public class ConnectionExplorerPanel extends Panel } }); } catch (IOException e) { - // adb failed somehow, we do nothing. We should be displaying the - // error from the output - // of the shell command. + Logger.error("failed to do add new folder", e); + throw new RuntimeException(e); } refresh(parentEntry); } @@ -690,7 +516,7 @@ public class ConnectionExplorerPanel extends Panel String newPath = fullPath.substring(0, lastIndex) + PATH_SEPARATOR + renameDialog.getValue(); - TreeItem[] items = mTree.getSelection(); + TreeItem[] items = tree.getSelection(); if (items.length != 1) { return; @@ -709,7 +535,7 @@ public class ConnectionExplorerPanel extends Panel } public void flush() { - mTreeViewer.refresh(parentEntry); + treeViewer.refresh(parentEntry); } public boolean isCancelled() { @@ -717,9 +543,8 @@ public class ConnectionExplorerPanel extends Panel } }); } catch (IOException e) { - // adb failed somehow, we do nothing. We should be displaying the - // error from the output - // of the shell command. + Logger.error("failed to do rename", e); + throw new RuntimeException(e); } refresh(parentEntry); } @@ -730,10 +555,7 @@ public class ConnectionExplorerPanel extends Panel if (ret == IDialogConstants.CANCEL_ID) return; - TreeItem[] items = mTree.getSelection(); - - // FileEntry entry = (FileEntry) items[0].getData(); - // final FileEntry parentEntry = entry.getParent(); + TreeItem[] items = tree.getSelection(); for (TreeItem item : items) { final FileEntry entry = (FileEntry) item.getData(); @@ -753,7 +575,7 @@ public class ConnectionExplorerPanel extends Panel } public void flush() { - mTreeViewer.refresh(entry.getParent()); + treeViewer.refresh(entry.getParent()); } public boolean isCancelled() { @@ -761,10 +583,9 @@ public class ConnectionExplorerPanel extends Panel } }); } catch (IOException e) { - // adb failed somehow, we do nothing. We should be displaying - // the - // error from the output - // of the shell command. + Logger.error("failed to do delete", e); + throw new RuntimeException(e); + } refresh(entry.getParent()); } @@ -775,7 +596,7 @@ public class ConnectionExplorerPanel extends Panel * Force a full refresh of the explorer. */ public void refresh() { - mTreeViewer.refresh(true); + treeViewer.refresh(true); } /** @@ -789,12 +610,12 @@ public class ConnectionExplorerPanel extends Panel * @see IDebugBridgeChangeListener#serverChanged(SmartDevelopmentBridge) */ public void bridgeChanged(final SmartDevelopmentBridge bridge) { - if (mTree.isDisposed() == false) { + if (tree.isDisposed() == false) { exec(new Runnable() { public void run() { - if (mTree.isDisposed() == false) { + if (tree.isDisposed() == false) { // set up the data source. - mTreeViewer.setInput(bridge); + treeViewer.setInput(bridge); } else { // tree is disposed, we need to do something. @@ -809,8 +630,8 @@ public class ConnectionExplorerPanel extends Panel } // all current devices are obsolete - synchronized (mDevicesToExpand) { - mDevicesToExpand.clear(); + synchronized (devicesToExpand) { + devicesToExpand.clear(); } } @@ -821,20 +642,20 @@ public class ConnectionExplorerPanel extends Panel * the entry to refresh. */ private void refresh(final FileEntry entry) { - Display d = mTreeViewer.getTree().getDisplay(); + Display d = treeViewer.getTree().getDisplay(); d.asyncExec(new Runnable() { public void run() { - mTreeViewer.refresh(entry); + treeViewer.refresh(entry); } }); } public void refreshSelection() { if (currentFileEntry == null) return; - Display d = mTreeViewer.getTree().getDisplay(); + Display d = treeViewer.getTree().getDisplay(); d.asyncExec(new Runnable() { public void run() { - mTreeViewer.refresh(currentFileEntry); + treeViewer.refresh(currentFileEntry); } }); } @@ -862,7 +683,7 @@ public class ConnectionExplorerPanel extends Panel final FileEntry[] entryArray = entries .toArray(new FileEntry[entries.size()]); - // get a progressdialog + // get a progress dialog new ProgressMonitorDialog(mParent.getShell()).run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) @@ -976,7 +797,7 @@ public class ConnectionExplorerPanel extends Panel * Pushes a file on a device. * * @param local - * the local filepath of the file to push + * the local file path of the file to push * @param remoteDirectory * the remote destination directory on the device */ @@ -1039,14 +860,14 @@ public class ConnectionExplorerPanel extends Panel { if( device.isOffline()) return; - mDevicesList.add(device); + devicesList.add(device); ToolsInstall.installPackages(device); exec(new Runnable() { public void run() { - if (mTree.isDisposed() == false) { + if (tree.isDisposed() == false) { // refresh all - mTreeViewer.refresh(); + treeViewer.refresh(); // notify the listener of a possible selection change. notifyListeners(); @@ -1061,23 +882,20 @@ public class ConnectionExplorerPanel extends Panel } }); - // if it doesn't have clients yet, it'll need to be manually expanded - // when it gets them. - // if (device.hasClients() == false) { - synchronized (mDevicesToExpand) { - mDevicesToExpand.add(device); + synchronized (devicesToExpand) { + devicesToExpand.add(device); } } @Override public void deviceDisconnected(IDevice device) { - mDevicesList.remove(device); + devicesList.remove(device); exec(new Runnable() { public void run() { - if (mTree.isDisposed() == false) { + if (tree.isDisposed() == false) { // refresh all - mTreeViewer.refresh(); + treeViewer.refresh(); // notify the listener of a possible selection change. notifyListeners(); @@ -1092,11 +910,8 @@ public class ConnectionExplorerPanel extends Panel } }); - // if it doesn't have clients yet, it'll need to be manually expanded - // when it gets them. - // if (device.hasClients() == false) { - synchronized (mDevicesToExpand) { - mDevicesToExpand.add(device); + synchronized (devicesToExpand) { + devicesToExpand.add(device); } // } } @@ -1104,13 +919,13 @@ public class ConnectionExplorerPanel extends Panel @Override public void deviceChanged(IDevice device, int changeMask) { if (changeMask == 1) { - mDevicesList.add(device); + devicesList.add(device); ToolsInstall.installPackages(device); exec(new Runnable() { public void run() { - if (mTree.isDisposed() == false) { + if (tree.isDisposed() == false) { // refresh all - mTreeViewer.refresh(); + treeViewer.refresh(); // notify the listener of a possible selection change. notifyListeners(); @@ -1125,24 +940,21 @@ public class ConnectionExplorerPanel extends Panel } }); - // if it doesn't have clients yet, it'll need to be manually - // expanded when it gets them. - // if (device.hasClients() == false) { - synchronized (mDevicesToExpand) { - mDevicesToExpand.add(device); + synchronized (devicesToExpand) { + devicesToExpand.add(device); } } } public ArrayList getDeviceList() { - return mDevicesList; + return devicesList; } private void exec(Runnable runnable) { - if( mTree.isDisposed() == false) + if( tree.isDisposed() == false) { try { - Display display = mTree.getDisplay(); + Display display = tree.getDisplay(); display.asyncExec(runnable); } catch (SWTException e) { // tree is disposed, we need to do something. lets remove ourselves @@ -1157,7 +969,7 @@ public class ConnectionExplorerPanel extends Panel private void notifyListeners() { // get the selection - TreeItem[] items = mTree.getSelection(); + TreeItem[] items = tree.getSelection(); FileEntry file = null; @@ -1178,10 +990,10 @@ public class ConnectionExplorerPanel extends Panel if (devices.length != 0) { mCurrentDevice = devices[0]; file = devices[0].getFileListingService().getRoot(); - for(TreeItem item : mTree.getItems()) + for(TreeItem item : tree.getItems()) { if( item.getText().equals(file.getName())) - mTree.setSelection(item); + tree.setSelection(item); } } else mCurrentDevice = null; @@ -1193,7 +1005,7 @@ public class ConnectionExplorerPanel extends Panel } public TreeViewer getTreeViewer() { - return mTreeViewer; + return treeViewer; } class FileNameValidator implements IInputValidator { @@ -1279,11 +1091,11 @@ public class ConnectionExplorerPanel extends Panel exec(new Runnable() { public void run() { - if (mTree.isDisposed() == false) { - for(TreeItem item : mTree.getItems()) + if (tree.isDisposed() == false) { + for(TreeItem item : tree.getItems()) { if( item.getText().equals(selectedEntry.getName())) - mTree.setSelection(item); + tree.setSelection(item); } } else { // tree is disposed, we need to do something. diff --git a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/explorer/Messages.java b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/explorer/Messages.java index 8fa3a0a..f765206 100644 --- a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/explorer/Messages.java +++ b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/explorer/Messages.java @@ -38,7 +38,6 @@ public class Messages { } public static String getString(String key) { - // TODO Auto-generated method stub try { return RESOURCE_BUNDLE.getString(key); } catch (MissingResourceException e) { @@ -47,7 +46,6 @@ public class Messages { } public static String getString(String key, Object binding) { - // TODO Auto-generated method stub try { return RESOURCE_BUNDLE.getString(key); } catch (MissingResourceException e) { diff --git a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/log/AddViewDialog.java b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/log/AddViewDialog.java index a8d0fae..0f84ea8 100644 --- a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/log/AddViewDialog.java +++ b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/log/AddViewDialog.java @@ -49,7 +49,7 @@ import com.samsung.tizen.sdblib.IDevice; import com.samsung.tizen.sdblib.SmartDevelopmentBridge; /** - * Small dialog box to open new log view with some options. + * Small dialog box to open new logtab with some options. */ public class AddViewDialog extends Dialog { @@ -165,12 +165,6 @@ public class AddViewDialog extends Dialog { if (tabName != null) tabNameText.setText(tabName); tabNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); -// tabNameText.addModifyListener(new ModifyListener() { -// public void modifyText(ModifyEvent e) { -// tabName = tabNameText.getText(); -// validate(); -// } -// }); l = new Label(top, SWT.NONE); l.setText("Device : "); @@ -201,26 +195,6 @@ public class AddViewDialog extends Dialog { } } -// dCombo.addSelectionListener(new SelectionAdapter() { -// @Override -// public void widgetSelected(SelectionEvent e) { -// if (dCombo.getItemCount() != 0) { -// // get the selection -// device = dCombo.getItem(dCombo.getSelectionIndex()); -// validate(); -// } -// } -// }); - - // separator -// l = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); -// l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - -// Composite mid = new Composite(shell, SWT.NONE); -// mid.setLayoutData(new GridData(GridData.FILL_BOTH)); -// mid.setLayout(new GridLayout(2, false)); - - Group mid = new Group(shell, SWT.SHADOW_IN); mid.setText("Search Keywords"); mid.setLayoutData(new GridData(GridData.FILL_BOTH)); @@ -235,15 +209,6 @@ 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)); -// tagText.addModifyListener(new ModifyListener() { -// public void modifyText(ModifyEvent e) { -// if( tagText.getText().length() != 0) -// tagKeyword = tagText.getText(); -// else -// tagKeyword = null; -// validate(); -// } -// }); l = new Label(mid, SWT.NONE); l.setText("Pid : "); @@ -254,13 +219,6 @@ 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)); -// pidText.addModifyListener(new ModifyListener() { -// public void modifyText(ModifyEvent e) { -// if( pidText.getText().length() != 0) -// pidKeyword = pidText.getText(); -//// validate(); -// } -// }); l = new Label(mid, SWT.NONE); l.setText("Message : "); @@ -271,101 +229,6 @@ public class AddViewDialog extends Dialog { msgText.setMessage("Separated by a space/comma"); msgText.setToolTipText("Search Message Keywords are separated by a space as well as a comma"); msgText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); -// msgText.addModifyListener(new ModifyListener() { -// public void modifyText(ModifyEvent e) { -// if( msgText.getText().length() != 0) -// msgKeyword = msgText.getText(); -//// validate(); -// } -// }); - -// // center part with the filter parameters -// Composite mid = new Composite(shell, SWT.NONE); -// mid.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); -// mid.setLayout(new GridLayout(3, false)); -// -// final Button btnPid = new Button(mid, SWT.CHECK); -// btnPid.setText("Pid"); -// if (bPid) -// btnPid.setSelection(true); -// btnPid.addSelectionListener(new SelectionListener() { -// -// @Override -// public void widgetSelected(SelectionEvent e) { -// if (btnPid.getSelection()) -// bPid = true; -// else -// bPid = false; -// validate(); -// } -// -// @Override -// public void widgetDefaultSelected(SelectionEvent e) { -// } -// }); -// -// final Button btnTag = new Button(mid, SWT.CHECK); -// btnTag.setText("Tag"); -// if (bTag) -// btnTag.setSelection(true); -// btnTag.addSelectionListener(new SelectionListener() { -// -// @Override -// public void widgetSelected(SelectionEvent e) { -// if (btnTag.getSelection()) -// bTag = true; -// else -// bTag = false; -// validate(); -// } -// -// @Override -// public void widgetDefaultSelected(SelectionEvent e) { -// } -// }); -// -// final Button btnMsg = new Button(mid, SWT.CHECK); -// btnMsg.setText("Message"); -// if (bMsg) -// btnMsg.setSelection(true); -// btnMsg.addSelectionListener(new SelectionListener() { -// -// @Override -// public void widgetSelected(SelectionEvent e) { -// if (btnMsg.getSelection()) -// bMsg = true; -// else -// bMsg = false; -// validate(); -// } -// -// @Override -// public void widgetDefaultSelected(SelectionEvent e) { -// } -// }); -// -// Composite bottom = new Composite(shell, SWT.NONE); -// bottom.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); -// bottom.setLayout(new GridLayout(2, false)); -// -// l = new Label(bottom, SWT.NONE); -// l.setText("Search : "); -// -// searchText = new Text(bottom, SWT.SINGLE | SWT.BORDER); -// searchText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); -// searchText.setEnabled(false); -// if (keyword != null) -// searchText.setText(keyword); -// searchText.addModifyListener(new ModifyListener() { -// public void modifyText(ModifyEvent e) { -// keyword = searchText.getText(); -// validate(); -// } -// }); - - // separator -// l = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); -// l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // bottom part with the ok/cancel Composite bottomComp = new Composite(shell, SWT.NONE); @@ -429,13 +292,8 @@ public class AddViewDialog extends Dialog { } }); -// validate(); } -// public String getKeyword() { -// return keyword; -// } - public String getName() { return tabName; } @@ -459,56 +317,7 @@ public class AddViewDialog extends Dialog { return msgKeyword; } -// public boolean getPidChecked() { -// return bPid; -// } -// -// public boolean getTagChecked() { -// return bTag; -// } -// -// public boolean getMsgChecked() { -// return bMsg; -// } - - // /** - // * Validates the content of the 2 text fields and enable/disable "ok", - // while - // * setting up the warning/error message. - // */ - private void validate() { - // - if (tabName == null || tabName.equals("")) { - okButton.setEnabled(false); - return; - } - // then we check it only contains digits. - if (device == null) { - okButton.setEnabled(false); - return; - } - -// if (bMsg || bPid || bTag) { -// if (!searchText.getEnabled()) -// searchText.setEnabled(true); -// -// if (keyword == null || keyword.equals("")) { -// okButton.setEnabled(false); -// return; -// } -// -// } else { -// if (searchText.getEnabled()) -// searchText.setEnabled(false); -// } - okButton.setEnabled(true); - } - public void setName(String name) { this.tabName = name; } -// -// public void setKeyword(String word) { -// this.keyword = word; -// } } \ No newline at end of file diff --git a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/log/LogPanel.java b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/log/LogPanel.java index 2f9a12c..599b201 100644 --- a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/log/LogPanel.java +++ b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/log/LogPanel.java @@ -77,19 +77,13 @@ public class LogPanel extends Panel implements IDeviceChangeListener { public static int ENABLE_DEFAULT = 1; public static int ENABLE_ALL = 2; - private String mDefaultLogSave; + private String defaultLogSave; private Composite parent; private TabFolder folders; private Text filterText; private LogColors colors; - /** - * Circular buffer containing the logcat output. This is unfiltered. The - * valid content goes from mBufferStart to - * mBufferEnd - 1. Therefore its number of item is - * mBufferEnd - mBufferStart. - */ public static ArrayList tabs = new ArrayList(); private LogTab currentTab; @@ -111,7 +105,7 @@ public class LogPanel extends Panel implements IDeviceChangeListener { public String time; } - private ITableFocusListener mGlobalListener; + private ITableFocusListener globalListener; /** message data, separated from content for multi line messages */ protected static class LogMessage { @@ -157,10 +151,6 @@ public class LogPanel extends Panel implements IDeviceChangeListener { parent = p; - // Composite top = new Composite(parent, SWT.NONE); - // top.setLayoutData(new GridData(GridData.FILL_BOTH)); - // top.setLayout(new GridLayout(1, false)); - // create the tab folder folders = new TabFolder(parent, SWT.NONE); folders.setLayoutData(new GridData(GridData.FILL_BOTH)); @@ -273,7 +263,7 @@ public class LogPanel extends Panel implements IDeviceChangeListener { table.setHeaderVisible(true); table.setLinesVisible(true); - if (mGlobalListener != null) { + if (globalListener != null) { addTableToFocusListener(table); } @@ -401,7 +391,7 @@ public class LogPanel extends Panel implements IDeviceChangeListener { public void setTableFocusListener(ITableFocusListener listener) { // record the global listener, to make sure table created after // this call will still be setup. - mGlobalListener = listener; + globalListener = listener; for (LogTab tab : tabs) { addTableToFocusListener(tab.getTable()); @@ -431,11 +421,11 @@ public class LogPanel extends Panel implements IDeviceChangeListener { // listener table.addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { - mGlobalListener.focusGained(activator); + globalListener.focusGained(activator); } public void focusLost(FocusEvent e) { - mGlobalListener.focusLost(activator); + globalListener.focusLost(activator); } }); } @@ -486,7 +476,7 @@ public class LogPanel extends Panel implements IDeviceChangeListener { dlg.setText("Export Log"); dlg.setFileName(getCurrentLogTab().getFilterName() +"-log.txt"); - String defaultPath = mDefaultLogSave; + String defaultPath = defaultLogSave; if (defaultPath == null) { defaultPath = System.getProperty("user.home"); //$NON-NLS-1$ } @@ -510,7 +500,7 @@ public class LogPanel extends Panel implements IDeviceChangeListener { } while (again); if (fileName != null) { - mDefaultLogSave = dlg.getFilterPath(); + defaultLogSave = dlg.getFilterPath(); // loop on the selection and output the file. try { @@ -544,7 +534,7 @@ public class LogPanel extends Panel implements IDeviceChangeListener { return; AddViewDialog dlg = new AddViewDialog(parent.getShell(), getCurrentLogTab().getFilterDeviceName()); - // LogView view = null; + if (dlg.open()) { for (IDevice device : SmartDevelopmentBridge.getBridge() .getDevices()) { @@ -627,29 +617,12 @@ public class LogPanel extends Panel implements IDeviceChangeListener { return; } - // private void autosave(LogMessage msg) - // { - // if( autoFile!=null) - // try { - // autoFile.append(msg.toString()); - // autoFile.append('\n'); - // } - // catch (IOException e) - // { - // e.printStackTrace(); - // } - // } - public static TableColumn createTableColumn(Table parent, String header, int style, String sample_text) { // create the column TableColumn col = new TableColumn(parent, style); - // if there is no pref store or the entry is missing, we use the - // sample - // text and pack the column. - // Otherwise we just read the width from the prefs and apply it. col.setText(sample_text); col.pack(); @@ -665,16 +638,6 @@ public class LogPanel extends Panel implements IDeviceChangeListener { return tabs.get(index); } else return null; - // - // // if mFilters is null or index is invalid, we return the - // default - // // filter. It doesn't matter if that one is null as well, since - // we - // // would return null anyway. - // if (index == 0 || mFilters == null) { - // return mDefaultFilter; - // } - } public void stopAll() { diff --git a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/log/LogTab.java b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/log/LogTab.java index 6d6f97e..f80dd96 100644 --- a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/log/LogTab.java +++ b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/log/LogTab.java @@ -84,7 +84,6 @@ public class LogTab { private Table table; private TabItem tabItem; - private boolean mIsCurrentTabItem = false; private int mUnreadCount = 0; private static Pattern logPattern = Pattern @@ -93,32 +92,17 @@ public class LogTab { private ArrayList tableMessages = new ArrayList(); private ArrayList newMessages = new ArrayList(); - // private final ArrayList mfMessages = new - // ArrayList(); private LogMessage[] buffer = new LogMessage[STRING_BUFFER_LENGTH]; private LogMessageInfo lastMessageInfo = null; - private boolean mPendingAsyncRefresh = false; + private boolean pendingAsyncRefresh = false; private boolean isDefault = false; - private int mRemovedMessageCount = 0; + private int removedMessageCount = 0; - /** Represents the oldest message in the buffer */ private int indexStart = -1; - - /** - * Represents the next usable item in the buffer to receive new message. - * This can be equal to indexStart, but when used indexStart will be - * incremented as well. - */ private int indexEnd = -1; - /** - * Creates a filter with a particular mode. - * - * @param name - * The name to be displayed in the UI - */ public LogTab(String name, IDevice device, LogColors colors) { filterName = name; filterDevice = device; @@ -170,10 +154,6 @@ public class LogTab { return result.toArray(new String[(result.size())]); } - - /** - * Returns the UI display name. - */ public String getFilterName() { return filterName; } @@ -182,11 +162,6 @@ public class LogTab { return levelMode; } - // public String getFilterWord() - // { - // return filterWord; - // } - public String getPidFilter() { return pidFilterString; } @@ -203,14 +178,6 @@ public class LogTab { return filterDevice.getSerialNumber(); } - /** - * Set the Table ui widget associated with this filter. - * - * @param tabItem - * The item in the TabFolder - * @param table - * The Table object - */ public void setTab(TabItem tabItem) { this.tabItem = tabItem; } @@ -219,9 +186,6 @@ public class LogTab { this.table = table; } - /** - * Returns true if the filter is ready for ui. - */ public boolean uiReady() { return (table != null && tabItem != null); } @@ -242,32 +206,8 @@ public class LogTab { tabItem = null; } - // /** - // * Returns the current filtering mode. - // * - // * @return A bitmask. Possible values are MODE_PID, MODE_TAG, MODE_LEVEL - // */ - // public int getFilteringMode() { - // return filterMode; - // } - - /** - * Starts a new LogTab and set mCurrentLogTab as the current receiver. - * - * @param device - * the device to connect LogTab to. - */ public void startLogTab() { - // if (device == filterDevice) { - // return; - // } - - // if we have a LogTab already running - // if (filterDevice != null) { - // stopLogTab(false); - // filterDevice = null; - // } resetUI(false); if (filterDevice != null) { @@ -292,8 +232,6 @@ public class LogTab { } if (logger == null || logger.isCancelled) { - // LogTab was stopped/cancelled before - // the device became ready. return; } @@ -304,8 +242,6 @@ public class LogTab { } catch (Exception e) { Log.e("LogTab", e); } finally { - // at this point the command is - // terminated. logger = null; filterDevice = null; } @@ -319,78 +255,25 @@ public class LogTab { if (logger != null) { logger.isCancelled = true; - // when the thread finishes, no one will reference that - // object - // and it'll be destroyed logger = null; - // // reset the content buffer - // for (int i = 0; i < STRING_BUFFER_LENGTH; i++) { - // buffer[i] = null; - // } - // - // // because it's a circular buffer, it's hard to know if - // // the array is empty with both start/end at 0 or if it's - // // full - // // with both start/end at 0 as well. So to mean empty, we - // // use -1 - // indexStart = -1; - // indexEnd = -1; clear(); - // resetFilters(); resetUI(inUiThread); } } - /** - * Sets the selected state of the filter. - * - * @param selected - * selection state. - */ - public void setSelectedState(boolean selected) { - // if (selected) { - // if (tabItem != null) { - // tabItem.setText(filterName); - // } - // mUnreadCount = 0; - // } - mIsCurrentTabItem = selected; - } - - /** - * Adds a new message and optionally removes an old message. - *

- * The new message is filtered through {@link #accept(LogMessage)}. Calls to - * {@link #flush()} from a UI thread will display it (and other pending - * messages) to the associated {@link Table}. - * - * @param logMessage - * the MessageData object to filter - * @return true if the message was accepted. - */ public boolean addMessage(LogMessage newMessage, LogMessage oldMessage) { synchronized (tableMessages) { if (oldMessage != null) { 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); - mRemovedMessageCount++; + removedMessageCount++; } - // now we look for it in mNewMessages. This can - // happen if the new message is added - // and then removed because too many messages are - // added between calls to #flush() 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); } } @@ -398,8 +281,6 @@ public class LogTab { 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); } @@ -408,13 +289,6 @@ public class LogTab { } } - /** - * Filters a message. - * - * @param logMessage - * the Message - * @return true if the message is accepted by the filter. - */ boolean accept(LogMessage logMessage) { if (logMessage == null) return false; @@ -428,7 +302,6 @@ public class LogTab { } if (pidFilter != null || tagFilter != null || msgFilter != null) { - // if ((filterMode & FILTER_PID) == FILTER_PID) { if (pidFilter != null) { for( String filter : pidFilter) { @@ -439,7 +312,6 @@ public class LogTab { } } - // if ((filterMode & FILTER_TAG) == FILTER_TAG) { if (tagFilter != null) { for( String filter : tagFilter ){ if (logMessage.data.tag.toLowerCase().contains( @@ -449,7 +321,6 @@ public class LogTab { } } - // if ((filterMode & FILTER_MSG) == FILTER_MSG) { if (msgFilter != null) { for( String filter : msgFilter){ if (logMessage.msg.toLowerCase().contains( @@ -466,30 +337,21 @@ public class LogTab { return false; } - /** - * Takes all the accepted messages and display them. This must be called - * from a UI thread. - */ - // @UiThread public void flush() { - // if scroll bar is at the bottom, we will scroll ScrollBar bar = table.getVerticalBar(); boolean scroll = bar.getMaximum() == bar.getSelection() + bar.getThumb(); - // if we are not going to scroll, get the current first item being - // shown. int topIndex = table.getTopIndex(); - // disable drawing table.setRedraw(false); int totalCount = newMessages.size(); try { // remove the items of the old messages. - for (int i = 0; i < mRemovedMessageCount + for (int i = 0; i < removedMessageCount && table.getItemCount() > 0; i++) { table.remove(0); } @@ -515,13 +377,13 @@ public class LogTab { if (totalCount > 0) { table.showItem(table.getItem(totalCount - 1)); } - } else if (mRemovedMessageCount > 0) { + } else if (removedMessageCount > 0) { // we need to make sure the topIndex is still visible. // Because really old items are removed from the list, this // could make it disappear // if we don't change the scroll value at all. - topIndex -= mRemovedMessageCount; + topIndex -= removedMessageCount; if (topIndex < 0) { // looks like it disappeared. Lets just show the // first item @@ -532,7 +394,7 @@ public class LogTab { } newMessages.clear(); - mRemovedMessageCount = 0; + removedMessageCount = 0; } @@ -685,8 +547,8 @@ public class LogTab { // refresh, we // ask the Display // to run one in the UI thread. - if (mPendingAsyncRefresh == false) { - mPendingAsyncRefresh = true; + if (pendingAsyncRefresh == false) { + pendingAsyncRefresh = true; try { Display display = table.getDisplay(); @@ -756,7 +618,7 @@ public class LogTab { // be -1 or 0, as only the oldest // message is ever removed. tableMessages.remove(index); - mRemovedMessageCount++; + removedMessageCount++; } } } @@ -768,7 +630,6 @@ public class LogTab { // list tableMessages.add(newMessage); newMessages.add(newMessage); - // autosave( newMessage ); } } @@ -787,7 +648,7 @@ public class LogTab { } finally { // the pending refresh is done. - mPendingAsyncRefresh = false; + pendingAsyncRefresh = false; } } } else { @@ -937,7 +798,7 @@ public class LogTab { } public void msgClear() { - mRemovedMessageCount = 0; + removedMessageCount = 0; newMessages.clear(); lastMessageInfo = null; tableMessages.clear(); @@ -956,14 +817,6 @@ public class LogTab { msgClear(); } - // public void setFilterWord(String word) { - // filterWord = word; - // } - // - // public void setFilterMode(int mode) { - // filterMode = mode; - // } - public void setDevice(IDevice device) { filterDevice = device; } diff --git a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/properties/ConnectionExplorerInfoPropertyPages.java b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/properties/ConnectionExplorerInfoPropertyPages.java index 27c330b..eb01a98 100644 --- a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/properties/ConnectionExplorerInfoPropertyPages.java +++ b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/properties/ConnectionExplorerInfoPropertyPages.java @@ -79,7 +79,6 @@ public class ConnectionExplorerInfoPropertyPages extends PropertyPage implements FileEntry f = (FileEntry)getElement().getAdapter(FileEntry.class); // Path text field Label pathValueText = new Label(composite, SWT.NONE); -// pathValueText.setText(((IResource) getElement()).getFullPath().toString()); pathValueText.setText(f.getFullPath()); } diff --git a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/sdblib/dnd/FileEntryDropAdapter.java b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/sdblib/dnd/FileEntryDropAdapter.java index 8bb2c06..4fcc96a 100644 --- a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/sdblib/dnd/FileEntryDropAdapter.java +++ b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/sdblib/dnd/FileEntryDropAdapter.java @@ -89,6 +89,8 @@ public class FileEntryDropAdapter implements IDropActionDelegate { for (int i = 0; i < entries.length; i++) { File f = new File(entries[i]); + if( resource == null ) + return false; IPath localPath = resource.getFullPath().append(f.getName()); IResource newRes = resource.getWorkspace().getRoot().findMember(localPath); diff --git a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/ui/LogView.java b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/ui/LogView.java index cb26e67..26f8f0f 100644 --- a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/ui/LogView.java +++ b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/ui/LogView.java @@ -162,14 +162,11 @@ public final class LogView extends ViewPart { // now create the log view logPanel = new LogPanel(colors); - logPanel.setActions( logLevelActions, addAction, removeAction, editAction, exportAction, clearAction); + logPanel.setActions( logLevelActions, addAction, removeAction, editAction, exportAction, clearAction); placeActions(); logPanel.setActionEnabled(LogPanel.ENABLE_NOTHING); logPanel.createPanel(parent); - // ConnectionPlugin.getDefault().addSelectionListener(this); - // place the actions. - // setup the copy action clipboard = new Clipboard(d); IActionBars actionBars = getViewSite().getActionBars(); -- 2.7.4