Implement option for auto start on windows

cusax-fix
Damian Minkov 18 years ago
parent 35fc52d2c2
commit 9c0c242946

@ -1710,6 +1710,7 @@ javax.swing.event, javax.swing.border"/>
prefix="resources/images/plugin/generalconfig"/> prefix="resources/images/plugin/generalconfig"/>
<zipfileset dir="${resources}" includes="application.properties" <zipfileset dir="${resources}" includes="application.properties"
prefix="resources"/> prefix="resources"/>
<zipfileset src="${lib.noinst}/izpack-shortcut-link.jar" prefix=""/>
</jar> </jar>
</target> </target>
</project> </project>

Binary file not shown.

@ -28,6 +28,9 @@
import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.*;
import java.io.*;
import com.izforge.izpack.util.os.*;
/** /**
* *
* @author Yana Stamcheva * @author Yana Stamcheva
@ -81,6 +84,7 @@ private void initGUI()
mainPanel.add(Box.createVerticalStrut(10)); mainPanel.add(Box.createVerticalStrut(10));
autoStartCheckBox.setText( autoStartCheckBox.setText(
Resources.getString("autoStartOption")); Resources.getString("autoStartOption"));
autoStartCheckBox.addActionListener(this);
} }
{ {
groupMessagesCheckBox = new JCheckBox(); groupMessagesCheckBox = new JCheckBox();
@ -274,7 +278,38 @@ public void actionPerformed(ActionEvent event)
if (sourceObject.equals(autoStartCheckBox)) if (sourceObject.equals(autoStartCheckBox))
{ {
//TODO: Implement auto start setting. try
{
String workingDir = new File(".").getCanonicalPath();
String appName =
Resources.getApplicationString("applicationName");
ShellLink shortcut = new ShellLink(ShellLink.STARTUP, appName);
shortcut.setLinkType(ShellLink.STARTUP);
shortcut.setUserType(ShellLink.CURRENT_USER);
shortcut.setDescription(
"This starts " + appName + " Application");
shortcut.setIconLocation(
workingDir + File.separator + "sc-logo.ico", 0);
shortcut.setShowCommand(ShellLink.MINNOACTIVE);
shortcut.setTargetPath(workingDir + File.separator + "run.exe");
shortcut.setWorkingDirectory(workingDir);
if(autoStartCheckBox.isSelected())
shortcut.save();
else
{
// before we can get the filename of the link
// we have to save it
shortcut.save();
new File(shortcut.getFileName()).delete();
}
} catch (Exception e)
{
logger.error("Cannot create/delete startup shortcut", e);
}
} }
if (sourceObject.equals(groupMessagesCheckBox)) if (sourceObject.equals(groupMessagesCheckBox))
{ {

@ -35,6 +35,19 @@ public class Resources
*/ */
private static final String IMAGE_RESOURCE_NAME private static final String IMAGE_RESOURCE_NAME
= "net.java.sip.communicator.plugin.generalconfig.resources"; = "net.java.sip.communicator.plugin.generalconfig.resources";
/**
* The name of the resource, where application properties are
* stored.
*/
private static final String APPLICATION_RESUORCE_LOCATION
= "resources.application";
/**
* The application resource bundle.
*/
private static final ResourceBundle APPLICATION_RESOURCE_BUNDLE
= ResourceBundle.getBundle(APPLICATION_RESUORCE_LOCATION);
/** /**
* The string resource bundle. * The string resource bundle.
@ -64,6 +77,23 @@ public static String getString(String key)
return '!' + key + '!'; return '!' + key + '!';
} }
} }
/**
* Returns an application property string corresponding to the given key.
* @param key The key of the string.
* @return A string corresponding to the given key.
*/
public static String getApplicationString(String key)
{
try
{
return APPLICATION_RESOURCE_BUNDLE.getString(key);
}
catch (MissingResourceException e)
{
return '!' + key + '!';
}
}
/** /**
* Loads an image from a given image identifier. * Loads an image from a given image identifier.

Loading…
Cancel
Save