9월, 2015의 게시물 표시

The lifecycle of an Android Activity

이미지

Writing to the Eclipse console

먼저 plugin.xml 에서 디펜던시를 org.eclipse.ui.console을 추가하고 나서 private MessageConsole findConsole(String name) {      ConsolePlugin plugin = ConsolePlugin.getDefault();      IConsoleManager conMan = plugin.getConsoleManager();      IConsole[] existing = conMan.getConsoles();      for (int i = 0; i < existing.length; i++)         if (name.equals(existing[i].getName()))            return (MessageConsole) existing[i];      //no console found, so create a new one      MessageConsole myConsole = new MessageConsole(name, null);      conMan.addConsoles(new IConsole[]{myConsole});      return myConsole;   } 메서드를 추가. 이름은 "Console" 혹은 "System output" 을 입력해서 아래처럼 사용 MessageConsole myConsole = findConsole("System Output");   MessageConsoleStream out = myConsole.newMessageStream(); ...

Reading resources from a Eclipse plugin

Bundle bundle = Platform.getBundle( "de.vogella.example.readfile" ); URL fileURL = bundle.getEntry( "files/test.txt" ); try {     URL resolvedFileURL = FileLocator.toFileURL(fileURL); URI resolvedURI = new URI(resolvedFileURL.getProtocol(), resolvedFileURL.getPath(), null); File file = new File(resolvedURI);    //file = new File(FileLocator.resolve(fileURL).toURI());    boolean a = file.exists();    MessageDialog.openInformation( window.getShell(), "Sample2", file.toPath().toAbsolutePath().toString() + ", " + String.valueOf(a));    System.out.println(file.toPath().toAbsolutePath().toString()); } catch (URISyntaxException e1) {      e1.printStackTrace(); } catch (IOException e1) {      e1.printStackTrace(); } http://blog.vogella.com/2010/07/06/reading-resources-from-plugin/

Read registry on 64bit machine

var hlkm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64); var key = hlkm.OpenSubKey(@"SOFTWARE\JavaSoft\Java Plug-in\11.31.2"); var java = key.GetValue("JavaHome"); http://stackoverflow.com/questions/13728491/opensubkey-returns-null-for-a-registry-key-that-i-can-see-in-regedit-exe