List of usage examples for java.lang Module Module
Module(ModuleLayer layer, ClassLoader loader, ModuleDescriptor descriptor, URI uri)
From source file:com.powermonitor.epitech.ViewModules.java
@Override public void onCreate(Bundle saveInstance) { super.onCreate(saveInstance); setContentView(R.layout.viewmodules); modNames = new SparseArray<String>(); this.list = (ListView) findViewById(R.id.ViewModules_modulesListView); this.dataList = new ArrayList<Module>(); try {/*from w w w. j a v a 2 s .c om*/ modulesID = new JSONArray(getIntent().getStringExtra("ModulesID")); for (int i = 0; i < modulesID.length(); i++) { JSONObject obj = modulesID.getJSONObject(i); modNames.put(obj.getInt("id"), obj.getString("name")); this.dataList.add(new Module(obj.getInt("id"), obj.getString("name"), null, true)); } } catch (JSONException e) { e.printStackTrace(); modulesID = new JSONArray(); } // List view // Communication.INSTANCE.getModulesList(new RequestHandler(this) { // @Override // public void onResult(JSONObject result, JSONObject params) { // JSONArray modList; // try { // modList = result.getJSONArray("modules"); // for (int i = 0; i < modList.length(); i++) { // JSONObject obj = modList.getJSONObject(i); // Module mod = new Module(obj.getInt("id"), obj.getString("name"), null, true); // ViewModules.this.modNames.append(mod.id, mod.getName()); // ViewModules.this.dataList.add(mod); // } // adapter.notifyDataSetChanged(); // } catch (JSONException ex) { // Logger.getLogger(ViewModules.class.getName()).log(Level.SEVERE, null, ex); // } // } // }); //this.dataList.add(new Module(0)); this.adapter = new ModuleListAdapter(this, R.layout.modulerow_min, this.dataList); this.list.setAdapter(this.adapter); // Date filter dateFrom = (EditText) findViewById(R.id.ViewModules_dateFrom); dateTo = (EditText) findViewById(R.id.ViewModules_dateTo); dateFrom.setOnClickListener(new OnDateClickListener()); dateTo.setOnClickListener(new OnDateClickListener()); // Chart this.chartViewAdapter = new ChartViewAdapter(getSupportFragmentManager()); this.chartViewPager = (ViewPager) this.findViewById(R.id.ViewModules_pager); this.chartViewPager.setAdapter(this.chartViewAdapter); this.chartViewPager.setOffscreenPageLimit(2); // Button Validate this.validate = (Button) findViewById(R.id.ViewModules_bValidate); this.validate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { LineChartFragment chart = (LineChartFragment) ViewModules.this.chartViewAdapter.getFragment(0); LineChartFragment chart2 = (LineChartFragment) ViewModules.this.chartViewAdapter.getFragment(1); LineChartFragment chart3 = (LineChartFragment) ViewModules.this.chartViewAdapter.getFragment(2); if (chart != null) chart.empty(); if (chart2 != null) chart2.empty(); if (chart3 != null) chart3.empty(); if (ViewModules.this.dateFrom.getTag() == null || ViewModules.this.dateTo.getTag() == null) { ErrorDialog eDialog = new ErrorDialog(ViewModules.this, "Veuillez entrer une date de dbut et une date de fin", null); eDialog.show(); return; } // for (int i = 0; i < ViewModules.this.adapter.getCount(); i++) { // CheckBox cb = (CheckBox) list.getChildAt(i).findViewById(R.id.name); // if (cb.isChecked()) { // Communication.INSTANCE.getModuleConsoData(ViewModules.this.dataList.get(i).id, // ((Long) ViewModules.this.dateFrom.getTag()).intValue(), ((Long) ViewModules.this.dateTo.getTag()).intValue(), 2, // ViewModules.this.onConsoDataFetched); // } // } for (int id = 0; id < modulesID.length(); id++) { try { int moduleID = modulesID.getJSONObject(id).getInt("id"); Communication.INSTANCE.getModuleConsoData(moduleID, ((Long) ViewModules.this.dateFrom.getTag()).intValue(), ((Long) ViewModules.this.dateTo.getTag()).intValue(), 1, ViewModules.this.onConsoDataFetchedW); Communication.INSTANCE.getModuleConsoData(moduleID, ((Long) ViewModules.this.dateFrom.getTag()).intValue(), ((Long) ViewModules.this.dateTo.getTag()).intValue(), 2, ViewModules.this.onConsoDataFetchedA); Communication.INSTANCE.getModuleConsoData(moduleID, ((Long) ViewModules.this.dateFrom.getTag()).intValue(), ((Long) ViewModules.this.dateTo.getTag()).intValue(), 3, ViewModules.this.onConsoDataFetchedV); } catch (JSONException e) { e.printStackTrace(); } } // Communication.INSTANCE.getModuleConsoData(ViewModules.this.dataList.get(2).id, // ((Long) ViewModules.this.dateFrom.getTag()).intValue(), ((Long) ViewModules.this.dateTo.getTag()).intValue(), 2, // ViewModules.this.onConsoDataFetched); } }); }
From source file:com.powermonitor.epitech.ConfigModules.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstance) { View v = inflater.inflate(R.layout.configmodules, container, false); getActivity().setTitle("Modules"); // Create list view this.consult = (Button) v.findViewById(R.id.consulter); this.listView = (ListView) v.findViewById(R.id.ConfigModules_modulesListView); this.adapter = new ModuleListAdapter(v.getContext(), R.layout.modulerow, dataList); this.adapter.setToggleVisibility(true); this.listView.setAdapter(adapter); registerForContextMenu(this.listView); try {/*from ww w . java2 s. c o m*/ JSONArray list = modulesList.getJSONArray("modules"); for (int i = 0; i < list.length(); i++) { JSONObject o = list.getJSONObject(i); JSONObject defaultProfile = o.optJSONObject("defaultProfile"); int internalProfileID = o.getInt("internalProfileId"); Profile.Small defProfile; if (defaultProfile == null) { defProfile = new Profile.Small(0, ""); } else { defProfile = new Profile.Small(defaultProfile.getInt("id"), defaultProfile.getString("name")); } Module m = new Module(o.getInt("id"), o.getString("name"), defProfile, o.getBoolean("status")); m.setInternalProfileId(internalProfileID); dataList.add(m); } } catch (JSONException ex) { Logger.getLogger(Communication.class.getName()).log(Level.SEVERE, null, ex); } this.adapter.setOnItemCheckedListener(new ModuleListAdapter.OnItemCheckedListener() { @Override public void onItemsChecked(List<Module> list) { checkedItems = list; if (list.size() > 0) consult.setVisibility(View.VISIBLE); else consult.setVisibility(View.GONE); } }); this.consult.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { JSONArray arr = new JSONArray(); if (checkedItems != null) { for (Module m : checkedItems) { JSONObject obj = new JSONObject(); try { obj.put("name", m.getName()); obj.put("id", m.id); arr.put(obj); } catch (JSONException e) { e.printStackTrace(); } } } Intent i = new Intent(ConfigModules.this.getActivity(), ViewModules.class); i.putExtra("ModulesID", arr.toString()); startActivity(i); } }); return v; }
From source file:net.firejack.platform.installation.processor.OFRInstallProcessor.java
private Module getModule(File ofr) throws IOException, XPathExpressionException { XPath xpath = factory.newXPath(); InputStream file = ArchiveUtils.getFile(ofr, PackageFileType.PACKAGE_XML.getOfrFileName()); Object evaluate = xpath.evaluate("/package", new InputSource(file), XPathConstants.NODE); String path = (String) xpath.evaluate("@path", evaluate, XPathConstants.STRING); String name = (String) xpath.evaluate("@name", evaluate, XPathConstants.STRING); String version = (String) xpath.evaluate("@version", evaluate, XPathConstants.STRING); String dependencies = (String) xpath.evaluate("@dependencies", evaluate, XPathConstants.STRING); IOUtils.closeQuietly(file);/* ww w. ja v a2s. c om*/ String lookup = path + "." + name; Integer ver = VersionUtils.convertToNumber(version); return new Module(ofr, lookup, ver, dependencies); }
From source file:org.eclipse.dirigible.runtime.scripting.AbstractScriptExecutor.java
@Override public List<Module> retrieveModulesByExtension(IRepository repository, String extension, String... rootPaths) throws IOException { Map<String, Module> modules = new HashMap<String, Module>(); for (int i = rootPaths.length - 1; i >= 0; i--) { List<IEntity> entities = repository.searchName(rootPaths[i], "%" + extension, false); for (IEntity entity : entities) { if (entity.exists()) { String path = entity.getPath(); String moduleName = getModuleName(path); Module module = new Module(moduleName, path, readResourceData(repository, path), entity.getInformation()); modules.put(moduleName, module); }/*from w w w . j a va 2s . co m*/ } } return Arrays.asList(modules.values().toArray(new Module[] {})); }