use of java.beans.PropertyChangeListener in project bndtools by bndtools.
the class RunPropertiesPart method createSection.
private void createSection(Section section, FormToolkit toolkit) {
section.setText("Runtime Properties");
final Composite composite = toolkit.createComposite(section);
section.setClient(composite);
// Create controls: Run Properties
Label lblRunProperties = toolkit.createLabel(composite, "OSGi Framework properties:");
tblRunProperties = toolkit.createTable(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
viewRunProperties = new TableViewer(tblRunProperties);
runPropertiesModifier = new MapEntryCellModifier<>(viewRunProperties);
tblRunProperties.setHeaderVisible(true);
final TableColumn tblRunPropsCol1 = new TableColumn(tblRunProperties, SWT.NONE);
tblRunPropsCol1.setText("Name");
tblRunPropsCol1.setWidth(100);
final TableColumn tblRunPropsCol2 = new TableColumn(tblRunProperties, SWT.NONE);
tblRunPropsCol1.setText("Value");
tblRunPropsCol1.setWidth(100);
viewRunProperties.setUseHashlookup(true);
viewRunProperties.setColumnProperties(MapEntryCellModifier.getColumnProperties());
runPropertiesModifier.addCellEditorsToViewer();
viewRunProperties.setCellModifier(runPropertiesModifier);
viewRunProperties.setContentProvider(new MapContentProvider());
viewRunProperties.setLabelProvider(new PropertiesTableLabelProvider());
Control createRemovePropsToolBar = createRemovePropsPart.createControl(composite, SWT.FLAT | SWT.VERTICAL);
// Create controls: program args
Label lblProgramArgs = toolkit.createLabel(composite, "Launcher Arguments:");
txtProgramArgs = toolkit.createText(composite, "", SWT.MULTI | SWT.BORDER);
ToolTips.setupMessageAndToolTipFromSyntax(txtProgramArgs, Constants.RUNPROGRAMARGS);
// Create controls: vm args
Label lblVmArgs = toolkit.createLabel(composite, "JVM Arguments:");
txtVmArgs = toolkit.createText(composite, "", SWT.MULTI | SWT.BORDER);
ToolTips.setupMessageAndToolTipFromSyntax(txtVmArgs, Constants.RUNVM);
// Layout
GridLayout gl;
GridData gd;
gl = new GridLayout(2, false);
gl.marginWidth = 0;
gl.marginHeight = 0;
composite.setLayout(gl);
lblRunProperties.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
gd = new GridData(SWT.FILL, SWT.FILL, true, false);
gd.heightHint = 50;
gd.widthHint = 50;
tblRunProperties.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.TOP, false, true);
createRemovePropsToolBar.setLayoutData(gd);
lblProgramArgs.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
gd.heightHint = 40;
gd.widthHint = 50;
txtProgramArgs.setLayoutData(gd);
lblVmArgs.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
gd.heightHint = 40;
gd.widthHint = 50;
txtVmArgs.setLayoutData(gd);
// Listeners
viewRunProperties.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
createRemovePropsPart.setRemoveEnabled(!viewRunProperties.getSelection().isEmpty());
}
});
createRemovePropsPart.addListener(new AddRemoveListener() {
@Override
public void addSelected() {
runProperties.put("name", "");
viewRunProperties.add("name");
markDirty();
viewRunProperties.editElement("name", 0);
}
@Override
public void removeSelected() {
@SuppressWarnings("rawtypes") Iterator iter = ((IStructuredSelection) viewRunProperties.getSelection()).iterator();
while (iter.hasNext()) {
Object item = iter.next();
runProperties.remove(item);
viewRunProperties.remove(item);
}
markDirty();
}
});
runPropertiesModifier.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
markDirty();
}
});
txtProgramArgs.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent ev) {
lock.ifNotModifying(new Runnable() {
@Override
public void run() {
markDirty();
programArgs = txtProgramArgs.getText();
if (programArgs.length() == 0)
programArgs = null;
}
});
}
});
txtVmArgs.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent ev) {
lock.ifNotModifying(new Runnable() {
@Override
public void run() {
markDirty();
vmArgs = txtVmArgs.getText();
if (vmArgs.length() == 0)
vmArgs = null;
}
});
}
});
composite.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
Rectangle area = composite.getClientArea();
Point preferredSize = tblRunProperties.computeSize(SWT.DEFAULT, SWT.DEFAULT);
int width = area.width - 2 * tblRunProperties.getBorderWidth();
if (preferredSize.y > area.height + tblRunProperties.getHeaderHeight()) {
// Subtract the scrollbar width from the total column width
// if a vertical scrollbar will be required
Point vBarSize = tblRunProperties.getVerticalBar().getSize();
width -= vBarSize.x;
}
Point oldSize = tblRunProperties.getSize();
if (oldSize.x > area.width) {
// table is getting smaller so make the columns
// smaller first and then resize the table to
// match the client area width
tblRunPropsCol1.setWidth(width / 3);
tblRunPropsCol2.setWidth(width - tblRunPropsCol1.getWidth());
tblRunProperties.setSize(area.width, area.height);
} else {
// table is getting bigger so make the table
// bigger first and then make the columns wider
// to match the client area width
tblRunProperties.setSize(area.width, area.height);
tblRunPropsCol1.setWidth(width / 3);
tblRunPropsCol2.setWidth(width - tblRunPropsCol1.getWidth());
}
}
});
}
use of java.beans.PropertyChangeListener in project JMRI by JMRI.
the class Section method initializeBlocks.
private void initializeBlocks() {
for (int i = 0; i < blockNameList.size(); i++) {
Block b = InstanceManager.getDefault(jmri.BlockManager.class).getBlock(blockNameList.get(i));
if (b == null) {
log.error("Missing Block - " + blockNameList.get(i) + " - when initializing Section - " + getSystemName());
} else {
if (mBlockEntries.isEmpty()) {
mFirstBlock = b;
}
mBlockEntries.add(b);
mLastBlock = b;
PropertyChangeListener listener = (PropertyChangeEvent e) -> {
handleBlockChange(e);
};
b.addPropertyChangeListener(listener);
mBlockListeners.add(listener);
}
}
initializationNeeded = false;
}
use of java.beans.PropertyChangeListener in project JMRI by JMRI.
the class AddressPanel method initGUI.
/**
* Create, initialize and place the GUI objects.
*/
private void initGUI() {
mainPanel = new JPanel();
this.setContentPane(mainPanel);
this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
mainPanel.setLayout(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
constraints.anchor = GridBagConstraints.CENTER;
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.insets = new Insets(2, 2, 2, 2);
constraints.weightx = 1;
constraints.weighty = 0;
constraints.gridx = 0;
constraints.gridy = 0;
constraints.ipadx = -16;
if (jmri.util.SystemType.isLinux()) {
constraints.ipady = 0;
} else {
constraints.ipady = -16;
}
addrSelector.setVariableSize(true);
mainPanel.add(addrSelector.getCombinedJPanel(), constraints);
setButton = new JButton(Bundle.getMessage("ButtonSet"));
constraints.gridx = GridBagConstraints.RELATIVE;
constraints.fill = GridBagConstraints.NONE;
constraints.weightx = 0;
constraints.ipadx = constraints.ipady = 0;
mainPanel.add(setButton, constraints);
setButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
consistAddress = null;
changeOfAddress();
}
});
rosterBox = new RosterEntrySelectorPanel();
getRosterEntrySelector().setNonSelectedItem(Bundle.getMessage("NoLocoSelected"));
getRosterEntrySelector().setToolTipText(Bundle.getMessage("SelectLocoFromRosterTT"));
getRosterEntrySelector().addPropertyChangeListener("selectedRosterEntries", new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent pce) {
rosterItemSelected();
}
});
constraints.gridx = 0;
constraints.gridy = GridBagConstraints.RELATIVE;
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.weightx = 1;
constraints.weighty = 0;
constraints.gridwidth = GridBagConstraints.REMAINDER;
mainPanel.add(getRosterEntrySelector(), constraints);
conRosterBox = NceConsistRoster.instance().fullRosterComboBox();
if (NceConsistRoster.instance().numEntries() > 0) {
// empty entry
conRosterBox.insertItemAt(Bundle.getMessage("NoConsistSelected"), 0);
conRosterBox.setSelectedIndex(0);
conRosterBox.setToolTipText(Bundle.getMessage("SelectConsistFromRosterTT"));
conRosterBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
consistRosterSelected();
}
});
constraints.gridx = 0;
constraints.gridy = GridBagConstraints.RELATIVE;
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.weightx = 1;
constraints.weighty = 0;
mainPanel.add(conRosterBox, constraints);
}
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new FlowLayout());
dispatchButton = new JButton(Bundle.getMessage("ButtonDispatch"));
buttonPanel.add(dispatchButton);
dispatchButton.setEnabled(false);
dispatchButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dispatchAddress();
}
});
releaseButton = new JButton(Bundle.getMessage("ButtonRelease"));
buttonPanel.add(releaseButton);
releaseButton.setEnabled(false);
releaseButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
releaseAddress();
}
});
progButton = new JButton(Bundle.getMessage("ButtonProgram"));
buttonPanel.add(progButton);
progButton.setEnabled(false);
progButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
openProgrammer();
}
});
constraints.gridx = 0;
constraints.gridy = GridBagConstraints.RELATIVE;
constraints.gridwidth = 2;
constraints.weighty = 0;
constraints.insets = new Insets(0, 0, 0, 0);
mainPanel.add(buttonPanel, constraints);
pack();
}
use of java.beans.PropertyChangeListener in project JMRI by JMRI.
the class VSDecoderPreferences method set.
public void set(VSDecoderPreferences tp) {
setAutoStartEngine(tp.isAutoStartingEngine());
setAutoLoadDefaultVSDFile(tp.isAutoLoadingDefaultVSDFile());
setDefaultVSDFilePath(tp.getDefaultVSDFilePath());
setDefaultVSDFileName(tp.getDefaultVSDFileName());
setListenerPosition(tp.getListenerPosition());
setAudioMode(tp.getAudioMode());
if (listeners != null) {
for (int i = 0; i < listeners.size(); i++) {
PropertyChangeListener l = listeners.get(i);
PropertyChangeEvent e = new PropertyChangeEvent(this, "VSDecoderPreferences", null, this);
l.propertyChange(e);
}
}
}
use of java.beans.PropertyChangeListener in project JMRI by JMRI.
the class AbstractNamedBean method dispose.
@Override
@OverridingMethodsMustInvokeSuper
public void dispose() {
PropertyChangeListener[] listeners = pcs.getPropertyChangeListeners();
for (PropertyChangeListener l : listeners) {
pcs.removePropertyChangeListener(l);
register.remove(l);
listenerRefs.remove(l);
}
}
Aggregations