/*******************************************************************************
 * See the NOTICE file distributed with this work for additional information
 * regarding copyright ownership.
 * 
 * Licensed 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 hr.fer.zemris.vhdllab.platform.ui.command;

import java.util.prefs.Preferences;

import org.springframework.richclient.command.ActionCommand;
import org.springframework.richclient.command.CommandManager;
import org.springframework.richclient.command.support.ApplicationWindowAwareCommand;

public class WelcomeCommand extends ApplicationWindowAwareCommand {

    public static final String ID = "welcomeCommand";

    protected static final String PREF_WELCOME_DIALOG_SHOW_COUNT = "welcome.dialog.show.count";

    public WelcomeCommand() {
        super(ID);
    }

    @Override
    protected void doExecuteCommand() {
        Preferences pref = Preferences.userNodeForPackage(WelcomeCommand.class);
        int count = pref.getInt(PREF_WELCOME_DIALOG_SHOW_COUNT, 0);

        if (count < 5) {
            showWelcomeDialog();

            pref.putInt(PREF_WELCOME_DIALOG_SHOW_COUNT, count + 1);
        }
    }

    protected void showWelcomeDialog() {
        CommandManager cm = getApplicationWindow().getCommandManager();
        ActionCommand command = (ActionCommand) cm.getCommand("bugsCommand");
        command.execute();
    }

}

@@ -914,16 +914,92 @@
 ences;%0A%0A
+import javax.swing.JComponent;%0A%0Aimport org.apache.commons.lang.SystemUtils;%0A
 import o
@@ -1051,16 +1051,16 @@
 ommand;%0A
-
 import o
@@ -1197,16 +1197,191 @@
 Command;
+%0Aimport org.springframework.richclient.dialog.ApplicationDialog;%0Aimport org.springframework.richclient.dialog.CloseAction;%0Aimport org.springframework.richclient.text.HtmlPane;
 %0A%0Apublic
@@ -1879,9 +1879,10 @@
 t %3C 
-5
+10
 ) %7B%0A
@@ -1892,16 +1892,19 @@
         
+ //
  showWel
@@ -1916,16 +1916,52 @@
 ialog();
+%0A            showUpdateJavaDialog();
 %0A%0A      
@@ -2230,16 +2230,16 @@
 mand%22);%0A
-
         
@@ -2264,10 +2264,1265 @@
 %0A    %7D%0A%0A
+    protected void showUpdateJavaDialog() %7B%0A        if (!SystemUtils.JAVA_RUNTIME_VERSION.startsWith(%221.6.0_21%22)) %7B%0A            UpdateJavaDialog dialog = new UpdateJavaDialog();%0A            dialog.setParentComponent(getApplicationWindow().getControl());%0A            dialog.showDialog();%0A        %7D%0A    %7D%0A%0A    private static class UpdateJavaDialog extends ApplicationDialog %7B%0A%0A        public UpdateJavaDialog() %7B%0A            super();%0A%0A            setTitle(%22Update Java%22);%0A            setModal(false);%0A            setCloseAction(CloseAction.DISPOSE);%0A        %7D%0A%0A        @Override%0A        protected JComponent createDialogContentPane() %7B%0A            HtmlPane pane = new HtmlPane();%0A%0A            pane.setText(%22%3Chtml%3EA number of VHDLLab bugs are actually bugs in Java itself.%3Cbr /%3E%22%0A                        + %22Please update Java for added stability.%3Cbr /%3E%22%0A                        + %22%3Ca href='http://www.java.com/en/download/index.jsp'%3Ehttp://www.java.com/en/download/index.jsp%3C/a%3E%22);%0A%0A            return pane;%0A        %7D%0A%0A        @Override%0A        protected boolean onFinish() %7B%0A            return true;%0A        %7D%0A%0A        @Override%0A        protected Object%5B%5D getCommandGroupMembers() %7B%0A            return new Object%5B%5D %7B getFinishCommand() %7D;%0A        %7D%0A%0A    %7D%0A%0A
 %7D%0A

Complete - # 47: reminder za update na noviju verziju Jave http://morgoth.zemris.fer.hr/trac/vhdllab/ticket/47