use of org.eclipse.jface.util.PropertyChangeEvent in project eclipse.platform.text by eclipse.
the class PropagatingFontFieldEditor method startPropagate.
/**
* Starts the propagation of the font preference stored in the source preference
* store under the source key to the target preference store using the target
* preference key.
*
* @param source the source preference store
* @param sourceKey the key to be used in the source preference store
* @param target the target preference store
* @param targetKey the key to be used in the target preference store
*/
public static void startPropagate(final IPreferenceStore source, final String sourceKey, final IPreferenceStore target, final String targetKey) {
source.addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (sourceKey.equals(event.getProperty()))
propagateFont(source, sourceKey, target, targetKey);
}
});
propagateFont(source, sourceKey, target, targetKey);
}
use of org.eclipse.jface.util.PropertyChangeEvent in project knime-core by knime.
the class KNIMECorePlugin method start.
/**
* This method is called upon plug-in activation.
*
* @param context The OSGI bundle context
* @throws Exception If this plugin could not be started
*/
@Override
public void start(final BundleContext context) throws Exception {
super.start(context);
if (!Boolean.getBoolean("java.awt.headless") && (Display.getCurrent() != null)) {
getImageRegistry();
}
try {
// get the preference store
// with the preferences for nr threads and tempDir
IPreferenceStore pStore = KNIMECorePlugin.getDefault().getPreferenceStore();
initMaxThreadCountProperty();
initTmpDirProperty();
// set log file level to stored
String logLevelFile = pStore.getString(HeadlessPreferencesConstants.P_LOGLEVEL_LOG_FILE);
NodeLogger.setAppenderLevelRange(NodeLogger.LOGFILE_APPENDER, LEVEL.valueOf(logLevelFile), LEVEL.FATAL);
final boolean enableWorkflowRelativeLogging = pStore.getBoolean(HeadlessPreferencesConstants.P_LOG_FILE_LOCATION);
NodeLogger.logInWorkflowDir(enableWorkflowRelativeLogging);
final boolean enableGlobalInWfLogging = pStore.getBoolean(HeadlessPreferencesConstants.P_LOG_GLOBAL_IN_WF_DIR);
NodeLogger.logGlobalMsgsInWfDir(enableGlobalInWfLogging);
pStore.addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent event) {
if (event.getProperty().equals(HeadlessPreferencesConstants.P_MAXIMUM_THREADS)) {
if (!(event.getNewValue() instanceof Integer)) {
// not set, they send an empty string
return;
}
int count;
try {
count = (Integer) event.getNewValue();
KNIMEConstants.GLOBAL_THREAD_POOL.setMaxThreads(count);
} catch (Exception e) {
LOGGER.error("Unable to get maximum thread count " + " from preference page.", e);
}
} else if (event.getProperty().equals(HeadlessPreferencesConstants.P_TEMP_DIR)) {
if (!(event.getNewValue() instanceof String)) {
// not set, they send an empty string
return;
}
String dirName = (String) event.getNewValue();
if (dirName.isEmpty()) {
return;
}
File f = new File(dirName);
LOGGER.debug("Setting temp dir to " + f.getAbsolutePath());
try {
KNIMEConstants.setKNIMETempDir(f);
} catch (Exception e) {
LOGGER.error("Setting temp dir failed: " + e.getMessage(), e);
}
} else if (event.getProperty().equals(HeadlessPreferencesConstants.P_LOGLEVEL_LOG_FILE)) {
if (!(event.getNewValue() instanceof String)) {
// not set, they send an empty string
return;
}
String newName = (String) event.getNewValue();
if (newName.isEmpty()) {
return;
}
LEVEL level = LEVEL.WARN;
try {
level = LEVEL.valueOf(newName);
} catch (IllegalArgumentException iae) {
LOGGER.error("Invalid log level " + newName + ", using WARN");
}
NodeLogger.setAppenderLevelRange(NodeLogger.LOGFILE_APPENDER, level, LEVEL.FATAL);
} else if (event.getProperty().equals(HeadlessPreferencesConstants.P_LOG_FILE_LOCATION)) {
if (!(event.getNewValue() instanceof Boolean)) {
// when preferences are imported and this value is not set, they send an empty string
return;
}
Boolean enable = (Boolean) event.getNewValue();
NodeLogger.logInWorkflowDir(enable);
} else if (event.getProperty().equals(HeadlessPreferencesConstants.P_LOG_GLOBAL_IN_WF_DIR)) {
if (!(event.getNewValue() instanceof Boolean)) {
// when preferences are imported and this value is not set, they send an empty string
return;
}
Boolean enable = (Boolean) event.getNewValue();
NodeLogger.logGlobalMsgsInWfDir(enable);
} else if (P_LOGLEVEL_CONSOLE.equals(event.getProperty())) {
if (!(event.getNewValue() instanceof String)) {
// not set, they send an empty string
return;
}
String newName = (String) event.getNewValue();
if (newName.isEmpty()) {
return;
}
setLogLevel(newName);
} else if (HeadlessPreferencesConstants.P_DATABASE_DRIVERS.equals(event.getProperty())) {
String dbDrivers = (String) event.getNewValue();
initDatabaseDriver(dbDrivers);
} else if (HeadlessPreferencesConstants.P_DATABASE_TIMEOUT.equals(event.getProperty())) {
DatabaseConnectionSettings.setDatabaseTimeout(Integer.parseInt(event.getNewValue().toString()));
}
}
});
// end property listener
String logLevelConsole = pStore.getString(P_LOGLEVEL_CONSOLE);
if (!Boolean.getBoolean("java.awt.headless") && PlatformUI.isWorkbenchRunning()) {
try {
ConsoleViewAppender.FORCED_APPENDER.write(KNIMEConstants.WELCOME_MESSAGE);
ConsoleViewAppender.INFO_APPENDER.write("Log file is located at: " + KNIMEConstants.getKNIMEHomeDir() + File.separator + NodeLogger.LOG_FILE + "\n");
} catch (IOException ioe) {
LOGGER.error("Could not print welcome message: ", ioe);
}
setLogLevel(logLevelConsole);
}
// encryption key supplier registered with the eclipse framework
// and serves as a master key provider
KnimeEncryption.setEncryptionKeySupplier(new EclipseEncryptionKeySupplier());
// load database driver files from core preference page
String dbDrivers = pStore.getString(HeadlessPreferencesConstants.P_DATABASE_DRIVERS);
initDatabaseDriver(dbDrivers);
DatabaseConnectionSettings.setDatabaseTimeout(pStore.getInt(HeadlessPreferencesConstants.P_DATABASE_TIMEOUT));
} catch (Throwable e) {
LOGGER.error("Error while starting workbench, some setting may not have been applied properly: " + e.getMessage(), e);
}
}
use of org.eclipse.jface.util.PropertyChangeEvent in project knime-core by knime.
the class KNIMEUIPlugin method start.
/**
* This method is called upon plug-in activation.
*
* @param context The bundle context
* @throws Exception If failed
*/
@Override
public void start(final BundleContext context) throws Exception {
super.start(context);
// create a knime encryption supplier that reads in an encryption key
// from the user via a dialog or directly from the preference page
KnimeEncryption.setEncryptionKeySupplier(MasterKeyPreferencePage.SUPPLIER);
if (Display.getCurrent() != null) {
// do not load UI stuff if we run, e.g. the batch executor
getImageRegistry().put("knime", imageDescriptorFromPlugin(PLUGIN_ID, "/icons/knime_default.png"));
}
IPreferenceStore prefStore = getPreferenceStore();
int freqHistorySize = prefStore.getInt(PreferenceConstants.P_FAV_FREQUENCY_HISTORY_SIZE);
int usedHistorySize = prefStore.getInt(PreferenceConstants.P_FAV_LAST_USED_SIZE);
boolean wrapColumnHeaderInTable = prefStore.getBoolean(PreferenceConstants.P_WRAP_TABLE_HEADER);
prefStore.addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent event) {
String prop = event.getProperty();
if (PreferenceConstants.P_FAV_FREQUENCY_HISTORY_SIZE.equals(prop)) {
if (!(event.getNewValue() instanceof Integer)) {
// not set, they send an empty string
return;
}
int count;
try {
count = (Integer) event.getNewValue();
NodeUsageRegistry.setMaxFrequentSize(count);
} catch (Exception e) {
LOGGER.error("Unable to set maximum number of " + "frequently used nodes", e);
}
} else if (PreferenceConstants.P_FAV_LAST_USED_SIZE.equals(prop)) {
if (!(event.getNewValue() instanceof Integer)) {
// not set, they send an empty string
return;
}
int count;
try {
count = (Integer) event.getNewValue();
NodeUsageRegistry.setMaxLastUsedSize(count);
} catch (Exception e) {
LOGGER.error("Unable to set maximum number of " + "last used nodes", e);
}
} else if (PreferenceConstants.P_WRAP_TABLE_HEADER.equals(prop) && (event.getNewValue() instanceof Boolean)) {
CorePlugin.getInstance().setWrapColumnHeaderInTableViews((Boolean) event.getNewValue());
}
}
});
try {
NodeUsageRegistry.setMaxFrequentSize(freqHistorySize);
NodeUsageRegistry.setMaxLastUsedSize(usedHistorySize);
} catch (Exception e) {
LOGGER.error("Error during loading of node usage history: ", e);
}
CorePlugin.getInstance().setWrapColumnHeaderInTableViews(wrapColumnHeaderInTable);
// hide already installed IU by default in install wizard
// its a bit dirty but there is no API to set the option
// the constants are taken from AvailableIUsPage
IDialogSettings ds = ProvUIActivator.getDefault().getDialogSettings();
IDialogSettings ds2 = ds.getSection("AvailableIUsPage");
if (ds2 == null) {
ds2 = ds.addNewSection("AvailableIUsPage");
ds2.put("HideInstalledContent", true);
} else if (ds2.get("HideInstalledContent") == null) {
ds2.put("HideInstalledContent", true);
}
}
use of org.eclipse.jface.util.PropertyChangeEvent in project knime-core by knime.
the class NodeOutputView method createPartControl.
/**
* {@inheritDoc}
*/
@Override
public void createPartControl(final Composite parent) {
// Toolbar
IToolBarManager toolbarMGR = getViewSite().getActionBars().getToolBarManager();
// create button for stick with branch.
final RetargetAction lockAction = new RetargetAction("StayOnBranch", "Pin view to new node added to branch", IAction.AS_CHECK_BOX);
lockAction.setImageDescriptor(ImageDescriptor.createFromFile(this.getClass(), "icons/lock.png"));
lockAction.setChecked(m_branchLocked);
lockAction.setEnabled(m_pinned);
lockAction.addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent event) {
if (lockAction.isChecked()) {
m_branchLocked = true;
m_selectionWhenLocked = m_lastSelection;
} else {
m_branchLocked = false;
selectionChanged(null, m_lastSelectionWhilePinned);
}
}
});
toolbarMGR.add(lockAction);
// create button which allows to "pin" selection:
m_pinButton = new RetargetAction("PinView", "Pin view to selected node", IAction.AS_CHECK_BOX);
m_pinButton.setImageDescriptor(ImageDescriptor.createFromFile(this.getClass(), "icons/pin.png"));
m_pinButton.setChecked(m_pinned);
m_pinButton.setEnabled(true);
m_pinButton.addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent event) {
if (m_pinButton.isChecked()) {
m_pinned = true;
m_lastSelectionWhilePinned = m_lastSelection;
lockAction.setEnabled(true);
} else {
m_pinned = false;
selectionChanged(null, m_lastSelectionWhilePinned);
lockAction.setEnabled(false);
}
}
});
toolbarMGR.add(m_pinButton);
toolbarMGR.add(new Separator());
// configure drop down menu
IMenuManager dropDownMenu = getViewSite().getActionBars().getMenuManager();
// drop down menu entry for outport table:
final RetargetAction menuentrytable = new RetargetAction("OutputTable", "Show Output Table", IAction.AS_RADIO_BUTTON);
menuentrytable.setChecked(DISPLAYOPTIONS.TABLE.equals(m_choice));
menuentrytable.setEnabled(true);
menuentrytable.addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent event) {
if (menuentrytable.isChecked()) {
m_choice = DISPLAYOPTIONS.TABLE;
updateNodeContainerInfo(m_lastNode);
}
}
});
dropDownMenu.add(menuentrytable);
// drop down menu entry for node variables:
final RetargetAction dropdownmenuvars = new RetargetAction("NodeVariables", "Show Variables", IAction.AS_RADIO_BUTTON);
dropdownmenuvars.setChecked(DISPLAYOPTIONS.VARS.equals(m_choice));
dropdownmenuvars.setEnabled(true);
dropdownmenuvars.addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent event) {
if (dropdownmenuvars.isChecked()) {
m_choice = DISPLAYOPTIONS.VARS;
updateNodeContainerInfo(m_lastNode);
}
}
});
dropDownMenu.add(dropdownmenuvars);
// drop down menu entry for configuration/settings:
final RetargetAction menuentrysettings = new RetargetAction("NodeConf", "Show Configuration", IAction.AS_RADIO_BUTTON);
menuentrysettings.setChecked(DISPLAYOPTIONS.SETTINGS.equals(m_choice));
menuentrysettings.setEnabled(true);
menuentrysettings.addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent event) {
if (menuentrysettings.isChecked()) {
m_choice = DISPLAYOPTIONS.SETTINGS;
updateNodeContainerInfo(m_lastNode);
}
}
});
dropDownMenu.add(menuentrysettings);
// drop down menu entry for configuration/settings:
final RetargetAction menuentryallsettings = new RetargetAction("NodeConfAll", "Show Entire Configuration", IAction.AS_RADIO_BUTTON);
menuentryallsettings.setChecked(DISPLAYOPTIONS.ALLSETTINGS.equals(m_choice));
menuentryallsettings.setEnabled(true);
menuentryallsettings.addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent event) {
if (menuentryallsettings.isChecked()) {
m_choice = DISPLAYOPTIONS.ALLSETTINGS;
updateNodeContainerInfo(m_lastNode);
}
}
});
dropDownMenu.add(menuentryallsettings);
// drop down menu entry for node graph annotations
final RetargetAction menuentrygraphannotations = new RetargetAction("NodeGraphAnno", "Show Graph Annotations", IAction.AS_RADIO_BUTTON);
menuentrygraphannotations.setChecked(DISPLAYOPTIONS.GRAPHANNOTATIONS.equals(m_choice));
menuentrygraphannotations.setEnabled(true);
menuentrygraphannotations.addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent event) {
if (menuentrygraphannotations.isChecked()) {
m_choice = DISPLAYOPTIONS.GRAPHANNOTATIONS;
updateNodeContainerInfo(m_lastNode);
}
}
});
dropDownMenu.add(menuentrygraphannotations);
// Content
GridLayoutFactory.swtDefaults().numColumns(2).applyTo(parent);
// Node Title:
Label titlelabel = new Label(parent, SWT.NONE);
titlelabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
titlelabel.setText("Node: ");
m_title = new Text(parent, SWT.BORDER);
m_title.setEditable(false);
m_title.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
m_title.setText("n/a.");
// Panel for currently displayed information (some information
// providers will add more elements to this):
Composite infoPanel = new Composite(parent, SWT.NONE);
GridData infoGrid = new GridData(SWT.FILL, SWT.TOP, true, false);
infoGrid.horizontalSpan = 2;
infoPanel.setLayoutData(infoGrid);
GridLayoutFactory.swtDefaults().numColumns(3).applyTo(infoPanel);
m_info = new Label(infoPanel, SWT.NONE);
m_info.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
m_info.setText("n/a. ");
m_portIndex = new ComboViewer(infoPanel);
m_portIndex.add(new String[] { "port 0", "port 1", "port 2" });
m_portIndex.getCombo().setEnabled(false);
m_portIndex.getCombo().setSelection(new Point(m_portIndexInit, m_portIndexInit));
m_portIndex.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
ISelection sel = event.getSelection();
try {
int newIndex = Integer.parseInt(sel.toString().substring(5).replace(']', ' ').trim());
NodeContainer node;
if (m_workflow.containsNodeContainer(m_lastNode)) {
node = m_workflow.getNodeContainer(m_lastNode);
updateDataTable(node, newIndex);
}
} catch (NumberFormatException nfe) {
// ignore.
}
}
});
// Table:
// stack panel switches between KNIME data table view and SWT table for other info
m_stackPanel = new Composite(parent, SWT.NONE);
m_stackPanel.setLayout(new StackLayout());
GridData tableGrid = new GridData(SWT.FILL, SWT.FILL, true, true);
m_stackPanel.setLayoutData(tableGrid);
// DataTable view wrapped in AWT-SWT bridge
m_tableView = new TableView();
m_tableViewPanel = new Panel2CompositeWrapper(m_stackPanel, m_tableView, SWT.NONE);
m_errorLabel = new Label(m_stackPanel, SWT.NONE);
// SWT Table for the other info
m_table = new Table(m_stackPanel, SWT.MULTI | SWT.BORDER);
m_table.setLinesVisible(true);
m_table.setHeaderVisible(true);
tableGrid.horizontalSpan = 2;
m_table.setLayoutData(tableGrid);
String[] titles = { "Name", "Value" };
for (int i = 0; i < titles.length; i++) {
TableColumn column = new TableColumn(m_table, SWT.NONE);
column.setText(titles[i]);
}
for (int i = 0; i < titles.length; i++) {
m_table.getColumn(i).pack();
}
m_lastNode = null;
getViewSite().getPage().addSelectionListener(this);
if (m_choice.equals(DISPLAYOPTIONS.TABLE)) {
((StackLayout) m_stackPanel.getLayout()).topControl = m_tableViewPanel;
m_stackPanel.layout();
} else {
((StackLayout) m_stackPanel.getLayout()).topControl = m_table;
m_stackPanel.layout();
}
m_stackPanel.layout();
selectionChanged(null, m_lastSelection);
}
use of org.eclipse.jface.util.PropertyChangeEvent in project knime-core by knime.
the class FontStyleDialog method createColorSelector.
private void createColorSelector(final Composite parent) {
Composite panel = new Composite(parent, SWT.FILL);
GridData gData = new GridData(GridData.FILL_HORIZONTAL);
panel.setLayoutData(gData);
panel.setLayout(new GridLayout(2, false));
Label msg = new Label(panel, SWT.LEFT);
msg.setText("Font color (click to change):");
msg.setLayoutData(gData);
final ColorSelector sel = new ColorSelector(panel);
sel.setColorValue(m_defColor.getRGB());
sel.addListener(new IPropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent event) {
m_color = sel.getColorValue();
}
});
m_color = null;
}
Aggregations