use of org.eclipse.jface.dialogs.IDialogSettings in project tdi-studio-se by Talend.
the class JobScriptsExportWizardPage method setDefaultDestination.
/**
* yzhang Comment method "setDefaultDestination".
*/
protected void setDefaultDestination() {
//$NON-NLS-1$
String userDir = System.getProperty("user.dir");
IPath path = new Path(userDir);
int length = nodes.length;
//$NON-NLS-1$
String destinationFile = "";
if (getDialogSettings() != null) {
IDialogSettings section = getDialogSettings().getSection(DESTINATION_FILE);
if (section != null) {
destinationFile = section.get(DESTINATION_FILE);
}
}
if (destinationFile == null || "".equals(destinationFile)) {
//$NON-NLS-1$
if (length == 1) {
// TODOthis is changed by shenhaize first open ,it show contains in the combo
path = path.append(getDefaultFileNameWithType());
} else if (length > 1) {
// i changed here ..
path = path.append(getDefaultFileNameWithType());
}
} else {
// path = new Path(destinationFile);
if (CoreRuntimePlugin.getInstance().getDesignerCoreService().getPreferenceStoreBooleanValue(IRepositoryPrefConstants.USE_EXPORT_SAVE)) {
path = new Path(destinationFile);
} else {
path = path.append(getDefaultFileNameWithType());
}
}
setDestinationValue(path.toOSString());
}
use of org.eclipse.jface.dialogs.IDialogSettings in project tdi-studio-se by Talend.
the class JavaJobScriptsExportWSWizardPage method initialiseDefaultDialogSettings.
/**
* this set default dialog settings if none already exists.
*/
private void initialiseDefaultDialogSettings() {
IDialogSettings dialogSettings = getDialogSettings();
if (dialogSettings != null) {
// set default export type according to system properties
String exportType = dialogSettings.get(STORE_EXPORTTYPE_ID);
//$NON-NLS-1$
String defaultExportType = System.getProperty("talend.export.job.default.type");
if ((exportType == null || exportType.equals("")) && defaultExportType != null && !defaultExportType.equals("")) {
//$NON-NLS-1$ //$NON-NLS-2$
dialogSettings.put(STORE_EXPORTTYPE_ID, defaultExportType);
}
}
// else ignors it
}
use of org.eclipse.jface.dialogs.IDialogSettings in project tdi-studio-se by Talend.
the class JavaJobScriptsExportWSWizardPage method restoreWidgetValuesForPOJO.
protected void restoreWidgetValuesForPOJO() {
IDialogSettings settings = getDialogSettings();
if (settings != null) {
String[] directoryNames = settings.getArray(STORE_DESTINATION_NAMES_ID);
String fileName = getDefaultFileNameWithType();
if (!fileName.endsWith(FileConstants.ZIP_FILE_SUFFIX)) {
fileName = fileName + FileConstants.ZIP_FILE_SUFFIX;
}
if (directoryNames != null && directoryNames.length > 0) {
// destination
for (int i = 0; i < directoryNames.length; i++) {
// }
if (directoryNames[i].toLowerCase().endsWith(FileConstants.ZIP_FILE_SUFFIX)) {
//$NON-NLS-1$
directoryNames[i] = (directoryNames[i].charAt(0) + "").toUpperCase() + directoryNames[i].substring(1);
addDestinationItem(directoryNames[i]);
}
}
//$NON-NLS-1$
setDestinationValue(directoryNames[0].substring(0, (directoryNames[0].lastIndexOf("\\") + 1)) + fileName);
} else {
setDefaultDestination();
}
shellLauncherButton.setSelection(settings.getBoolean(STORE_SHELL_LAUNCHER_ID));
jobItemButton.setSelection(settings.getBoolean(STORE_JOB_ID));
jobScriptButton.setSelection(settings.getBoolean(STORE_SOURCE_ID));
contextButton.setSelection(settings.getBoolean(STORE_CONTEXT_ID));
applyToChildrenButton.setSelection(settings.getBoolean(APPLY_TO_CHILDREN_ID));
chkButton.setSelection(settings.getBoolean(EXTRACT_ZIP_FILE));
zipOption = String.valueOf(chkButton.getSelection());
// genCodeButton.setSelection(settings.getBoolean(STORE_GENERATECODE_ID));
}
launcherCombo.setItems(JobScriptsManager.getLauncher());
if (JobScriptsManager.getLauncher().length > 0) {
launcherCombo.select(0);
}
if (getProcessItem() != null && contextCombo != null) {
// don't update the property, this one will be automatically updated if needed when call the getItem()
// try {
// process[0].setProcess((ProcessItem) ProxyRepositoryFactory.getInstance().getUptodateProperty(
// getProcessItem().getProperty()).getItem());
// } catch (PersistenceException e) {
// ExceptionHandler.process(e);
// }
ProcessItem item = getProcessItem();
try {
String id = item.getProperty().getId();
IRepositoryViewObject lastVersion = ProxyRepositoryFactory.getInstance().getLastVersion(id);
item = (ProcessItem) lastVersion.getProperty().getItem();
} catch (PersistenceException e) {
throw new RuntimeException(e);
}
List<String> contextNames;
contextNames = ExportJobUtil.getJobContexts(item);
contextCombo.setItems(contextNames.toArray(new String[contextNames.size()]));
if (contextNames.size() > 0) {
contextCombo.select(0);
}
}
if (log4jLevelCombo != null) {
log4jLevelCombo.setItems(Log4jPrefsSettingManager.getLevel());
if (Log4jPrefsSettingManager.getLevel().length > 0) {
log4jLevelCombo.select(2);
}
}
}
use of org.eclipse.jface.dialogs.IDialogSettings in project tesb-studio-se by Talend.
the class JavaCamelJobScriptsExportWSWizardPage method handleEvent.
@Override
public void handleEvent(Event e) {
super.handleEvent(e);
Widget source = e.widget;
if (source instanceof Combo) {
String destination = ((Combo) source).getText();
if (getDialogSettings() != null) {
IDialogSettings section = getDialogSettings().getSection(DESTINATION_FILE);
if (section == null) {
section = getDialogSettings().addNewSection(DESTINATION_FILE);
}
section.put(DESTINATION_FILE, destination);
}
}
}
use of org.eclipse.jface.dialogs.IDialogSettings in project tesb-studio-se by Talend.
the class JavaCamelJobScriptsExportWSWizardPage method restoreWidgetValuesForKar.
private void restoreWidgetValuesForKar() {
IDialogSettings settings = getDialogSettings();
if (settings != null) {
String[] directoryNames = settings.getArray(STORE_DESTINATION_NAMES_ID);
if (directoryNames != null && directoryNames.length > 0) {
String fileName = getDefaultFileName().get(0) + '_' + getDefaultFileName().get(1) + getOutputSuffix();
for (String directoryName : directoryNames) {
String destination = new Path(directoryName).append(fileName).toOSString();
addDestinationItem(destination);
setDestinationValue(destination);
}
} else {
setDefaultDestination();
}
} else {
setDefaultDestination();
}
}
Aggregations