Search in sources :

Example 6 with Instance

use of org.omegat.filters2.Instance in project omegat by omegat-org.

the class FilterEditor method removeButtonActionPerformed.

// </editor-fold>//GEN-END:initComponents
private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_removeButtonActionPerformed
    int row = instances.getSelectedRow();
    Files instance = filter.getFiles().get(row);
    if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(this, StringUtil.format(OStrings.getString("FILTEREDITOR_really_delete_filter_instance"), instance.getSourceFilenameMask()), OStrings.getString("FILTEREDITOR_Confirm_deletion_TITLE"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE)) {
        filter.getFiles().remove(row);
        instances.setModel(new OneFilterTableModel(filter));
    }
}
Also used : OneFilterTableModel(org.omegat.filters2.master.OneFilterTableModel) Files(gen.core.filters.Files)

Example 7 with Instance

use of org.omegat.filters2.Instance in project TOSCAna by StuPro-TOSCAna.

the class CloudFormationModule method build.

/**
 *     Build the template
 *     1. Add CFNInit to corresponding instance resource
 *     2. Check if EC2 instances need access to S3. If yes, then
 *     2a. Add necessary IAM resources to the module
 *     2b. Add <tt>Authentication<tt> and <tt>IamInstanceProfile<tt> to corresponding instance resource
 */
@Override
public void build() {
    for (Map.Entry<String, CFNInit> pair : cfnInitMap.entrySet()) {
        Resource res = this.getResource(pair.getKey());
        if (res instanceof Instance) {
            Instance instance = (Instance) res;
            if (!pair.getValue().getConfigs().isEmpty()) {
                instance.addCFNInit(pair.getValue()).userData(new UserData(getUserDataFn(pair.getKey(), CONFIG_SETS, this)));
            }
        }
    }
    if (!fileUploadList.isEmpty()) {
        Role instanceRole = getS3InstanceRole(this);
        getS3Policy(this).roles(instanceRole);
        getS3InstanceProfile(this).roles(instanceRole);
        Authentication s3authentication = getS3Authentication(bucketName);
        for (String instanceName : authenticationSet) {
            Resource res = this.getResource(instanceName);
            if (res instanceof Instance) {
                Instance instance = (Instance) res;
                instance.authentication(s3authentication).iamInstanceProfile(ref(INSTANCE_PROFILE));
            }
        }
    }
    if (this.hasKeyPair()) {
        strParam(KEYNAME).type(KEYNAME_TYPE).description(KEYNAME_DESCRIPTION).constraintDescription(KEYNAME_CONSTRAINT_DESCRIPTION);
    }
}
Also used : AuthenticationUtils.getS3InstanceRole(org.opentosca.toscana.plugins.cloudformation.util.AuthenticationUtils.getS3InstanceRole) Role(com.scaleset.cfbuilder.iam.Role) Instance(com.scaleset.cfbuilder.ec2.Instance) UserData(com.scaleset.cfbuilder.ec2.UserData) AuthenticationUtils.getS3Authentication(org.opentosca.toscana.plugins.cloudformation.util.AuthenticationUtils.getS3Authentication) Authentication(com.scaleset.cfbuilder.cloudformation.Authentication) Resource(com.scaleset.cfbuilder.core.Resource) CFNInit(com.scaleset.cfbuilder.ec2.metadata.CFNInit) HashMap(java.util.HashMap) Map(java.util.Map)

Example 8 with Instance

use of org.omegat.filters2.Instance in project omegat by omegat-org.

the class FilterMaster method getDefaultSettingsFromFilter.

/**
 * Create default filter's config.
 *
 * @param filterClassname
 *            filter's classname
 * @return default filter's config
 */
public static Filter getDefaultSettingsFromFilter(final String filterClassname) {
    IFilter f = getFilterInstance(filterClassname);
    if (f == null) {
        return null;
    }
    Filter fc = new Filter();
    fc.setClassName(f.getClass().getName());
    fc.setEnabled(true);
    for (Instance ins : f.getDefaultInstances()) {
        Files ff = new Files();
        ff.setSourceEncoding(ins.getSourceEncoding());
        ff.setSourceFilenameMask(ins.getSourceFilenameMask());
        ff.setTargetEncoding(ins.getTargetEncoding());
        ff.setTargetFilenamePattern(ins.getTargetFilenamePattern());
        fc.getFiles().add(ff);
    }
    return fc;
}
Also used : IFilter(org.omegat.filters2.IFilter) IFilter(org.omegat.filters2.IFilter) Filter(gen.core.filters.Filter) AbstractFilter(org.omegat.filters2.AbstractFilter) Instance(org.omegat.filters2.Instance) Files(gen.core.filters.Files)

Example 9 with Instance

use of org.omegat.filters2.Instance in project omegat by omegat-org.

the class FilterMaster method cloneConfig.

/**
 * Clone config for editing
 *
 * @return new config instance
 */
public static Filters cloneConfig(Filters orig) {
    Filters c = new Filters();
    c.setRemoveTags(orig.isRemoveTags());
    c.setRemoveSpacesNonseg(orig.isRemoveSpacesNonseg());
    c.setPreserveSpaces(orig.isPreserveSpaces());
    c.setIgnoreFileContext(orig.isIgnoreFileContext());
    for (Filter f : orig.getFilters()) {
        c.getFilters().add(cloneFilter(f));
    }
    return c;
}
Also used : Filters(gen.core.filters.Filters) IFilter(org.omegat.filters2.IFilter) Filter(gen.core.filters.Filter) AbstractFilter(org.omegat.filters2.AbstractFilter)

Aggregations

IFilter (org.omegat.filters2.IFilter)4 Instance (com.scaleset.cfbuilder.ec2.Instance)3 Files (gen.core.filters.Files)3 Filter (gen.core.filters.Filter)3 AbstractFilter (org.omegat.filters2.AbstractFilter)3 CFNInit (com.scaleset.cfbuilder.ec2.metadata.CFNInit)2 File (java.io.File)2 SdkClientException (com.amazonaws.SdkClientException)1 Authentication (com.scaleset.cfbuilder.cloudformation.Authentication)1 Resource (com.scaleset.cfbuilder.core.Resource)1 SecurityGroup (com.scaleset.cfbuilder.ec2.SecurityGroup)1 UserData (com.scaleset.cfbuilder.ec2.UserData)1 EC2BlockDeviceMapping (com.scaleset.cfbuilder.ec2.instance.EC2BlockDeviceMapping)1 EC2EBSBlockDevice (com.scaleset.cfbuilder.ec2.instance.ec2blockdevicemapping.EC2EBSBlockDevice)1 CFNCommand (com.scaleset.cfbuilder.ec2.metadata.CFNCommand)1 CFNPackage (com.scaleset.cfbuilder.ec2.metadata.CFNPackage)1 Role (com.scaleset.cfbuilder.iam.Role)1 DBInstance (com.scaleset.cfbuilder.rds.DBInstance)1 Option (gen.core.filters.Filter.Option)1 Filters (gen.core.filters.Filters)1