plugin = this;
if (OSChecker.isWindows())
+ {
this.os = WINDOWS;
+ }
else
+ {
this.os = LINUX;
+ }
}
if (ce.getName().equals("tools")) {
String packagename = ce.getAttribute("packagename");
if (packagename == null)
+ {
continue;
+ }
String sourcepath = ce.getAttribute("sourcepath");
if (sourcepath == null)
+ {
continue;
+ }
String description = ce.getAttribute("description");
Path sourcePath = new Path(InstallPathConfig.getPlatformVersionPath() + "/" + sourcepath);
File packageList = new File(sourcePath.toOSString());
if (device.isEmulator()) {
if (!architecture.equals("i386"))
+ {
return null;
+ }
} else {
if (!architecture.equals("armel"))
+ {
return null;
+ }
}
DebugTool dt = new DebugTool(packagename, f.getName(), sourcepath, version, description, architecture, "tar");
package org.tizen.common.connection.debugtools;
+import static org.tizen.common.util.CollectionUtil.isEmpty;
+import static org.tizen.common.util.IOUtil.tryClose;
+
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import org.tizen.common.util.SdbCommandUtil;
import org.tizen.common.util.log.Logger;
import org.tizen.sdblib.IDevice;
-import org.tizen.sdblib.SdbCommandRejectedException;
import org.tizen.sdblib.SdbShellProcess;
-import org.tizen.sdblib.SyncService;
-import org.tizen.sdblib.SyncService.SyncResult;
-import org.tizen.sdblib.TimeoutException;
class PackageInstallMonitorDialog extends ProgressMonitorDialog {
public PackageInstallMonitorDialog(Shell parent) {
String msg = ToolsInstallMessages.CANNOT_CREATE_DIRECTORY;
if (checkExitCode(cmd, msg) == false)
+ {
installCoreException(msg, null);
+ }
}
private boolean checkExitCode( String cmd, String msg ) throws CoreException
Logger.error(msg, e);
}finally
{
- if( br != null )
- try {
- br.close();
- } catch (IOException e) {
- Logger.error("Error to close BufferedReader", e);
- }
+ tryClose( br );
}
return result;
}
}
break;
} else
+ {
ret = false;
+ }
}
} catch (IOException e) {
installCoreException(ToolsInstallMessages.CANNOT_CHECK_INSTALLED, e);
Logger.error(ToolsInstallMessages.CANNOT_CHECK_INSTALLED, e);
} finally {
- if(br != null)
- try {
- br.close();
- } catch (IOException e) {
- Logger.error("Error to close BufferedReader", e);
- }
+ tryClose( br );
}
return ret;
final List<DebugTool> allDebugTools = ConnectionPlugin.getDebugTools(device);
List<DebugTool> installDebugTools = new ArrayList<DebugTool>();
- if (allDebugTools == null || allDebugTools.size() == 0)
+ if ( isEmpty( allDebugTools ) )
+ {
return;
+ }
boolean isInstalled = false;
for ( DebugTool dt : allDebugTools ) {
try {
String name = getNameFromInputDialog("New File Resource", "New File Name: ", entry, "");
if (name == null)
+ {
return;
+ }
String fullPath = FilenameUtil.addDoubleQuote(entry.getFullEscapedPath() + "/" + name);
String command = String.format("touch %s; echo $?", fullPath);
String name = getNameFromInputDialog("New Folder Resource", "New Folder Name: ", entry, "");
if (name == null)
+ {
return;
+ }
// create the mkdir command
String fullPath = FilenameUtil.addDoubleQuote(entry.getFullEscapedPath() + "/" + name);
inputDialog = new InputDialog(Display.getCurrent().getActiveShell(), title, message, initValue, new FileNameValidator());
if (inputDialog.open() != Window.OK)
+ {
return null;
+ }
String input = inputDialog.getValue();
// same entry is already exist..
if (findDuplicateFileEntry(input, entry))
+ {
again = true;
+ }
} while (again);
String name = getNameFromInputDialog("Rename Resource", "New name: ", entry.getParent(), entry.getName());
if (name == null)
+ {
return;
+ }
String fullPath = entry.getFullEscapedPath();
int lastIndex = fullPath.lastIndexOf(PATH_SEPARATOR);
public void refreshSelection()
{
if (treeViewer.getTree().getSelectionCount() == 0)
+ {
return;
+ }
refresh(getSingleFileEntry());
}
public void deviceConnected(IDevice device)
{
if (device.isOffline())
+ {
return;
+ }
devicesList.add(device);
ToolsInstall.installPackages(device);
execRefresh();
{
if (selectedEntry == null)
+ {
return;
+ }
if (!selectedEntry.isRoot())
+ {
return;
+ }
final Tree tree = treeViewer.getTree();
exec(new Runnable()
return '!' + key + '!';\r
}\r
}\r
- private static String messageBind(String message, Object[] args, String argZero, String argOne) {\r
- int length = message.length();\r
- //estimate correct size of string buffer to avoid growth\r
- int bufLen = length + (args.length * 5);\r
- if (argZero != null)\r
- bufLen += argZero.length() - 3;\r
- if (argOne != null)\r
- bufLen += argOne.length() - 3;\r
- StringBuffer buffer = new StringBuffer(bufLen < 0 ? 0 : bufLen);\r
- for (int i = 0; i < length; i++) {\r
- char c = message.charAt(i);\r
- switch (c) {\r
- case '{' :\r
- int index = message.indexOf('}', i);\r
- // if we don't have a matching closing brace then...\r
- if (index == -1) {\r
- buffer.append(c);\r
- break;\r
- }\r
- i++;\r
- if (i >= length) {\r
- buffer.append(c);\r
- break;\r
- }\r
- // look for a substitution\r
- int number = -1;\r
- try {\r
- number = Integer.parseInt(message.substring(i, index));\r
- } catch (NumberFormatException e) {\r
- throw (IllegalArgumentException) new IllegalArgumentException().initCause(e);\r
- }\r
- if (number == 0 && argZero != null)\r
- buffer.append(argZero);\r
- else if (number == 1 && argOne != null)\r
- buffer.append(argOne);\r
- else {\r
- if (number >= args.length || number < 0) {\r
- buffer.append("<missing argument>"); //$NON-NLS-1$\r
- i = index;\r
- break;\r
- }\r
- buffer.append(args[number]);\r
- }\r
- i = index;\r
- break;\r
- case '\'' :\r
- // if a single quote is the last char on the line then skip it\r
- int nextIndex = i + 1;\r
- if (nextIndex >= length) {\r
- buffer.append(c);\r
- break;\r
- }\r
- char next = message.charAt(nextIndex);\r
- // if the next char is another single quote then write out one\r
- if (next == '\'') {\r
- i++;\r
- buffer.append(c);\r
- break;\r
- }\r
- // otherwise we want to read until we get to the next single quote\r
- index = message.indexOf('\'', nextIndex);\r
- // if there are no more in the string, then skip it\r
- if (index == -1) {\r
- buffer.append(c);\r
- break;\r
- }\r
- // otherwise write out the chars inside the quotes\r
- buffer.append(message.substring(nextIndex, index));\r
- i = index;\r
- break;\r
- default :\r
- buffer.append(c);\r
- }\r
- }\r
- return buffer.toString();\r
- }\r
}\r
*/
package org.tizen.common.connection.log;
+import static org.tizen.common.util.StringUtil.isEmpty;
+
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
dialogName = "Edit LogTab";
tabName = tab.getLogTabName();
if (tab.getDeviceSerialNumber() == null)
+ {
return;
+ }
device = tab.getDeviceSerialNumber();
pidKeyword = tab.getPidFilter();
}
bOk = true;
-
- if (tabNameText.getText().length() != 0)
- tabName = tabNameText.getText();
- else
+
+ if ( isEmpty( tabNameText.getText() ) )
+ {
tabName = TEMPNAME + cnt++;
-
- if (tagText.getText().length() != 0)
- tagKeyword = tagText.getText();
+ }
else
- tagKeyword = null;
+ {
+ tabName = tabNameText.getText();
+ }
- if (pidText.getText().length() != 0)
- pidKeyword = pidText.getText();
+ if ( isEmpty( tagText.getText() ) )
+ {
+ tagKeyword = null;
+ }
else
- pidKeyword = null;
+ {
+ tagKeyword = tagText.getText();
+ }
- if (msgText.getText().length() != 0)
- msgKeyword = msgText.getText();
+ if ( isEmpty( pidText.getText() ) )
+ {
+ pidKeyword = null;
+ }
else
+ {
+ pidKeyword = pidText.getText();
+ }
+
+ if ( isEmpty( msgText.getText() ) )
+ {
msgKeyword = null;
+ }
+ else
+ {
+ msgKeyword = msgText.getText();
+ }
device = dCombo.getItem(dCombo.getSelectionIndex());
{
int index = tabFolder.getSelectionIndex();
if(index == -1)
+ {
return ;
+ }
TabItem item = tabFolder.getItem(index);
LogTab logTab = getSelectionLogTab();
if(logTab == null)
+ {
return ;
+ }
setEnableAndCheckState(logTab);
stackLayout.topControl = item.getControl();
level = (int) Math.pow(2, level);
if (setCheck)
+ {
levelMode |= level;
+ }
else
+ {
levelMode &= (~level);
+ }
getSelectionLogTab().setLevelMode(levelMode);
getSelectionLogTab().filterMessages();
case SWT.PAGE_DOWN:\r
scrollBy(ImageSelector.this.pageIncrement);\r
break;\r
+ default:\r
+ break;\r
}\r
}\r
\r
this.selection = this.items.size() - 1;\r
changeColor(this.selection, true);\r
break;\r
+ default:\r
+ break; \r
}\r
\r
}\r
}\r
this.checkboxes = null;\r
break;\r
+ default:\r
+ break;\r
}\r
\r
}\r
}\r
needRedraw = true;\r
break;\r
+ default:\r
+ break;\r
}\r
\r
if (needRedraw) {\r
case SWT.ESC:\r
TextAssist.this.popup.setVisible(false);\r
break;\r
+ \r
+ default:\r
+ break;\r
}\r
}\r
};\r
return new UpDownTransition();\r
case UP_TO_DOWN_AND_APPEAR:\r
return new UpDownAppearTransition();\r
+ default:\r
+ return null;\r
}\r
- return null;\r
}\r
\r
}\r
*/
package org.tizen.common.core.application;
+import static org.tizen.common.util.SWTUtil.syncExec;
+
import java.io.File;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IStartup;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
}
executeInstallManger();
- if (workbench != null) {
- final Display display = workbench.getDisplay();
- display.syncExec( new Runnable() {
- public void run() {
- if (!display.isDisposed())
- workbench.close();
- }
- });
- }
+ syncExec( new Runnable() {
+ public void run() {
+ if (!workbench.getDisplay().isDisposed())
+ {
+ workbench.close();
+ }
+ }
+ });
}
private boolean isExistUpdatablePackage()
for ( int i=0, n=ArrayUtil.size( array ) ; i<n ; ++i )
{
- if ( null != array[i] ) continue;
+ if ( null != array[i] )
+ {
+ continue;
+ }
fail( msg );
}
case NoToAll :
case No :
break;
+ default:
+ break;
}
monitor.worked(1);
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
-import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.channels.FileChannel;
public abstract class HostUtil{
-// public static final String USER = System.getenv("USER");
-// public static final String USER_HOME = System.getenv("HOME");
public static final String LINE_SEPARATOR = System.getProperty("line.separator"); //$NON-NLS-1$
public static final String FILE_SEPARATOR = System.getProperty("file.separator"); //$NON-NLS-1$
-// private static final String PROC_PATH = "/proc"; //$NON-NLS-1$
private static final String SHELL_COMMAND_LINUX= "/bin/sh"; //$NON-NLS-1$
private static final String SHELL_COMMAND_WINDOW= "cmd"; //$NON-NLS-1$
File file = new File( path );
- if( file != null && file.exists() )
- return true;
- else
- return false;
+ return file.exists();
}
public static boolean execute(String command){
}catch(Exception e){
e.printStackTrace();
return false;
- }finally{
}
return i == 0;
}
e.printStackTrace();
return null;
} finally{
+ tryClose( input );
if(proc!=null)
+ {
proc.destroy();
- tryClose( input );
+ }
}
return contents.toString().trim();
if (proc.exitValue() != 0)
throw new Exception("Failed to execute command: " + command);
} finally {
+ tryClose( input );
if(proc!=null)
+ {
proc.destroy();
- tryClose( input );
+ }
}
}
long size= fcin.size();
fcin.transferTo(0, size, fcout);
desFile.setExecutable(canExecute);
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- throw e;
- } catch (IOException e) {
- e.printStackTrace();
- throw e;
}finally{
tryClose( fcout, fcin, fos, fis );
}
buffer.append("\n");
if ( os != null )
+ {
os.write( (line + "\n").getBytes());
+ }
}
}
} catch (IOException ioe) {
final int ST_ESCAPE = 1;
int status = ST_NORMAL;
int index = 0;
- if ( 0 == targetIndex ) writer = new StringWriter();
+ if ( 0 == targetIndex )
+ {
+ writer = new StringWriter();
+ }
while ( 0 <= ( ch = reader.read() ) ) {
if ( ST_ESCAPE == status ) {
status = ST_NORMAL;
status = ST_ESCAPE;
continue;
} else if ( delimeter == ch ) {
- if ( index == targetIndex ) return writer.toString();
+ if ( index == targetIndex )
+ {
+ return writer.toString();
+ }
++index;
- if ( index == targetIndex ) writer = new StringWriter();
+ if ( index == targetIndex )
+ {
+ writer = new StringWriter();
+ }
continue;
}
}
- if ( null != writer ) writer.write( (int) ch );
+ if ( null != writer )
+ {
+ writer.write( (int) ch );
+ }
+ }
+ if ( index == targetIndex )
+ {
+ return writer.toString();
}
- if ( index == targetIndex ) return writer.toString();
return null;
}
catch ( final IOException e )
*/\r
package org.tizen.common.util.cache;\r
\r
+import static org.tizen.common.util.SWTUtil.tryDispose;\r
+\r
import java.util.ArrayList;\r
import java.util.List;\r
\r
*/\r
public static Font getFont(Font font) {\r
try {\r
- if (font == null || font.isDisposed()) return null;\r
+ if (font == null || font.isDisposed())\r
+ {\r
+ return null;\r
+ }\r
\r
FontData fd = font.getFontData()[0];\r
return getFont(fd);\r