Skip to content
This repository has been archived by the owner on Apr 13, 2024. It is now read-only.

Commit

Permalink
fixing updater preference strins
Browse files Browse the repository at this point in the history
  • Loading branch information
awanthika committed Apr 8, 2016
1 parent 8093f77 commit e3c1d88
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

public class WorkbenchToolkit {

public static IPreferenceStore getPrefernaceStore(){
public static IPreferenceStore getPreferenceStore(){
IPreferenceStore preferenceStore = PlatformUI.getPreferenceStore();
return preferenceStore;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.PlatformUI;
import org.wso2.developerstudio.eclipse.platform.ui.Activator;
import org.wso2.developerstudio.eclipse.platform.ui.WorkbenchToolkit;

public class ClientTrustStorePreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
Expand All @@ -45,7 +44,7 @@ public ClientTrustStorePreferencePage() {

@Override
public void init(IWorkbench arg0) {
preferenceStore = WorkbenchToolkit.getPrefernaceStore();
preferenceStore = WorkbenchToolkit.getPreferenceStore();
setPreferenceStore(preferenceStore);
setDescription("WSO2 Developer Studio Custom Client Trust Store Preference.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.PlatformUI;
import org.wso2.developerstudio.eclipse.platform.ui.WorkbenchToolkit;

public class DeveloperPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {

Expand All @@ -47,7 +48,7 @@ public void createFieldEditors() {

@Override
public void init(IWorkbench arg0) {
preferenceStore = PlatformUI.getPreferenceStore();
preferenceStore = WorkbenchToolkit.getPreferenceStore();
setPreferenceStore(preferenceStore);
preferenceStore.setDefault(PLUGIN_TEMPLATE_URL, PreferenceInitializer.KERNEL_SAMPLES_GIT);
preferenceStore.setDefault(SHOW_HIDDEN_FEATURES, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,23 @@ public class PreferenceConstants {
public static final String ELEVENPM = "23:00";


public static final String UPDATE_DATE_INTERVAL = "UPDATE_INTAVAL";
public static final String UPDATE_TIME_INTERVAL = "UPDATE_TIME_INTAVAL";
public static final String UPDATE_DATE_INTERVAL = "UPDATE_INTAVAL_DATE";
public static final String UPDATE_TIME_INTERVAL = "UPDATE_INTAVAL_TIME";
public static final String AUTOMATIC_UPDATE_STATUS = "AUTOMATIC_UPATE_STATUS";
public static final String ENABLE_AUTOMATIC_UPDATES = "ENABLE_AUTOMATIC_UPDATES";
public static final String ENABLE_AUTOMATIC_UPDATES = "ENABLING_DEVSTUDIO_AUTOMATIC_UPDATES";

public static final String DOWNLOAD_UPDATES = "&Install available updates automatically";
public static final String NOTIFY_ME_IF_UPDATES_AVAILABLE = "&Notify me when updates are available";
public static final String UPDATE_NOTIFICATION_CONFIGURATION = "UPDATE_NOTIFICATION_CONFIGURATION";
public static final String UPDATE_NOTIFICATION_CONFIGURATION = "UPDATE_INSTALLATION_PROCESS_CONFIGURATION";
public static final String INSTALL_AUTOMATICALLY = "AUTOMATIC";
public static final String NOTIFY_ME = "NOTIFY_ME";

public static final String RUN_ON_STARTUP = "&Check for Updates every time eclipse starts up";
public static final String SCHEDULE_UPDATER = "&Check for Updates at the configured time";
public static final String UPDATE_RUNNING_CONFIGURATION = "UPDATE_RUNNING_CONFIGURATION";
public static final String UPDATE_RUNNING_CONFIGURATION = "UPDATE_INSTALLATION_CONFIGURATION";
public static final String STARTUP = "STARTUP";
public static final String SCHEDULE = "SCHEDULE";

public static final String RELESE_SITE_URL = "RELESE_SITE_URL";
public static final String RELESE_SITE_URL = "RELEASE_SITE_URL";
public static final String UPDATE_SITE_URL = "UPDATE_SITE_URL";
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,13 @@ public class UpdateCheckerPreferencePage extends FieldEditorPreferencePage imple
private RadioGroupFieldEditor updateInstallationRadioBttn;
private RadioGroupFieldEditor updateSchedulingRadioBttn;

public UpdateCheckerPreferencePage() {
super(GRID);
}

@Override
public void init(IWorkbench workbench) {
preferenceStore = WorkbenchToolkit.getPrefernaceStore();
public void init(IWorkbench arg) {
preferenceStore = WorkbenchToolkit.getPreferenceStore();
setPreferenceStore(preferenceStore);
setDescription("Set Preferences for WSO2 Developer Studio Updates and Install Process ");
setPreferenceDefaults(preferenceStore);
Expand All @@ -60,23 +64,28 @@ public static void setPreferenceDefaults(IPreferenceStore preferenceStore) {
preferenceStore.setDefault(PreferenceConstants.UPDATE_RUNNING_CONFIGURATION, PreferenceConstants.STARTUP);
preferenceStore.setDefault(PreferenceConstants.UPDATE_DATE_INTERVAL, PreferenceConstants.DEFAULT_SUNDAY);
preferenceStore.setDefault(PreferenceConstants.UPDATE_TIME_INTERVAL, PreferenceConstants.DEFAULT_EIGHT_AM);
preferenceStore.setDefault(PreferenceConstants.UPDATE_NOTIFICATION_CONFIGURATION,
PreferenceConstants.NOTIFY_ME);
preferenceStore.setDefault(PreferenceConstants.ENABLE_AUTOMATIC_UPDATES, true);
}

@Override
protected void createFieldEditors() {


fieldEditorParent = getFieldEditorParent();
boolean isSchedulingEnabled = false;
BooleanFieldEditor enableAutomaticUpdates = new BooleanFieldEditor(PreferenceConstants.ENABLE_AUTOMATIC_UPDATES,
"Check for updates Automatically", fieldEditorParent);
addField(enableAutomaticUpdates);
boolean isUpdatesEnabled = preferenceStore.getBoolean(PreferenceConstants.ENABLE_AUTOMATIC_UPDATES);
addBlankSeparator(fieldEditorParent);
setSeparator(fieldEditorParent);
addField(new BooleanFieldEditor(PreferenceConstants.ENABLE_AUTOMATIC_UPDATES, "Check for updates Automatically",
fieldEditorParent));
setSeparator(fieldEditorParent);

boolean isUpdatesEnabled = preferenceStore.getBoolean(PreferenceConstants.ENABLE_AUTOMATIC_UPDATES);

enableDisableSet = new Composite(fieldEditorParent, SWT.LEFT);
addBlankSeparator(enableDisableSet);

addBlankSeparator(enableDisableSet);
updateSchedulingRadioBttn = new RadioGroupFieldEditor(PreferenceConstants.UPDATE_RUNNING_CONFIGURATION,
"Automatic Updates Scheduling", 1,
new String[][] { { PreferenceConstants.RUN_ON_STARTUP, PreferenceConstants.STARTUP },
Expand All @@ -90,7 +99,7 @@ protected void createFieldEditors() {
isSchedulingEnabled = true;
}

String[][] intervals = { { PreferenceConstants.DAILY, PreferenceConstants.DAILY },
String[][] dayIntervals = { { PreferenceConstants.DAILY, PreferenceConstants.DAILY },
{ PreferenceConstants.DEFAULT_SUNDAY, PreferenceConstants.DEFAULT_SUNDAY },
{ PreferenceConstants.EVERY_MONDAY, PreferenceConstants.EVERY_MONDAY },
{ PreferenceConstants.EVERY_TUESDAY, PreferenceConstants.EVERY_TUESDAY },
Expand All @@ -99,7 +108,7 @@ protected void createFieldEditors() {
{ PreferenceConstants.EVERY_FRIDAY, PreferenceConstants.EVERY_FRIDAY },
{ PreferenceConstants.EVERY_SATURDAY, PreferenceConstants.EVERY_SATURDAY } };
intervalDayEditor = new ComboFieldEditor(PreferenceConstants.UPDATE_DATE_INTERVAL, "Check for updates ",
intervals, enableDisableSet);
dayIntervals, enableDisableSet);
addField(intervalDayEditor);
intervalDayEditor.setEnabled(isUpdatesEnabled && isSchedulingEnabled, enableDisableSet);

Expand Down Expand Up @@ -127,15 +136,15 @@ protected void createFieldEditors() {
{ PreferenceConstants.NINEPM, PreferenceConstants.NINEPM },
{ PreferenceConstants.TENPM, PreferenceConstants.TENPM },
{ PreferenceConstants.ELEVENPM, PreferenceConstants.ELEVENPM } };
intervalTimeEditor = new ComboFieldEditor(PreferenceConstants.UPDATE_TIME_INTERVAL, "", timeIntervals,
intervalTimeEditor = new ComboFieldEditor(PreferenceConstants.UPDATE_TIME_INTERVAL, "at", timeIntervals,
enableDisableSet);
intervalTimeEditor.setEnabled(isUpdatesEnabled && isSchedulingEnabled, enableDisableSet);
addField(intervalTimeEditor);
intervalTimeEditor.setEnabled(isUpdatesEnabled && isSchedulingEnabled, enableDisableSet);

setSeparator(enableDisableSet);
addBlankSeparator(enableDisableSet);
updateInstallationRadioBttn = new RadioGroupFieldEditor(PreferenceConstants.UPDATE_NOTIFICATION_CONFIGURATION,
"Specify Update Schedule", 1,
"Specify Installation Preference", 1,
new String[][] { { PreferenceConstants.NOTIFY_ME_IF_UPDATES_AVAILABLE, PreferenceConstants.NOTIFY_ME },
{ PreferenceConstants.DOWNLOAD_UPDATES, PreferenceConstants.INSTALL_AUTOMATICALLY } },
enableDisableSet);
Expand Down Expand Up @@ -165,6 +174,7 @@ private void addBlankSeparator(Composite parent) {
label.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 3, 1));
}

@Override
public void propertyChange(PropertyChangeEvent event) {
FieldEditor fe = (FieldEditor) event.getSource();
if (PreferenceConstants.ENABLE_AUTOMATIC_UPDATES.equals(fe.getPreferenceName())) {
Expand All @@ -190,13 +200,10 @@ public void propertyChange(PropertyChangeEvent event) {
}
intervalDayEditor.setEnabled(isScheduler, enableDisableSet);
intervalTimeEditor.setEnabled(isScheduler, enableDisableSet);
} else if (PreferenceConstants.UPDATE_DATE_INTERVAL.equals(fe.getPreferenceName())) {

}
setPreferenceDefaults(preferenceStore);
super.propertyChange(event);
}

public static void setAutomaticUpdatePreference(String value) {
preferenceStore.setDefault(PreferenceConstants.ENABLE_AUTOMATIC_UPDATES, value);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public void earlyStartup() {
// check if user has set startup updates
// Read updater preferences
IPreferenceStore prefPage = PlatformUI.getPreferenceStore();
UpdateCheckerPreferencePage.setPreferenceDefaults(prefPage);
boolean isAutomaticUpdate = prefPage.getBoolean(PreferenceConstants.ENABLE_AUTOMATIC_UPDATES);
String updateRunConfig = prefPage.getString(PreferenceConstants.UPDATE_RUNNING_CONFIGURATION);
if (updateRunConfig == null || updateRunConfig.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ protected IStatus run(IProgressMonitor monitor) {
downloadMetaFile();
Map<String, String> availaleDevStudioFeatureVerions = new HashMap<String, String>();
availaleDevStudioFeatureVerions = readMetaDataFiletoMap();
deleteDownloadedTempFile();
if (availaleDevStudioFeatureVerions.isEmpty()) {
log.error(Messages.UpdateCheckerJob_4);
promptUserError(Messages.UpdateMetaFileReaderJob_3, ERROR_TITLE);
Expand Down Expand Up @@ -128,6 +129,17 @@ protected IStatus run(IProgressMonitor monitor) {
// installed return cancel
}

private void deleteDownloadedTempFile() {
File downloadedMetaFile = new File(fileLoc);
File downloadedFolderLoc = new File(folderLoc);
if (downloadedMetaFile.exists()) {
downloadedMetaFile.delete();
if (downloadedFolderLoc.exists()) {
downloadedFolderLoc.delete();
}
}
}

/**
* version would come as 4.0.0-201512221344 we need to create the
* installable unit version object from the version string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ public class UpdateMetaFileReaderJobListener extends JobChangeAdapter {
private static final String UPDATER_DIALOG_TITLE = Messages.UpdatemetaFileReaderJobListener_1;
protected static final String YES = "Yes";
protected static final String NO = "No";
protected static final String DAILY = "Daily";
protected static final String WEEKLY = "Weekly";
protected static final String MONTHLY = "Monthly";
private static org.wso2.developerstudio.eclipse.updater.job.UpdateMetaFileReaderJob UpdateMetaFileReaderJob;

protected static IDeveloperStudioLog log = Logger.getLog(UpdaterPlugin.PLUGIN_ID);
Expand Down

0 comments on commit e3c1d88

Please sign in to comment.