lkishalmi commented on a change in pull request #2119: URL: https://github.com/apache/netbeans/pull/2119#discussion_r436408902
########## File path: ide/editor.autosave/licenseinfo.xml ########## @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +--> +<licenseinfo> + <fileset> + <file>src/org/netbeans/modules/editor/autosave/auto_save.png</file> + <file>src/org/netbeans/modules/editor/autosave/auto_save24.png</file> Review comment: I have not seen this auto_save24.png used. If it is not used, It should be removed. ########## File path: ide/editor.autosave/nbproject/project.properties ########## @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.8 +javadoc.title=Editor Autosave +javahelp.hs=autosave-hs.xml Review comment: Also is this needed? ########## File path: ide/editor.autosave/src/org/netbeans/modules/editor/autosave/ToggleAutoSaveAction.java ########## @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.netbeans.modules.editor.autosave; + +import java.util.prefs.PreferenceChangeListener; +import org.openide.awt.ActionID; +import org.openide.awt.ActionRegistration; +import org.openide.util.HelpCtx; +import org.openide.util.NbBundle; +import org.openide.util.actions.BooleanStateAction; + +@ActionID(id = "org.netbeans.modules.editor.autosave.ToggleAutoSaveAction", category = "Edit") +@ActionRegistration(displayName = "#CTL_AutoSave", lazy = false) [email protected]("CTL_AutoSave=Autosave") +public final class ToggleAutoSaveAction extends BooleanStateAction { + + private final PreferenceChangeListener pcl = evt -> setBooleanState(AutoSaveController.prefs() + .getBoolean(AutoSaveController.KEY_ACTIVE, AutoSaveController.KEY_ACTIVE_DEFAULT)); + + @Override + public String getName() { + return NbBundle.getMessage(ToggleAutoSaveAction.class, "CTL_AutoSave"); + } + + @Override + protected void initialize() { + super.initialize(); + + AutoSaveController.prefs().addPreferenceChangeListener(pcl); + + this.addPropertyChangeListener(evt -> { + if (BooleanStateAction.PROP_BOOLEAN_STATE.equals(evt.getPropertyName())) { + AutoSaveController.prefs().putBoolean(AutoSaveController.KEY_ACTIVE, getBooleanState()); + } + }); + this.setBooleanState(AutoSaveController.prefs().getBoolean(AutoSaveController.KEY_ACTIVE, + AutoSaveController.KEY_ACTIVE_DEFAULT)); + } + + @Override + protected String iconResource() { + return "org/netbeans/modules/editor/autosave/auto_save.png"; Review comment: Shall be declared as a static final constant with //NOI18N at the end. Also it could be annotated with @StaticResource ########## File path: ide/editor.autosave/manifest.mf ########## @@ -0,0 +1,9 @@ +Manifest-Version: 1.0 +OpenIDE-Module: org.netbeans.modules.editor.autosave/1 +OpenIDE-Module-Install: org/netbeans/modules/editor/autosave/Installer.class +OpenIDE-Module-Layer: org/netbeans/modules/editor/autosave/layer.xml +OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/editor/autosave/Bundle.properties +OpenIDE-Module-Requires: org.netbeans.api.javahelp.Help Review comment: Is this still required? ########## File path: ide/editor.autosave/src/org/netbeans/modules/editor/autosave/Installer.java ########## @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.netbeans.modules.editor.autosave; + +import java.lang.ref.WeakReference; +import java.util.prefs.PreferenceChangeListener; +import org.netbeans.modules.editor.autosave.command.AutoSaveController; +import org.openide.modules.ModuleInstall; + +public class Installer extends ModuleInstall { Review comment: Also instead of the Installer http://bits.netbeans.org/dev/javadoc/org-openide-modules/org/openide/modules/package-summary.html see OnStart and OnStop annotation which could be added to two public static Runnable inner classes in AutoSave controller. ########## File path: ide/editor.autosave/manifest.mf ########## @@ -0,0 +1,9 @@ +Manifest-Version: 1.0 +OpenIDE-Module: org.netbeans.modules.editor.autosave/1 +OpenIDE-Module-Install: org/netbeans/modules/editor/autosave/Installer.class +OpenIDE-Module-Layer: org/netbeans/modules/editor/autosave/layer.xml Review comment: I hope the layer and the installer can be removed. ########## File path: ide/editor.autosave/nbproject/project.properties ########## @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + Review comment: I think is.eager=true would be recommended here. Otherwise it would be a normal module which requires to be enabled by the user. ########## File path: ide/editor.autosave/src/org/netbeans/modules/editor/autosave/layer.xml ########## @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> Review comment: If the layer file become empty, let's get rid of it. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
