List of usage examples for com.google.gwt.user.rebind SourceWriter outdent
void outdent();
From source file:org.drools.guvnor.gwtutil.PerspectiveFactoryGenerator.java
License:Apache License
private void generateGetModuleEditorMethod(SourceWriter sourceWriter, Map<String, List<ModuleEditorConfiguration>> registeredEditors) { sourceWriter.println(// ww w. jav a 2 s . c o m "public AbstractModuleEditor getModuleEditor(Module module, ClientFactory clientFactory, EventBus eventBus, boolean isHistoryReadOnly, Command refreshCommand) {"); sourceWriter.indent(); for (List<ModuleEditorConfiguration> moduleEditorConfigurations : registeredEditors.values()) { for (ModuleEditorConfiguration moduleEditorConfiguration : moduleEditorConfigurations) { String format = moduleEditorConfiguration.getFormat(); String editorClassName = moduleEditorConfiguration.getEditorClass(); sourceWriter.println("if(module.getFormat().equals(\"" + format + "\")) {"); sourceWriter.indent(); sourceWriter.println("return new " + editorClassName + "(module, clientFactory, eventBus, isHistoryReadOnly, refreshCommand);"); sourceWriter.outdent(); sourceWriter.println("}"); } } sourceWriter.println("return null;"); sourceWriter.outdent(); sourceWriter.println("}"); }
From source file:org.drools.guvnor.gwtutil.PerspectiveFactoryGenerator.java
License:Apache License
private void generateGetPerspectiveMethod(SourceWriter sourceWriter, Map<String, List<ModuleEditorConfiguration>> registeredEditors) { sourceWriter.println("public Perspective getPerspective(String perspectiveType) {"); sourceWriter.indent();/*from w w w. j a va 2 s. c o m*/ sourceWriter.println("if(\"soaservice\".equals(perspectiveType)) {"); sourceWriter.indent(); sourceWriter.println("return new org.drools.guvnor.client.perspective.soa.SOAPerspective();"); sourceWriter.outdent(); sourceWriter.println("}"); sourceWriter.println("return null;"); sourceWriter.outdent(); sourceWriter.println("}"); }
From source file:org.drools.guvnor.gwtutil.PerspectiveFactoryGenerator.java
License:Apache License
private void generateGetModulesHeaderViewMethod(SourceWriter sourceWriter, Map<String, List<ModuleEditorConfiguration>> registeredEditors) { sourceWriter.println("public IsWidget getModulesHeaderView(String perspectiveType) {"); sourceWriter.indent();// w w w . j a v a 2 s . c o m sourceWriter.println("String title;"); sourceWriter.println("ImageResource image;"); sourceWriter.println("if(\"soaservice\".equals(perspectiveType)) {"); sourceWriter.indent(); sourceWriter.println("title = \"Services\";"); sourceWriter.println("image = images.packages();"); sourceWriter.outdent(); sourceWriter.println("}"); sourceWriter.println("title = \"Services\";"); sourceWriter.println("image = images.packages();"); sourceWriter.println("StackItemHeaderViewImpl view = new StackItemHeaderViewImpl();"); sourceWriter.println("StackItemHeader header = new StackItemHeader( view );"); sourceWriter.println("header.setName( title );"); sourceWriter.println("header.setImageResource( image );"); sourceWriter.println("return view;"); sourceWriter.outdent(); sourceWriter.println("}"); }
From source file:org.drools.guvnor.gwtutil.PerspectiveFactoryGenerator.java
License:Apache License
private void generateGetModulesTreeRootNodeHeaderMethod(SourceWriter sourceWriter, Map<String, List<ModuleEditorConfiguration>> registeredEditors) { sourceWriter.println("public SafeHtml getModulesTreeRootNodeHeader(String perspectiveType) {"); sourceWriter.indent();//from w w w .ja v a 2s .c om sourceWriter.println("String title;"); sourceWriter.println("ImageResource image;"); sourceWriter.println("if(\"soaservice\".equals(perspectiveType)) {"); sourceWriter.indent(); sourceWriter.println("title = \"Services\";"); sourceWriter.println("image = images.chartOrganisation();"); sourceWriter.outdent(); sourceWriter.println("}"); sourceWriter.println("title = \"Services\";"); sourceWriter.println("image = images.packages();"); sourceWriter.println("return Util.getHeader( image, title );"); sourceWriter.outdent(); sourceWriter.println("}"); }
From source file:org.drools.guvnor.gwtutil.PerspectiveFactoryGenerator.java
License:Apache License
private void generateGetModulesNewAssetMenuMethod(SourceWriter sourceWriter, Map<String, List<ModuleEditorConfiguration>> registeredEditors) { sourceWriter.println(/*from w ww . j a v a 2 s .c o m*/ "public Widget getModulesNewAssetMenu(String perspectiveType, ClientFactory clientFactory, EventBus eventBus) {"); sourceWriter.indent(); sourceWriter.println("if(\"soaservice\".equals(perspectiveType)) {"); sourceWriter.indent(); sourceWriter.println( "return (new org.drools.guvnor.client.asseteditor.soa.SOAServicesNewAssetMenu( clientFactory, eventBus )).asWidget();"); sourceWriter.outdent(); sourceWriter.println("}"); sourceWriter.println( "return (new org.drools.guvnor.client.asseteditor.soa.SOAServicesNewAssetMenu( clientFactory, eventBus )).asWidget();"); sourceWriter.outdent(); sourceWriter.println("}"); }
From source file:org.drools.guvnor.gwtutil.PerspectiveFactoryGenerator.java
License:Apache License
private void generateGetModuleEditorActionToolbarMethod(SourceWriter sourceWriter, Map<String, List<ModuleEditorConfiguration>> registeredEditors) { sourceWriter.println(// ww w . j a va2 s .c om "public Widget getModuleEditorActionToolbar(Module data, ClientFactory clientFactory, EventBus eventBus, boolean readOnly, Command refreshCommand) {"); sourceWriter.indent(); sourceWriter.println("if(\"soaservice\".equals(data.getFormat())) {"); sourceWriter.indent(); sourceWriter.println( "return new org.drools.guvnor.client.widgets.soa.toolbar.PackageEditorActionToolbar(data, clientFactory, eventBus, readOnly, refreshCommand);"); sourceWriter.outdent(); sourceWriter.println("}"); sourceWriter.println( "return new org.drools.guvnor.client.widgets.soa.toolbar.PackageEditorActionToolbar(data, clientFactory, eventBus, readOnly, refreshCommand);"); sourceWriter.outdent(); sourceWriter.println("}"); }
From source file:org.drools.guvnor.gwtutil.PerspectiveFactoryGenerator.java
License:Apache License
private void generateGetAssetEditorActionToolbarMethod(SourceWriter sourceWriter, Map<String, List<ModuleEditorConfiguration>> registeredEditors) { sourceWriter.println(/*from w ww. jav a2s. c om*/ "public Widget getAssetEditorActionToolbar(String perspectiveType, Asset asset, Widget editor, ClientFactory clientFactory, EventBus eventBus, boolean readOnly) {"); sourceWriter.indent(); sourceWriter.println("if(\"soaservice\".equals(perspectiveType)) {"); sourceWriter.indent(); sourceWriter.println( "return new org.drools.guvnor.client.widgets.soa.toolbar.AssetEditorActionToolbar(asset, editor, clientFactory, eventBus, readOnly);"); sourceWriter.outdent(); sourceWriter.println("}"); sourceWriter.println( "return new org.drools.guvnor.client.widgets.soa.toolbar.AssetEditorActionToolbar(asset, editor, clientFactory, eventBus, readOnly);"); sourceWriter.outdent(); sourceWriter.println("}"); }
From source file:org.eclipse.che.util.ExtensionRegistryGenerator.java
License:Open Source License
/** * Generate the content of the class//from w w w .ja va 2s . co m * * @param logger * @param context * @param packageName * @param className * @param extensions * @throws UnableToCompleteException */ private void generateClass(TreeLogger logger, GeneratorContext context, String packageName, String className, List<JClassType> extensions) throws UnableToCompleteException { PrintWriter pw = context.tryCreate(logger, packageName, className); if (pw == null) { return; } ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(packageName, className); // generate imports generateImports(extensions, composerFactory); // interface composerFactory.addImplementedInterface(ExtensionRegistry.class.getCanonicalName()); // get source writer SourceWriter sw = composerFactory.createSourceWriter(context, pw); // begin class definition // fields sw.println("private final Map<String, ExtensionDescription> extensions = new HashMap<>();"); generateConstructor(className, extensions, sw); // methods generateGetExtensionsMethod(sw); // close it out sw.outdent(); sw.println("}"); context.commit(logger, pw); }
From source file:org.eclipse.che.util.ExtensionRegistryGenerator.java
License:Open Source License
/** * Generate constructor with dependencies added into field * * @param className//from ww w. j a v a 2s . com * @param extensions * @param sw * @throws UnableToCompleteException */ private void generateConstructor(String className, List<JClassType> extensions, SourceWriter sw) throws UnableToCompleteException { // constructor sw.indent(); sw.print("public %s()", className); sw.println("{"); sw.indent(); { for (JClassType extension : extensions) { sw.println("{"); sw.indent(); /* Array<DependencyDescription> deps = Collections.<DependencyDescription> createArray(); */ generateDependenciesForExtension(sw, extension); Extension annotation = extension.getAnnotation(Extension.class); /* extensions.put("ide.ext.demo", new ExtensionDescription("ide.ext.demo", "1.0.0", "Demo extension", deps, demoExtProvider)); */ // the class's fqn String extensionId = extension.getQualifiedSourceName(); sw.println("extensions.put(\"%s\", new ExtensionDescription(\"%s\",\"%s\",\"%s\",\"%s\",deps));", escape(extensionId), escape(extensionId), escape(annotation.version()), escape(annotation.title()), escape(annotation.description())); sw.outdent(); sw.println("}"); } } sw.outdent(); sw.println("}"); }
From source file:org.eclipse.che.util.ExtensionRegistryGenerator.java
License:Open Source License
/** * Generate the code for {@link ExtensionRegistry#getExtensionDescriptions()} * * @param sw//ww w . j ava 2 s. c o m */ private void generateGetExtensionsMethod(SourceWriter sw) { /* @Override public StringMap<ExtensionDescription> getExtensionDescriptions() { return extensions; } */ sw.println("@Override"); sw.println("public Map<String, ExtensionDescription> getExtensionDescriptions()"); sw.println("{"); sw.indent(); sw.println("return extensions;"); sw.outdent(); sw.println("}"); }