Example usage for java.util List indexOf

List of usage examples for java.util List indexOf

Introduction

In this page you can find the example usage for java.util List indexOf.

Prototype

int indexOf(Object o);

Source Link

Document

Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.

Usage

From source file:edu.cmu.tetrad.search.Mimbuild3.java

private TetradMatrix getCov(ICovarianceMatrix cov, List<Node> latents, Node[][] clusters) {
    if (latents.size() != clusters.length) {
        throw new IllegalArgumentException();
    }//from ww w. j  ava2  s.  c o m

    TetradMatrix measurescov = cov.getMatrix();

    TetradMatrix latentscov = new TetradMatrix(latents.size(), latents.size());

    for (int i = 0; i < latentscov.rows(); i++) {
        for (int j = i; j < latentscov.columns(); j++) {
            if (i == j)
                latentscov.set(i, j, 1.0);
            else {
                double v = RandomUtil.getInstance().nextDouble();
                latentscov.set(i, j, v);
                latentscov.set(j, i, v);
            }
        }
    }

    double[][] loadings = new double[clusters.length][];

    for (int i = 0; i < clusters.length; i++) {
        loadings[i] = new double[clusters[i].length];
    }

    for (int i = 0; i < clusters.length; i++) {
        loadings[i] = new double[clusters[i].length];

        for (int j = 0; j < clusters[i].length; j++) {
            loadings[i][j] = RandomUtil.getInstance().nextDouble() - .5;
        }
    }

    int[][] indicatorIndices = new int[clusters.length][];
    List<Node> vars = cov.getVariables();

    for (int i = 0; i < clusters.length; i++) {
        indicatorIndices[i] = new int[clusters[i].length];

        for (int j = 0; j < clusters[i].length; j++) {
            indicatorIndices[i][j] = vars.indexOf(clusters[i][j]);
        }
    }

    double[] delta = new double[measurescov.rows()];

    for (int i = 0; i < delta.length; i++) {
        delta[i] = 1;
    }

    int numParams = 0;

    for (int i = 0; i < latentscov.rows(); i++) {
        for (int j = i; j < latentscov.columns(); j++) {
            if (i == j && fixLatentVariances)
                continue;
            numParams++;
        }
    }

    for (int i = 0; i < clusters.length; i++) {
        numParams += clusters[i].length;
    }

    double[] values = new double[numParams];
    int count = 0;

    for (int i = 0; i < clusters.length; i++) {
        for (int j = i; j < clusters.length; j++) {
            if (i == j && fixLatentVariances)
                continue;
            values[count++] = latentscov.get(i, j);
        }
    }

    for (int i = 0; i < clusters.length; i++) {
        for (int j = 0; j < clusters[i].length; j++) {
            values[count++] = loadings[i][j];
        }
    }

    // First a fast search over the non-measured-varance parameters.
    Function1 function1 = new Function1(indicatorIndices, measurescov, loadings, latentscov, numParams);
    MultivariateMinimum search2 = new ConjugateGradientSearch();
    minimum = search2.findMinimum(function1, values, 8, 8);

    double[] values2 = new double[delta.length];
    int count2 = 0;

    for (int i = 0; i < delta.length; i++) {
        values2[count2++] = delta[i];
    }

    // Then a slower search for the measured-variance parameters from that starting point...
    Function2 function2 = new Function2(indicatorIndices, measurescov, loadings, latentscov, delta,
            delta.length);
    MultivariateMinimum search3 = new ConjugateGradientSearch();
    minimum = search3.findMinimum(function2, values2, 8, 8);

    double N = cov.getSampleSize();

    int p = 0;

    for (Node[] nodes : clusters) {
        p += nodes.length;
    }

    int df = (p) * (p + 1) / 2 - numParams;
    double x = (N - 1) * minimum;
    this.pValue = 1.0 - new ChiSquaredDistribution(df).cumulativeProbability(x);

    this.latentsCov = latentscov;
    return latentscov;
}

From source file:fm.smart.r1.activity.CreateItemActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ExceptionHandler.register(this);
    setContentView(R.layout.create_item);
    final Intent queryIntent = getIntent();
    Bundle extras = queryIntent.getExtras();
    list_id = (String) extras.get("list_id");
    cue = (String) extras.get("cue");
    response = (String) extras.get("response");
    cue_language = (String) extras.get("cue_language");
    response_language = (String) extras.get("response_language");
    character_cue = (String) extras.get("character_cue");
    character_response = (String) extras.get("character_response");
    pos = (String) extras.get("pos");

    Button button = (Button) findViewById(R.id.create_item_submit);
    button.setOnClickListener(this);

    TextView cue_text = (TextView) findViewById(R.id.cue);
    if (!TextUtils.isEmpty(cue)) {
        cue_text.setText(cue);/*from ww w  .j a  v  a 2s. c om*/
    }
    TextView response_text = (TextView) findViewById(R.id.response);
    if (!TextUtils.isEmpty(response)) {
        response_text.setText(response);
    }
    TextView cue_character_text = (TextView) findViewById(R.id.cue_character);
    if (!TextUtils.isEmpty(character_cue)) {
        cue_character_text.setText(character_cue);
    }
    TextView response_character_text = (TextView) findViewById(R.id.response_character);
    if (!TextUtils.isEmpty(character_response)) {
        response_character_text.setText(character_response);
    }

    TextView cue_legend = (TextView) findViewById(R.id.create_item_cue_legend);
    cue_legend.setText(Utils.INV_LANGUAGE_MAP.get(cue_language) + " Term");
    TextView response_legend = (TextView) findViewById(R.id.create_item_response_legend);
    response_legend.setText(Utils.INV_LANGUAGE_MAP.get(response_language) + " Term");
    TextView cue_character_textView = (TextView) findViewById(R.id.create_item_cue_character);
    cue_character_textView.setText(Utils.INV_LANGUAGE_MAP.get(cue_language) + " Character Text");
    TextView response_character_textView = (TextView) findViewById(R.id.create_item_response_character);
    response_character_textView.setText(Utils.INV_LANGUAGE_MAP.get(response_language) + " Character Text");

    List<String> pos_list = new Vector<String>(Utils.POS_MAP.keySet());
    Collections.sort(pos_list);

    ArrayAdapter<String> pos_adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
            pos_list);
    // .simple_spinner_item
    Spinner pos_textView = (Spinner) findViewById(R.id.pos);
    pos_textView.setAdapter(pos_adapter);
    if (!TextUtils.isEmpty(pos)) {
        pos_textView.setSelection(pos_list.indexOf(pos));
    } else {
        pos_textView.setSelection(pos_list.indexOf("Noun"));
    }

    EditText cue_character_input_textView = (EditText) findViewById(R.id.cue_character);
    if (!Utils.isIdeographicLanguage(Main.search_lang)) {
        cue_character_textView.setVisibility(View.GONE);
        cue_character_input_textView.setVisibility(View.GONE);
    } else if (!TextUtils.isEmpty(character_cue)) {
        cue_character_input_textView.setText(character_cue);
    }

    EditText response_character_input_textView = (EditText) findViewById(R.id.response_character);
    if (!Utils.isIdeographicLanguage(Main.result_lang)) {
        response_character_textView.setVisibility(View.GONE);
        response_character_input_textView.setVisibility(View.GONE);
    } else if (!TextUtils.isEmpty(character_response)) {
        response_character_input_textView.setText(character_response);
    }

}

From source file:dk.sdu.mmmi.featureous.views.codecharacterization.TanglingViewChart.java

private void createView() {
    Controller c = Controller.getInstance();
    Set<TraceModel> traces = c.getTraceSet().getFirstLevelTraces();

    List<Result> ress = new ArrayList<Result>(new StaticTangling(pkg).calculateAndReturnAll(traces, null));

    for (Result r : ress) {
        //            OutputUtil.log(r.name + ";" +r.value);
    }//from   ww w. j  ava  2  s .c o m
    Result.sortByName(ress);

    if (sortByValue) {
        Collections.sort(ress);
        //            Collections.reverse(ress);
    }

    double max = 0;
    for (Result r : ress) {
        if (r.value > max) {
            max = r.value;
        }
    }

    for (Result r : ress) {
        String label = "" + (ress.indexOf(r) + 1);
        data.addValue(r.value, r.name, label);
        //            data.addValue(max - r.value, r.name + "f", label);
    }

    double total = 0;
    for (Result r : ress) {
        total += r.value;
    }

    jchart.setTitle(jchart.getTitle().getText());// + "\n" + "Total tang = " + String.format("%.5f", total));

    CategoryPlot plot = jchart.getCategoryPlot();
    ((StackedBarRenderer) plot.getRenderer()).setDrawBarOutline(true);
    plot.getRenderer().setOutlineStroke(new BasicStroke(0.1f));

    for (int i = 0; i < data.getRowCount(); i++) {
        Set<Object> elems = new HashSet<Object>();
        for (ClassModel cm : c.getTraceSet().getAllClassIDs()) {
            if (!pkg) {
                elems.add(cm);
            } else {
                elems.add(cm.getPackageName());
            }
        }
        for (Object cm : elems) {
            String key = data.getRowKey(i).toString();
            String name = "";
            if (!pkg) {
                name = ((ClassModel) cm).getName();
            } else {
                name = (String) cm;
            }
            if (key != null && key.startsWith(name)) {
                Color col = Color.pink;
                if (!pkg) {
                    col = Controller.getInstance().getAffinity()
                            .getClassAffinity(((ClassModel) cm).getName()).color;
                } else {
                    col = Controller.getInstance().getAffinity().getPkgAffinity((String) cm).color;
                }

                plot.getRenderer().setSeriesPaint(i, col);
                //                    if(key.endsWith("f")){
                //                        plot.getRenderer().setSeriesOutlinePaint(i, col);
                //                    }else{
                plot.getRenderer().setSeriesOutlinePaint(i, Color.DARK_GRAY);
                //                    }
                break;
            }
        }
    }
    //        plot.setRowRenderingOrder(SortOrder.DESCENDING);

}

From source file:org.jajuk.ui.views.StatView.java

/**
 * Device size pie.//  www .  jav  a 2 s.  c  om
 * 
 * @return the chart
 */
private ChartPanel createDeviceRepartition() {
    try {
        DefaultPieDataset pdata = null;
        JFreeChart jfchart = null;
        // data
        pdata = new DefaultPieDataset();
        // prepare devices
        long lTotalSize = 0;
        double dOthers = 0;
        List<Device> devices = DeviceManager.getInstance().getDevices();
        long[] lSizes = new long[DeviceManager.getInstance().getElementCount()];
        ReadOnlyIterator<File> it = FileManager.getInstance().getFilesIterator();
        while (it.hasNext()) {
            File file = it.next();
            lTotalSize += file.getSize();
            lSizes[devices.indexOf(file.getDirectory().getDevice())] += file.getSize();
        }
        for (Device device : devices) {
            long lSize = lSizes[devices.indexOf(device)];
            if (lTotalSize > 0 && (double) lSize / lTotalSize < 0.05) {
                // less than 5% -> go to others
                dOthers += lSize;
            } else {
                double dValue = Math.round((double) lSize / 1073741824);
                pdata.setValue(device.getName(), dValue);
            }
        }
        if (dOthers > 0) {
            double dValue = Math.round((dOthers / 1073741824));
            pdata.setValue(Messages.getString("StatView.3"), dValue);
        }
        // chart
        jfchart = ChartFactory.createPieChart3D(Messages.getString("StatView.4"), pdata, true, true, true);
        // set the background color for the chart...
        PiePlot plot = (PiePlot) jfchart.getPlot();
        plot.setLabelFont(PiePlot.DEFAULT_LABEL_FONT);
        plot.setNoDataMessage(Messages.getString("StatView.5"));
        plot.setForegroundAlpha(0.5f);
        plot.setBackgroundAlpha(0.5f);
        plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} = {1} GB ({2})"));
        plot.setToolTipGenerator(new StandardPieToolTipGenerator("{0} = {1} GB ({2})"));
        return new ChartPanel(jfchart);
    } catch (RuntimeException e) {
        Log.error(e);
        return null;
    }
}

From source file:com.amalto.workbench.actions.XSDDeleteConceptWrapAction.java

/**
 * Author: Fliu this fun is to filter out all the children listed in the selections, all left is the top parent
 * level ones in the selections//from  w  w  w.j  av  a 2s. c o m
 *
 * @param selections
 * @return all parent array with no corresponding children in the selection list
 */
private Object[] filterSelectedItemsToDel(IStructuredSelection selections) {
    Object[] objs = selections.toArray();
    List lst = new ArrayList();

    for (Object obj : objs) {
        if (obj instanceof XSDElementDeclarationImpl) {
            continue;
        }
        for (Object objOther : objs) {
            if (obj == objOther) {
                continue;
            }
            Object[] offsprings = populateAllOffspring(objOther, new ArrayList());
            for (Object offspring : offsprings) {
                if (offspring == obj) {
                    if (lst.indexOf(obj) < 0) {
                        lst.add(obj);
                    }
                }
            }
        }
    }

    for (Object ca : objs) {
        if (lst.indexOf(ca) >= 0) {
            lst.remove(ca);
        } else {
            lst.add(ca);
        }
    }
    return lst.toArray();
}

From source file:fll.web.playoff.Playoff.java

/**
 * Build the list of teams ordered from top to bottom (visually) of a single
 * elimination bracket./*from w  ww  .  ja v  a2s . co  m*/
 * 
 * @param connection connection to the database
 * @param teams the teams in the playoffs
 * @return a List of teams
 * @throws SQLException on a database error
 */
public static List<Team> buildInitialBracketOrder(final Connection connection,
        final BracketSortType bracketSort, final WinnerType winnerCriteria, final List<? extends Team> teams)
        throws SQLException {
    if (null == connection) {
        throw new NullPointerException("Connection cannot be null");
    }

    final List<? extends Team> seedingOrder;
    if (BracketSortType.ALPHA_TEAM == bracketSort) {
        seedingOrder = teams;

        // sort by team name
        Collections.sort(seedingOrder, Team.TEAM_NAME_COMPARATOR);
    } else if (BracketSortType.RANDOM == bracketSort) {
        seedingOrder = teams;
        // assign a random number to each team
        final double[] randoms = new double[seedingOrder.size()];
        final Random generator = new Random();
        for (int i = 0; i < randoms.length; ++i) {
            randoms[i] = generator.nextDouble();
        }
        Collections.sort(seedingOrder, new Comparator<Team>() {
            public int compare(final Team one, final Team two) {
                final int oneIdx = seedingOrder.indexOf(one);
                final int twoIdx = seedingOrder.indexOf(two);
                return Double.compare(randoms[oneIdx], randoms[twoIdx]);
            }
        });
    } else {
        // standard seeding
        final int tournament = Queries.getCurrentTournament(connection);
        final int numSeedingRounds = TournamentParameters.getNumSeedingRounds(connection, tournament);
        if (numSeedingRounds < 1) {
            throw new FLLRuntimeException(
                    "Cannot initialize playoff brackets using scores from seeding rounds when the number of seeing rounds is less than 1");
        }

        seedingOrder = Queries.getPlayoffSeedingOrder(connection, winnerCriteria, teams);
    }

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("seedingOrder: " + seedingOrder);
    }

    final int[] seeding = computeInitialBrackets(seedingOrder.size());

    // give byes to the last byesNeeded teams.
    final List<Team> list = new LinkedList<Team>();
    for (final int element : seeding) {
        if (element > seedingOrder.size()) {
            list.add(Team.BYE);
        } else {
            final Team team = seedingOrder.get(element - 1);
            list.add(team);
        }
    }

    if (list.size() != seeding.length) {
        throw new InternalError("Programming error, list size should be the same as seeding length");
    }
    return list;

}

From source file:com.vmware.vfabric.ide.eclipse.tcserver.internal.ui.ExtendedTcStaticResourcesEditorSection.java

@Override
public void createSection(Composite parent) {
    super.createSection(parent);
    FormToolkit toolkit = getFormToolkit(parent.getDisplay());

    Section section = toolkit.createSection(parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED
            | ExpandableComposite.TITLE_BAR | Section.DESCRIPTION | ExpandableComposite.FOCUS_TITLE);
    section.setText("Application Reload Behavior");
    section.setDescription("Configure application reload behavior on changes to project resources.");

    section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));

    Composite composite = toolkit.createComposite(section);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;//from  w  w  w  .  j a  v a2 s .c om
    layout.marginHeight = 5;
    layout.marginWidth = 1;
    layout.verticalSpacing = 5;
    layout.horizontalSpacing = 10;
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));
    toolkit.paintBordersFor(composite);
    section.setClient(composite);

    enableAgentButton = toolkit.createButton(composite, "Enable Java Agent-based reloading (experimental)",
            SWT.CHECK);
    GridDataFactory.fillDefaults().span(2, 1).applyTo(enableAgentButton);
    enableAgentButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            if (updating) {
                return;
            }
            try {
                updating = true;
                boolean enabled = enableAgentButton.getSelection();
                execute(new ModifyAgentRedeployCommand(serverWorkingCopy, enabled));
                try {
                    List<?> list = serverWorkingCopy.getTomcatConfiguration().getWebModules();
                    int i = 0;
                    Iterator<?> iterator = list.iterator();
                    while (iterator.hasNext()) {
                        WebModule module = (WebModule) iterator.next();
                        WebModule newModule = new WebModule(module.getPath(), module.getDocumentBase(),
                                module.getMemento(), !enabled);
                        execute(new ModifyWebModuleCommand(serverWorkingCopy.getTomcatConfiguration(), i,
                                newModule));
                        i++;
                    }
                } catch (Exception e) {
                    return;
                }
            } finally {
                updating = false;
            }
        }
    });

    Composite optionsComposite = new Composite(composite, SWT.NONE);
    GridLayout optionsLayout = new GridLayout(2, false);
    optionsLayout.marginWidth = 1;
    optionsLayout.marginHeight = 2;
    optionsComposite.setLayout(optionsLayout);
    GridDataFactory.fillDefaults().applyTo(optionsComposite);
    toolkit.paintBordersFor(optionsComposite);

    toolkit.createLabel(optionsComposite, "Options:");
    agentOptionsText = toolkit.createText(optionsComposite, "");
    GridDataFactory.fillDefaults().grab(true, false).applyTo(agentOptionsText);
    agentOptionsText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            if (updating) {
                return;
            }
            try {
                updating = true;
                String value = agentOptionsText.getText();
                execute(new ModifyAgentOptionsCommand(serverWorkingCopy, value));
            } finally {
                updating = false;
            }
        }
    });

    enableButton = toolkit.createButton(composite, "Enable JMX-based reloading", SWT.CHECK);
    GridDataFactory.fillDefaults().span(2, 1).applyTo(enableButton);
    enableButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            if (updating) {
                return;
            }
            try {
                updating = true;
                boolean enabled = enableButton.getSelection();
                execute(new ModifyEnhancedRedeployCommand(serverWorkingCopy, enabled));
                try {
                    List<?> list = serverWorkingCopy.getTomcatConfiguration().getWebModules();
                    int i = 0;
                    Iterator<?> iterator = list.iterator();
                    while (iterator.hasNext()) {
                        WebModule module = (WebModule) iterator.next();
                        WebModule newModule = new WebModule(module.getPath(), module.getDocumentBase(),
                                module.getMemento(), !enabled);
                        execute(new ModifyWebModuleCommand(serverWorkingCopy.getTomcatConfiguration(), i,
                                newModule));
                        i++;
                    }
                } catch (Exception e) {
                    return;
                }
            } finally {
                updating = false;
            }
        }
    });

    Label enhancedRedeploymentLabel = toolkit.createLabel(composite,
            "Define patterns for files that should be copied to deployed applications without triggereing a reload.\nSpring XML configuration files are handled separately.");
    GridDataFactory.fillDefaults().span(2, 1).applyTo(enhancedRedeploymentLabel);

    filenameTable = toolkit.createTable(composite, SWT.SINGLE | SWT.V_SCROLL | SWT.FULL_SELECTION);
    GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
    data.heightHint = 130;
    filenameTable.setLayoutData(data);
    filenamesTableViewer = new TableViewer(filenameTable);
    contentProvider = new StaticFilenamesContentProvider();
    filenamesTableViewer.setContentProvider(contentProvider);
    filenamesTableViewer.setLabelProvider(new FilenameLabelProvider());

    filenamesTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            Object obj = ((IStructuredSelection) event.getSelection()).getFirstElement();
            deleteButton.setEnabled(obj != null);
            updateButtons(obj);
        }
    });

    Composite buttonComposite = new Composite(composite, SWT.NONE);
    GridLayout buttonLayout = new GridLayout(1, true);
    buttonLayout.marginWidth = 0;
    buttonLayout.marginHeight = 0;
    buttonComposite.setLayout(buttonLayout);
    GridDataFactory.fillDefaults().applyTo(buttonComposite);

    addButton = toolkit.createButton(buttonComposite, "Add...", SWT.PUSH);
    GridDataFactory.fillDefaults().applyTo(addButton);
    addButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (updating) {
                return;
            }

            InputDialog dialog = new InputDialog(getShell(), "New filename pattern",
                    "Enter a new filename pattern for static resources (wildcards such as '*' and '?' are supported):",
                    "", new IInputValidator() {

                        public String isValid(String newText) {
                            if (StringUtils.isBlank(newText)) {
                                return "Pattern can't be empty";
                            }
                            return null;
                        }
                    });
            if (dialog.open() == Dialog.OK) {
                updating = true;
                List<Object> filenames = new ArrayList<Object>(
                        Arrays.asList(contentProvider.getElements(server)));
                filenames.add(dialog.getValue());
                execute(new ModifyStaticResourcesCommand(serverWorkingCopy, StringUtils.join(filenames, ",")));
                filenamesTableViewer.setInput(server);
                filenamesTableViewer.setSelection(new StructuredSelection(dialog.getValue()));
                // update buttons
                updating = false;
            }
        }
    });

    deleteButton = toolkit.createButton(buttonComposite, "Delete", SWT.PUSH);
    GridDataFactory.fillDefaults().applyTo(deleteButton);
    deleteButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            Object selectedArtefact = ((IStructuredSelection) filenamesTableViewer.getSelection())
                    .getFirstElement();
            if (updating) {
                return;
            }
            updating = true;
            List<Object> filenames = new ArrayList<Object>(Arrays.asList(contentProvider.getElements(server)));
            filenames.remove(selectedArtefact);
            execute(new ModifyStaticResourcesCommand(serverWorkingCopy, StringUtils.join(filenames, ",")));
            filenamesTableViewer.setInput(server);
            // update buttons
            updating = false;
        }
    });

    upButton = toolkit.createButton(buttonComposite, "Up", SWT.PUSH);
    GridDataFactory.fillDefaults().applyTo(upButton);
    upButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            Object selectedArtefact = ((IStructuredSelection) filenamesTableViewer.getSelection())
                    .getFirstElement();
            List<Object> modules = new ArrayList<Object>();
            modules.addAll(Arrays.asList(contentProvider.getElements(server)));
            int index = modules.indexOf(selectedArtefact);
            modules.remove(selectedArtefact);
            modules.add(index - 1, selectedArtefact);
            if (updating) {
                return;
            }
            updating = true;
            execute(new ModifyStaticResourcesCommand(serverWorkingCopy, StringUtils.join(modules, ",")));
            filenamesTableViewer.setInput(server);
            updateButtons(selectedArtefact);
            updating = false;
        }
    });

    downButton = toolkit.createButton(buttonComposite, "Down", SWT.PUSH);
    GridDataFactory.fillDefaults().applyTo(downButton);
    downButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            Object selectedArtefact = ((IStructuredSelection) filenamesTableViewer.getSelection())
                    .getFirstElement();
            List<Object> modules = new ArrayList<Object>();
            modules.addAll(Arrays.asList(contentProvider.getElements(server)));
            int index = modules.indexOf(selectedArtefact);
            modules.remove(selectedArtefact);
            modules.add(index + 1, selectedArtefact);
            if (updating) {
                return;
            }
            updating = true;
            execute(new ModifyStaticResourcesCommand(serverWorkingCopy, StringUtils.join(modules, ",")));
            filenamesTableViewer.setInput(server);
            updateButtons(selectedArtefact);
            updating = false;
        }
    });

    FormText restoreDefault = toolkit.createFormText(composite, true);
    GridDataFactory.fillDefaults().span(2, 1).applyTo(restoreDefault);
    restoreDefault.setText("<form><p><a href=\"exportbundle\">Restore default</a> filename patterns</p></form>",
            true, false);
    restoreDefault.addHyperlinkListener(new HyperlinkAdapter() {
        @Override
        public void linkActivated(HyperlinkEvent e) {
            updating = true;
            execute(new ModifyStaticResourcesCommand(serverWorkingCopy, TcServer.DEFAULT_STATIC_FILENAMES));
            filenamesTableViewer.setInput(server);
            updating = false;
        }
    });
    updateEnablement();
    initialize();
}

From source file:org.nekorp.workflow.desktop.control.imp.WorkflowAppPrototipo.java

private void updateUltimoCargado() {
    if (edicionMetadata.getServicioActual() != null) {
        ServicioLoaded actual = unloadAll();
        List<ServicioLoaded> servicios;
        if (edicionMetadata.getServicioActual().isNuevo()) {
            servicios = servicioLoadedListMetadata.getServiciosNuevos();
        } else {// w  w w  .  j av  a2s  .co  m
            servicios = servicioLoadedListMetadata.getServicios();
        }
        int index = servicios.indexOf(edicionMetadata.getServicioActual());
        servicios.add(index, actual);
        servicios.remove(edicionMetadata.getServicioActual());
        if (edicionMetadata.getServicioActual().isNuevo()) {
            servicioLoadedListMetadata.setServiciosNuevos(servicios);
        } else {
            servicioLoadedListMetadata.setServicios(servicios);
        }
    }
}

From source file:com.qcadoo.mes.assignmentToShift.print.xls.AssignmentToShiftXlsHelper.java

public String getListOfWorkers(final List<Entity> staffAssignmentToShifts) {
    if (staffAssignmentToShifts == null) {
        return L_EMPTY;
    }/*from   w ww  .  j a  v a 2s .  co m*/

    StringBuilder listOfWorkers = new StringBuilder();

    for (Entity staffAssignmentToShift : staffAssignmentToShifts) {
        Entity worker = staffAssignmentToShift.getBelongsToField(StaffAssignmentToShiftFields.WORKER);

        listOfWorkers.append(worker.getStringField(StaffFields.NAME));
        listOfWorkers.append(" ");
        listOfWorkers.append(worker.getStringField(StaffFields.SURNAME));

        if (staffAssignmentToShifts.indexOf(staffAssignmentToShift) != (staffAssignmentToShifts.size() - 1)) {
            listOfWorkers.append(", ");
        }
    }

    return listOfWorkers.toString();
}