Java Code Examples for javax.swing.DefaultListModel

The following are top voted examples for showing how to use javax.swing.DefaultListModel. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: rapidminer   File: ManageParallelLinesDialog.java   View source code 7 votes vote down vote up
/**
 * Vertical lines selected.
 */
private void setVerticalLineSelected() {
	// show horizontal lines
	rangeAxisSelectionCombobox.setEnabled(false);
	linesList.clearSelection();

	// get all horizontal lines and display them
	DefaultListModel<AxisParallelLineConfiguration> model = new DefaultListModel<AxisParallelLineConfiguration>();
	List<AxisParallelLineConfiguration> domainLines = engine.getPlotInstance().getMasterPlotConfiguration()
			.getDomainConfigManager().getCrosshairLines().getLines();
	for (int i = 0; i < domainLines.size(); i++) {
		AxisParallelLineConfiguration line = domainLines.get(i);
		model.addElement(line);
	}

	linesList.setModel(model);
}
 
Example 2
Project: LogisticApp   File: FracionalPanelBuilder.java   View source code 6 votes vote down vote up
private void initializeList() {

		this.listTrechos = new JList<RotaVO>();
		this.listTrechos.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		this.listTrechos.setLayoutOrientation(JList.VERTICAL);

		this.listTrechos.setModel(new DefaultListModel<RotaVO>());

		JScrollPane listScroller = new JScrollPane(this.listTrechos);

		GridBagConstraints gbc_list = new GridBagConstraints();
		gbc_list.gridheight = 2;
		gbc_list.gridwidth = 5;
		gbc_list.insets = new Insets(0, 0, 0, 5);
		gbc_list.fill = GridBagConstraints.BOTH;
		gbc_list.gridx = 1;
		gbc_list.gridy = 1;
		this.panelSecond.add(listScroller, gbc_list);
	}
 
Example 3
Project: rapidminer   File: ExtendedErrorDialog.java   View source code 6 votes vote down vote up
public StackTraceList(Throwable t) {
	super(new DefaultListModel());
	setFont(getFont().deriveFont(Font.PLAIN));
	setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
	appendAllStackTraces(t);
	addListSelectionListener(new ListSelectionListener() {

		@Override
		public void valueChanged(ListSelectionEvent e) {
			if (getSelectedIndex() >= 0) {
				if (!(getSelectedValue() instanceof FormattedStackTraceElement)) {
					editButton.setEnabled(false);
				} else {
					editButton.setEnabled(true);
				}
			} else {
				editButton.setEnabled(true);
			}
		}
	});
}
 
Example 4
Project: AgentWorkbench   File: AddComponentDialog.java   View source code 6 votes vote down vote up
/**
 * Gets the ComboBoxModel filter.
 * @return the ComboBoxModel filter
 */
private DefaultComboBoxModel<String> getNewComboBoxModelFilter() {

	Vector<String> filterStrings = new Vector<String>();
	DefaultListModel<ComponentTypeListElement> typeList = this.getListModelComponentTypes();
	for (int i=0; i < typeList.size(); i++) {
		ComponentTypeListElement ctle = typeList.getElementAt(i);
		if (filterStrings.contains(ctle.getDomain())==false) {
			filterStrings.add(ctle.getDomain());
		}
	}
	Collections.sort(filterStrings);
	
	comboBoxModeFilter = new DefaultComboBoxModel<String>();
	comboBoxModeFilter.addElement(AddComponentDialog.NoFilterString);
	for (String filterString : filterStrings) {
		comboBoxModeFilter.addElement(filterString);
	}
	return comboBoxModeFilter;
}
 
Example 5
Project: xdman   File: YoutubeGrabberDlg.java   View source code 6 votes vote down vote up
JPanel createP3() {
	p3 = new JPanel(new BorderLayout());
	model = new DefaultListModel();
	list = new JList(model);
	list.setCellRenderer(new YTListRenderer());
	p3.add(new JScrollPane(list));
	Box box = Box.createHorizontalBox();
	box.add(Box.createHorizontalGlue());
	btnDwnld = new JButton("Download");
	btnDwnld.addActionListener(this);
	btnCancel = new JButton("Close");
	btnCancel.addActionListener(this);
	box.add(btnDwnld);
	box.add(Box.createHorizontalStrut(10));
	box.add(btnCancel);
	btnCancel.setPreferredSize(btnDwnld.getPreferredSize());
	box.add(Box.createHorizontalStrut(10));
	box.add(Box.createRigidArea(new Dimension(0, 40)));
	p3.add(box, BorderLayout.SOUTH);

	box.setOpaque(true);
	box.setBackground(StaticResource.titleColor);
	return p3;
}
 
Example 6
Project: incubator-netbeans   File: SpellcheckerOptionsPanel.java   View source code 6 votes vote down vote up
private void updateLocales() {
    DefaultListModel model = new DefaultListModel();
    List<Locale> locales = new ArrayList<Locale>(Arrays.asList(DictionaryProviderImpl.getInstalledDictionariesLocales()));

    for (DictionaryDescription desc : addedDictionaries) {
        locales.add(desc.getLocale());
    }
    
    locales.removeAll(removedDictionaries);

    for (Locale l : locales) {
        model.addElement(l);
    }
    
    installedLocalesList.setModel(model);
}
 
Example 7
Project: JavaGraph   File: HelpFactory.java   View source code 6 votes vote down vote up
private JComponent createSyntaxPanel(Logic logic) {
    final JList<String> list = new JList<>();
    DefaultListModel<String> model = new DefaultListModel<>();
    Map<String,String> docMap = FormulaParser.getDocMap(logic);
    for (Map.Entry<String,String> entry : docMap.entrySet()) {
        model.addElement(entry.getKey());
    }
    list.setModel(model);
    list.setCellRenderer(new MyCellRenderer(docMap));
    list.addMouseListener(new DismissDelayer(list));
    list.setSelectionModel(new DefaultListSelectionModel() {
        @Override
        public void setSelectionInterval(int index0, int index1) {
            super.setSelectionInterval(-1, -1);
        }
    });
    JPanel result = new JPanel(new BorderLayout());
    result.setBorder(BorderFactory.createEmptyBorder(0, 6, 0, 0));
    result.add(new JLabel("<html><b>Syntax:"), BorderLayout.NORTH);
    result.add(new JScrollPane(list), BorderLayout.CENTER);
    return result;
}
 
Example 8
Project: Equella   File: SearchTool.java   View source code 6 votes vote down vote up
public PluginDialog()
{
	listModel = new DefaultListModel();

	list = new JList();
	list.setModel(listModel);
	list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

	for( String name : plugins.keySet() )
	{
		listModel.addElement(name);
	}

	setLayout(new BorderLayout());
	add(new JScrollPane(list));
}
 
Example 9
Project: freecol   File: TradeRouteInputPanel.java   View source code 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean importData(JComponent target, Transferable data) {
    JList<TradeRouteStop> stl = TradeRouteInputPanel.this.stopList;
    if (canImport(target, data.getTransferDataFlavors())
        && target == stl
        && data instanceof StopListTransferable) {
        List<TradeRouteStop> stops
            = ((StopListTransferable)data).getStops();
        DefaultListModel<TradeRouteStop> model
            = new DefaultListModel<>();
        int index = stl.getMaxSelectionIndex();
        for (TradeRouteStop stop : stops) {
            if (index < 0) {
                model.addElement(stop);
            } else {
                index++;
                model.add(index, stop);
            }
        }
        stl.setModel(model);
        return true;
    }
    return false;
}
 
Example 10
Project: incubator-netbeans   File: ActionMappings.java   View source code 6 votes vote down vote up
private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-HEADEREND:event_btnAddActionPerformed
    NotifyDescriptor.InputLine nd = new NonEmptyInputLine(org.openide.util.NbBundle.getMessage(ActionMappings.class, "TIT_Add_action"), org.openide.util.NbBundle.getMessage(ActionMappings.class, "LBL_AddAction"));
    Object ret = DialogDisplayer.getDefault().notify(nd);
    if (ret == NotifyDescriptor.OK_OPTION) {
        NetbeansActionMapping nam = new NetbeansActionMapping();
        nam.setDisplayName(nd.getInputText());
        nam.setActionName(CUSTOM_ACTION_PREFIX + nd.getInputText()); 
        getActionMappings().addAction(nam);
        if (handle != null) {
            handle.markAsModified(getActionMappings());
        }
        MappingWrapper wr = new MappingWrapper(nam);
        wr.setUserDefined(true);
        ((DefaultListModel)lstMappings.getModel()).addElement(wr);
        lstMappings.setSelectedIndex(lstMappings.getModel().getSize() - 1);
        lstMappings.ensureIndexIsVisible(lstMappings.getModel().getSize() - 1);
    }
}
 
Example 11
Project: incubator-netbeans   File: GlobalOptionsPanel.java   View source code 6 votes vote down vote up
/** Creates new form GlobalOptionsPanel */
public GlobalOptionsPanel() {
    initComponents();
    DefaultListModel dlm = new DefaultListModel();
    descMap = new HashMap<String, String>();
    int i = 0;
    String[] desc = SettingsPanel.getAvailableOptionsDescriptions();
    for (String s : SettingsPanel.AVAILABLE_OPTIONS) {
        dlm.addElement(s);
        descMap.put(s, desc[i]);
        i = i + 1;
    }
    jList1.setModel(dlm);
    jList1.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            String val = (String) jList1.getSelectedValue();
            if (val != null) {
                jTextArea1.setText(descMap.get(val));
            } else {
                jTextArea1.setText("");
            }
        }
    });
}
 
Example 12
Project: incubator-netbeans   File: CodeCompletionPanel.java   View source code 6 votes vote down vote up
private void javaCompletionExcluderDialogOkButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javaCompletionExcluderDialogOkButtonActionPerformed
    JList list = getSelectedExcluderList();
    String text = javaCompletionExcluderDialogTextField.getText();
    DefaultListModel model = (DefaultListModel) list.getModel();
    int index = model.size();
    if (javaExcluderEditing != null){
        // if this was an "edit" rather than "add", then remove the old entry first
        index = model.indexOf(javaExcluderEditing);
        model.remove(index);
        javaExcluderEditing = null;
    }
    String[] entries = text.split(","); // NOI18N
    for (String entry : entries) {
        // strip zero width spaces
        entry = entry.replaceAll("\u200B", "");  // NOI18N
        entry = entry.trim();
        if (entry.length() != 0 && entry.matches(JAVA_FQN_REGEX)){
            model.insertElementAt(entry, index);
            index++;
        }
    }
    updateExcluder(list);
    javaCompletionExcluderDialog2.setVisible(false);
    javaCompletionExcluderDialogTextField.setText(null);
}
 
Example 13
Project: incubator-netbeans   File: NewPluginPanel.java   View source code 6 votes vote down vote up
private void updateGoals() {
    DefaultListModel m = (DefaultListModel) goalsList.getModel();
    m.clear();

    if (selVi != null) {
        Set<String> goals = null;
        try {
            goals = PluginIndexManager.getPluginGoals(selVi.getGroupId(),
                    selVi.getArtifactId(), selVi.getVersion());
        } catch (Exception ex) {
            // TODO - put err msg in dialog?
            Exceptions.printStackTrace(ex);
        }
        if (goals != null) {
            for (String goal : goals) {
                m.addElement(new GoalEntry(goal));
            }
        }
    }
}
 
Example 14
Project: incubator-netbeans   File: TagManager.java   View source code 6 votes vote down vote up
@Override
public void perform () {
    try {
        final DefaultListModel targetsModel = new DefaultListModel();
        targetsModel.addElement(INITIAL_MESSAGE);
        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run () {
                panel.tagList.setModel(targetsModel);
                if (!targetsModel.isEmpty()) {
                    panel.tagList.setSelectedIndex(0);
                }
            }
        });
        refreshRevisions(this);
    } finally {
        backgroundSupport = null;
    }
}
 
Example 15
Project: incubator-netbeans   File: AntArtifactChooser.java   View source code 6 votes vote down vote up
/**
 * Set up GUI fields according to the requested project.
 * @param project a subproject, or null
 */
private void populateAccessory( Project project ) {
    
    DefaultListModel model = (DefaultListModel)jListArtifacts.getModel();
    model.clear();
    jTextFieldName.setText(project == null ? "" : ProjectUtils.getInformation(project).getDisplayName()); //NOI18N
    
    if ( project != null ) {
        
        List<AntArtifact> artifacts = new ArrayList<AntArtifact>();
        for (int i=0; i<artifactTypes.length; i++) {
            artifacts.addAll (Arrays.asList(AntArtifactQuery.findArtifactsByType(project, artifactTypes[i])));
        }
        
        for(AntArtifact artifact : artifacts) {
            URI uris[] = artifact.getArtifactLocations();
            for( int y = 0; y < uris.length; y++ ) {
                model.addElement( new AntArtifactItem(artifact, uris[y]));
            }
        }
        jListArtifacts.setSelectionInterval(0, model.size());
    }
    
}
 
Example 16
Project: https-github.com-apache-zookeeper   File: ZooInspectorNodeViewersDialog.java   View source code 6 votes vote down vote up
public void valueChanged(ListSelectionEvent e) {
    JButton removeButton = buttons.get(Button.remove);
    JButton upButton = buttons.get(Button.up);
    JButton downButton = buttons.get(Button.down);
    int index = viewersList.getSelectedIndex();

    if (index == -1) {
        removeButton.setEnabled(false);
        upButton.setEnabled(false);
        downButton.setEnabled(false);
    } else {
        removeButton.setEnabled(true);
        if (index == 0) {
            upButton.setEnabled(false);
        } else {
            upButton.setEnabled(true);
        }
        if (index == ((DefaultListModel) viewersList.getModel()).getSize()) {
            downButton.setEnabled(false);
        } else {
            downButton.setEnabled(true);
        }
    }
}
 
Example 17
Project: DocIT   File: DeptView.java   View source code 6 votes vote down vote up
public DeptView(Controller controller) {
	this.controller = controller;
	frame = new JFrame();
	namePanel = new JPanel(new GridLayout(1, 2, 0, 0));
	managerPanel = new JPanel(new GridLayout(1, 2, 66, 0));
	employeePanel = new JPanel(new GridLayout(1, 2, 30, 0));
	subDeptPanel = new JPanel(new GridLayout(1, 2, 20, 0));
	salaryPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 20, 0));
	buttonPanel = new JPanel(new GridLayout(1, 3, 20, 0));
	subDeptLabel = new JLabel();
	salaryLabel = new JLabel();
	cutButton = new JButton();
	saveButton = new JButton();
	okButton = new JButton();
	cancelButton = new JButton();
	nameField = new JTextField();
	managerButton = new JButton();
	employeeListModel = new DefaultListModel();
	subDeptListModel = new DefaultListModel();
	employeeList = new JList(employeeListModel);
	subDeptList = new JList(subDeptListModel);
	init();
}
 
Example 18
Project: LogisticApp   File: FracionalPanelBuilder.java   View source code 6 votes vote down vote up
private void updateListTrechos(RotaVO rota) throws CadastroException {
	DefaultListModel<RotaVO> model = new DefaultListModel<RotaVO>();
	ListModel<RotaVO> currentModel = this.listTrechos.getModel();

	// as rotas precisam ser sequenciais
	// logo se a origem da nova rota não for igual ao destino da última,
	// lançar exceção
	if (currentModel.getSize() > 0) {
		RotaVO last = currentModel.getElementAt(currentModel.getSize() - 1);
		if (!last.getDescricaoDestino().equals(rota.getDescricaoOrigem()))
			throw new CadastroException("Trecho inválido. A próxima rota precisa possuir "
					+ last.getDescricaoDestino() + " como origem.");
	}

	for (int i = 0; i < currentModel.getSize(); i++) {
		RotaVO trecho = currentModel.getElementAt(i);
		model.addElement(trecho);
	}
	model.addElement(rota);
	this.listTrechos.setModel(model);
}
 
Example 19
Project: incubator-netbeans   File: ClassPathUiSupport.java   View source code 6 votes vote down vote up
/** Moves items up in the list. The indices array will contain 
 * indices to be selected after the change was done.
 */
public static int[] moveUp( DefaultListModel listModel, int indices[]) {
            
    if( indices == null || indices.length == 0 ) {
        assert false : "MoveUp button should be disabled"; // NOI18N
    }
    
    // Move the items up
    for( int i = 0; i < indices.length; i++ ) {
        Object item = listModel.get( indices[i] );
        listModel.remove( indices[i] );
        listModel.add( indices[i] - 1, item ); 
        // Keep the selection a before
        indices[i] -= 1;
    }
    
    return indices;
    
}
 
Example 20
Project: incubator-netbeans   File: ClassPathUiSupport.java   View source code 6 votes vote down vote up
public static int[] addJarFiles( DefaultListModel listModel, int[] indices, String filePaths[], File base, 
        String[] variables, Callback callback) {
    int lastIndex = indices == null || indices.length == 0 ? listModel.getSize() - 1 : indices[indices.length - 1];
    int[] indexes = new int[filePaths.length];
    for( int i = 0, delta = 0; i+delta < filePaths.length; ) {            
        int current = lastIndex + 1 + i;
        ClassPathSupport.Item item = ClassPathSupport.Item.create( filePaths[i], base, null, variables != null ? variables[i] : null);
        if (callback != null) {
            callback.initItem(item);
        }
        if ( !listModel.contains( item ) ) {
            listModel.add( current, item );
            indexes[delta + i] = listModel.indexOf( item );
            i++;
        }
        else {
            indexes[i + delta] = listModel.indexOf( item );
            delta++;
        }            
    }
    return indexes;

}
 
Example 21
Project: incubator-netbeans   File: CodeTemplatesModel.java   View source code 6 votes vote down vote up
public TM(
    String mimeType,
    Map<String, CodeTemplateDescription> codeTemplatesMap, 
    Vector<String> headers,
    List<Vector<String>> data,
    List<String> supportedContexts
) {
    super(new Vector<Vector>(data), headers);
    this.mimeType = mimeType;
    this.codeTemplatesMap = codeTemplatesMap;
    this.contexts = new HashMap<>(codeTemplatesMap.size());
    this.supportedContexts = new DefaultListModel<>();
    for (String context : supportedContexts) {
        this.supportedContexts.addElement(context);                
    }
}
 
Example 22
Project: incubator-netbeans   File: FolderList.java   View source code 6 votes vote down vote up
private void addFiles (final File[] toAddArr, final Set<? super File> invalidRoots) {
    final int[] indecesToSelect = new int[toAddArr.length];
    final DefaultListModel model = (DefaultListModel)this.roots.getModel();
    final File[] relatedFolders = this.relatedFolderList == null ?
        new File[0] : this.relatedFolderList.getFiles();
    for (int i=0, index=model.size(); i<toAddArr.length; i++) {
        File normalizedFile = toAddArr[i];
        if (!isValidRoot(normalizedFile, relatedFolders, this.projectFolder)) {
            invalidRoots.add (normalizedFile);
        }
        else {
            int pos = model.indexOf (normalizedFile);
            if (pos == -1) {
                model.addElement (normalizedFile);
                indecesToSelect[i] = index;
            }
            else {
                indecesToSelect[i] = pos;
            }
            index++;
        }
    }
    this.roots.setSelectedIndices(indecesToSelect);
    this.firePropertyChange(PROP_FILES, null, null);
}
 
Example 23
Project: marathonv5   File: RListTest.java   View source code 6 votes vote down vote up
public void selectSpecialItemSelection() {
    final LoggingRecorder lr = new LoggingRecorder();
    siw(new Runnable() {
        @Override public void run() {
            list = (JList) ComponentUtils.findComponent(JList.class, frame);
            DefaultListModel model = (DefaultListModel) list.getModel();
            model.set(0, " Special Characters ([],)");
            list.setSelectedIndices(new int[] { 0 });
            RList rList = new RList(list, null, null, lr);
            rList.focusLost(null);
        }
    });
    Call call = lr.getCall();
    AssertJUnit.assertEquals("select", call.getFunction());
    AssertJUnit.assertEquals("[\\ Special Characters ([]\\,)]", call.getState());
}
 
Example 24
Project: Cognizant-Intelligent-Test-Scripter   File: StartUp.java   View source code 6 votes vote down vote up
private void loadRecent() {
    recentModel = new DefaultListModel();
    for (RecentItem recentItem : sMainFrame.getRecentItems().getRECENT_ITEMS()) {
        recentModel.addElement(recentItem);
    }
    recentItems.setModel(recentModel);
    if (recentModel.isEmpty()) {
        recentToggle.setEnabled(false);
        recentToggle.setForeground(Color.GRAY);
        appToggle.setSelected(true);
    } else {
        recentItems.setSelectedIndex(0);
        recentToggle.setSelected(true);
    }

}
 
Example 25
Project: MyCourses   File: MagazaYonetimiGUI.java   View source code 6 votes vote down vote up
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    // TODO add your handling code here:
    try{
    CalisanBase calisan = null;
    
    String ad = jTextField1.getText();
    String soyad = jTextField2.getText();
    String meslek = jComboBox1.getSelectedItem().toString();
    
    switch(meslek){
        case "Stajyer": calisan = new Stajyer(ad, soyad);break;
        case "Personel": calisan = new Personel(ad, soyad); break;
        case "Mudur": calisan = new Mudur(ad,soyad); break; 
    }
    String item = calisan.getMeslek() + " " + calisan.getAd() + " " + calisan.getSoyad();
    ((DefaultListModel) jList1.getModel()).addElement(item);
    }
    catch(Exception e){
        
    }
}
 
Example 26
Project: rapidminer   File: RadVizPlotter.java   View source code 6 votes vote down vote up
@Override
public void setPlotColumn(int index, boolean plot) {
	if (plot) {
		this.colorColumn = index;
	} else {
		this.colorColumn = -1;
	}
	// ignore list
	DefaultListModel ignoreModel = (DefaultListModel) ignoreList.getModel();
	ignoreModel.clear();
	for (int i = 0; i < this.dataTable.getNumberOfColumns(); i++) {
		if (i == this.colorColumn) {
			continue;
		}
		ignoreModel.addElement(this.dataTable.getColumnName(i));
	}
	repaint();
}
 
Example 27
Project: incubator-netbeans   File: CustomizerCompile.java   View source code 6 votes vote down vote up
private void addProcessorButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addProcessorButtonActionPerformed
    final AddAnnotationProcessor panel = new AddAnnotationProcessor();
    final DialogDescriptor desc = new DialogDescriptor(panel, NbBundle.getMessage (CustomizerCompile.class, "LBL_AddAnnotationProcessor_Title")); //NOI18N
    desc.setValid(false);
    panel.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            String fqn = panel.getProcessorFQN();
            desc.setValid(fqn.length() > 0);
        }
    });
    Dialog dlg = DialogDisplayer.getDefault().createDialog(desc);
    dlg.setVisible (true);
    if (desc.getValue() == DialogDescriptor.OK_OPTION) {
        ((DefaultListModel)annotationProcessorsList.getModel()).addElement(panel.getProcessorFQN());
    }
    dlg.dispose();
}
 
Example 28
Project: incubator-netbeans   File: J2SEModularProjectProperties.java   View source code 6 votes vote down vote up
private void collectLibs(DefaultListModel model, List<String> libs, List<String> jarReferences) {
    for (int i = 0; i < model.size(); i++) {
        ClassPathSupport.Item item = (ClassPathSupport.Item) model.get(i);
        if (item.getType() == ClassPathSupport.Item.TYPE_LIBRARY) {
            if (!item.isBroken() && !libs.contains(item.getLibrary().getName())) {
                libs.add(item.getLibrary().getName());
            }
        }
        if (item.getType() == ClassPathSupport.Item.TYPE_JAR) {
            if (item.getReference() != null && item.getVariableBasedProperty() == null && !jarReferences.contains(item.getReference())) {
                //TODO reference is null for not yet persisted items.
                // there seems to be no way to generate a reference string without actually
                // creating and writing the property..
                jarReferences.add(item.getReference());
            }
        }
    }
}
 
Example 29
Project: incubator-netbeans   File: PathsCustomizer.java   View source code 6 votes vote down vote up
public void setModels(final DefaultListModel mpModel, final DefaultListModel cpModel) {
    this.model = new JoinModel(mpModel, cpModel);
    this.list.setModel(this.model);
    DefaultTreeModel mpTreeModel = toTreeModel(mpModel, MODULEPATH);
    DefaultTreeModel cpTreeModel = toTreeModel(cpModel, CLASSPATH);
    mpModel.addListDataListener(new ListModelListener(mpModel, mpTreeModel, mpTree));
    cpModel.addListDataListener(new ListModelListener(cpModel, cpTreeModel, cpTree));
    mpTree.setModel(mpTreeModel);
    cpTree.setModel(cpTreeModel);
    SelectionModel mpTreeSelectionModel = new SelectionModel();
    SelectionModel cpTreeSelectionModel = new SelectionModel();
    mpTreeSelectionModel.addTreeSelectionListener(new SelectionListener(mpTreeModel, this.list, null, cpTreeSelectionModel));
    cpTreeSelectionModel.addTreeSelectionListener(new SelectionListener(cpTreeModel, this.list, mpModel, mpTreeSelectionModel));
    mpTree.setSelectionModel(mpTreeSelectionModel);
    cpTree.setSelectionModel(cpTreeSelectionModel);
}
 
Example 30
Project: marathonv5   File: JListJavaElementTest.java   View source code 5 votes vote down vote up
public void assertContentWithMultipleDuplicates() {
    SwingUtilities.invokeLater(new Runnable() {
        @Override public void run() {
            JList jlist = (JList) ComponentUtils.findComponent(JList.class, frame);
            DefaultListModel model = (DefaultListModel) jlist.getModel();
            model.set(2, "List Item - 1");
            model.set(3, "List Item - 1");
        }
    });
    IJavaElement list = driver.findElementByName("list-1");
    String expected = "[[\"List Item - 1\",\"List Item - 2\",\"List Item - 1(1)\",\"List Item - 1(2)\",\"List Item - 5\",\"List Item - 6\",\"List Item - 7\",\"List Item - 8\",\"List Item - 9\",\"List Item - 10\",\"List Item - 11\",\"List Item - 12\",\"List Item - 13\",\"List Item - 14\",\"List Item - 15\",\"List Item - 16\",\"List Item - 17\",\"List Item - 18\",\"List Item - 19\",\"List Item - 20\",\"List Item - 21\",\"List Item - 22\",\"List Item - 23\",\"List Item - 24\",\"List Item - 25\",\"List Item - 26\",\"List Item - 27\",\"List Item - 28\",\"List Item - 29\",\"List Item - 30\"]]";
    AssertJUnit.assertEquals(expected, list.getAttribute("content"));
}
 
Example 31
Project: incubator-netbeans   File: CodeCompletionPanel.java   View source code 5 votes vote down vote up
private void javaCompletionExcluderEditButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javaCompletionExcluderEditButtonActionPerformed
    JList list = getSelectedExcluderList();
    int index = list.getSelectedIndex();
    if (index == -1)
    return;
    DefaultListModel model = (DefaultListModel) list.getModel();
    javaExcluderEditing = (String) model.getElementAt(index);
    openExcluderEditor();
}
 
Example 32
Project: incubator-netbeans   File: BranchSelector.java   View source code 5 votes vote down vote up
private void applyFilter () {
    HgBranch selectedBranch = getSelectedBranch();
    DefaultListModel targetsModel = new DefaultListModel();
    targetsModel.removeAllElements();
    HgBranch toSelect = null;
    String filter = panel.txtFilter.getText();
    synchronized (LOCK) {
        for (HgBranch branch : branches) {
            if (applies(filter, branch)) {
                if (selectedBranch != null && branch.getRevisionInfo().getCSetShortID().equals(selectedBranch.getRevisionInfo().getCSetShortID())) {
                    toSelect = branch;
                } else if (parentRevision != null && branch.getRevisionInfo().getCSetShortID().equals(parentRevision.getChangesetId())) {
                    toSelect = branch;
                }
                targetsModel.addElement(branch);
            }
        }
    }
    if (targetsModel.isEmpty()) {
        targetsModel.addElement(NO_BRANCH);
    }
    if (!Arrays.equals(targetsModel.toArray(), ((DefaultListModel) panel.branchList.getModel()).toArray())) {
        panel.branchList.setModel(targetsModel);
        if (toSelect != null) {
            panel.branchList.setSelectedValue(toSelect, true);
        } else if (targetsModel.size() > 0) {
            panel.branchList.setSelectedIndex(0);
        }
    }
}
 
Example 33
Project: JavaGridControl   File: SensorZone.java   View source code 5 votes vote down vote up
public SensorZone(String name, List<String> sensors) {
	this.setBorder(new TitledBorder(name + ":"));

	DefaultListModel<String> model = new DefaultListModel<>();
	for (String s : sensors)
		model.addElement(s);
	this.sensors.setModel(model);
	this.setViewportView(this.sensors);
}
 
Example 34
Project: powertext   File: ParameterizedCompletionChoicesWindow.java   View source code 5 votes vote down vote up
/**
 * Constructor.
 *
 * @param parent The parent window (hosting the text component).
 * @param ac The auto-completion instance.
 * @param context The completion context.
 */
public ParameterizedCompletionChoicesWindow(Window parent,
					AutoCompletion ac,
					final ParameterizedCompletionContext context) {

	super(parent);
	this.ac = ac;
	ComponentOrientation o = ac.getTextComponentOrientation();

	model = new DefaultListModel();
	list = new JList(model);
	if (ac.getParamChoicesRenderer()!=null) {
		list.setCellRenderer(ac.getParamChoicesRenderer());
	}
	list.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseClicked(MouseEvent e) {
			if (e.getClickCount()==2) {
				context.insertSelectedChoice();
			}
		}
	});
	sp = new JScrollPane(list);

	setContentPane(sp);
	applyComponentOrientation(o);
	setFocusableWindowState(false);

	// Give apps a chance to decorate us with drop shadows, etc.
	PopupWindowDecorator decorator = PopupWindowDecorator.get();
	if (decorator!=null) {
		decorator.decorate(this);
	}

}
 
Example 35
Project: incubator-netbeans   File: FmtCodeGeneration.java   View source code 5 votes vote down vote up
private void downButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_downButtonActionPerformed
    int idx = membersOrderList.getSelectedIndex();
    if (idx >= 0 && idx < membersOrderList.getModel().getSize() - 1) {
        Object val = membersOrderList.getModel().getElementAt(idx);
        ((DefaultListModel)membersOrderList.getModel()).removeElementAt(idx);
        ((DefaultListModel)membersOrderList.getModel()).insertElementAt(val, idx + 1);
        membersOrderList.setSelectedIndex(idx + 1);
    }
}
 
Example 36
Project: sbc-qsystem   File: FServiceChangeDialod.java   View source code 5 votes vote down vote up
private void jRemoveSelectedOfficeButtonAction(java.awt.event.ActionEvent evt) {
    DefaultListModel model = (DefaultListModel) jOfficeSelected.getModel();
    int selectedIndex = jOfficeSelected.getSelectedIndex();
    QOffice officeToRemove = (QOffice) jOfficeSelected.getSelectedValue();
    if (selectedIndex != -1) {
        model.remove(selectedIndex);
    }
    officesToRemove.add(officeToRemove);

    //Remove the office from the "Add" list, if it exists there
    if (officesToAdd.contains(officeToRemove)) {
        officesToAdd.remove(officeToRemove);
    }
}
 
Example 37
Project: Equella   File: ControlDialog.java   View source code 5 votes vote down vote up
private void setup()
{
	JLabel label = new JLabel(getTitle());

	model = new DefaultListModel();
	list = new JList(model);
	list.setCellRenderer(new Renderer(repository));
	list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	list.addListSelectionListener(this);
	list.addMouseListener(this);

	ok = new JButton("OK");
	cancel = new JButton("Cancel");

	ok.addActionListener(this);
	cancel.addActionListener(this);

	final int height1 = label.getPreferredSize().height;
	final int height2 = ok.getPreferredSize().height;
	final int width1 = cancel.getPreferredSize().width;

	final int[] rows = {height1, TableLayout.FILL, height2,};
	final int[] cols = {TableLayout.FILL, width1, width1,};

	content = new JPanel(new TableLayout(rows, cols));
	content.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

	content.add(label, new Rectangle(0, 0, 3, 1));
	content.add(new JScrollPane(list), new Rectangle(0, 1, 3, 1));
	content.add(ok, new Rectangle(1, 2, 1, 1));
	content.add(cancel, new Rectangle(2, 2, 1, 1));

	updateButtons();
}
 
Example 38
Project: Equella   File: NetworkShuffleList.java   View source code 5 votes vote down vote up
private void setup()
{
	add = new JButton(CurrentLocale.get("com.dytech.edge.admin.helper.networkshufflelist.add"));
	remove = new JButton(CurrentLocale.get("com.dytech.edge.admin.helper.networkshufflelist.remove"));

	add.addActionListener(this);
	remove.addActionListener(this);

	model = new DefaultListModel();
	list = new JList(model);
	list.addListSelectionListener(this);

	listScroll = new JScrollPane(list);

	final int height1 = add.getPreferredSize().height;
	final int width1 = add.getPreferredSize().width;

	final int[] rows = new int[]{height1, height1, TableLayout.FILL};
	final int[] columns = new int[]{width1, TableLayout.FILL};

	TableLayout layout = new TableLayout(rows, columns, 5, 5);
	setLayout(layout);

	add(add, new Rectangle(0, 0, 1, 1));
	add(remove, new Rectangle(0, 1, 1, 1));
	add(listScroll, new Rectangle(1, 0, 1, 3));

	refreshButtons();
}
 
Example 39
Project: incubator-netbeans   File: CategoryPanelFormatters.java   View source code 5 votes vote down vote up
private void formattersMoveDownButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_formattersMoveDownButtonActionPerformed
    int index = formattersList.getSelectedIndex();
    if (index < 0) return ;
    DefaultListModel model = (DefaultListModel) formattersList.getModel();
    if (index >= (model.getSize() - 1)) return ;
    Object obj = model.remove(index);
    model.insertElementAt(obj, index + 1);
    formattersList.setSelectedIndex(index + 1);
}
 
Example 40
Project: incubator-netbeans   File: CategoryPanelFormatters.java   View source code 5 votes vote down vote up
@Override
public void load() {
    VariablesFormatter[] formatters = VariablesFormatter.loadFormatters();
    DefaultListModel filterClassesModel = (DefaultListModel) formattersList.getModel();
    filterClassesModel.clear();
    if (formatters != null) {
        for (int i = 0; i < formatters.length; i++) {
            filterClassesModel.addElement(formatters[i]);
        }
        if (formatters.length > 0) {
            formattersList.setSelectedValue(formatters[0], true);
        }
    }
}