Package pl.net.bluesoft.rnd.util.i18n

Examples of pl.net.bluesoft.rnd.util.i18n.I18NSource$ThreadUtil


        super.handleRenderRequest(renderRequest, response, window);
      }
    }
    else if (portletMode.equals(PortletMode.EDIT)) {
      locale = renderRequest.getLocale();
      I18NSource i18NSource = I18NSourceFactory.createI18NSource(locale);
      final GenericUserPortletSettingsPanel editPane = new GenericUserPortletSettingsPanel(
          i18NSource, getSelectedViewKeys(), getRegisteredViews());
      editPane.addListener(new GenericUserPortletSettingsPanel.SaveListener() {
        @Override
        public void onSave() {
View Full Code Here


        initComponent();
        initLayout();
    }

    private void initComponent() {
        I18NSource messages = I18NSource.ThreadUtil.getThreadI18nSource();

        privilegeDescriptionLabel = new Label(getDescription(permissionDefinition));
        privilegeDescriptionLabel.setContentMode(Label.CONTENT_XHTML); // TODO don't use XHTML switch to style names

        roleNameDescriptionLabel = new Label(messages.getMessage("permission.editor.assigned.roles"));

        roleNameComboBox = new RoleNameComboBox();
        roleNameComboBox.setHandler(this);

        roleNameLayout = new CssLayout() {
View Full Code Here

    }

  public static Map<BundleItem, Collection<WidgetItem>> loadAvailableWidgets(Application application)
            throws ClassNotFoundException {
    ProcessToolRegistry reg = GenericEditorApplication.getRegistry();
        I18NSource i18NSource = I18NSource.ThreadUtil.getThreadI18nSource();

    Map<BundleItem, Collection<WidgetItem>> availableWidgets = new HashMap<BundleItem, Collection<WidgetItem>>();

        Map<String, Class<? extends ProcessToolWidget>> registeredWidgets = reg.getAvailableWidgets();
        if (registeredWidgets == null || registeredWidgets.size() == 0) {
            return  availableWidgets;
        }

        // Widgets are available in registry by both @AliasName and their class name
        // we don't want to present each step twice so we exclude duplicates. Do note
        // that java.lang.Class does not override hashCode() and equals() so we use it's name
        Map<String, Class<? extends ProcessToolWidget>> viewableWidgets = new HashMap<String, Class<? extends ProcessToolWidget>>();
        for (Class<? extends ProcessToolWidget> widgetClass : registeredWidgets.values()) {
            viewableWidgets.put(widgetClass.getName(), widgetClass);
        }

        // Create sorted structure of widgets by processing their annotations
        Map<String, List<Class<? extends ProcessToolWidget>>> sortedWidgets = new HashMap<String, List<Class<? extends ProcessToolWidget>>>();
        for (Class<? extends ProcessToolWidget> widgetClass : viewableWidgets.values()) {
            String widgetGroupName = "unsorted";
           
            WidgetGroup widgetGroup = Classes.getClassAnnotation(widgetClass, WidgetGroup.class);
            if (widgetGroup != null) {
                widgetGroupName = widgetGroup.value();
            }

            List<Class<? extends ProcessToolWidget>> widgetGroupItems = sortedWidgets.get(widgetGroupName);
            if (widgetGroupItems == null) {
                widgetGroupItems = new ArrayList<Class<? extends ProcessToolWidget>>();
                sortedWidgets.put(widgetGroupName, widgetGroupItems);
            }

            widgetGroupItems.add(widgetClass);
        }

        // Process the sorted structure to final form
    for (Map.Entry<String, List<Class<? extends ProcessToolWidget>>> e : sortedWidgets.entrySet()) {
      String bundleName = e.getKey();
            String bundleDescriptionKey = BUNDLE_DESC_PREFIX + bundleName;

            BundleItem bundleItem = new BundleItem(
                    bundleName,
                    i18NSource.getMessage(bundleDescriptionKey),
                    new ArrayList<I18NProvider>(),
                    new ArrayList<URL>()
            );

           
View Full Code Here

    private WidgetItemInStep widget;

    // TODO this class and method needs a a major rework
  public void loadWidget(final WidgetItemInStep widget, boolean reloadProperties) {
        this.widget = widget;
        I18NSource messages = I18NSource.ThreadUtil.getThreadI18nSource();
    removeAllComponents();
        setStyleName(Reindeer.PANEL_LIGHT);
    if (widget == null) {
        setCaption("");
        return;
        }
        VerticalLayout layout = (VerticalLayout) getContent();
    layout.addComponent(new Label(widget.getWidgetItem().getDescription()));       
    if ((widget.getProperties() == null || widget.getProperties().size() == 0) && (widget.getPermissions() == null || widget.getPermissions().size() == 0)) {
      layout.addComponent(new Label(messages.getMessage("form.no.parameters.defined")));
    } else {
            TabSheet ts = new TabSheet();
            ts.setWidth("100%");
            if (widget.hasProperties()) {
                if (reloadProperties) {
                    PropertiesPanel propertiesPanel = new PropertiesPanel();
                    propertiesPanel.init(widget.getWidgetItem().getClassInfo());
                    propertiesPanel.refreshForm(false, widget.getProperties());
                    widget.setWidgetPropertiesPanel(propertiesPanel);
                }
                ts.addTab(widget.getWidgetPropertiesPanel(), messages.getMessage("form.properties"));
            }
            if (widget.hasPermissions()) {
                PermissionEditor permissionEditor = new PermissionEditor();
                permissionEditor.setMargin(true);
                permissionEditor.setProvider(new PermissionProvider() {
                    @Override
                    public Collection<Permission> getPermissions() {
                        return new LinkedHashSet<Permission>(widget.getPermissions());
                    }

                    @Override
                    public Collection<PermissionDefinition> getPermissionDefinitions() {
                        return widget.getPermissionDefinitions();
                    }

                    @Override
                    public boolean isNewPermissionDefinitionAllowed() {
                        return false;
                    }

                    @Override
                    public void addPermission(Permission permission) {
                        Set<Permission> newPermissions = new LinkedHashSet<Permission>(widget.getPermissions());
                        newPermissions.add(permission);
                        widget.setPermissions(new ArrayList<Permission>(newPermissions));
                    }

                    @Override
                    public void removePermission(Permission permission) {
                        Set<Permission> newPermissions = new LinkedHashSet<Permission>(widget.getPermissions());
                        newPermissions.remove(permission);
                        widget.setPermissions(new ArrayList<Permission>(newPermissions));
                    }
                });
                permissionEditor.loadData();
                ts.addTab(permissionEditor, messages.getMessage("form.permissions"));

            }
            layout.addComponent(ts);
    }
  }
View Full Code Here

    public AutoStepEditorWindow(StepEditorApplication application, String jsonConfig, String url, String stepName, String stepType) {
    super(application, jsonConfig, url, stepName, stepType);
  }

  public ComponentContainer init() {
    I18NSource messages = I18NSource.ThreadUtil.getThreadI18nSource();

        VerticalLayout vll = new VerticalLayout();
    vll.setWidth(100, Sizeable.UNITS_PERCENTAGE);
        vll.addComponent(new Label(messages.getMessage("jse.instructions"), Label.CONTENT_XHTML));
    vll.setSpacing(true);

    if (stepType != null) {
            propertiesPanel = new PropertiesPanel();

            Class<?> stepClass = getStepClass(stepType);
        propertiesPanel.init(stepClass);
        propertiesPanel.refreshForm(false, getLoadedJsonData(jsonConfig));

            stepTypeLabel = styled(new Label(propertiesPanel.getClassInfo().getDocName()), "h2");
           
            tabSheet = new TabSheet();
            tabSheet.addTab(propertiesPanel, messages.getMessage("form.properties"));

            vll.addComponent(stepTypeLabel);
            vll.addComponent(tabSheet);
    }
      
View Full Code Here

      
    return vll;
  }
   
  private Map<String,Object> getLoadedJsonData(String jsonConfig) {
    I18NSource messages = I18NSource.ThreadUtil.getThreadI18nSource();
    if (StringUtils.isEmpty(jsonConfig))
      return new HashMap<String,Object>();
    try {
            Map<String,Object> propertiesMap =  mapper.readValue(
                    jsonConfig,
                    new TypeReference<HashMap<String, Object>>() {}
            );
            // decode base64 and drop empty properties
            if (propertiesMap != null && !propertiesMap.isEmpty()) {
        Iterator<Map.Entry<String, Object>> it = propertiesMap.entrySet().iterator();
                while (it.hasNext()) {
          Map.Entry<String, Object> e = it.next();
          String propertyName = e.getKey();
                    Object encodedValue = e.getValue();
                    if (encodedValue == null) {
                        it.remove();
                        continue;
                    }

                    if (encodedValue instanceof String) {
                        if (encodedValue.toString().trim().isEmpty()) {
                            it.remove();
                            continue;
                        }
                        byte[] decoded = Base64.decodeBase64(encodedValue.toString().getBytes());
                        propertiesMap.put(propertyName, new String(decoded));
                    }
                }
            }
            return propertiesMap;
    } catch (JsonMappingException e) {
      logger.log(Level.SEVERE, "Error parsing JSON data", e);
    } catch (JsonGenerationException e) {
      logger.log(Level.SEVERE, "Error parsing JSON data", e);
    } catch (IOException e) {
      logger.log(Level.SEVERE, "Error parsing JSON data", e);
    }
    application.getMainWindow().showNotification(messages.getMessage("jse.error.read"));
    return null;
  }
View Full Code Here

                    propertiesMap.put(propertyName, encodedValue);
                }
            }
        }

    I18NSource messages = I18NSource.ThreadUtil.getThreadI18nSource();
    TaskConfig tc = new TaskConfig();
    tc.setTaskName(propertiesPanel.getClassInfo().getAliasName());
    tc.setParams(propertiesMap);
   
    try {
      return mapper.writeValueAsString(tc);
    } catch (JsonMappingException e) {
      logger.log(Level.SEVERE, "Error creating JSON", e);
    } catch (JsonGenerationException e) {
      logger.log(Level.SEVERE, "Error creating JSON", e);
    } catch (IOException e) {
      logger.log(Level.SEVERE, "Error creating JSON", e);
    }
    application.getMainWindow().showNotification(messages.getMessage("jse.error.write"));
    return "";
   
  }
View Full Code Here

            field.setCaption(createCaptionByPropertyId(property.getPropertyId()));
        } else {
            field.setCaption(property.getName());
        }

        I18NSource messages = I18NSource.ThreadUtil.getThreadI18nSource();
        if (property.getDescription() == null) {
            field.setDescription(messages.getMessage(
                    "property.field.description.short.format",
                    new Object[] { property.getPropertyId() }
            ));
        } else {
            field.setDescription(messages.getMessage(
                    "property.field.description.format",
                    new Object[] { property.getDescription(), property.getPropertyId() }
            ));
        }
View Full Code Here

        initComponent();
        initLayout();
    }

    private void initComponent() {
        final I18NSource messages = I18NSource.ThreadUtil.getThreadI18nSource();

        queueDescriptionLabel = new Label(messages.getMessage("queue.editor.description"));

        addQueueNameField = new TextField();
        addQueueNameField.setNullRepresentation("");
        addQueueNameField.setInputPrompt(messages.getMessage("queue.editor.name.prompt"));

        addQueueButton = VaadinUtility.button(messages.getMessage("queue.editor.add"), new Runnable() {
            @Override
            public void run() {
                String queueName = (String) addQueueNameField.getValue();
                if (queueName == null || queueName.trim().isEmpty()) {
                    getApplication().getMainWindow().showNotification(
                            messages.getMessage("queue.new.no.name"),
                            Window.Notification.TYPE_TRAY_NOTIFICATION
                    );
                    return;
                }
View Full Code Here

   
    return comp;
  }
 
  private ComponentContainer buildLayout() {
    I18NSource messages = I18NSource.ThreadUtil.getThreadI18nSource();
        prepareAvailableWidgetsComponent();
       
    stepTree = new Tree(messages.getMessage("stepTree.title"), getCurrentStep());
        stepTree.setItemCaptionMode(Tree.ITEM_CAPTION_MODE_PROPERTY);
        stepTree.setItemCaptionPropertyId("name");
    stepTree.setDragMode(TreeDragMode.NODE);
    stepTree.addActionHandler(this);
        stepTree.addListener(this);
    stepTree.setSelectable(true);
    stepTree.setImmediate(true);
        stepTree.setItemDescriptionGenerator(new PropertiesDescriptionGenerator());
        stepTree.expandItemsRecursively(rootItem);
    stepTree.setDropHandler(new TreeDropHandler(stepTree, stepTreeContainer));

        paramPanel = new WidgetFormWindow();

        permissionEditor = new PermissionEditor();
        permissionEditor.setMargin(true);
        permissionEditor.setProvider(new PermissionProvider() {
            @Override
            public Collection<Permission> getPermissions() {
                return permissions;
            }

            @Override
            public Collection<PermissionDefinition> getPermissionDefinitions() {
                PermissionDefinition perm1 = new PermissionDefinition();
                perm1.setKey("SEARCH");
                perm1.setDescription("editor.permissions.description.step.SEARCH");
                return Arrays.asList(perm1);
            }

            @Override
            public boolean isNewPermissionDefinitionAllowed() {
                return false;
            }

            @Override
            public void addPermission(Permission permission) {
                permissions.add(permission);
            }

            @Override
            public void removePermission(Permission permission) {
                permissions.remove(permission);
            }
        });

        VerticalLayout assignmentLayout = prepareAssignmentLayout();
        VerticalLayout stepDefinitionLayout = buildStateDefinitionLayout();
        VerticalLayout stepLayout = buildWidgetEditorTabContent();

        VerticalLayout vl = new VerticalLayout();
        vl.setSizeFull();
        vl.setSpacing(true);
        vl.addComponent(new Label(messages.getMessage("userstep.editor.instructions"), Label.CONTENT_XHTML));

        TabSheet ts = new TabSheet();
        ts.setSizeFull();
        ts.addTab(stepLayout, messages.getMessage("userstep.editor.widgets.tabcaption"));
        ts.addTab(stepDefinitionLayout, messages.getMessage("userstep.state.tabcaption"));
        ts.addTab(assignmentLayout, messages.getMessage("userstep.editor.assignment.tabcaption"));
        ts.addTab(permissionEditor, messages.getMessage("userstep.editor.permissions.tabcaption"));
        ts.setSelectedTab(stepLayout);
        vl.addComponent(ts);
        vl.setExpandRatio(ts, 1.0f);
        return vl;
View Full Code Here

TOP

Related Classes of pl.net.bluesoft.rnd.util.i18n.I18NSource$ThreadUtil

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.