Example usage for java.util LinkedHashSet add

List of usage examples for java.util LinkedHashSet add

Introduction

In this page you can find the example usage for java.util LinkedHashSet add.

Prototype

boolean add(E e);

Source Link

Document

Adds the specified element to this set if it is not already present (optional operation).

Usage

From source file:org.jsweet.transpiler.Java2TypeScriptTranslator.java

private int initAnonymousClass(JCNewClass newClass) {
    int anonymousClassIndex = getScope().anonymousClasses.indexOf(newClass.def);
    if (anonymousClassIndex == -1) {
        anonymousClassIndex = getScope().anonymousClasses.size();
        getScope().anonymousClasses.add(newClass.def);
        getScope().anonymousClassesConstructors.add(newClass);
        LinkedHashSet<VarSymbol> finalVars = new LinkedHashSet<>();
        getScope().finalVariables.add(finalVars);
        new TreeScanner() {
            public void visitIdent(JCIdent var) {
                if (var.sym != null && (var.sym instanceof VarSymbol)) {
                    VarSymbol varSymbol = (VarSymbol) var.sym;
                    if (varSymbol.getEnclosingElement() instanceof MethodSymbol && varSymbol
                            .getEnclosingElement().getEnclosingElement() == getParent(JCClassDecl.class).sym) {
                        finalVars.add((VarSymbol) var.sym);
                    }//from w ww.  j a  v  a 2  s . c  om
                }
            }
        }.visitClassDef(newClass.def);

    }
    return anonymousClassIndex;
}

From source file:com.ah.ui.actions.BaseAction.java

protected void updateTableView() throws Exception {
    log.info("updateTableView", "saving columns for table: " + tableId + ", " + selectedColumnIds);
    LinkedHashSet<HmTableColumn> columns = new LinkedHashSet<HmTableColumn>();
    HmUser hmUser = QueryUtil.findBoById(HmUser.class, getUserContext().getId(), new ImplQueryBo());
    if (hmUser == null)
        hmUser = getUserContext();/*from  w  ww .  j  a  v  a  2s .  com*/
    if (selectedColumnIds != null) {
        // key column should not be unselected
        if (keyColumnId != NO_KEY_COLUMN && !selectedColumnIds.contains(Integer.valueOf(keyColumnId))) {
            selectedColumnIds.add(0, keyColumnId);
            addActionMessage(MgrUtil.getUserMessage(KEY_COLUMN_UNSELECTED));
        }

        int i = 0;
        for (Integer columnId : selectedColumnIds) {
            HmTableColumn column = new HmTableColumn(columnId);
            column.setTableId(tableId);
            column.setUseremail(hmUser == null ? "null_value" : hmUser.getEmailAddress());
            column.setPosition(i++);
            columns.add(column);
        }
    }

    List<HmTableColumn> oldColumns = getUserContext().getTableViews().get(tableId);
    if (hmUser != null && !HAUtil.isSlave()) {
        if (oldColumns != null) {
            hmUser.removeTableColumns(tableId);
            hmUser.getTableColumns().removeAll(oldColumns);
        }
        hmUser.getTableColumns().addAll(columns);
        hmUser.addTableColumns(new ArrayList<HmTableColumn>(columns));
        //         hmUser = QueryUtil.updateBo(hmUser);
        getUserContext().setTableColumns(hmUser.getTableColumns());
    } else {
        if (oldColumns != null) {
            if (getUserContext().getTableColumns() != null) {
                getUserContext().getTableColumns().removeAll(oldColumns);
            }
        }
        if (getUserContext().getTableColumns() != null) {
            getUserContext().getTableColumns().addAll(columns);
        } else {
            getUserContext().setTableColumns(new ArrayList<HmTableColumn>(columns));
        }
    }
    getUserContext().createTableViews();
}

From source file:org.pentaho.di.ui.spoon.Spoon.java

public void openFile(boolean importfile) {
    SpoonPerspective activePerspective = SpoonPerspectiveManager.getInstance().getActivePerspective();

    // In case the perspective wants to handle open/save itself, let it...
    ////ww w  .  j a  v  a  2  s  .  com
    if (!importfile) {
        if (activePerspective instanceof SpoonPerspectiveOpenSaveInterface) {
            ((SpoonPerspectiveOpenSaveInterface) activePerspective).open();
            return;
        }
    }

    String activePerspectiveId = activePerspective.getId();
    boolean etlPerspective = activePerspectiveId.equals(MainSpoonPerspective.ID);

    if (rep == null || importfile || !etlPerspective) { // Load from XML

        FileDialog dialog = new FileDialog(shell, SWT.OPEN);

        LinkedHashSet<String> extensions = new LinkedHashSet<String>();
        LinkedHashSet<String> extensionNames = new LinkedHashSet<String>();
        StringBuilder allExtensions = new StringBuilder();
        for (FileListener l : fileListeners) {
            for (String ext : l.getSupportedExtensions()) {
                extensions.add("*." + ext);
                allExtensions.append("*.").append(ext).append(";");
            }
            Collections.addAll(extensionNames, l.getFileTypeDisplayNames(Locale.getDefault()));
        }
        extensions.add("*");
        extensionNames.add(BaseMessages.getString(PKG, "Spoon.Dialog.OpenFile.AllFiles"));

        String[] exts = new String[extensions.size() + 1];
        exts[0] = allExtensions.toString();
        System.arraycopy(extensions.toArray(new String[extensions.size()]), 0, exts, 1, extensions.size());

        String[] extNames = new String[extensionNames.size() + 1];
        extNames[0] = BaseMessages.getString(PKG, "Spoon.Dialog.OpenFile.AllTypes");
        System.arraycopy(extensionNames.toArray(new String[extensionNames.size()]), 0, extNames, 1,
                extensionNames.size());

        dialog.setFilterExtensions(exts);

        setFilterPath(dialog);
        String filename = dialog.open();
        if (filename != null) {

            if (importfile) {
                if (activePerspective instanceof SpoonPerspectiveOpenSaveInterface) {
                    ((SpoonPerspectiveOpenSaveInterface) activePerspective).importFile(filename);
                    return;
                }
            }

            lastDirOpened = dialog.getFilterPath();
            openFile(filename, importfile);
        }
    } else {
        SelectObjectDialog sod = new SelectObjectDialog(shell, rep);
        if (sod.open() != null) {
            RepositoryObjectType type = sod.getObjectType();
            String name = sod.getObjectName();
            RepositoryDirectoryInterface repDir = sod.getDirectory();

            // Load a transformation
            if (RepositoryObjectType.TRANSFORMATION.equals(type)) {
                TransLoadProgressDialog tlpd = new TransLoadProgressDialog(shell, rep, name, repDir, null); // Loads
                // the
                // last
                // version
                TransMeta transMeta = tlpd.open();
                sharedObjectsFileMap.put(transMeta.getSharedObjects().getFilename(),
                        transMeta.getSharedObjects());
                setTransMetaVariables(transMeta);

                if (transMeta != null) {
                    if (log.isDetailed()) {
                        log.logDetailed(BaseMessages.getString(PKG, "Spoon.Log.LoadToTransformation", name,
                                repDir.getName()));
                    }
                    props.addLastFile(LastUsedFile.FILE_TYPE_TRANSFORMATION, name, repDir.getPath(), true,
                            rep.getName());
                    addMenuLast();
                    transMeta.clearChanged();
                    // transMeta.setFilename(name); // Don't do it, it's a bad idea!
                    addTransGraph(transMeta);
                }
                refreshGraph();
                refreshTree();
            } else if (RepositoryObjectType.JOB.equals(type)) {
                // Load a job
                JobLoadProgressDialog jlpd = new JobLoadProgressDialog(shell, rep, name, repDir, null); // Loads
                // the last version
                JobMeta jobMeta = jlpd.open();
                sharedObjectsFileMap.put(jobMeta.getSharedObjects().getFilename(), jobMeta.getSharedObjects());
                setJobMetaVariables(jobMeta);
                if (jobMeta != null) {
                    props.addLastFile(LastUsedFile.FILE_TYPE_JOB, name, repDir.getPath(), true, rep.getName());
                    saveSettings();
                    addMenuLast();
                    addJobGraph(jobMeta);
                }
                refreshGraph();
                refreshTree();
            }
        }
    }
}

From source file:org.sakaiproject.content.impl.BaseContentService.java

/**
 * {@inheritDoc}// www  .  java 2s. c o m
 * @see org.sakaiproject.content.api.ContentHostingService#getRoleViews(String)
 */
public Set<String> getRoleViews(final String id) {
    String ref = getReference(id);
    LinkedHashSet<String> roleIds = new LinkedHashSet<String>();
    AuthzGroup realm = null;

    try {
        realm = m_authzGroupService.getAuthzGroup(ref);
    } catch (GroupNotDefinedException e) {
        // if there is no authz group then no roles can have been defined.
        return roleIds;
    }

    Set<Role> roles = realm.getRoles();
    for (Role role : roles) {
        if (role.isAllowed(AUTH_RESOURCE_READ)) {
            roleIds.add(role.getId());
        }
    }

    return roleIds;
}