use of org.eclipse.jface.preference.PreferenceStore in project cubrid-manager by CUBRID.
the class CMHostNodePersistManager method loadSevers.
/**
*
* Load added host from preference file path
*
* @param workspacePath String
* @return boolean whether import
*
*/
public boolean loadSevers(String workspacePath) {
synchronized (this) {
String settingPath = workspacePath + File.separator + ".metadata" + File.separator + ".plugins" + File.separator + "org.eclipse.core.runtime" + File.separator + ".settings" + File.separator;
//Load global preference setting
QueryOptions.load(settingPath, null);
String serverPath = settingPath + File.separator + "com.cubrid.cubridmanager.ui.prefs";
PreferenceStore preference = new PreferenceStore(serverPath);
int size = serverList.size();
try {
preference.load();
String xmlString = preference.getString(SERVER_XML_CONTENT);
if (xmlString == null || xmlString.trim().length() == 0) {
return false;
}
ByteArrayInputStream in = new ByteArrayInputStream(xmlString.getBytes("UTF-8"));
IXMLMemento memento = XMLMemento.loadMemento(in);
loadServers(memento, true, settingPath);
} catch (IOException e) {
LOGGER.error(e.getMessage());
}
boolean isImported = size != serverList.size();
if (isImported) {
saveServers();
}
return isImported;
}
}
use of org.eclipse.jface.preference.PreferenceStore in project cubrid-manager by CUBRID.
the class CQBGroupNodePersistManager method loadGroupNode.
/**
* Load group nodes from file preference.
*
* @param workspacePath String
* @return boolean whether import
*/
public boolean loadGroupNode(String workspacePath) {
synchronized (this) {
String filePath = workspacePath + File.separator + ".metadata" + File.separator + ".plugins" + File.separator + "org.eclipse.core.runtime" + File.separator + ".settings" + File.separator + "com.cubrid.cubridquery.ui.prefs";
PreferenceStore preference = new PreferenceStore(filePath);
int size = groupNodeList.size();
try {
preference.load();
String xmlString = preference.getString(COM_CUBRID_QB_DBGROUP);
if (xmlString == null || xmlString.trim().length() == 0) {
return false;
}
ByteArrayInputStream in = new ByteArrayInputStream(xmlString.getBytes("UTF-8"));
IXMLMemento memento = XMLMemento.loadMemento(in);
loadGroupNode(memento);
} catch (IOException e) {
LOGGER.error(e.getMessage());
}
boolean isImported = size != groupNodeList.size();
if (isImported) {
saveAllGroupNode();
}
return isImported;
}
}
use of org.eclipse.jface.preference.PreferenceStore in project cubrid-manager by CUBRID.
the class CQBDBNodePersistManager method loadDatabases.
/**
*
* Load added host from file preference
*
* @param workspacePath String
* @return boolean whether imported
*
*/
public boolean loadDatabases(String workspacePath) {
synchronized (this) {
String settingPath = workspacePath + File.separator + ".metadata" + File.separator + ".plugins" + File.separator + "org.eclipse.core.runtime" + File.separator + ".settings" + File.separator;
String serverPath = settingPath + File.separator + "com.cubrid.cubridquery.ui.prefs";
PreferenceStore preference = new PreferenceStore(serverPath);
int size = databaseList.size();
try {
preference.load();
String xmlString = preference.getString(DATABASE_XML_CONTENT);
if (xmlString == null || xmlString.trim().length() == 0) {
return false;
}
ByteArrayInputStream in = new ByteArrayInputStream(xmlString.getBytes("UTF-8"));
IXMLMemento memento = XMLMemento.loadMemento(in);
loadDatabases(memento, true, settingPath);
} catch (IOException e) {
LOGGER.error(e.getMessage());
}
boolean isImported = size != databaseList.size();
if (isImported) {
saveDatabases();
}
return isImported;
}
}
use of org.eclipse.jface.preference.PreferenceStore in project eclipse.platform.text by eclipse.
the class ChangeEncodingAction method run.
@Override
public void run() {
final IResource resource = getResource();
final Shell parentShell = getTextEditor().getSite().getShell();
final IEncodingSupport encodingSupport = getEncodingSupport();
if (resource == null && encodingSupport == null) {
MessageDialog.openInformation(parentShell, fDialogTitle, TextEditorMessages.ChangeEncodingAction_message_noEncodingSupport);
return;
}
Dialog dialog = new Dialog(parentShell) {
private AbstractEncodingFieldEditor fEncodingEditor;
private IPreferenceStore store = null;
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText(fDialogTitle);
}
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
composite = new Composite(composite, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
composite.setLayout(layout);
GridData data = new GridData(GridData.FILL_BOTH);
composite.setLayoutData(data);
composite.setFont(parent.getFont());
DialogPage page = new MessageDialogPage(composite) {
@Override
public void setErrorMessage(String newMessage) {
super.setErrorMessage(newMessage);
setButtonEnabledState(IDialogConstants.OK_ID, newMessage == null);
setButtonEnabledState(APPLY_ID, newMessage == null);
}
private void setButtonEnabledState(int id, boolean state) {
Button button = getButton(id);
if (button != null)
button.setEnabled(state);
}
};
if (resource != null) {
// $NON-NLS-1$
fEncodingEditor = new ResourceEncodingFieldEditor("", composite, resource, null);
fEncodingEditor.setPage(page);
fEncodingEditor.load();
} else {
// $NON-NLS-1$
fEncodingEditor = new EncodingFieldEditor(ENCODING_PREF_KEY, "", null, composite);
store = new PreferenceStore();
String defaultEncoding = encodingSupport.getDefaultEncoding();
store.setDefault(ENCODING_PREF_KEY, defaultEncoding);
String encoding = encodingSupport.getEncoding();
if (encoding != null)
store.setValue(ENCODING_PREF_KEY, encoding);
fEncodingEditor.setPreferenceStore(store);
fEncodingEditor.setPage(page);
fEncodingEditor.load();
if (encoding == null || encoding.equals(defaultEncoding) || encoding.length() == 0)
fEncodingEditor.loadDefault();
}
return composite;
}
@Override
protected void createButtonsForButtonBar(Composite parent) {
createButton(parent, APPLY_ID, TextEditorMessages.ChangeEncodingAction_button_apply_label, false);
super.createButtonsForButtonBar(parent);
}
@Override
protected void buttonPressed(int buttonId) {
if (buttonId == APPLY_ID)
apply();
else
super.buttonPressed(buttonId);
}
@Override
protected void okPressed() {
apply();
super.okPressed();
}
private void apply() {
fEncodingEditor.store();
if (resource == null) {
String encoding = fEncodingEditor.getPreferenceStore().getString(fEncodingEditor.getPreferenceName());
encodingSupport.setEncoding(encoding);
}
}
};
dialog.open();
}
use of org.eclipse.jface.preference.PreferenceStore in project eclipse.platform.text by eclipse.
the class ChainedPreferenceStoreTest method testChainedStore3.
/**
* Case where the initial implementation used to throw an IAE
*/
@Test
public void testChainedStore3() {
IPreferenceStore store1 = new PreferenceStore();
IPreferenceStore store2 = new PreferenceStore();
IPreferenceStore chainedStore = new ChainedPreferenceStore(new IPreferenceStore[] { store1, store2 });
store2.setDefault(PROPERTY, DEFAULT_VALUE);
chainedStore.addPropertyChangeListener(fPropertyChangeListener);
// simulated removal with oldValue == null
store1.firePropertyChangeEvent(PROPERTY, null, null);
chainedStore.removePropertyChangeListener(fPropertyChangeListener);
assertEquals(1, fEvents.size());
PropertyChangeEvent event = fEvents.get(0);
assertEquals(chainedStore, event.getSource());
assertEquals(PROPERTY, event.getProperty());
assertEquals(null, event.getOldValue());
assertEquals(DEFAULT_VALUE, event.getNewValue());
}
Aggregations