Example usage for com.google.gwt.user.rebind SourceWriter indent

List of usage examples for com.google.gwt.user.rebind SourceWriter indent

Introduction

In this page you can find the example usage for com.google.gwt.user.rebind SourceWriter indent.

Prototype

void indent();

Source Link

Usage

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  .  j  a va  2s .  co 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();

    sourceWriter.println("if(\"soaservice\".equals(perspectiveType)) {");
    sourceWriter.indent();//from w w  w. j  av a  2s  .  co m
    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();
    sourceWriter.println("String title;");
    sourceWriter.println("ImageResource image;");

    sourceWriter.println("if(\"soaservice\".equals(perspectiveType)) {");
    sourceWriter.indent();/*from w  w  w.ja v  a 2s .c  o m*/
    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();
    sourceWriter.println("String title;");
    sourceWriter.println("ImageResource image;");

    sourceWriter.println("if(\"soaservice\".equals(perspectiveType)) {");
    sourceWriter.indent();/*ww  w.  j  a  va2 s  . co  m*/
    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(/*w  w w  .  j  a v  a2s .  co 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(/*from w  ww  .  j av a 2s . 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  w w .ja v  a2s .  co m*/
            "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 constructor with dependencies added into field
 *
 * @param className/* ww w  .  j a va 2  s  . 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/*from  w w w  .  ja  v  a2  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("}");
}

From source file:org.example.modular_mvp.base.rebind.ExtensionManagerGenerator.java

License:Open Source License

private void generateClass(TreeLogger logger, GeneratorContext context, String packageName, String className,
        List<ExtensionDefinition> extensions) {
    PrintWriter pw = context.tryCreate(logger, packageName, className);
    if (pw == null) {
        return;//  w  ww .  java  2 s . c o  m
    }

    ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(packageName, className);

    // imports
    composerFactory.addImport(ArrayList.class.getCanonicalName());
    composerFactory.addImport(List.class.getCanonicalName());
    composerFactory.addImport(ExtensionDefinition.class.getCanonicalName());
    composerFactory.addImport(ExtensionManager.class.getCanonicalName());

    // interface
    composerFactory.addImplementedInterface(ExtensionManager.class.getCanonicalName());

    SourceWriter sw = composerFactory.createSourceWriter(context, pw);

    // begin class definition
    sw.indent();

    // fields
    sw.println("private final List<NavigatorItem> items = new ArrayList<NavigatorItem>();");

    // constructor
    sw.println("public " + className + "() {");
    sw.indent();
    for (ExtensionDefinition extension : extensions) {
        for (ExtensionDefinition.NavigatorItem item : extension.value()) {
            sw.println("items.add(new NavigatorItem(\"%s\", \"%s\"));", escape(item.name()),
                    escape(item.token()));
        }
    }
    sw.outdent();
    sw.println("}");

    // methods
    // getNavigatorItems
    sw.println("public List<NavigatorItem> getNavigatorItems() {");
    sw.indentln("return items;");
    sw.println("}");

    // close it out
    sw.outdent();
    sw.println("}");

    context.commit(logger, pw);
}