rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
public void nd_aid(RubyId id) { u3 = id; }
public RubyId nd_aid() { return (RubyId)u3; }
public void nd_aid(RubyId id) { u3 = id; }
assertEquals(1, favorites.size());
assertEquals(2, favorites.size());
public void testFavs() throws Exception { FavoriteService fs = (FavoriteService) getBean("favoriteService"); Map favorites = fs.getFavorites(); assertNotNull(favorites); assertEquals(1, favorites.size()); assertEquals("Grey Goose", favorites.get("Dan")); }
Object object = favorites.get("IndecisiveDan"); System.out.println(object.getClass()); assertTrue(object instanceof List); List l = (List) object; assertEquals(2, l.size());
public void testFavs() throws Exception { FavoriteService fs = (FavoriteService) getBean("favoriteService"); Map favorites = fs.getFavorites(); assertNotNull(favorites); assertEquals(1, favorites.size()); assertEquals("Grey Goose", favorites.get("Dan")); }
context.registerTool("testTool", new TestTool());
public static void main(String arg[]) { Log.traceExceptions(true); Log.setLevel(Log.ALL); Log.setTarget(System.err); if (arg.length != 0) { System.out.println("Enabling log types"); Log.enableTypes(arg); } // Build a context WebMacro wm = null; Context context = null; try { wm = new WM(); context = new Context(null); Object names[] = { "prop" }; context.setProperty(names, "Example property"); } catch (Exception e) { e.printStackTrace(); } try { context.put("helloworld", "Hello World"); context.put("hello", "Hello"); context.put("file", "include.txt"); TestObject[] fruits = { new TestObject("apple",false), new TestObject("lemon",true), new TestObject("pear",false), new TestObject("orange",true), new TestObject("watermelon",false), new TestObject("peach",false), new TestObject("lime",true) }; SelectList sl = new SelectList(fruits, 3); context.put("sl-fruits", sl); context.put("fruits", fruits); context.put("flipper", new TestObject("flip",false)); context.registerTool("testTool", new TestTool()); System.out.println("- - - - - - - - - - - - - - - - - - - -"); System.out.println("Context contains: helloWorld, hello, file, TestObject[] fruits, SelectList sl(fruits, 3), TestObject flipper"); System.out.println("- - - - - - - - - - - - - - - - - - - -"); Template t1 = new StreamTemplate(wm.getBroker(), new InputStreamReader(System.in)); t1.parse(); Writer w = new OutputStreamWriter(System.out); System.out.println("*** RESULT ***"); t1.write(w,context); w.close(); System.out.println("*** DONE ***"); //System.out.println(result); } catch (Exception e) { e.printStackTrace(); } }
new XmlMetadataGenerator(this, metaInfDir, destFile), new DocumentationGenerator(this, destFile), new XsdGenerator(this, destFile)
new XmlMetadataGenerator(metaInfDir, destFile), new DocumentationGenerator(destFile), new XsdGenerator(destFile)
public void execute() throws BuildException { if (namespace == null) { throw new BuildException("'namespace' must be specified"); } if (srcDir == null) { throw new BuildException("'srcDir' must be specified"); } if (destFile == null) { throw new BuildException("'destFile' must be specified"); } if (propertyEditorPaths != null) { List editorSearchPath = new LinkedList(Arrays.asList(PropertyEditorManager.getEditorSearchPath())); StringTokenizer paths = new StringTokenizer(propertyEditorPaths, " ,"); editorSearchPath.addAll(Collections.list(paths)); PropertyEditorManager.setEditorSearchPath((String[]) editorSearchPath.toArray(new String[editorSearchPath.size()])); } ClassLoader oldCL = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); try { String[] excludedClasses = null; if (this.excludedClasses != null) { excludedClasses = this.excludedClasses.split(" *, *"); } MappingLoader mappingLoader = new QdoxMappingLoader(namespace, getFiles(srcDir), excludedClasses); GeneratorPlugin[] plugins = new GeneratorPlugin[]{ new XmlMetadataGenerator(this, metaInfDir, destFile), new DocumentationGenerator(this, destFile), new XsdGenerator(this, destFile) }; // load the mappings Set namespaces = mappingLoader.loadNamespaces(); if (namespaces.isEmpty()) { System.out.println("Warning: no namespaces found!"); } // generate the files for (Iterator iterator = namespaces.iterator(); iterator.hasNext();) { NamespaceMapping namespaceMapping = (NamespaceMapping) iterator.next(); for (int i = 0; i < plugins.length; i++) { GeneratorPlugin plugin = plugins[i]; plugin.generate(namespaceMapping); } } log("...done."); } catch (Exception e) { throw new BuildException(e); } finally { Thread.currentThread().setContextClassLoader(oldCL); } }
plugin.setLog(this);
public void execute() throws BuildException { if (namespace == null) { throw new BuildException("'namespace' must be specified"); } if (srcDir == null) { throw new BuildException("'srcDir' must be specified"); } if (destFile == null) { throw new BuildException("'destFile' must be specified"); } if (propertyEditorPaths != null) { List editorSearchPath = new LinkedList(Arrays.asList(PropertyEditorManager.getEditorSearchPath())); StringTokenizer paths = new StringTokenizer(propertyEditorPaths, " ,"); editorSearchPath.addAll(Collections.list(paths)); PropertyEditorManager.setEditorSearchPath((String[]) editorSearchPath.toArray(new String[editorSearchPath.size()])); } ClassLoader oldCL = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); try { String[] excludedClasses = null; if (this.excludedClasses != null) { excludedClasses = this.excludedClasses.split(" *, *"); } MappingLoader mappingLoader = new QdoxMappingLoader(namespace, getFiles(srcDir), excludedClasses); GeneratorPlugin[] plugins = new GeneratorPlugin[]{ new XmlMetadataGenerator(this, metaInfDir, destFile), new DocumentationGenerator(this, destFile), new XsdGenerator(this, destFile) }; // load the mappings Set namespaces = mappingLoader.loadNamespaces(); if (namespaces.isEmpty()) { System.out.println("Warning: no namespaces found!"); } // generate the files for (Iterator iterator = namespaces.iterator(); iterator.hasNext();) { NamespaceMapping namespaceMapping = (NamespaceMapping) iterator.next(); for (int i = 0; i < plugins.length; i++) { GeneratorPlugin plugin = plugins[i]; plugin.generate(namespaceMapping); } } log("...done."); } catch (Exception e) { throw new BuildException(e); } finally { Thread.currentThread().setContextClassLoader(oldCL); } }
public XmlMetadataGenerator(LogFacade log, String metaInfDir, File schema) {
public XmlMetadataGenerator(String metaInfDir, File schema) {
public XmlMetadataGenerator(LogFacade log, String metaInfDir, File schema) { this.metaInfDir = metaInfDir; this.log = log; this.schema = schema; }
this.log = log;
public XmlMetadataGenerator(LogFacade log, String metaInfDir, File schema) { this.metaInfDir = metaInfDir; this.log = log; this.schema = schema; }
public DocumentationGenerator(LogFacade log, File destFile) {
public DocumentationGenerator(File destFile) {
public DocumentationGenerator(LogFacade log, File destFile) { this.destFile = destFile; this.log = log; }
this.log = log;
public DocumentationGenerator(LogFacade log, File destFile) { this.destFile = destFile; this.log = log; }
public XsdGenerator(LogFacade log, File destFile) {
public XsdGenerator(File destFile) {
public XsdGenerator(LogFacade log, File destFile) { this.destFile = destFile; this.log = log; }
this.log = log;
public XsdGenerator(LogFacade log, File destFile) { this.destFile = destFile; this.log = log; }
JUnitXMLHelper.validate(new File(PATH_TO_TEST_OUTPUT, htmlFiles[i]));
JUnitXMLHelper.readXmlFile(new File(PATH_TO_TEST_OUTPUT, htmlFiles[i]), true);
public void testHTMLReportValidity() throws Exception { // Serialize the current coverage data to disk ProjectData.saveGlobalProjectData(); String dataFileName = CoverageDataFileHandler.getDefaultDataFile().getAbsolutePath(); // Then we need to generate the HTML report String[] args = new String[] { "--format", "html", "--datafile", dataFileName, "--destination", PATH_TO_TEST_OUTPUT.getAbsolutePath(), PATH_TO_SOURCES.getAbsolutePath(), PATH_TO_SOURCES_2.getAbsolutePath() }; net.sourceforge.cobertura.reporting.Main.main(args); // Get all files from report directory String htmlFiles[] = PATH_TO_TEST_OUTPUT.list(new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(".html"); } }); Arrays.sort(htmlFiles); assertTrue(htmlFiles.length >= 5); // Assert that all required files are there String[] requiredFiles = { "index.html", "help.html", "frame-packages.html", "frame-summary.html", "frame-sourcefiles.html" }; for (int i = 0; i < requiredFiles.length; i++) { if (!containsFile(htmlFiles, requiredFiles[i])) { fail("File " + requiredFiles[i] + " not found among report files"); } } // Validate selected files String previousPrefix = "NONE"; for (int i = 0; i < htmlFiles.length; i++) { // Validate file if has prefix different than previous one, or is required file if (containsFile(requiredFiles, htmlFiles[i]) || !htmlFiles[i].startsWith(previousPrefix)) { JUnitXMLHelper.validate(new File(PATH_TO_TEST_OUTPUT, htmlFiles[i])); } if (htmlFiles[i].length() > 7) { previousPrefix = htmlFiles[i].substring(0, 7); } else { previousPrefix = htmlFiles[i]; } } // Mark that test was successful so report will be deleted testSuccessful = true; }
Coverage coverage = CoverageUnmarshaller.parse(coverageData);
CoverageReport coverage = new CoverageReport(coverageData);
public static void main(String[] args) throws Exception { long startTime = System.currentTimeMillis(); LongOpt[] longOpts = new LongOpt[4]; longOpts[0] = new LongOpt("format", LongOpt.REQUIRED_ARGUMENT, null, 'f'); longOpts[1] = new LongOpt("instrumentation", LongOpt.REQUIRED_ARGUMENT, null, 'i'); longOpts[2] = new LongOpt("output", LongOpt.REQUIRED_ARGUMENT, null, 'o'); longOpts[3] = new LongOpt("source", LongOpt.REQUIRED_ARGUMENT, null, 's'); Getopt g = new Getopt(Main.class.getName(), args, ":f:i:o:s:", longOpts); int c; while ((c = g.getopt()) != -1) { switch (c) { case 'f': format = new String(g.getOptarg()); if (!format.equalsIgnoreCase("html") && !format.equalsIgnoreCase("xml")) { throw new Exception("Error: format \"" + format + "\" must be either html or xml"); } break; case 'i': serializationFile = new File(g.getOptarg()); if (!serializationFile.exists()) { throw new Exception("Error: serialization file " + serializationFile + " does not exist"); } if (serializationFile.isDirectory()) { throw new Exception("Error: serialization file " + serializationFile + " cannot be a directory"); } break; case 'o': outputDir = new File(g.getOptarg()); if (outputDir.exists() && outputDir.isFile()) { throw new Exception("Error: destination directory " + outputDir + " already exists and is a file"); } outputDir.mkdirs(); break; case 's': sourceDir = new File(g.getOptarg()); if (!sourceDir.exists()) { throw new Exception("Error: source directory " + sourceDir + " does not exist"); } if (sourceDir.isFile()) { throw new Exception("Error: source directory " + sourceDir + " should be a directory, not a file"); } break; } } if (logger.isDebugEnabled()) { logger.debug("format is " + format); logger.debug("serializationFile is " + serializationFile.getAbsolutePath()); logger.debug("outputDir is " + outputDir.getAbsolutePath()); logger.debug("sourceDir is " + sourceDir.getAbsolutePath()); } InputStream is = null; ObjectInputStream objects = null; try { is = new FileInputStream(serializationFile); objects = new ObjectInputStream(is); Map coverageData = (Map)objects.readObject(); Coverage coverage = CoverageUnmarshaller.parse(coverageData); if (format.equalsIgnoreCase("xml")) { new XMLReport(coverage, outputDir, sourceDir); } else if (format.equalsIgnoreCase("html")) { new HTMLReport(coverage, outputDir, sourceDir); } } finally { if (is != null) is.close(); if (objects != null) objects.close(); } long stopTime = System.currentTimeMillis(); System.out .println("Reporting time: " + (stopTime - startTime) + "ms"); }
connectMenu.remove(item);
public void initialize() { if (Spark.isMac()) { roomListener = new DockRoomListener(); SparkManager.getChatManager().addChatRoomListener(roomListener); // Remove the About Menu Item from the help menu MainWindow mainWindow = SparkManager.getMainWindow(); JMenu helpMenu = mainWindow.getMenuByName("Help"); Component[] menuComponents = helpMenu.getMenuComponents(); Component prev = null; for (int i = 0; i < menuComponents.length; i++) { Component current = menuComponents[i]; if (current instanceof JMenuItem) { JMenuItem item = (JMenuItem) current; if ("About".equals(item.getText())) { helpMenu.remove(item); // We want to remove the seperator if (prev != null && (prev instanceof JSeparator)) { helpMenu.remove(prev); } } } prev = current; } JMenu connectMenu = mainWindow.getMenuByName("Spark"); connectMenu.setText("Connect"); menuComponents = connectMenu.getMenuComponents(); JSeparator lastSeperator = null; for (int i = 0; i < menuComponents.length; i++) { Component current = menuComponents[i]; if (current instanceof JMenuItem) { JMenuItem item = (JMenuItem) current; if ("Preferences".equals(item.getText())) { //connectMenu.remove(item); } else if ("Log Out".equals(item.getText())) { connectMenu.remove(item); } } else if (current instanceof JSeparator) { lastSeperator = (JSeparator) current; } } if (lastSeperator != null) { connectMenu.remove(lastSeperator); } // register an application listener to show the about box Application application = Application.getApplication(); // application.setEnabledPreferencesMenu(true); // application.addPreferencesMenuItem(); application.addApplicationListener(new ApplicationAdapter() { public void handlePreferences(ApplicationEvent applicationEvent) { SparkManager.getPreferenceManager().showPreferences(); } public void handleReOpenApplication(ApplicationEvent event) { MainWindow mainWindow = SparkManager.getMainWindow(); if (!mainWindow.isVisible()) { mainWindow.setState(Frame.NORMAL); mainWindow.setVisible(true); } } public void handleQuit(ApplicationEvent applicationEvent) { System.exit(0); } }); new AppleStatusMenu().display(); } }
application.setEnabledPreferencesMenu(true); application.addPreferencesMenuItem();
public void initialize() { if (Spark.isMac()) { roomListener = new DockRoomListener(); SparkManager.getChatManager().addChatRoomListener(roomListener); // Remove the About Menu Item from the help menu MainWindow mainWindow = SparkManager.getMainWindow(); JMenu helpMenu = mainWindow.getMenuByName("Help"); Component[] menuComponents = helpMenu.getMenuComponents(); Component prev = null; for (int i = 0; i < menuComponents.length; i++) { Component current = menuComponents[i]; if (current instanceof JMenuItem) { JMenuItem item = (JMenuItem) current; if ("About".equals(item.getText())) { helpMenu.remove(item); // We want to remove the seperator if (prev != null && (prev instanceof JSeparator)) { helpMenu.remove(prev); } } } prev = current; } JMenu connectMenu = mainWindow.getMenuByName("Spark"); connectMenu.setText("Connect"); menuComponents = connectMenu.getMenuComponents(); JSeparator lastSeperator = null; for (int i = 0; i < menuComponents.length; i++) { Component current = menuComponents[i]; if (current instanceof JMenuItem) { JMenuItem item = (JMenuItem) current; if ("Preferences".equals(item.getText())) { //connectMenu.remove(item); } else if ("Log Out".equals(item.getText())) { connectMenu.remove(item); } } else if (current instanceof JSeparator) { lastSeperator = (JSeparator) current; } } if (lastSeperator != null) { connectMenu.remove(lastSeperator); } // register an application listener to show the about box Application application = Application.getApplication(); // application.setEnabledPreferencesMenu(true); // application.addPreferencesMenuItem(); application.addApplicationListener(new ApplicationAdapter() { public void handlePreferences(ApplicationEvent applicationEvent) { SparkManager.getPreferenceManager().showPreferences(); } public void handleReOpenApplication(ApplicationEvent event) { MainWindow mainWindow = SparkManager.getMainWindow(); if (!mainWindow.isVisible()) { mainWindow.setState(Frame.NORMAL); mainWindow.setVisible(true); } } public void handleQuit(ApplicationEvent applicationEvent) { System.exit(0); } }); new AppleStatusMenu().display(); } }
if (f1.exists() != f2.exists() && f1.isFile() != f2.isFile() && f1.isDirectory() != f2.isDirectory())
if (f1.exists() != f2.exists() || f1.isFile() != f2.isFile() || f1.isDirectory() != f2.isDirectory())
public static boolean contentsEqual(File f1, File f2, boolean ignoreWhitespace) throws IOException { if (f1 == f2) return true; if (f1 == null && f2 == null) return true; if (f1 == null || f2 == null) return false; if (f1.exists() != f2.exists() && f1.isFile() != f2.isFile() && f1.isDirectory() != f2.isDirectory()) return false; if (!f1.exists()) return true; if (f1.isDirectory()) { final File[] files1 = f1.listFiles(); for (final File file1 : files1) { final File file2 = new File(f2, file1.getName()); if (!contentsEqual(file1, file2, ignoreWhitespace)) return false; } // TODO same quantity of files return true; } else { Reader r1 = null; Reader r2 = null; try { r1 = new FileReader(f1); r2 = new FileReader(f2); if (!IOUtils.contentsEqual(r1, r2, ignoreWhitespace)) return false; } finally { try { if (r1 != null) r1.close(); } catch (IOException ignored) { } try { if (r2 != null) r2.close(); } catch (IOException ignored) { } } return true; } }
if (_context == null) _context = c.cloneContext();
public MacroTemplate(Context c, Template t){ _template = t; _origContext = c; org.webmacro.util.Pool pool = c.getPool(); _context = (pool==null) ? c.cloneContext() : (Context)c.getPool().get(); }
registerEditor("java.io.File", "org.apache.xbean.spring.context.impl.FileEditor");
public static void registerCustomEditors() { registerEditor("java.net.URI", "org.apache.xbean.spring.context.impl.URIEditor"); registerEditor("javax.management.ObjectName", "org.apache.xbean.spring.context.impl.ObjectNameEditor"); }
throw new ContextException("Foreach: Cannot evaluate limit");
throw new ContextException("#foreach: Cannot evaluate limit");
public void write(FastWriter out, Context context) throws ContextException, IOException { Object l, limit, from; long loopLimit=-1, loopStart=1, loopIndex=0; l = list; while (l instanceof Macro) l = ((Macro) l).evaluate(context); if (limitExpr != null) { limit = limitExpr; while (limit instanceof Macro) limit = ((Macro) limit).evaluate(context); if (Expression.isNumber(limit)) loopLimit = Expression.numberValue(limit); else throw new ContextException("Foreach: Cannot evaluate limit"); } if (index != null && indexFromExpr != null) { from = indexFromExpr; while (from instanceof Macro) from = ((Macro) from).evaluate(context); if (Expression.isNumber(from)) loopStart = Expression.numberValue(from); else throw new ContextException("Foreach: Cannot evaluate loop start"); } try { if (l instanceof Object[]) { Object[] alist = (Object[]) l; for (int i = 0; i < alist.length; i++) { target.setValue(context, alist[i]); if (index != null) index.setValue(context, new Long(loopIndex + loopStart)); body.write(out, context); ++loopIndex; if (loopLimit > 0 && loopIndex >= loopLimit) break; } } else { Iterator iter; try { iter = PropertyOperator.getIterator(l); } catch (Exception e) { throw new ContextException("The object used as the list of values in a foreach statement must have some way of returning a list type, or be a list type itself. See the documentation for PropertyOperator.getIterator() for more details. No such property was found on the supplied object: " + l + ": ", e); } while(iter.hasNext()) { target.setValue(context, iter.next()); if (index != null) index.setValue(context, new Long(loopIndex + loopStart)); body.write(out, context); ++loopIndex; if (loopLimit > 0 && loopIndex >= loopLimit) break; } } } catch (ContextException e) { String errorText = "Foreach: Unable to set list index"; context.getBroker().getLog("engine").error(errorText); writeWarning(errorText, out); } }
throw new ContextException("Foreach: Cannot evaluate loop start");
throw new ContextException("#foreach: Cannot evaluate loop start");
public void write(FastWriter out, Context context) throws ContextException, IOException { Object l, limit, from; long loopLimit=-1, loopStart=1, loopIndex=0; l = list; while (l instanceof Macro) l = ((Macro) l).evaluate(context); if (limitExpr != null) { limit = limitExpr; while (limit instanceof Macro) limit = ((Macro) limit).evaluate(context); if (Expression.isNumber(limit)) loopLimit = Expression.numberValue(limit); else throw new ContextException("Foreach: Cannot evaluate limit"); } if (index != null && indexFromExpr != null) { from = indexFromExpr; while (from instanceof Macro) from = ((Macro) from).evaluate(context); if (Expression.isNumber(from)) loopStart = Expression.numberValue(from); else throw new ContextException("Foreach: Cannot evaluate loop start"); } try { if (l instanceof Object[]) { Object[] alist = (Object[]) l; for (int i = 0; i < alist.length; i++) { target.setValue(context, alist[i]); if (index != null) index.setValue(context, new Long(loopIndex + loopStart)); body.write(out, context); ++loopIndex; if (loopLimit > 0 && loopIndex >= loopLimit) break; } } else { Iterator iter; try { iter = PropertyOperator.getIterator(l); } catch (Exception e) { throw new ContextException("The object used as the list of values in a foreach statement must have some way of returning a list type, or be a list type itself. See the documentation for PropertyOperator.getIterator() for more details. No such property was found on the supplied object: " + l + ": ", e); } while(iter.hasNext()) { target.setValue(context, iter.next()); if (index != null) index.setValue(context, new Long(loopIndex + loopStart)); body.write(out, context); ++loopIndex; if (loopLimit > 0 && loopIndex >= loopLimit) break; } } } catch (ContextException e) { String errorText = "Foreach: Unable to set list index"; context.getBroker().getLog("engine").error(errorText); writeWarning(errorText, out); } }
String errorText = "Foreach: Unable to set list index";
String errorText = "#foreach: Unable to set list index";
public void write(FastWriter out, Context context) throws ContextException, IOException { Object l, limit, from; long loopLimit=-1, loopStart=1, loopIndex=0; l = list; while (l instanceof Macro) l = ((Macro) l).evaluate(context); if (limitExpr != null) { limit = limitExpr; while (limit instanceof Macro) limit = ((Macro) limit).evaluate(context); if (Expression.isNumber(limit)) loopLimit = Expression.numberValue(limit); else throw new ContextException("Foreach: Cannot evaluate limit"); } if (index != null && indexFromExpr != null) { from = indexFromExpr; while (from instanceof Macro) from = ((Macro) from).evaluate(context); if (Expression.isNumber(from)) loopStart = Expression.numberValue(from); else throw new ContextException("Foreach: Cannot evaluate loop start"); } try { if (l instanceof Object[]) { Object[] alist = (Object[]) l; for (int i = 0; i < alist.length; i++) { target.setValue(context, alist[i]); if (index != null) index.setValue(context, new Long(loopIndex + loopStart)); body.write(out, context); ++loopIndex; if (loopLimit > 0 && loopIndex >= loopLimit) break; } } else { Iterator iter; try { iter = PropertyOperator.getIterator(l); } catch (Exception e) { throw new ContextException("The object used as the list of values in a foreach statement must have some way of returning a list type, or be a list type itself. See the documentation for PropertyOperator.getIterator() for more details. No such property was found on the supplied object: " + l + ": ", e); } while(iter.hasNext()) { target.setValue(context, iter.next()); if (index != null) index.setValue(context, new Long(loopIndex + loopStart)); body.write(out, context); ++loopIndex; if (loopLimit > 0 && loopIndex >= loopLimit) break; } } } catch (ContextException e) { String errorText = "Foreach: Unable to set list index"; context.getBroker().getLog("engine").error(errorText); writeWarning(errorText, out); } }
public Object getArg(int argId, BuildContext bc)
public Object getArg(int argId)
public Object getArg(int argId, BuildContext bc) throws BuildException { if (buildArgs == null) return null; else return buildArgs.getArg(argId, bc); }
else return buildArgs.getArg(argId, bc);
else return buildArgs.getArg(argId);
public Object getArg(int argId, BuildContext bc) throws BuildException { if (buildArgs == null) return null; else return buildArgs.getArg(argId, bc); }
throw new BuildException("Template " + o + " not found: ", ne);
throw new BuildException("#parse: Template " + o + " not found: ", ne);
public Object build(DirectiveBuilder builder, BuildContext bc) throws BuildException { Object o = builder.getArg(PARSE_TEMPLATE, bc); if (o instanceof Macro) { template = (Macro) o; return this; } else try { return bc.getBroker().get("template", o.toString()); } catch (NotFoundException ne) { throw new BuildException("Template " + o + " not found: ", ne); } }
String warning = "Error reading template: " + fname;
String warning = "#parse: Error reading template: " + fname;
public void write(FastWriter out, Context context) throws ContextException, IOException { String fname = template.evaluate(context).toString(); try { Template tmpl = (Template) context.getBroker().get("template", fname); tmpl.write(out,context); } catch (IOException e) { String warning = "Error reading template: " + fname; context.getLog("engine").warning(warning, e); writeWarning(warning, out); } catch (Exception e) { String warning = "Template not found: " + fname; context.getLog("engine").warning(warning,e); writeWarning(warning, out); } }
String warning = "Template not found: " + fname;
String warning = "#parse: Template not found: " + fname;
public void write(FastWriter out, Context context) throws ContextException, IOException { String fname = template.evaluate(context).toString(); try { Template tmpl = (Template) context.getBroker().get("template", fname); tmpl.write(out,context); } catch (IOException e) { String warning = "Error reading template: " + fname; context.getLog("engine").warning(warning, e); writeWarning(warning, out); } catch (Exception e) { String warning = "Template not found: " + fname; context.getLog("engine").warning(warning,e); writeWarning(warning, out); } }
try { return b.get("url", name).toString(); } catch (ResourceException re) { try {
try { return b.get("url", name).toString(); } catch (Exception e) { URL url = null;
protected String getFile(Broker b, String name) throws PropertyException { try { return b.get("url", name).toString(); } catch (ResourceException re) { try { try { // The UrlProvider knows, how to do this, // so let him do the work for us return b.get("url", name).toString(); } catch (NullPointerException npe) { throw npe; } catch (Exception e) { throw makePropertyException("Found by Broker, but could not be retrieved", e); } } catch (NullPointerException npe) { throw makePropertyException("Not found by url provider or broker"); } catch (Exception e) { throw makePropertyException("Unexpected exception while getting from Broker", e); } } catch (Exception e) { throw makePropertyException("Unexpected exception while getting from url provider", e); } }
return b.get("url", name).toString();
url = b.getResource(name); if (url == null) throw makePropertyException("Resource not found by URL provider or Broker"); URLConnection conn = url.openConnection(); StringBuffer sb = new StringBuffer (); InputStream in = conn.getInputStream(); String enc = conn.getContentEncoding(); if (enc == null) enc = b.getSetting("TemplateEncoding"); int cnt=0; byte[] buff = new byte[4096]; while ( (cnt = in.read(buff)) > 0) { sb.append (new String (buff, 0, cnt, enc)); } in.close(); return sb.toString();
protected String getFile(Broker b, String name) throws PropertyException { try { return b.get("url", name).toString(); } catch (ResourceException re) { try { try { // The UrlProvider knows, how to do this, // so let him do the work for us return b.get("url", name).toString(); } catch (NullPointerException npe) { throw npe; } catch (Exception e) { throw makePropertyException("Found by Broker, but could not be retrieved", e); } } catch (NullPointerException npe) { throw makePropertyException("Not found by url provider or broker"); } catch (Exception e) { throw makePropertyException("Unexpected exception while getting from Broker", e); } } catch (Exception e) { throw makePropertyException("Unexpected exception while getting from url provider", e); } }
catch (NullPointerException npe) { throw npe;
catch (IOException ioe) { throw makePropertyException("Error streaming file from: " + url, ioe);
protected String getFile(Broker b, String name) throws PropertyException { try { return b.get("url", name).toString(); } catch (ResourceException re) { try { try { // The UrlProvider knows, how to do this, // so let him do the work for us return b.get("url", name).toString(); } catch (NullPointerException npe) { throw npe; } catch (Exception e) { throw makePropertyException("Found by Broker, but could not be retrieved", e); } } catch (NullPointerException npe) { throw makePropertyException("Not found by url provider or broker"); } catch (Exception e) { throw makePropertyException("Unexpected exception while getting from Broker", e); } } catch (Exception e) { throw makePropertyException("Unexpected exception while getting from url provider", e); } }
catch (Exception e) { throw makePropertyException("Found by Broker, but could not be retrieved", e); } } catch (NullPointerException npe) { throw makePropertyException("Not found by url provider or broker"); } catch (Exception e) { throw makePropertyException("Unexpected exception while getting from Broker", e); } } catch (Exception e) { throw makePropertyException("Unexpected exception while getting from url provider", e); }
}
protected String getFile(Broker b, String name) throws PropertyException { try { return b.get("url", name).toString(); } catch (ResourceException re) { try { try { // The UrlProvider knows, how to do this, // so let him do the work for us return b.get("url", name).toString(); } catch (NullPointerException npe) { throw npe; } catch (Exception e) { throw makePropertyException("Found by Broker, but could not be retrieved", e); } } catch (NullPointerException npe) { throw makePropertyException("Not found by url provider or broker"); } catch (Exception e) { throw makePropertyException("Unexpected exception while getting from Broker", e); } } catch (Exception e) { throw makePropertyException("Unexpected exception while getting from url provider", e); } }
LOGGER.debug("addClassData: " + classData.getName()); String parentClassName = getClassNameIgnoreInner(classData.getName()); LOGGER.debug("\tparentClassName = " + parentClassName); String keyName = new ClassData(parentClassName).getBaseName(); LOGGER.debug("\tkeyName = " + keyName); ClassData parent = getClassData(classData.getName()); if (parent == null) { LOGGER.debug("\tno parent"); parent = new ClassData(parentClassName); } classData.merge(parent); LOGGER.debug("putting " + keyName + " = " + classData.getName()); children.put(keyName, classData);
String sourceFileName = classData.getSourceFileName(); SourceFileData sourceFileData = (SourceFileData)children.get(sourceFileName); if (sourceFileData == null) { sourceFileData = new SourceFileData(sourceFileName); this.children.put(sourceFileName, sourceFileData); } sourceFileData.addClassData(classData);
public void addClassData(ClassData classData) { // this method aggregates data if classData is an inner class // with the data from the top level class that it is contained in LOGGER.debug("addClassData: " + classData.getName()); String parentClassName = getClassNameIgnoreInner(classData.getName()); LOGGER.debug("\tparentClassName = " + parentClassName); String keyName = new ClassData(parentClassName).getBaseName(); LOGGER.debug("\tkeyName = " + keyName); ClassData parent = getClassData(classData.getName()); if (parent == null) { LOGGER.debug("\tno parent"); parent = new ClassData(parentClassName); } classData.merge(parent); // Each key is a class basename, stored as an String object. // Each value is information about the class, stored as a ClassData object. LOGGER.debug("putting " + keyName + " = " + classData.getName()); children.put(keyName, classData); }
serviceNotificationErrorCalled = false;
notificationCalled = false;
private void rest() { serviceNotificationErrorCalled = false; }
assertFalse(serviceNotificationErrorCalled); serviceNotificationErrorCalled = true;
assertFalse(notificationCalled); notificationCalled = true;
public void serviceNotificationError(ServiceMonitor serviceMonitor, ServiceEvent serviceEvent, Throwable throwable) { assertFalse(serviceNotificationErrorCalled); serviceNotificationErrorCalled = true; assertSame(SERVICE_MONITOR, serviceMonitor); assertSame(SERVICE_EVENT, serviceEvent); assertSame(THROWABLE, throwable); }
kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor1); kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor1); kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor1);
kernelMonitorBroadcaster.addKernelMonitor(kernelMonitors[1]); kernelMonitorBroadcaster.addKernelMonitor(kernelMonitors[1]); kernelMonitorBroadcaster.addKernelMonitor(kernelMonitors[1]);
public void testDoubleAdd() { kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor1); kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor1); kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor1); kernelMonitorBroadcaster.serviceNotificationError(SERVICE_MONITOR, SERVICE_EVENT, THROWABLE); // note the mock monitor asserts that it is only called once before requreing a reset assertTrue(kernelMonitor1.wasServiceNotificationErrorCalled()); }
assertTrue(kernelMonitor1.wasServiceNotificationErrorCalled());
assertNotificationCorrect();
public void testDoubleAdd() { kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor1); kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor1); kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor1); kernelMonitorBroadcaster.serviceNotificationError(SERVICE_MONITOR, SERVICE_EVENT, THROWABLE); // note the mock monitor asserts that it is only called once before requreing a reset assertTrue(kernelMonitor1.wasServiceNotificationErrorCalled()); }
kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor1); kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor2); kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor3); kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor4);
public void testFireEvent() { kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor1); kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor2); kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor3); kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor4); kernelMonitorBroadcaster.serviceNotificationError(SERVICE_MONITOR, SERVICE_EVENT, THROWABLE); assertTrue(kernelMonitor1.wasServiceNotificationErrorCalled()); assertTrue(kernelMonitor2.wasServiceNotificationErrorCalled()); assertTrue(kernelMonitor3.wasServiceNotificationErrorCalled()); assertTrue(kernelMonitor4.wasServiceNotificationErrorCalled()); }
assertTrue(kernelMonitor1.wasServiceNotificationErrorCalled()); assertTrue(kernelMonitor2.wasServiceNotificationErrorCalled()); assertTrue(kernelMonitor3.wasServiceNotificationErrorCalled()); assertTrue(kernelMonitor4.wasServiceNotificationErrorCalled());
assertNotificationCorrect();
public void testFireEvent() { kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor1); kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor2); kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor3); kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor4); kernelMonitorBroadcaster.serviceNotificationError(SERVICE_MONITOR, SERVICE_EVENT, THROWABLE); assertTrue(kernelMonitor1.wasServiceNotificationErrorCalled()); assertTrue(kernelMonitor2.wasServiceNotificationErrorCalled()); assertTrue(kernelMonitor3.wasServiceNotificationErrorCalled()); assertTrue(kernelMonitor4.wasServiceNotificationErrorCalled()); }
kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor1); kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor2); kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor3); kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor4);
kernelMonitorBroadcaster.serviceNotificationError(SERVICE_MONITOR, SERVICE_EVENT, THROWABLE); assertNotificationCorrect(); for (int i = 0; i < kernelMonitors.length; i++) { MockKernelMonitor kernelMonitor = kernelMonitors[i]; kernelMonitor.rest(); } kernelMonitorBroadcaster.removeKernelMonitor(kernelMonitors[1]);
public void testRemove() { kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor1); kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor2); kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor3); kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor4); kernelMonitorBroadcaster.serviceNotificationError(SERVICE_MONITOR, SERVICE_EVENT, THROWABLE); assertTrue(kernelMonitor1.wasServiceNotificationErrorCalled()); assertTrue(kernelMonitor2.wasServiceNotificationErrorCalled()); assertTrue(kernelMonitor3.wasServiceNotificationErrorCalled()); assertTrue(kernelMonitor4.wasServiceNotificationErrorCalled()); kernelMonitor1.rest(); kernelMonitor2.rest(); kernelMonitor3.rest(); kernelMonitor4.rest(); kernelMonitorBroadcaster.removeKernelMonitor(kernelMonitor2); kernelMonitorBroadcaster.serviceNotificationError(SERVICE_MONITOR, SERVICE_EVENT, THROWABLE); assertTrue(kernelMonitor1.wasServiceNotificationErrorCalled()); assertFalse(kernelMonitor2.wasServiceNotificationErrorCalled()); assertTrue(kernelMonitor3.wasServiceNotificationErrorCalled()); assertTrue(kernelMonitor4.wasServiceNotificationErrorCalled()); }
assertTrue(kernelMonitor1.wasServiceNotificationErrorCalled()); assertTrue(kernelMonitor2.wasServiceNotificationErrorCalled()); assertTrue(kernelMonitor3.wasServiceNotificationErrorCalled()); assertTrue(kernelMonitor4.wasServiceNotificationErrorCalled()); kernelMonitor1.rest(); kernelMonitor2.rest(); kernelMonitor3.rest(); kernelMonitor4.rest(); kernelMonitorBroadcaster.removeKernelMonitor(kernelMonitor2); kernelMonitorBroadcaster.serviceNotificationError(SERVICE_MONITOR, SERVICE_EVENT, THROWABLE); assertTrue(kernelMonitor1.wasServiceNotificationErrorCalled()); assertFalse(kernelMonitor2.wasServiceNotificationErrorCalled()); assertTrue(kernelMonitor3.wasServiceNotificationErrorCalled()); assertTrue(kernelMonitor4.wasServiceNotificationErrorCalled());
for (int i = 0; i < kernelMonitors.length; i++) { MockKernelMonitor kernelMonitor = kernelMonitors[i]; if (i == 1) { assertFalse(kernelMonitor.wasNotificationCalled()); } else { assertTrue(kernelMonitor.wasNotificationCalled()); } }
public void testRemove() { kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor1); kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor2); kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor3); kernelMonitorBroadcaster.addKernelMonitor(kernelMonitor4); kernelMonitorBroadcaster.serviceNotificationError(SERVICE_MONITOR, SERVICE_EVENT, THROWABLE); assertTrue(kernelMonitor1.wasServiceNotificationErrorCalled()); assertTrue(kernelMonitor2.wasServiceNotificationErrorCalled()); assertTrue(kernelMonitor3.wasServiceNotificationErrorCalled()); assertTrue(kernelMonitor4.wasServiceNotificationErrorCalled()); kernelMonitor1.rest(); kernelMonitor2.rest(); kernelMonitor3.rest(); kernelMonitor4.rest(); kernelMonitorBroadcaster.removeKernelMonitor(kernelMonitor2); kernelMonitorBroadcaster.serviceNotificationError(SERVICE_MONITOR, SERVICE_EVENT, THROWABLE); assertTrue(kernelMonitor1.wasServiceNotificationErrorCalled()); assertFalse(kernelMonitor2.wasServiceNotificationErrorCalled()); assertTrue(kernelMonitor3.wasServiceNotificationErrorCalled()); assertTrue(kernelMonitor4.wasServiceNotificationErrorCalled()); }
kernelMonitorBroadcaster.removeKernelMonitor(kernelMonitor1);
kernelMonitorBroadcaster.removeKernelMonitor(new MockKernelMonitor("unassociated monitor"));
public void testRemoveUnassociated() { kernelMonitorBroadcaster.removeKernelMonitor(kernelMonitor1); }
kernelMonitors.add(kernelMonitor);
kernelMonitors.addIfAbsent(kernelMonitor);
public void addKernelMonitor(KernelMonitor kernelMonitor) { kernelMonitors.add(kernelMonitor); }
if (forkedJVMDebugPort != null && forkedJVMDebugPort.intValue() > 0) { getJava().createJvmarg().setValue("-Xdebug"); getJava().createJvmarg().setValue("-Xrunjdwp:transport=dt_socket,address=" + forkedJVMDebugPort + ",server=y,suspend=y"); }
public void execute() throws BuildException { CommandLineBuilder builder = null; try { builder = new CommandLineBuilder(); if (dataFile != null) builder.addArg("--datafile", dataFile); if (toDir != null) builder.addArg("--destination", toDir.getAbsolutePath()); // ignoreRegex.setRegex() is never called, but that's ok // because ant sets it somehow, I think for (int i = 0; i < ignoreRegexs.size(); i++) { Ignore ignoreRegex = (Ignore)ignoreRegexs.get(i); builder.addArg("--ignore", ignoreRegex.getRegex()); } createArgumentsForFilesets(builder); builder.saveArgs(); } catch (IOException ioe) { getProject().log("Error creating commands file.", Project.MSG_ERR); throw new BuildException("Unable to create the commands file.", ioe); } // Execute GPL licensed code in separate virtual machine getJava().createArg().setValue("--commandsfile"); getJava().createArg().setValue(builder.getCommandLineFile()); if (getJava().executeJava() != 0) { throw new BuildException( "Error instrumenting classes. See messages above."); } builder.dispose(); }
System.out.println(article); rootResource.putMethod(session.getURI(filePath),article);
if(session.getExistence(filePath)){ rootResource.putMethod(filePath,article); } else { rootResource.putMethod(session.getURI(filePath),article); }
public void store() throws IDOStoreException{ boolean storeOk = true; clearErrorKeys(); if (getHeadline().trim().equals("")) { addErrorKey(KEY_ERROR_HEADLINE_EMPTY); storeOk = false; } if (getBody().trim().equals("")) { addErrorKey(KEY_ERROR_BODY_EMPTY); storeOk = false; } // if (getRequestedStatus() != null && getRequestedStatus().equals(ContentItemCase.STATUS_PUBLISHED)) {// if (getCase().getPublishedFromDate() == null) {// addErrorKey(KEY_ERROR_PUBLISHED_FROM_DATE_EMPTY);// storeOk = false;// }// } // String filename = getHeadline();// if(null==filename || filename.length()==0) {// filename = "empty";// } try { IWUserContext iwuc = IWContext.getInstance(); IWApplicationContext iwac = iwuc.getApplicationContext(); IWSlideSession session = (IWSlideSession)IBOLookup.getSessionInstance(iwuc,IWSlideSession.class); IWSlideService service = (IWSlideService)IBOLookup.getServiceInstance(iwac,IWSlideService.class); WebdavRootResource rootResource = session.getWebdavRootResource(); IWSlideService slideService = (IWSlideService)IBOLookup.getServiceInstance(iwac,IWSlideService.class); String filePath=getArticleResourcePath(); String articleFolderPath = getArticlePath(); slideService.createAllFoldersInPath(articleFolderPath); rootResource.proppatchMethod(articleFolderPath,new PropertyName("IW:",CONTENT_TYPE),"LocalizedFile",true); String article = getAsXML(); System.out.println(article); rootResource.putMethod(session.getURI(filePath),article); rootResource.proppatchMethod(filePath,new PropertyName("IW:",CONTENT_TYPE),ARTICLE_FILENAME_SCOPE,true); rootResource.close(); try { load(filePath); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } catch (IOException e1) { storeOk = false; // TODO Auto-generated catch block e1.printStackTrace(); } if (storeOk) { if (getRequestedStatus() != null) { setStatus(getRequestedStatus()); setRequestedStatus(null); } }else { throw new ArticleStoreException(); } }
public static String getArticleYearMonthPath() {
public static String getArticleYearMonthPath(String basePath) {
public static String getArticleYearMonthPath() { IWTimestamp now = new IWTimestamp(); String folderString = ArticleUtil.getArticleRootPath()+"/"+now.getYear()+"/"+now.getDateString("MM"); return folderString; }
String folderString = ArticleUtil.getArticleRootPath()+"/"+now.getYear()+"/"+now.getDateString("MM");
String folderString = basePath+"/"+now.getYear()+"/"+now.getDateString("MM");
public static String getArticleYearMonthPath() { IWTimestamp now = new IWTimestamp(); String folderString = ArticleUtil.getArticleRootPath()+"/"+now.getYear()+"/"+now.getDateString("MM"); return folderString; }
tab.getTitleLabel().setForeground(Color.red);
final JLabel titleLabel = tab.getTitleLabel();
public void makeTabRed(final ChatRoom room) { final int index = indexOfComponent(room); if (index != -1) { SparkTab tab = getTabAt(index); Font font = tab.getTitleLabel().getFont(); tab.getTitleLabel().setForeground(Color.red); Font newFont = font.deriveFont(Font.BOLD); tab.getTitleLabel().setFont(newFont); } }
tab.getTitleLabel().setFont(newFont);
titleLabel.setFont(newFont); titleLabel.setForeground(Color.red);
public void makeTabRed(final ChatRoom room) { final int index = indexOfComponent(room); if (index != -1) { SparkTab tab = getTabAt(index); Font font = tab.getTitleLabel().getFont(); tab.getTitleLabel().setForeground(Color.red); Font newFont = font.deriveFont(Font.BOLD); tab.getTitleLabel().setFont(newFont); } }
Iterator statusItemIterator = dndList.iterator();
Iterator statusItemIterator = statusList.iterator();
public StatusItem getItemFromPresence(Presence presence) { // Handle offline presence if (presence == null) { return null; } Iterator statusItemIterator = dndList.iterator(); while (statusItemIterator.hasNext()) { StatusItem item = (StatusItem)statusItemIterator.next(); if (presence.getStatus() != null && item.getPresence().getStatus() != null) { if ((presence.getMode() == item.getPresence().getMode()) && (presence.getType() == item.getPresence().getType()) && (presence.getStatus().equals(item.getPresence().getStatus()))) { return item; } } } statusItemIterator = dndList.iterator(); while (statusItemIterator.hasNext()) { StatusItem item = (StatusItem)statusItemIterator.next(); if ((presence.getMode() == item.getPresence().getMode()) && (presence.getType() == item.getPresence().getType())) { return item; } } return null; }
statusItemIterator = dndList.iterator();
statusItemIterator = statusList.iterator();
public StatusItem getItemFromPresence(Presence presence) { // Handle offline presence if (presence == null) { return null; } Iterator statusItemIterator = dndList.iterator(); while (statusItemIterator.hasNext()) { StatusItem item = (StatusItem)statusItemIterator.next(); if (presence.getStatus() != null && item.getPresence().getStatus() != null) { if ((presence.getMode() == item.getPresence().getMode()) && (presence.getType() == item.getPresence().getType()) && (presence.getStatus().equals(item.getPresence().getStatus()))) { return item; } } } statusItemIterator = dndList.iterator(); while (statusItemIterator.hasNext()) { StatusItem item = (StatusItem)statusItemIterator.next(); if ((presence.getMode() == item.getPresence().getMode()) && (presence.getType() == item.getPresence().getType())) { return item; } } return null; }
public NotFoundException(String reason) { super(reason);
public NotFoundException(String reason, Exception e) { super(reason,e);
public NotFoundException(String reason) { super(reason); }
IWApplicationContext iwac = iwuc.getApplicationContext();
public void store() throws IDOStoreException{ boolean storeOk = true; clearErrorKeys(); if (getHeadline().trim().equals("")) { addErrorKey(KEY_ERROR_HEADLINE_EMPTY); storeOk = false; } if (getBody().trim().equals("")) { addErrorKey(KEY_ERROR_BODY_EMPTY); storeOk = false; } // if (getRequestedStatus() != null && getRequestedStatus().equals(ContentItemCase.STATUS_PUBLISHED)) {// if (getCase().getPublishedFromDate() == null) {// addErrorKey(KEY_ERROR_PUBLISHED_FROM_DATE_EMPTY);// storeOk = false;// }// } // String filename = getHeadline();// if(null==filename || filename.length()==0) {// filename = "empty";// } try { IWUserContext iwuc = IWContext.getInstance(); IWApplicationContext iwac = iwuc.getApplicationContext(); IWSlideSession session = (IWSlideSession)IBOLookup.getSessionInstance(iwuc,IWSlideSession.class); WebdavRootResource rootResource = session.getWebdavRootResource(); IWSlideService slideService = (IWSlideService)IBOLookup.getServiceInstance(iwac,IWSlideService.class); //Setting the path for creating new file/creating localized version/updating existing file String filePath=getResourcePath(); String articleFolderPath=getArticlePath(); if(articleFolderPath!=null) { filePath=articleFolderPath+"/"+getArticleName(); }else { filePath=getArticleResourcePath(); articleFolderPath = getArticlePath(); } slideService.createAllFoldersInPath(articleFolderPath); rootResource.proppatchMethod(articleFolderPath,new PropertyName("IW:",CONTENT_TYPE),"LocalizedFile",true); String article = getAsXML();// System.out.println(article); //Conflict fix: uri for creating but path for updating //Note! This is a patch to what seems to be a bug in WebDav //Apparently in verion below works in some cases and the other in other cases. //Seems to be connected to creating files in folders created in same tomcat session or similar //not quite clear... if(session.getExistence(filePath)){ if(!rootResource.putMethod(filePath,article)) { rootResource.putMethod(session.getURI(filePath),article); } } else { if(!rootResource.putMethod(session.getURI(filePath),article)) { rootResource.putMethod(filePath,article); } } rootResource.proppatchMethod(filePath,new PropertyName("IW:",CONTENT_TYPE),ARTICLE_FILENAME_SCOPE,true); rootResource.close(); try { load(filePath); } catch (Exception e) { e.printStackTrace(); } } catch (IOException e1) { storeOk = false; e1.printStackTrace(); } if (storeOk) { if (getRequestedStatus() != null) { setStatus(getRequestedStatus()); setRequestedStatus(null); } }else { throw new ArticleStoreException(); } }
IWSlideService slideService = (IWSlideService)IBOLookup.getServiceInstance(iwac,IWSlideService.class);
public void store() throws IDOStoreException{ boolean storeOk = true; clearErrorKeys(); if (getHeadline().trim().equals("")) { addErrorKey(KEY_ERROR_HEADLINE_EMPTY); storeOk = false; } if (getBody().trim().equals("")) { addErrorKey(KEY_ERROR_BODY_EMPTY); storeOk = false; } // if (getRequestedStatus() != null && getRequestedStatus().equals(ContentItemCase.STATUS_PUBLISHED)) {// if (getCase().getPublishedFromDate() == null) {// addErrorKey(KEY_ERROR_PUBLISHED_FROM_DATE_EMPTY);// storeOk = false;// }// } // String filename = getHeadline();// if(null==filename || filename.length()==0) {// filename = "empty";// } try { IWUserContext iwuc = IWContext.getInstance(); IWApplicationContext iwac = iwuc.getApplicationContext(); IWSlideSession session = (IWSlideSession)IBOLookup.getSessionInstance(iwuc,IWSlideSession.class); WebdavRootResource rootResource = session.getWebdavRootResource(); IWSlideService slideService = (IWSlideService)IBOLookup.getServiceInstance(iwac,IWSlideService.class); //Setting the path for creating new file/creating localized version/updating existing file String filePath=getResourcePath(); String articleFolderPath=getArticlePath(); if(articleFolderPath!=null) { filePath=articleFolderPath+"/"+getArticleName(); }else { filePath=getArticleResourcePath(); articleFolderPath = getArticlePath(); } slideService.createAllFoldersInPath(articleFolderPath); rootResource.proppatchMethod(articleFolderPath,new PropertyName("IW:",CONTENT_TYPE),"LocalizedFile",true); String article = getAsXML();// System.out.println(article); //Conflict fix: uri for creating but path for updating //Note! This is a patch to what seems to be a bug in WebDav //Apparently in verion below works in some cases and the other in other cases. //Seems to be connected to creating files in folders created in same tomcat session or similar //not quite clear... if(session.getExistence(filePath)){ if(!rootResource.putMethod(filePath,article)) { rootResource.putMethod(session.getURI(filePath),article); } } else { if(!rootResource.putMethod(session.getURI(filePath),article)) { rootResource.putMethod(filePath,article); } } rootResource.proppatchMethod(filePath,new PropertyName("IW:",CONTENT_TYPE),ARTICLE_FILENAME_SCOPE,true); rootResource.close(); try { load(filePath); } catch (Exception e) { e.printStackTrace(); } } catch (IOException e1) { storeOk = false; e1.printStackTrace(); } if (storeOk) { if (getRequestedStatus() != null) { setStatus(getRequestedStatus()); setRequestedStatus(null); } }else { throw new ArticleStoreException(); } }
slideService.createAllFoldersInPath(articleFolderPath);
boolean hadToCreate = session.createAllFoldersInPath(articleFolderPath);
public void store() throws IDOStoreException{ boolean storeOk = true; clearErrorKeys(); if (getHeadline().trim().equals("")) { addErrorKey(KEY_ERROR_HEADLINE_EMPTY); storeOk = false; } if (getBody().trim().equals("")) { addErrorKey(KEY_ERROR_BODY_EMPTY); storeOk = false; } // if (getRequestedStatus() != null && getRequestedStatus().equals(ContentItemCase.STATUS_PUBLISHED)) {// if (getCase().getPublishedFromDate() == null) {// addErrorKey(KEY_ERROR_PUBLISHED_FROM_DATE_EMPTY);// storeOk = false;// }// } // String filename = getHeadline();// if(null==filename || filename.length()==0) {// filename = "empty";// } try { IWUserContext iwuc = IWContext.getInstance(); IWApplicationContext iwac = iwuc.getApplicationContext(); IWSlideSession session = (IWSlideSession)IBOLookup.getSessionInstance(iwuc,IWSlideSession.class); WebdavRootResource rootResource = session.getWebdavRootResource(); IWSlideService slideService = (IWSlideService)IBOLookup.getServiceInstance(iwac,IWSlideService.class); //Setting the path for creating new file/creating localized version/updating existing file String filePath=getResourcePath(); String articleFolderPath=getArticlePath(); if(articleFolderPath!=null) { filePath=articleFolderPath+"/"+getArticleName(); }else { filePath=getArticleResourcePath(); articleFolderPath = getArticlePath(); } slideService.createAllFoldersInPath(articleFolderPath); rootResource.proppatchMethod(articleFolderPath,new PropertyName("IW:",CONTENT_TYPE),"LocalizedFile",true); String article = getAsXML();// System.out.println(article); //Conflict fix: uri for creating but path for updating //Note! This is a patch to what seems to be a bug in WebDav //Apparently in verion below works in some cases and the other in other cases. //Seems to be connected to creating files in folders created in same tomcat session or similar //not quite clear... if(session.getExistence(filePath)){ if(!rootResource.putMethod(filePath,article)) { rootResource.putMethod(session.getURI(filePath),article); } } else { if(!rootResource.putMethod(session.getURI(filePath),article)) { rootResource.putMethod(filePath,article); } } rootResource.proppatchMethod(filePath,new PropertyName("IW:",CONTENT_TYPE),ARTICLE_FILENAME_SCOPE,true); rootResource.close(); try { load(filePath); } catch (Exception e) { e.printStackTrace(); } } catch (IOException e1) { storeOk = false; e1.printStackTrace(); } if (storeOk) { if (getRequestedStatus() != null) { setStatus(getRequestedStatus()); setRequestedStatus(null); } }else { throw new ArticleStoreException(); } }
rootResource.proppatchMethod(articleFolderPath,new PropertyName("IW:",CONTENT_TYPE),"LocalizedFile",true);
if(hadToCreate){ String fixedFolderURL = session.getURI(articleFolderPath); rootResource.proppatchMethod(fixedFolderURL,PROPERTY_CONTENT_TYPE,"LocalizedFile",true); } else{ rootResource.proppatchMethod(articleFolderPath,PROPERTY_CONTENT_TYPE,"LocalizedFile",true); }
public void store() throws IDOStoreException{ boolean storeOk = true; clearErrorKeys(); if (getHeadline().trim().equals("")) { addErrorKey(KEY_ERROR_HEADLINE_EMPTY); storeOk = false; } if (getBody().trim().equals("")) { addErrorKey(KEY_ERROR_BODY_EMPTY); storeOk = false; } // if (getRequestedStatus() != null && getRequestedStatus().equals(ContentItemCase.STATUS_PUBLISHED)) {// if (getCase().getPublishedFromDate() == null) {// addErrorKey(KEY_ERROR_PUBLISHED_FROM_DATE_EMPTY);// storeOk = false;// }// } // String filename = getHeadline();// if(null==filename || filename.length()==0) {// filename = "empty";// } try { IWUserContext iwuc = IWContext.getInstance(); IWApplicationContext iwac = iwuc.getApplicationContext(); IWSlideSession session = (IWSlideSession)IBOLookup.getSessionInstance(iwuc,IWSlideSession.class); WebdavRootResource rootResource = session.getWebdavRootResource(); IWSlideService slideService = (IWSlideService)IBOLookup.getServiceInstance(iwac,IWSlideService.class); //Setting the path for creating new file/creating localized version/updating existing file String filePath=getResourcePath(); String articleFolderPath=getArticlePath(); if(articleFolderPath!=null) { filePath=articleFolderPath+"/"+getArticleName(); }else { filePath=getArticleResourcePath(); articleFolderPath = getArticlePath(); } slideService.createAllFoldersInPath(articleFolderPath); rootResource.proppatchMethod(articleFolderPath,new PropertyName("IW:",CONTENT_TYPE),"LocalizedFile",true); String article = getAsXML();// System.out.println(article); //Conflict fix: uri for creating but path for updating //Note! This is a patch to what seems to be a bug in WebDav //Apparently in verion below works in some cases and the other in other cases. //Seems to be connected to creating files in folders created in same tomcat session or similar //not quite clear... if(session.getExistence(filePath)){ if(!rootResource.putMethod(filePath,article)) { rootResource.putMethod(session.getURI(filePath),article); } } else { if(!rootResource.putMethod(session.getURI(filePath),article)) { rootResource.putMethod(filePath,article); } } rootResource.proppatchMethod(filePath,new PropertyName("IW:",CONTENT_TYPE),ARTICLE_FILENAME_SCOPE,true); rootResource.close(); try { load(filePath); } catch (Exception e) { e.printStackTrace(); } } catch (IOException e1) { storeOk = false; e1.printStackTrace(); } if (storeOk) { if (getRequestedStatus() != null) { setStatus(getRequestedStatus()); setRequestedStatus(null); } }else { throw new ArticleStoreException(); } }
if(session.getExistence(filePath)){ if(!rootResource.putMethod(filePath,article)) { rootResource.putMethod(session.getURI(filePath),article); } } else { if(!rootResource.putMethod(session.getURI(filePath),article)) { rootResource.putMethod(filePath,article); }
if(rootResource.putMethod(filePath,article)){ rootResource.proppatchMethod(filePath,PROPERTY_CONTENT_TYPE,ARTICLE_FILENAME_SCOPE,true);
public void store() throws IDOStoreException{ boolean storeOk = true; clearErrorKeys(); if (getHeadline().trim().equals("")) { addErrorKey(KEY_ERROR_HEADLINE_EMPTY); storeOk = false; } if (getBody().trim().equals("")) { addErrorKey(KEY_ERROR_BODY_EMPTY); storeOk = false; } // if (getRequestedStatus() != null && getRequestedStatus().equals(ContentItemCase.STATUS_PUBLISHED)) {// if (getCase().getPublishedFromDate() == null) {// addErrorKey(KEY_ERROR_PUBLISHED_FROM_DATE_EMPTY);// storeOk = false;// }// } // String filename = getHeadline();// if(null==filename || filename.length()==0) {// filename = "empty";// } try { IWUserContext iwuc = IWContext.getInstance(); IWApplicationContext iwac = iwuc.getApplicationContext(); IWSlideSession session = (IWSlideSession)IBOLookup.getSessionInstance(iwuc,IWSlideSession.class); WebdavRootResource rootResource = session.getWebdavRootResource(); IWSlideService slideService = (IWSlideService)IBOLookup.getServiceInstance(iwac,IWSlideService.class); //Setting the path for creating new file/creating localized version/updating existing file String filePath=getResourcePath(); String articleFolderPath=getArticlePath(); if(articleFolderPath!=null) { filePath=articleFolderPath+"/"+getArticleName(); }else { filePath=getArticleResourcePath(); articleFolderPath = getArticlePath(); } slideService.createAllFoldersInPath(articleFolderPath); rootResource.proppatchMethod(articleFolderPath,new PropertyName("IW:",CONTENT_TYPE),"LocalizedFile",true); String article = getAsXML();// System.out.println(article); //Conflict fix: uri for creating but path for updating //Note! This is a patch to what seems to be a bug in WebDav //Apparently in verion below works in some cases and the other in other cases. //Seems to be connected to creating files in folders created in same tomcat session or similar //not quite clear... if(session.getExistence(filePath)){ if(!rootResource.putMethod(filePath,article)) { rootResource.putMethod(session.getURI(filePath),article); } } else { if(!rootResource.putMethod(session.getURI(filePath),article)) { rootResource.putMethod(filePath,article); } } rootResource.proppatchMethod(filePath,new PropertyName("IW:",CONTENT_TYPE),ARTICLE_FILENAME_SCOPE,true); rootResource.close(); try { load(filePath); } catch (Exception e) { e.printStackTrace(); } } catch (IOException e1) { storeOk = false; e1.printStackTrace(); } if (storeOk) { if (getRequestedStatus() != null) { setStatus(getRequestedStatus()); setRequestedStatus(null); } }else { throw new ArticleStoreException(); } }
rootResource.proppatchMethod(filePath,new PropertyName("IW:",CONTENT_TYPE),ARTICLE_FILENAME_SCOPE,true);
else{ String fixedURL = session.getURI(filePath); rootResource.putMethod(fixedURL,article); rootResource.proppatchMethod(fixedURL,PROPERTY_CONTENT_TYPE,ARTICLE_FILENAME_SCOPE,true); }
public void store() throws IDOStoreException{ boolean storeOk = true; clearErrorKeys(); if (getHeadline().trim().equals("")) { addErrorKey(KEY_ERROR_HEADLINE_EMPTY); storeOk = false; } if (getBody().trim().equals("")) { addErrorKey(KEY_ERROR_BODY_EMPTY); storeOk = false; } // if (getRequestedStatus() != null && getRequestedStatus().equals(ContentItemCase.STATUS_PUBLISHED)) {// if (getCase().getPublishedFromDate() == null) {// addErrorKey(KEY_ERROR_PUBLISHED_FROM_DATE_EMPTY);// storeOk = false;// }// } // String filename = getHeadline();// if(null==filename || filename.length()==0) {// filename = "empty";// } try { IWUserContext iwuc = IWContext.getInstance(); IWApplicationContext iwac = iwuc.getApplicationContext(); IWSlideSession session = (IWSlideSession)IBOLookup.getSessionInstance(iwuc,IWSlideSession.class); WebdavRootResource rootResource = session.getWebdavRootResource(); IWSlideService slideService = (IWSlideService)IBOLookup.getServiceInstance(iwac,IWSlideService.class); //Setting the path for creating new file/creating localized version/updating existing file String filePath=getResourcePath(); String articleFolderPath=getArticlePath(); if(articleFolderPath!=null) { filePath=articleFolderPath+"/"+getArticleName(); }else { filePath=getArticleResourcePath(); articleFolderPath = getArticlePath(); } slideService.createAllFoldersInPath(articleFolderPath); rootResource.proppatchMethod(articleFolderPath,new PropertyName("IW:",CONTENT_TYPE),"LocalizedFile",true); String article = getAsXML();// System.out.println(article); //Conflict fix: uri for creating but path for updating //Note! This is a patch to what seems to be a bug in WebDav //Apparently in verion below works in some cases and the other in other cases. //Seems to be connected to creating files in folders created in same tomcat session or similar //not quite clear... if(session.getExistence(filePath)){ if(!rootResource.putMethod(filePath,article)) { rootResource.putMethod(session.getURI(filePath),article); } } else { if(!rootResource.putMethod(session.getURI(filePath),article)) { rootResource.putMethod(filePath,article); } } rootResource.proppatchMethod(filePath,new PropertyName("IW:",CONTENT_TYPE),ARTICLE_FILENAME_SCOPE,true); rootResource.close(); try { load(filePath); } catch (Exception e) { e.printStackTrace(); } } catch (IOException e1) { storeOk = false; e1.printStackTrace(); } if (storeOk) { if (getRequestedStatus() != null) { setStatus(getRequestedStatus()); setRequestedStatus(null); } }else { throw new ArticleStoreException(); } }
add(buttonPanel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
add(buttonPanel, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
public ChatToolBar() { buttonPanel = new JPanel(); buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); rightPanel = new JPanel(); rightPanel.setOpaque(false); rightPanel.setLayout(new BorderLayout()); // Set Layout setLayout(new GridBagLayout()); buttonPanel.setOpaque(false); add(buttonPanel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); setOpaque(false); }
chatRoom = (ChatRoomImpl)container.getChatRoom(from);
chatRoom = (ChatRoomImpl)container.getChatRoom(jid);
private void showAlert(Message message) { final String body = message.getBody(); String subject = message.getSubject(); StringBuffer buf = new StringBuffer(); if (subject != null) { buf.append(Res.getString("subject") + ": ").append(subject); buf.append("\n\n"); } buf.append(body); String host = SparkManager.getSessionManager().getServerAddress(); String from = message.getFrom() != null ? message.getFrom() : ""; final TranscriptWindow window = new TranscriptWindow(); window.insertCustomMessage(null, buf.toString()); JPanel p = new JPanel(); p.setLayout(new BorderLayout()); p.add(window, BorderLayout.CENTER); p.setBorder(BorderFactory.createLineBorder(Color.lightGray)); SparkToaster toaster = new SparkToaster(); toaster.setDisplayTime(30000); toaster.setBorder(BorderFactory.createBevelBorder(0)); String title = host; if (!from.contains("@")) { ChatManager chatManager = SparkManager.getChatManager(); ChatContainer container = chatManager.getChatContainer(); ChatRoomImpl chatRoom = null; try { chatRoom = (ChatRoomImpl)container.getChatRoom(from); } catch (ChatRoomNotFoundException e) { chatRoom = new ChatRoomImpl(from, from, Res.getString("message.broadcast.from", from)); chatRoom.setTabIcon(SparkRes.getImageIcon(SparkRes.INFORMATION_IMAGE)); chatRoom.setIconHandler(true); chatRoom.getBottomPanel().setVisible(false); chatRoom.getToolBar().setVisible(false); SparkManager.getChatManager().getChatContainer().addChatRoom(chatRoom); } chatRoom.insertMessage(message); container.makeTabRed(chatRoom); } else if (message.getFrom() != null) { String jid = StringUtils.parseBareAddress(from); String nickname = SparkManager.getUserManager().getUserNicknameFromJID(jid); ChatManager chatManager = SparkManager.getChatManager(); ChatContainer container = chatManager.getChatContainer(); ChatRoomImpl chatRoom = null; try { chatRoom = (ChatRoomImpl)container.getChatRoom(from); } catch (ChatRoomNotFoundException e) { chatRoom = new ChatRoomImpl(jid, nickname, Res.getString("message.broadcast.from", nickname)); chatRoom.setTabIcon(SparkRes.getImageIcon(SparkRes.INFORMATION_IMAGE)); chatRoom.setIconHandler(true); SparkManager.getChatManager().getChatContainer().addChatRoom(chatRoom); } chatRoom.insertMessage(message); container.makeTabRed(chatRoom); chatRoom.addMessageListener(new MessageListener() { boolean waiting = true; public void messageReceived(ChatRoom room, Message message) { if (waiting) { useDefaultRoomSettings((ChatRoomImpl)room); waiting = false; } } public void messageSent(ChatRoom room, Message message) { if (waiting) { useDefaultRoomSettings((ChatRoomImpl)room); waiting = false; } } }); } }
public String getInput(String title, String description, Icon icon, Component parent) { textArea = new JTextArea(); textArea.setLineWrap(true);
public String getInput(String title, String description, Icon icon, int width, int height) { this.width = width; this.height = height;
public String getInput(String title, String description, Icon icon, Component parent) { textArea = new JTextArea(); textArea.setLineWrap(true); TitlePanel titlePanel = new TitlePanel(title, description, icon, true); // Construct main panel w/ layout. final JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); mainPanel.add(titlePanel, BorderLayout.NORTH); // The user should only be able to close this dialog. final Object[] options = {"Ok", "Cancel"}; optionPane = new JOptionPane(new JScrollPane(textArea), JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, options, options[0]); mainPanel.add(optionPane, BorderLayout.CENTER); // Let's make sure that the dialog is modal. Cannot risk people // losing this dialog. JOptionPane p = new JOptionPane(); dialog = p.createDialog(parent, title); dialog.setModal(true); dialog.pack(); dialog.setSize(width, height); dialog.setContentPane(mainPanel); dialog.setLocationRelativeTo(parent); optionPane.addPropertyChangeListener(this); // Add Key Listener to Send Field textArea.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyChar() == KeyEvent.VK_TAB) { optionPane.requestFocus(); } else if (e.getKeyChar() == KeyEvent.VK_ESCAPE) { dialog.dispose(); } } }); textArea.requestFocus(); dialog.setVisible(true); return stringValue; }
TitlePanel titlePanel = new TitlePanel(title, description, icon, true); final JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); mainPanel.add(titlePanel, BorderLayout.NORTH); final Object[] options = {"Ok", "Cancel"}; optionPane = new JOptionPane(new JScrollPane(textArea), JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, options, options[0]); mainPanel.add(optionPane, BorderLayout.CENTER); JOptionPane p = new JOptionPane(); dialog = p.createDialog(parent, title); dialog.setModal(true); dialog.pack(); dialog.setSize(width, height); dialog.setContentPane(mainPanel); dialog.setLocationRelativeTo(parent); optionPane.addPropertyChangeListener(this); textArea.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyChar() == KeyEvent.VK_TAB) { optionPane.requestFocus(); } else if (e.getKeyChar() == KeyEvent.VK_ESCAPE) { dialog.dispose(); } } }); textArea.requestFocus(); dialog.setVisible(true); return stringValue;
return getInput(title, description, icon, SparkManager.getMainWindow());
public String getInput(String title, String description, Icon icon, Component parent) { textArea = new JTextArea(); textArea.setLineWrap(true); TitlePanel titlePanel = new TitlePanel(title, description, icon, true); // Construct main panel w/ layout. final JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); mainPanel.add(titlePanel, BorderLayout.NORTH); // The user should only be able to close this dialog. final Object[] options = {"Ok", "Cancel"}; optionPane = new JOptionPane(new JScrollPane(textArea), JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, options, options[0]); mainPanel.add(optionPane, BorderLayout.CENTER); // Let's make sure that the dialog is modal. Cannot risk people // losing this dialog. JOptionPane p = new JOptionPane(); dialog = p.createDialog(parent, title); dialog.setModal(true); dialog.pack(); dialog.setSize(width, height); dialog.setContentPane(mainPanel); dialog.setLocationRelativeTo(parent); optionPane.addPropertyChangeListener(this); // Add Key Listener to Send Field textArea.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyChar() == KeyEvent.VK_TAB) { optionPane.requestFocus(); } else if (e.getKeyChar() == KeyEvent.VK_ESCAPE) { dialog.dispose(); } } }); textArea.requestFocus(); dialog.setVisible(true); return stringValue; }
public RolloverButton(Icon icon) { super(icon);
public RolloverButton() {
public RolloverButton(Icon icon) { super(icon); decorate(); }
messageEventRequestListener = new ChatMessageEventRequestListener(); SparkManager.getMessageEventManager().addMessageEventRequestListener(messageEventRequestListener);
public ChatRoomImpl(final String participantJID, String participantNickname, String title) { this.participantJID = participantJID; this.participantNickname = participantNickname; AndFilter presenceFilter = new AndFilter(new PacketTypeFilter(Presence.class), new FromContainsFilter(this.participantJID)); // Register PacketListeners AndFilter messageFilter = new AndFilter(new PacketTypeFilter(Message.class), new FromContainsFilter(participantJID)); SparkManager.getConnection().addPacketListener(this, messageFilter); SparkManager.getConnection().addPacketListener(this, presenceFilter); // The roomname will be the participantJID this.roomname = participantJID; // Use the agents username as the Tab Title this.tabTitle = title; // The name of the room will be the node of the user jid + conversation. final SimpleDateFormat formatter = new SimpleDateFormat("h:mm a"); this.roomTitle = participantNickname; // Add RoomInfo this.getSplitPane().setRightComponent(null); getSplitPane().setDividerSize(0); roster = SparkManager.getConnection().getRoster(); presence = roster.getPresence(participantJID); RosterEntry entry = roster.getEntry(participantJID); tabIcon = SparkManager.getUserManager().getTabIconForPresence(presence); PacketFilter filter = new AndFilter(new PacketTypeFilter(Presence.class), new FromContainsFilter(participantJID)); SparkManager.getConnection().addPacketListener(new PacketListener() { public void processPacket(Packet packet) { presence = (Presence)packet; } }, filter); // Create toolbar buttons. ChatRoomButton infoButton = new ChatRoomButton("", SparkRes.getImageIcon(SparkRes.PROFILE_IMAGE_24x24)); infoButton.setToolTipText(Res.getString("message.view.information.about.this.user")); // Create basic toolbar. getToolBar().addChatRoomButton(infoButton); // If the user is not in the roster, then allow user to add them. if (entry == null && !StringUtils.parseResource(participantJID).equals(participantNickname)) { ChatRoomButton addToRosterButton = new ChatRoomButton("", SparkRes.getImageIcon(SparkRes.ADD_IMAGE_24x24)); addToRosterButton.setToolTipText(Res.getString("message.add.this.user.to.your.roster")); getToolBar().addChatRoomButton(addToRosterButton); addToRosterButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { RosterDialog rosterDialog = new RosterDialog(); rosterDialog.setDefaultJID(participantJID); rosterDialog.setDefaultNickname(getParticipantNickname()); rosterDialog.showRosterDialog(SparkManager.getChatManager().getChatContainer().getChatFrame()); } }); } // Show VCard. infoButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VCardManager vcard = SparkManager.getVCardManager(); vcard.viewProfile(participantJID, SparkManager.getChatManager().getChatContainer()); } }); // If this is a private chat from a group chat room, do not show toolbar. if (StringUtils.parseResource(participantJID).equals(participantNickname)) { getToolBar().setVisible(false); } typingTimer = new Timer(2000, new ActionListener() { public void actionPerformed(ActionEvent e) { long now = System.currentTimeMillis(); if (now - lastTypedCharTime > 2000) { if (!sendNotification) { // send cancel SparkManager.getMessageEventManager().sendCancelledNotification(getParticipantJID(), threadID); sendNotification = true; } } } }); typingTimer.start(); // Add message event request listener messageEventRequestListener = new ChatMessageEventRequestListener(); SparkManager.getMessageEventManager().addMessageEventRequestListener(messageEventRequestListener); lastActivity = System.currentTimeMillis(); // Add VCard Panel final VCardPanel vcardPanel = new VCardPanel(participantJID); getToolBar().add(vcardPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); }
MessageEvent messageEvent = (MessageEvent) message.getExtension("x", "jabber:x:event"); if(messageEvent != null) { checkEvents(message.getFrom(), message.getPacketID(), messageEvent); }
public void insertMessage(Message message) { // Debug info super.insertMessage(message); getTranscriptWindow().insertOthersMessage(participantNickname, message); // Set the participant jid to their full JID. participantJID = message.getFrom(); }
logger.info("Data file does not contain instrumentation "
LOGGER.info("Data file does not contain instrumentation "
private void generateSourceFile(SourceFileData sourceFileData) throws IOException { if (!sourceFileData.containsInstrumentationInfo()) { logger.info("Data file does not contain instrumentation " + "information for the file " + sourceFileData.getName() + ". Ensure this class was instrumented, and this " + "data file contains the instrumentation information."); } String filename = sourceFileData.getNormalizedName() + ".html"; File file = new File(destinationDir, filename); PrintStream out = null; try { out = new PrintStream(new FileOutputStream(file)); out.println("<html>"); out.println("<head>"); out.println("<title>Coverage Report</title>"); out .println("<link title=\"Style\" type=\"text/css\" rel=\"stylesheet\" href=\"css/main.css\" />"); out .println("<script type=\"text/javascript\" src=\"js/popup.js\"></script>"); out.println("</head>"); out.println("<body>"); out.print("<h5>Coverage Report - "); String classPackageName = sourceFileData.getPackageName(); if ((classPackageName != null) && classPackageName.length() > 0) { out.print(sourceFileData.getPackageName() + "."); } out.print(sourceFileData.getBaseName()); out.println("</h5>"); // Output the coverage summary for this class out.println("<p>"); out.println("<table class=\"report\">"); out.println(generateTableHeader("Classes in this File", false)); // TODO: Change this to actually show multiple classes. out.println(generateTableRowForSourceFile(sourceFileData)); out.println("</table>"); out.println("</p>"); // Output this class's source code with syntax and coverage highlighting out.println("<p>"); out .println("<table cellspacing=\"0\" cellpadding=\"0\" class=\"src\">"); BufferedReader br = null; try { File sourceFile = finder.findFile(sourceFileData.getName()); br = new BufferedReader(new FileReader(sourceFile)); String lineStr; JavaToHtml javaToHtml = new JavaToHtml(); int lineNumber = 1; while ((lineStr = br.readLine()) != null) { out.println("<tr>"); if (sourceFileData.isValidSourceLineNumber(lineNumber)) { long numberOfHits = sourceFileData .getHitCount(lineNumber); out.println(" <td class=\"numLineCover\">&nbsp;" + lineNumber + "</td>"); if (numberOfHits > 0) { out .println(" <td class=\"nbHitsCovered\">&nbsp;" + numberOfHits + "</td>"); out .println(" <td class=\"src\"><pre class=\"src\">&nbsp;" + javaToHtml.process(lineStr) + "</pre></td>"); } else { out .println(" <td class=\"nbHitsUncovered\">&nbsp;" + numberOfHits + "</td>"); out .println(" <td class=\"src\"><pre class=\"src\"><span class=\"srcUncovered\">&nbsp;" + javaToHtml.process(lineStr) + "</span></pre></td>"); } } else { out.println(" <td class=\"numLine\">&nbsp;" + lineNumber + "</td>"); out.println(" <td class=\"nbHits\">&nbsp;</td>"); out .println(" <td class=\"src\"><pre class=\"src\">&nbsp;" + javaToHtml.process(lineStr) + "</pre></td>"); } out.println("</tr>"); lineNumber++; } } finally { if (br != null) { br.close(); } } out.println("</table>"); out.println("</p>"); out.println("<div class=\"footer\">"); out .println("Reports generated by <a href=\"http://cobertura.sourceforge.net/\" target=\"_top\">Cobertura</a>."); out.println("</div>"); out.println("</body>"); out.println("</html>"); } finally { if (out != null) { out.close(); } } }
logger.info("Could not generate HTML file for source file "
LOGGER.info("Could not generate HTML file for source file "
private void generateSourceFiles() { Iterator iter = projectData.getSourceFiles().iterator(); while (iter.hasNext()) { SourceFileData sourceFileData = (SourceFileData)iter.next(); try { generateSourceFile(sourceFileData); } catch (IOException e) { logger.info("Could not generate HTML file for source file " + sourceFileData.getName() + ": " + e.getLocalizedMessage()); } } }
double ccn = 0;
File[] files = finder.findDirectory(packageData.getSourceFileName()); if (files.length == 0) { LOGGER.warn("No directories found for package: " + packageData.getSourceFileName()); } double ccnSum = 0; for (int i = 0; i < files.length; i++) { ccnSum += Util.getCCN(files[i], false); } double ccn = ccnSum / (double) files.length;
private String generateTableRowForPackage(PackageData packageData) { StringBuffer ret = new StringBuffer(); String url1 = "frame-summary-" + packageData.getName() + ".html"; String url2 = "frame-sourcefiles-" + packageData.getName() + ".html"; double lineCoverage = -1; double branchCoverage = -1; double ccn = 0;//Util.getCCN(finder.findFile(packageData.getSourceFileName()), false); if (packageData.getNumberOfValidLines() > 0) lineCoverage = packageData.getLineCoverageRate(); if (packageData.getNumberOfValidBranches() > 0) branchCoverage = packageData.getBranchCoverageRate(); ret.append(" <tr>"); ret.append("<td class=\"text\"><a href=\"" + url1 + "\" onClick='parent.sourceFileList.location.href=\"" + url2 + "\"'>" + generatePackageName(packageData) + "</a></td>"); ret.append("<td class=\"value\">" + packageData.getNumberOfChildren() + "</td>"); ret.append(generateTableColumnsFromData(lineCoverage, branchCoverage, ccn)); ret.append("</tr>"); return ret.toString(); }
compute(); List mine = Collections.EMPTY_LIST; synchronized(this) { mine = new ArrayList(cached); } for (Iterator it = mine.iterator(); it.hasNext(); ) { String path = (String) it.next(); if (path.replace('/', '\\').endsWith(filePart.replace('/', '\\'))) { return new File(path); } } return null; }
compute(); List mine = Collections.EMPTY_LIST; synchronized(this) { mine = new ArrayList(cached); } String tempFilePart = getCorrectedPath(filePart); for (Iterator it = mine.iterator(); it.hasNext(); ) { String path = (String) it.next(); if (path.endsWith(tempFilePart)) { return new File(path); } } return null; }
public File findFile(String filePart) { compute(); List mine = Collections.EMPTY_LIST; synchronized(this) { mine = new ArrayList(cached); } for (Iterator it = mine.iterator(); it.hasNext(); ) { String path = (String) it.next(); if (path.replace('/', '\\').endsWith(filePart.replace('/', '\\'))) { return new File(path); } } return null; }
if (file == null) { return 0; }
public static double getCCN(File file, boolean recursive) { int ccnAccumulator = 0; Vector files = getListOfFiles(file, recursive); if (files.isEmpty()) { logger.warn("Cannot find files to compute CCN, file=" + file.getAbsolutePath() + ", recursive=" + recursive); return 0; } Javancss javancss = new Javancss(files); List functionMetrics = javancss.getFunctionMetrics(); if (functionMetrics.size() <= 0) return 0; Iterator iter = functionMetrics.iterator(); while (iter.hasNext()) { Vector functionMetric = (Vector)iter.next(); ccnAccumulator += ((Integer)functionMetric .elementAt(JavancssConstants.FCT_CCN)).intValue(); } return (double)ccnAccumulator / functionMetrics.size(); }
final protected void registerTool(String name, ContextTool tool)
final public void registerTool(String name, ContextTool tool)
final protected void registerTool(String name, ContextTool tool) throws InvalidContextException { if (_toolbox == null) { _toolbox = new HashMap(); } _toolbox.put(name,tool); }
final protected void registerTools(String tools) {
final public void registerTools(String tools) {
final protected void registerTools(String tools) { Enumeration tenum = new StringTokenizer(tools); while (tenum.hasMoreElements()) { String toolName = (String) tenum.nextElement(); try { Class toolType = Class.forName(toolName); String varName = findToolName(toolName); ContextTool tool = (ContextTool) toolType.newInstance(); registerTool(varName,tool); } catch (ClassCastException cce) { _log.exception(cce); _log.error("Tool class " + toolName + " newInstance returns invalid type."); } catch (ClassNotFoundException ce) { _log.exception(ce); _log.error("Tool class " + toolName + " not found: " + ce); } catch (IllegalAccessException ia) { _log.exception(ia); _log.error("Tool class and methods must be public for " + toolName + ": " + ia); } catch (InvalidContextException e) { _log.exception(e); _log.error("InvalidContextException thrown while registering " + "Tool: " + toolName); } catch (InstantiationException ie) { _log.exception(ie); _log.error("Tool class " + toolName + " must have a public zero " + "argument or default constructor: " + ie); } } }
return setLocal(names, value);
return setLocal(names, value) || setTool(names, value);
final public boolean setProperty(final Object[] names, final Object value) throws PropertyException, InvalidContextException { if (names.length == 0) { return false; } else if (_bean == null) { return setLocal(names, value); } else { return PropertyOperator.setProperty(this,_bean,names,value); } }
return getOperator(instance.getClass()).getProperty(
if (instance == null) { return null; } else { return getOperator(instance.getClass()).getProperty(
static final public Object getProperty( final Context context, final Object instance, final Object[] names, int start) throws PropertyException, SecurityException, InvalidContextException { try { return getOperator(instance.getClass()).getProperty( context,instance,names,start,names.length - 1); } catch (NoSuchMethodException e) { _log.exception(e); throw new PropertyException("No method to access property: " + e,e); } }
}
static final public Object getProperty( final Context context, final Object instance, final Object[] names, int start) throws PropertyException, SecurityException, InvalidContextException { try { return getOperator(instance.getClass()).getProperty( context,instance,names,start,names.length - 1); } catch (NoSuchMethodException e) { _log.exception(e); throw new PropertyException("No method to access property: " + e,e); } }
if (instance == null) { return false; }
static final public boolean setProperty( final Context context, Object instance, final Object[] names, int start, final Object value) throws PropertyException, SecurityException, InvalidContextException { try { return getOperator(instance.getClass()).setProperty(context,instance,names,value,start); } catch (NoSuchMethodException e) { throw new PropertyException("No method to access property: " + e,e); } }
return new Block(name, finalStrings, finalMacros, ln, cn);
return new Block(name, finalStrings, finalMacros, finalLines, finalCols);
final public Object build(BuildContext bc) throws BuildException { ArrayList strings = new ArrayList((elements.size())); ArrayList macros = new ArrayList((elements.size())); int[] ln = new int[elements.size()]; int[] cn = new int[elements.size()]; Stack iterStack = new Stack(); StringBuffer s = new StringBuffer(); // flatten everything and view the content as being: // string (macro string)* string // store that as an array of strings and an array of // Macro objects and create a block. BlockIterator iter = new BBIterator(); while (iter.hasNext()) { Object o = iter.next(); if (o instanceof Builder) o = ((Builder) o).build(bc); if (o instanceof Block) { iterStack.push(iter); iter = ((Block) o).getBlockIterator(); } else { if (o instanceof Macro) { strings.add(s.toString()); s = new StringBuffer(); // do not reuse StringBuffer, // otherwise all strings will contain char[] of max length!! macros.add(o); // Now deal with the line numbers int size = macros.size(); if (ln.length < size) { ln = resizeIntArray(ln, ln.length * 2); cn = resizeIntArray(cn, cn.length * 2); } ln[size - 1] = iter.getLineNo(); cn[size - 1] = iter.getColNo(); } else if (o != null) { s.append(o.toString()); } } while (!iter.hasNext() && !iterStack.empty()) iter = (BlockIterator) iterStack.pop(); } strings.add(s.toString()); Macro finalMacros[] = (Macro[]) macros.toArray(mArray); String finalStrings[] = (String[]) strings.toArray(sArray); int finalLines[] = resizeIntArray(ln, macros.size()); int finalCols[] = resizeIntArray(cn, macros.size()); return new Block(name, finalStrings, finalMacros, ln, cn); }
if (_prof != null) _prof.destroy();
if (_prof != null) { stopTiming(); _prof.destroy(); }
public void clear() { Iterator i = _tools.entrySet().iterator(); while (i.hasNext()) { Map.Entry m = (Map.Entry) i.next(); ContextTool tool = (ContextTool) _toolbox.get(m.getKey()); tool.destroy(m.getValue()); } _tools.clear(); _globals.clear(); _bean = null; if (_prof != null) _prof.destroy(); }
cacheEnabled=((Boolean)values[2]).booleanValue();
public void restoreState(FacesContext ctx, Object state) { Object values[] = (Object[]) state; super.restoreState(ctx, values[0]); headlineAsLink=((Boolean)values[1]).booleanValue(); }
Object values[] = new Object[2];
Object values[] = new Object[3];
public Object saveState(FacesContext ctx) { Object values[] = new Object[2]; values[0] = super.saveState(ctx); values[1] = Boolean.valueOf(headlineAsLink); return values; }
values[2] = Boolean.valueOf(cacheEnabled);
public Object saveState(FacesContext ctx) { Object values[] = new Object[2]; values[0] = super.saveState(ctx); values[1] = Boolean.valueOf(headlineAsLink); return values; }
throws ServletException, IOException {
throws IOException {
final private void doRequest( HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { WebContext context = null; if (_problem != null) { init(); if (_problem != null) { try { resp.setContentType("text/html"); FastWriter out = getFastWriter(resp.getOutputStream(), resp.getCharacterEncoding()); out.write("<html><head><title>WebMacro Error</title></head>"); out.write("<body><h1><font color=\"red\">WebMacro Error: "); out.write("</font></h1><pre>"); out.write(_problem); out.write("</pre>"); out.write("Please contact the server administrator"); out.flush(); out.close(); } catch (Exception e) { _log.error(_problem, e); } return; } } boolean timing = false; try { context = newContext(req, resp); timing = Flags.PROFILE && context.isTiming(); if (timing) context.startTiming("WMServlet", req.getRequestURI()); Template t; try { if (timing) context.startTiming("handle"); t = handle(context); } finally { if (timing) context.stopTiming(); } if (t != null) { execute(t, context); } if (timing) context.startTiming("WMServlet.destroyContext()"); try { destroyContext(context); } finally { if (timing) context.stopTiming(); } } catch (HandlerException e) { if (context == null) { context = _wcPrototype.newInstance(req, resp); } _log.error("Your handler failed to handle the request:" + this, e); Template tmpl = error(context, "Your handler was unable to process the request successfully " + "for some reason. Here are the details:<p>" + "<pre>" + e + "</pre>"); execute(tmpl, context); } catch (Exception e) { if (context == null) { context = _wcPrototype.newInstance(req, resp); } _log.error("Your handler failed to handle the request:" + this, e); Template tmpl = error(context, "The handler WebMacro used to handle this request failed for " + "some reason. This is likely a bug in the handler written " + "for this application. Here are the details:<p>" + "<pre>" + e + "</pre>"); execute(tmpl, context); } finally { if (timing) context.stopTiming(); context.recycle(); } }
public void write(String s) throws IOException
public void write(int b) throws IOException
public void write(String s) throws IOException { this.write(s,0,s.length()); }
this.write(s,0,s.length());
if ((_cpos + 1) > CSIZE) cflush(); _cbuf[_cpos] = (char) b; _cpos++;
public void write(String s) throws IOException { this.write(s,0,s.length()); }
System.out.println("WebContext.getResponse() called!");
public final HttpServletResponse getResponse() { return _response; }
HtmlSelectOneMenu searchCategoryMenu = WFUtil.getSelectOneMenu(SEARCH_CATEGORY_ID, ref + "categories", ref + "searchCategoryId"); searchCategoryMenu.setConverter(new IntegerConverter()); p.getChildren().add(searchCategoryMenu);
private UIComponent getSearchPanel() { String ref = LIST_ARTICLES_BEAN_ID + "."; String bref = WFPage.CONTENT_BUNDLE + "."; WFContainer mainContainer = new WFContainer(); WFErrorMessages em = new WFErrorMessages(); em.addErrorMessage(SEARCH_PUBLISHED_FROM_ID); em.addErrorMessage(SEARCH_PUBLISHED_TO_ID); mainContainer.add(em); HtmlPanelGrid p = WFPanelUtil.getFormPanel(3); p.getChildren().add(WFUtil.group(WFUtil.getTextVB(bref + "published_from"), WFUtil.getText(":"))); p.getChildren().add(WFUtil.group(WFUtil.getTextVB(bref + "published_to"), WFUtil.getText(":"))); p.getChildren().add(WFUtil.group(WFUtil.getTextVB(bref + "category"), WFUtil.getText(":"))); HtmlInputText searchPublishedFromInput = WFUtil.getInputText(SEARCH_PUBLISHED_FROM_ID, ref + "searchPublishedFrom"); searchPublishedFromInput.setSize(20); searchPublishedFromInput.setConverter(new WFDateConverter()); p.getChildren().add(searchPublishedFromInput); HtmlInputText searchPublishedToInput = WFUtil.getInputText(SEARCH_PUBLISHED_TO_ID, ref + "searchPublishedTo"); searchPublishedToInput.setSize(20); searchPublishedToInput.setConverter(new WFDateConverter()); p.getChildren().add(searchPublishedToInput); HtmlSelectOneMenu searchCategoryMenu = WFUtil.getSelectOneMenu(SEARCH_CATEGORY_ID, ref + "categories", ref + "searchCategoryId"); searchCategoryMenu.setConverter(new IntegerConverter()); p.getChildren().add(searchCategoryMenu); mainContainer.add(p); mainContainer.add(WFUtil.getText(" ")); p = WFPanelUtil.getPlainFormPanel(1); p.getChildren().add(WFUtil.getButtonVB(LIST_BUTTON_ID, bref + "list", this)); mainContainer.add(p); return mainContainer; }
HtmlSelectOneMenu localeMenu = WFUtil.getSelectOneMenu(LOCALE_ID, ref + "allLocales", ref + "localeId"); localeMenu.setOnchange("document.forms[0].submit();"); c.add(localeMenu);
private UIComponent getViewArticlePanel() { String ref = ARTICLE_ITEM_BEAN_ID + "."; String bref = WFPage.CONTENT_BUNDLE + "."; WFContainer c = new WFContainer(); c.setStyleAttribute("padding", "10px"); c.setId(VIEW_ARTICLE_PANEL_ID); c.add(WFUtil.getTextVB(ref + "case.publishedFromDate")); c.add(new WFPlainOutputText("&nbsp;&nbsp;")); HtmlSelectOneMenu localeMenu = WFUtil.getSelectOneMenu(LOCALE_ID, ref + "allLocales", ref + "localeId"); localeMenu.setOnchange("document.forms[0].submit();"); c.add(localeMenu); c.add(WFUtil.getBreak(2)); c.add(WFUtil.getLinkVB("", ref + "headline", null)); c.add(WFUtil.getBreak(2)); WFPlainOutputText t = new WFPlainOutputText(); WFUtil.setValueBinding(t, "value", ref + "body"); c.add(t); c.add(WFUtil.getBreak(2)); c.add(WFUtil.getButtonVB(VIEW_ARTICLE_BACK_BUTTON_ID, bref + "back", this)); return c; }
WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "clear"); ContentItemCase caze = new ContentItemCaseBean(); caze.setPublishedFromDate(new Date()); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setCase", caze); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setLocaleId", "en"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setHeadline", "Electronic Reykjavik Up-And-Running (id = " + id + ")"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setTeaser", "Teaser"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setBody", "The first 24/7 service offered by Reykjavik Municipality as part of the Electronic Reykjavik " + "concept, was launched on May 25th., as planned. Now all applications and administration " + "processes regarding Music school applications and internal student registration are " + "implemented in the IdegaWeb eGOV solution.<br/><br/>" + "All applications are submitted through the Citizen Account to the Music schools. "+ "The schools use the system to process the applications. "+ "In the Citizen Account users can see the status of cases and applications, " + "view messages and communicate with the Music school administrators.<br/><br/>" + "For more information, you can access the website of Reykjavik <a href=\"#\">here</a>. " + "Click on the icon for Electronic Reykjavik (Rafrn Reykjavik) or go directly to the portal " + "<a href=\"#\">here</a>."); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setAuthor", "Author"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setComment", "Comment"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setDescription", "Description"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setStatus", ContentItemCase.STATUS_PUBLISHED); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setMainCategoryId", new Integer(3)); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setLocaleId", "sv"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setHeadline", "Electronic Rykjavik klar"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setBody", "Den frsta 24-timmarsmyndigheten fr Reykjaviks kommun igng."); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setLocaleId", "en");
ArticleItemBean articleItem = new ArticleItemBean(); try { articleItem.load(new File("/Test/article/"+id+".xml")); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "clear"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setLocaleId", "en"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setHeadline", notNull(articleItem.getHeadline())+" (id = " + id + ")"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setTeaser", notNull(articleItem.getTeaser())); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setBody", notNull(articleItem.getBody())); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setAuthor", notNull(articleItem.getAuthor())); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setComment", notNull(articleItem.getComment())); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setDescription", notNull(articleItem.getDescription())); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setStatus", ContentItemCase.STATUS_PUBLISHED ); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setMainCategoryId", new Integer(3)); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setLocaleId", "sv");
public void processAction(ActionEvent event) { if (event.getComponent().getId().equals(LIST_BUTTON_ID)) { WFUtil.invoke(LIST_ARTICLES_BEAN_ID, "list"); return; } else if (event.getComponent().getId().equals(VIEW_ARTICLE_BACK_BUTTON_ID)) { WFComponentSelector cs = (WFComponentSelector) event.getComponent().findComponent(DISPLAY_SELECTOR_ID); cs.setSelectedId(LIST_PANEL_ID, true); cs.setSelectedId(VIEW_ARTICLE_PANEL_ID, false); return; } UIComponent link = event.getComponent(); String id = WFUtil.getParameter(link, "id"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "clear"); ContentItemCase caze = new ContentItemCaseBean(); caze.setPublishedFromDate(new Date()); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setCase", caze); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setLocaleId", "en"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setHeadline", "Electronic Reykjavik Up-And-Running (id = " + id + ")"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setTeaser", "Teaser"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setBody", "The first 24/7 service offered by Reykjavik Municipality as part of the Electronic Reykjavik " + "concept, was launched on May 25th., as planned. Now all applications and administration " + "processes regarding Music school applications and internal student registration are " + "implemented in the IdegaWeb eGOV solution.<br/><br/>" + "All applications are submitted through the Citizen Account to the Music schools. "+ "The schools use the system to process the applications. "+ "In the Citizen Account users can see the status of cases and applications, " + "view messages and communicate with the Music school administrators.<br/><br/>" + "For more information, you can access the website of Reykjavik <a href=\"#\">here</a>. " + "Click on the icon for Electronic Reykjavik (Rafrn Reykjavik) or go directly to the portal " + "<a href=\"#\">here</a>."); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setAuthor", "Author"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setComment", "Comment"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setDescription", "Description"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setStatus", ContentItemCase.STATUS_PUBLISHED); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setMainCategoryId", new Integer(3)); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setLocaleId", "sv"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setHeadline", "Electronic Rykjavik klar"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setBody", "Den frsta 24-timmarsmyndigheten fr Reykjaviks kommun igng."); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setLocaleId", "en"); WFComponentSelector cs = (WFComponentSelector) event.getComponent().getParent().getParent().getParent().findComponent(DISPLAY_SELECTOR_ID); cs.setSelectedId(LIST_PANEL_ID, false); cs.setSelectedId(VIEW_ARTICLE_PANEL_ID, true); }
WFComponentSelector cs = (WFComponentSelector) event.getComponent().getParent().getParent().getParent().findComponent(DISPLAY_SELECTOR_ID); cs.setSelectedId(LIST_PANEL_ID, false); cs.setSelectedId(VIEW_ARTICLE_PANEL_ID, true);
WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setHeadline", notNull(articleItem.getHeadline())+" (id = " + id + ")"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setTeaser", notNull(articleItem.getTeaser())); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setBody", notNull(articleItem.getBody())); WFComponentSelector cs = (WFComponentSelector) event.getComponent().getParent().getParent().getParent().findComponent(DISPLAY_SELECTOR_ID); cs.setSelectedId(LIST_PANEL_ID, false); cs.setSelectedId(VIEW_ARTICLE_PANEL_ID, true); } catch (XmlException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }
public void processAction(ActionEvent event) { if (event.getComponent().getId().equals(LIST_BUTTON_ID)) { WFUtil.invoke(LIST_ARTICLES_BEAN_ID, "list"); return; } else if (event.getComponent().getId().equals(VIEW_ARTICLE_BACK_BUTTON_ID)) { WFComponentSelector cs = (WFComponentSelector) event.getComponent().findComponent(DISPLAY_SELECTOR_ID); cs.setSelectedId(LIST_PANEL_ID, true); cs.setSelectedId(VIEW_ARTICLE_PANEL_ID, false); return; } UIComponent link = event.getComponent(); String id = WFUtil.getParameter(link, "id"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "clear"); ContentItemCase caze = new ContentItemCaseBean(); caze.setPublishedFromDate(new Date()); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setCase", caze); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setLocaleId", "en"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setHeadline", "Electronic Reykjavik Up-And-Running (id = " + id + ")"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setTeaser", "Teaser"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setBody", "The first 24/7 service offered by Reykjavik Municipality as part of the Electronic Reykjavik " + "concept, was launched on May 25th., as planned. Now all applications and administration " + "processes regarding Music school applications and internal student registration are " + "implemented in the IdegaWeb eGOV solution.<br/><br/>" + "All applications are submitted through the Citizen Account to the Music schools. "+ "The schools use the system to process the applications. "+ "In the Citizen Account users can see the status of cases and applications, " + "view messages and communicate with the Music school administrators.<br/><br/>" + "For more information, you can access the website of Reykjavik <a href=\"#\">here</a>. " + "Click on the icon for Electronic Reykjavik (Rafrn Reykjavik) or go directly to the portal " + "<a href=\"#\">here</a>."); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setAuthor", "Author"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setComment", "Comment"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setDescription", "Description"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setStatus", ContentItemCase.STATUS_PUBLISHED); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setMainCategoryId", new Integer(3)); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setLocaleId", "sv"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setHeadline", "Electronic Rykjavik klar"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setBody", "Den frsta 24-timmarsmyndigheten fr Reykjaviks kommun igng."); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setLocaleId", "en"); WFComponentSelector cs = (WFComponentSelector) event.getComponent().getParent().getParent().getParent().findComponent(DISPLAY_SELECTOR_ID); cs.setSelectedId(LIST_PANEL_ID, false); cs.setSelectedId(VIEW_ARTICLE_PANEL_ID, true); }
MenuManager menuBar = new MenuManager(); MenuManager treeContextMenu = new MenuManager();
public DisplayedDocument(Shell shell, Dispatcher dispatcher) { // Shell this.shell = shell; shell.setText("Koala Notes"); shell.setLayout(new FillLayout(SWT.VERTICAL)); // Document document = new Document(); Note root = new Note("root", document, ""); // SashForm SashForm sashForm = new SashForm(shell, SWT.HORIZONTAL); // Tree and DisplayedNotes this.displayedNotes = new LinkedList<DisplayedNote>(); tree = new NoteTree(sashForm, dispatcher); new DisplayedNote(this, tree, root); // TabFolder tabFolder = new NoteTabFolder(sashForm); // Finish SashForm sashForm.setWeights(new int[] {20, 80}); // Action Groups actionGroups = new LinkedList<ActionGroup>(); actionGroups.add(new FileActionGroup(dispatcher, document)); actionGroups.add(new NoteActionGroup(dispatcher, tree)); // Menu Bar and Tree Context Menu MenuManager menuBar = new MenuManager(); MenuManager treeContextMenu = new MenuManager(); for (ActionGroup ag : actionGroups) { ag.populateMenuBar(menuBar); ag.populateTreeContextMenu(treeContextMenu); } tree.setContextMenu(treeContextMenu); shell.setMenuBar(menuBar.createMenuBar((Decorations) shell)); // Controllers new FileMenuController(dispatcher, this); new NoteMenuController(dispatcher, this); new MainController(dispatcher, this); new TreeController(dispatcher, tree); }
tree.setContextMenu(treeContextMenu); shell.setMenuBar(menuBar.createMenuBar((Decorations) shell));
public DisplayedDocument(Shell shell, Dispatcher dispatcher) { // Shell this.shell = shell; shell.setText("Koala Notes"); shell.setLayout(new FillLayout(SWT.VERTICAL)); // Document document = new Document(); Note root = new Note("root", document, ""); // SashForm SashForm sashForm = new SashForm(shell, SWT.HORIZONTAL); // Tree and DisplayedNotes this.displayedNotes = new LinkedList<DisplayedNote>(); tree = new NoteTree(sashForm, dispatcher); new DisplayedNote(this, tree, root); // TabFolder tabFolder = new NoteTabFolder(sashForm); // Finish SashForm sashForm.setWeights(new int[] {20, 80}); // Action Groups actionGroups = new LinkedList<ActionGroup>(); actionGroups.add(new FileActionGroup(dispatcher, document)); actionGroups.add(new NoteActionGroup(dispatcher, tree)); // Menu Bar and Tree Context Menu MenuManager menuBar = new MenuManager(); MenuManager treeContextMenu = new MenuManager(); for (ActionGroup ag : actionGroups) { ag.populateMenuBar(menuBar); ag.populateTreeContextMenu(treeContextMenu); } tree.setContextMenu(treeContextMenu); shell.setMenuBar(menuBar.createMenuBar((Decorations) shell)); // Controllers new FileMenuController(dispatcher, this); new NoteMenuController(dispatcher, this); new MainController(dispatcher, this); new TreeController(dispatcher, tree); }
Listener contextChangedListener = new Listener(d, MainController.CONTEXT_CHANGED);
public NoteTree(Composite parent, Dispatcher d) { // Tree and context menu. tree = new Tree(parent, SWT.MULTI); // Text editor for renaming tree nodes. treeEditor = new TreeEditor(tree); treeEditor.grabHorizontal = true; treeEditor.minimumWidth = 50; // Events. tree.addListener(SWT.MouseDoubleClick, new Listener(d, MainController.DISPLAY_TAB)); Listener contextChangedListener = new Listener(d, MainController.CONTEXT_CHANGED); tree.addListener(SWT.FocusIn, contextChangedListener); tree.addListener(SWT.Selection, contextChangedListener); }
tree.addListener(SWT.DefaultSelection, contextChangedListener);
public NoteTree(Composite parent, Dispatcher d) { // Tree and context menu. tree = new Tree(parent, SWT.MULTI); // Text editor for renaming tree nodes. treeEditor = new TreeEditor(tree); treeEditor.grabHorizontal = true; treeEditor.minimumWidth = 50; // Events. tree.addListener(SWT.MouseDoubleClick, new Listener(d, MainController.DISPLAY_TAB)); Listener contextChangedListener = new Listener(d, MainController.CONTEXT_CHANGED); tree.addListener(SWT.FocusIn, contextChangedListener); tree.addListener(SWT.Selection, contextChangedListener); }
allSubmenusAndActions = new ActionGroupHelper(); addNoteSubmenuAndActions = new ActionGroupHelper(); moveNoteSubmenuAndActions = new ActionGroupHelper(); ungroupedActions = new ActionGroupHelper(); allSubmenusAndActions.add(addNoteSubmenuAndActions); allSubmenusAndActions.add(moveNoteSubmenuAndActions); allSubmenusAndActions.add(ungroupedActions); addNoteSubmenuAndActions.add(addNoteAfter); addNoteSubmenuAndActions.add(addNoteUnder); moveNoteSubmenuAndActions.add(moveNoteLeft); moveNoteSubmenuAndActions.add(moveNoteRight); moveNoteSubmenuAndActions.add(moveNoteUp); moveNoteSubmenuAndActions.add(moveNoteDown); ungroupedActions.add(removeNotes); ungroupedActions.add(renameNote);
public NoteActionGroup(Dispatcher d, NoteTree tree) { this.tree = tree; addNoteAfter = new Action(d, NoteMenuController.ADD_NOTE_AFTER, "&After"); addNoteUnder = new Action(d, NoteMenuController.ADD_NOTE_UNDER, "&Under"); moveNoteLeft = new Action(d, NoteMenuController.MOVE_NOTE_LEFT, "&Left"); moveNoteRight = new Action(d, NoteMenuController.MOVE_NOTE_RIGHT, "&Right"); moveNoteUp = new Action(d, NoteMenuController.MOVE_NOTE_UP, "&Up"); moveNoteDown = new Action(d, NoteMenuController.MOVE_NOTE_DOWN, "&Down"); removeNotes = new Action(d, NoteMenuController.REMOVE_NOTES, "&Remove Notes"); removeNotes.setAccelerator(SWT.DEL); renameNote = new Action(d, NoteMenuController.RENAME_NOTE, "Re&name Note"); }
public TreeController(DisplayedDocument displayedDocument) { super(displayedDocument);
public TreeController(NoteTree tree, Dispatcher dispatcher) { this.tree = tree; this.dispatcher = dispatcher;
public TreeController(DisplayedDocument displayedDocument) { super(displayedDocument); }
source = source.substring(lastIndex);
source = source.substring(0, lastIndex);
public static long getUrlLastModified(URL u) { String protocol = u.getProtocol(); if (protocol.equals("file")) { // We're going to use the File mechanism instead File f = new File(u.getFile()); return f.lastModified(); } else if (protocol.equals("jar")) { // We'll extract the jar source and recurse String source = u.getFile(); int lastIndex = source.lastIndexOf("!"); if (lastIndex > 0) source = source.substring(lastIndex); try { return getUrlLastModified(new URL(source)); } catch (MalformedURLException e) { return 0; } } else { // Ask the URL, maybe it knows try { URLConnection uc = u.openConnection(); uc.connect(); return uc.getLastModified(); } catch (IOException e) { return 0; } } }
copyResourceFromJar("percentagesorttype.js", jsOutputDir);
copyResourceFromJar("customsorttypes.js", jsOutputDir);
public static void copy(File destinationDir) throws IOException { File cssOutputDir = new File(destinationDir, "css"); File imagesOutputDir = new File(destinationDir, "images"); File jsOutputDir = new File(destinationDir, "js"); destinationDir.mkdirs(); cssOutputDir.mkdir(); imagesOutputDir.mkdir(); jsOutputDir.mkdir(); copyResourceFromJar("help.css", cssOutputDir); copyResourceFromJar("main.css", cssOutputDir); copyResourceFromJar("sortabletable.css", cssOutputDir); copyResourceFromJar("source-viewer.css", cssOutputDir); copyResourceFromJar("tooltip.css", cssOutputDir); copyResourceFromJar("blank.png", imagesOutputDir); copyResourceFromJar("downsimple.png", imagesOutputDir); copyResourceFromJar("upsimple.png", imagesOutputDir); //copyResourceFromJar("numberksorttype.js", jsOutputDir); copyResourceFromJar("percentagesorttype.js", jsOutputDir); copyResourceFromJar("popup.js", jsOutputDir); copyResourceFromJar("sortabletable.js", jsOutputDir); copyResourceFromJar("stringbuilder.js", jsOutputDir); //copyResourceFromJar("uscurrencysorttype.js", jsOutputDir); copyResourceFromJar("help.html", destinationDir); copyResourceFromJar("index.html", destinationDir); }
if (files.isEmpty()) { logger.warn("Cannot find files to compute CCN, file=" + file.getAbsolutePath() + ", recursive=" + recursive); return 0; }
public static double getCCN(File file, boolean recursive) { int ccnAccumulator = 0; Vector files = getListOfFiles(file, recursive); Javancss javancss = new Javancss(files); List functionMetrics = javancss.getFunctionMetrics(); if (functionMetrics.size() <= 0) return 0; Iterator iter = functionMetrics.iterator(); while (iter.hasNext()) { Vector functionMetric = (Vector)iter.next(); ccnAccumulator += ((Integer)functionMetric .elementAt(JavancssConstants.FCT_CCN)).intValue(); } return (double)ccnAccumulator / functionMetrics.size(); }
File[] files = file.listFiles(new FileFilter() { public boolean accept(File pathname) { return pathname.getAbsolutePath().endsWith(".java"); }
File[] files = file.listFiles(new FileFilter() { public boolean accept(File pathname) { return pathname.isDirectory() || pathname.getAbsolutePath().endsWith(".java"); }
private static Vector getListOfFiles(File file, boolean recursive) { Vector ret = new Vector(); if (file.isFile()) { ret.add(file.getAbsolutePath()); } else if (file.isDirectory()) { File[] files = file.listFiles(new FileFilter() { public boolean accept(File pathname) { return pathname.getAbsolutePath().endsWith(".java"); } }); for (int i = 0; i < files.length; i++) { if (recursive) { ret.addAll(getListOfFiles(files[i], true)); } else { if (files[i].isFile()) { ret.add(files[i].getAbsolutePath()); } } } } return ret; }
public boolean accept(File pathname) { return pathname.getAbsolutePath().endsWith(".java"); }
public boolean accept(File pathname) { return pathname.isDirectory() || pathname.getAbsolutePath().endsWith(".java"); }
public boolean accept(File pathname) { return pathname.getAbsolutePath().endsWith(".java"); }
throw new UnsatisfiedConditionsException("Unsatisfied start conditions", serviceName, conditions);
throw new UnsatisfiedConditionsException("Unsatisfied stop conditions", serviceName, conditions);
public boolean waitForUnsatisfiedConditions(ServiceName serviceName, Set conditions) throws UnsatisfiedConditionsException { throw new UnsatisfiedConditionsException("Unsatisfied start conditions", serviceName, conditions); }