PDA

View Full Version : How to disable the Cancel button



henric
11-07-2007, 04:46 AM
Is there a way to disable the Cancel button in InstallAnywhere?

I would like to do that since the user shouldn't be able to cancel the installation once the user has pressed Install and the installation has started.

Best regards
Henric

pv7721
11-07-2007, 06:28 AM
Unfortunately, this is still not possible, even after 3 years since this feature request has been requested for the first time:

http://community.zerog.com/cgi-bin/ikonboard.cgi?s=4731965840afffff;act=ST;f=15;t=3656;hl=disable+and+cancel+and+button

Moreover, if the user hits the Cancel button, there is no rollback mechanism (for the files already installed, only the TEMP folder is cleaned).

henric
11-07-2007, 07:03 AM
Thanks for the rapid response.

I agree that it's a pity that this hasn't been implemented yet. Disabling Cancel button or rollback funtionality would have been good to have in this case.

Best regards
Henric

Yves Kreis
11-07-2007, 08:02 AM
Everything is possible... it's Java!
You can disable the Cancel button using Custom code.

Best Regards,
Yves

henric
11-07-2007, 08:29 AM
OK. How? Can you please supply some example code?

Best regards
Henric

Yves Kreis
11-07-2007, 08:44 AM
I don't have example code for this, but I can provide you the idea how to do it:
a) Write an extension to CustomCodePanel and register your own listener to the next button

Container guiContainer = ((GUIAccess) ccpp.getService(GUIAccess.class)).getFrame();
if (guiContainer instanceof JFrame) {
guiContainer = (Container) ((JFrame) guiContainer).getContentPane().getComponent(0);
JButton guiJButton = (JButton) ((Container) guiContainer.getComponent(3)).getComponent(2);
guiJButton.addActionListener(new NextListener(guiContainer));
}

b) In the listener, wait for the button text to be "Install" and afterwards disable the Cancel button.

I hope this helps.

Best Regards,
Yves

henric
11-08-2007, 08:07 AM
Thanks for your help.
I wrote some test code based on your idea but it seems like this doesn't work. I got the code to execute every time the next button was pressed. When the text was Install I disabled the Cancel button. But it seems like InstallAnywhere enables the button once the installation starts again.

I also tried to put the Custom code Panel as the last step in Pre-installation. Then I didn't need to add the listener to any button. Even in this case the Cancel button seem to get enabled. :confused:

I have given up for now. Instead I hope that this will be fixed sometime in the future. In that case we may be able to our next release instead.;)

Yves Kreis
11-08-2007, 12:57 PM
Try to put the Custom Code Panel as first step in the Install section...

Best Regards,
Yves

henric
11-09-2007, 03:04 AM
I tried to put a Custom Code Action in the install section but this didn't work. I am not sure how I put a custom code panel in the install section?

Best regards
Henric

Yves Kreis
11-09-2007, 03:10 AM
I will try to disable it today and let you know if I was successful...

Best Regards,
Yves

vishald
11-16-2007, 05:16 AM
Hi henric
It is not possible to disable cancel button on the installing panel through the way suggested by Yves Kreis.
because the way Yves Kreis is saying to disable the cancel button will work only for that custom code panel
and installing panel is not shown as a panel in the installation project(as u have already seen) so u cant substitute it.

If u find any other way please let me know

Yves Kreis
11-16-2007, 05:44 AM
I still need to solve a problem with my installer, as soon as I am done with it I will try to get the idea I announced working and will let you know about the results... Its Java, everything can be done!

Best Regards,
Yvse

Yves Kreis
11-27-2007, 03:50 AM
Good morning,

Unfortunately it took me longer to test this as I thought; I had to solve important problems first. But nevertheless this one is quite easy:
a) Use a CustomCodePanel in Pre-Install and store the GUIAccess object in a static variable.
b) Use a CustomCodeAction as first action during Install step and use the enableExitButton(false) method on the previously stored GUIAccess object.

Hope this helps.

Best Regards,
Yves

cristina
12-24-2007, 05:40 AM
Hi,
I was using IA7.5.
I did the following:
a) Use a CustomCodePanel in Pre-Install and store the GUIAccess object in a static variable.
b) Use a CustomCodeAction as first action during Install step and use the enableExitButton(false) method on the previously stored GUIAccess object.

It's 98% working because during the first 10-15 seconds of the Install step, where is shows:
"Installing.... Java Runtime Environment", the Cancel button is still enabled. But after that, the cancel/exit button is automatically disabled throughout the rest of the Install step.:o

Though in IA 2008 it's not working at all... :(

Kondalarao.n
12-29-2007, 03:18 AM
public class PanelDisableCancel extends CustomCodeAction{

@Override
public String getInstallStatusMessage() {
// TODO Auto-generated method stub
return null;
}

@Override
public String getUninstallStatusMessage() {
// TODO Auto-generated method stub
return null;
}

@Override
public void install(InstallerProxy ruleProxy) throws InstallException {

setInstallerProxy(ruleProxy);
GUIAccess gui = (GUIAccess)ruleProxy.getService(GUIAccess.class);
System.out.println("Haiiiiiiiiiiiiiii");
System.out.println(gui);
gui.getFrame().setTitle("new title");

try{
gui.setExitButtonEnabled(false);
}catch (Exception e) {
e.printStackTrace();
}
try{
gui.setNextButtonEnabled(false);
}catch (Exception e) {
e.printStackTrace();
}
try{
gui.setPreviousButtonEnabled(false);
}catch (Exception e) {
e.printStackTrace();
}

}

@Override
public void uninstall(UninstallerProxy arg0) throws InstallException {
try {
String installDirStr = arg0.substitute("$USER_INSTALL_DIR$");
FileService fs = (FileService)arg0.getService(FileService.class);
File installDir = new File(installDirStr);
if (installDir.exists())
fs.deleteDirectory(installDirStr, false,
true);
} catch (Exception e) {
File f = new File("c:\\logUninstall5.txt");
FileOutputStream fis = null;
try{
fis = new FileOutputStream(f);
fis.write(e.getMessage().getBytes());
fis.flush();
fis.close();
}
catch (Exception e1) {
// TODO: handle exception
}
}

}

vishald
01-03-2008, 03:58 AM
Hi Yves Kreis

Great work done

Thanks a lot it worked.

Yves Kreis
01-03-2008, 04:50 AM
You are welcome.

Best Regards,
Yves

ckanywhere529
01-17-2008, 02:32 PM
Good morning,

Unfortunately it took me longer to test this as I thought; I had to solve important problems first. But nevertheless this one is quite easy:
a) Use a CustomCodePanel in Pre-Install and store the GUIAccess object in a static variable.
b) Use a CustomCodeAction as first action during Install step and use the enableExitButton(false) method on the previously stored GUIAccess object.

Hope this helps.

Best Regards,
Yves

Hello,

One thing that is confusing me on this method is how to store the GUIAccess object in a static variable at PRE-INSTALL time and access this variable at INSTALL time.

Would I create CLASS A that Extends customcodepanel and CLASS B that Extends customcodeaction?

I think the EVERY VARIABLE IS A STRING in IA methodology has confused me on as to how I'd share the GUIAccess object between two classes using IA...

Maybe it's the lack of sleep :-( heh

Thanks,

CK

Yves Kreis
01-17-2008, 03:14 PM
public class a extends ... {
public static GUIAccess gui = ...
...
}
public class b extends ... {
...
a.gui.enableExitButton(false);
...
}

ckanywhere529
02-04-2008, 04:51 PM
public class a extends ... {
public static GUIAccess gui = ...
...
}
public class b extends ... {
...
a.gui.enableExitButton(false);
...
}

My understanding of above:

public class a extends CustomCodePanel {

CustomCodePanelProxy panelProxy = null;
public static GUIAccess gui = null;

public disableCancelDuringInstallPanel() {
}

public boolean setupUI(CustomCodePanelProxy customCodePanelProxy) {
panelProxy = customCodePanelProxy;
GUIAccess gui = (GUIAccess)customCodePanelProxy.getService(GUIAccess.class);
return false;
}

@Override
public void panelIsDisplayed() {

}

@Override
public String getTitle() {
return "Installing...";
}

@Override
public boolean okToContinue() {
return true;
}

@Override
public boolean okToGoPrevious() {
return false;
}
}

public class b extends CustomCodeAction {

private a testPanel; <-- I feel here is my issue (how can I get class b to see the GUIAccess object from class a (inited at PRE-INSTALL) :confused:

public disableCancelDuringInstallAction () {
}

@Override
public void install(InstallerProxy ip) throws InstallException {

try {
testPanel.gui.setExitButtonEnabled(false);
} catch (Exception e) {
e.printStackTrace();
}
}

@Override
public void uninstall(UninstallerProxy up) throws InstallException {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public String getInstallStatusMessage() {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public String getUninstallStatusMessage() {
throw new UnsupportedOperationException("Not supported yet.");
}

}

}

Yves Kreis
02-05-2008, 12:55 PM
Try the following:



public class b extends CustomCodeAction {

public disableCancelDuringInstallAction () {
}

@Override
public void install(InstallerProxy ip) throws InstallException {

try {
a.gui.setExitButtonEnabled(false);
} catch (Exception e) {
e.printStackTrace();
}
}

@Override
public void uninstall(UninstallerProxy up) throws InstallException {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public String getInstallStatusMessage() {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public String getUninstallStatusMessage() {
throw new UnsupportedOperationException("Not supported yet.");
}

}

ckanywhere529
02-05-2008, 01:03 PM
Try the following:

Thanks for the quick reply Yves. I got it running.
I was being a moron and expecting GUIAccess gui to
be initialized in a (using a same named LOCAL variable named gui lol)

One thing I noticed is the X box is still active, but the CANCEL button is inactive.

Any clue if this is something editable (from the looks of it, it doesn't look like part of the open IA api.)

Also, the panel (Pre-installation summary) now reads "Next" instead of "Install" because of the custom panel used to do this.

If the last panel returns false on setupUI, you'd think IA would catch this and display "install" on the second to last panel....

A workaround is to put the disableCancelButtonPanel before Pre-installation summary.

~Chris.

Yves Kreis
02-06-2008, 04:34 AM
Dear ckanywhere529,

The X box cannot be disabled as far as I know. If you find something I would be pleased to know! However it should not work...

You can try to put the CustomCodePanel earlier in the pre-install tasks. This might solve the Next <-> Install problem. You can also try to return true.

Best Regards,
Yves

genleo
02-19-2008, 06:29 AM
Hi all,
i followed Yves advice but it doesn't work :( :( :(

I have these classes:



public class MyPanel extends CustomCodePanel {

CustomCodePanelProxy panelProxy = null;
public static GUIAccess gui = null;

public A() {
}

public boolean setupUI(CustomCodePanelProxy customCodePanelProxy) {
panelProxy = customCodePanelProxy;
GUIAccess gui = (GUIAccess)customCodePanelProxy.getService(GUIAccess.class);
return false;
}

@Override
public void panelIsDisplayed() {

}

@Override
public String getTitle() {
return "Installing...";
}

@Override
public boolean okToContinue() {
return true;
}

@Override
public boolean okToGoPrevious() {
return false;
}
}

and



public class DisableCancelDuringInstallAction extends CustomCodeAction {

/**
*
*/
public DisableCancelDuringInstallAction() {
// TODO Auto-generated constructor stub
}

/* (non-Javadoc)
* @see com.zerog.ia.api.pub.CustomCodeAction#getInstallStatusMessage()
*/
@Override
public String getInstallStatusMessage() {
// TODO Auto-generated method stub
return null;
}

/* (non-Javadoc)
* @see com.zerog.ia.api.pub.CustomCodeAction#getUninstallStatusMessage()
*/
@Override
public String getUninstallStatusMessage() {
// TODO Auto-generated method stub
return null;
}

/* (non-Javadoc)
* @see com.zerog.ia.api.pub.CustomCodeAction#install(com.zerog.ia.api.pub.InstallerProxy)
*/
@Override
public void install(InstallerProxy arg0) throws InstallException {
try {
MyPanel.gui.setExitButtonEnabled(false);
} catch (Exception e) {
e.printStackTrace();
}


}

/* (non-Javadoc)
* @see com.zerog.ia.api.pub.CustomCodeAction#uninstall(com.zerog.ia.api.pub.UninstallerProxy)
*/
@Override
public void uninstall(UninstallerProxy arg0) throws InstallException {
// TODO Auto-generated method stub

}

}


I put MyPanel just before Pre-Installation Summary and DisableCancelDuringInstallAction as first action in Install section... can you help me?

Thanks

Yves Kreis
02-19-2008, 08:45 AM
In class A, method setupUI you create a second variable gui, i.e. you don't assign the result to the static one!

Best Regards,
Yves

genleo
02-19-2008, 08:51 AM
Sorry,
I have no class A, constructor public A() {} is public MyPanel() {}.

It doesn't work yet.

Yves Kreis
02-19-2008, 08:58 AM
Class MyPanel then instead of class A.

genleo
02-19-2008, 09:10 AM
Class MyPanel then instead of class A.

I think I'm going crazy... could you post me some piece of code???

Thanks a lot

Yves Kreis
02-19-2008, 09:18 AM
(...)

public boolean setupUI(CustomCodePanelProxy customCodePanelProxy) {
gui = (GUIAccess)customCodePanelProxy.getService(GUIAccess.class);
}
(...)


Best Regards,
Yves

genleo
02-19-2008, 09:35 AM
Thank you Yves,
finally I understood what the problem was. Now it works.

Best Regards

nikhilgupta
04-13-2009, 06:25 AM
I am using IA 2008 VP1 and have not been successful in disabling cancel button. gui object is set in CustomPanel code but when CustomCodeAction executes, gui becomes null. I tried using static int which retains its value from panel code to customcode action.
Is there something changed in IA 2008/

munsingh
04-28-2009, 08:05 AM
Well I have used the same code as provided in this thread and it works for me. I am using IA 2008 VP1.

Gloria Glickley
06-26-2009, 02:29 PM
(1) I followed the discussion of this thread, came out with custom panel code as below:


public class SetCustomPanel extends CustomCodePanel
{
CustomCodePanelProxy panelProxy = null;
public static GUIAccess gui = null;

public boolean setupUI(CustomCodePanelProxy customCodePanelProxy)
{
gui = (GUIAccess)customCodePanelProxy.getService(GUIAccess.class);
return false;
}
}

Compiled it to SetCustomPanel.class as part of our IS_Installer.jar file.
I'm not sure how to call this custom panel other than through Execute Custom Code Action. Is this a correct assumption?
When I added this panel as custom code action before the Pre-Install Summary panel, I then kept getting error stating this class is UNAVAILABLE.


com.ibm.filenet.is.install.SetCustomPanel
Status: ERROR
Additional Notes: ERROR - class com.ibm.filenet.is.install.SetCustomPanel unavailable.

What did I miss? Appreciate input to confirm.

(2) Also, for the 2nd part, the Custom Code to disable the Cancel button, to be called in the Install Task. The suggestion is to call as the first thing in the Install task. We have many visual trees in the Install Task like one for the USER_MAGIC_FOLER_x, one for User Install Folder, one for DO NOT INSTALL, etc. Should I add this custom code under the User Install Folder or it really doesn't matter?

PS - I'm actually using IA 2009 SP1. Sorry for the confusion since I want to continue using this thread instead of starting a new thread.
Regards, Gloria

Yves Kreis
06-26-2009, 06:58 PM
You need to include it as custom panel, not custom code!

Best Regards,
Yves

Gloria Glickley
06-29-2009, 01:48 PM
Thanks Yves.

I finally figured out on how to do the Custom Panel through Plugin. <Sigh>
Now I'm pretty sure both my custom panel in the preinstall and custom code in the install are called without errors. What my test shows that the 'Cancel' button is still showing as Enabled when the panel displays "Installing ... Java Runtime Environment'. Once this is done, the 'Cancel' button is finally Disabled when installer starts copying files.

Is this the best behavior I can get? Or is there any way to also disable the 'Cancel' button for installing the JRE?

Below is the excerpt of the code. Any comment is greatly appreciated.


This custom code panel is called right before the Pre-install Summary Panel.
public class SetCustomPanel extends CustomCodePanel
{
CustomCodePanelProxy panelProxy = null;
public static GUIAccess gui = null;

public boolean setupUI(CustomCodePanelProxy customCodePanelProxy)
{
gui = (GUIAccess)customCodePanelProxy.getService(GUIAccess.class);
return false;
}
}


This Custom code is executed as the 1st step under the $USER_INSTALL_DIR$ Visual Tree.
public class DisableCancelAtInstall extends CustomCodeAction
{
public void install( InstallerProxy ip ) throws InstallException
{
try {
SetCustomPanel.gui.setExitButtonEnabled(false);
} catch (Exception e) {
e.printStackTrace();
}
}
}

sukrit007
08-16-2009, 07:47 PM
You may also disable X button , by de-registering the window listener. Assuming that you have guiAccess object,

Frame frame = guiAccess.getFrame();
Container parentContainer = frame;
if(parentContainer instanceof JFrame) {
JFrame jframe = (JFrame) parentContainer;
WindowListener [] listeners =jframe.getWindowListeners();
for(WindowListener listener: listeners) {
if(!listener.getClass().getName().startsWith("java")) {
jframe.removeWindowListener(listener);
}
}
}




Thanks for the quick reply Yves. I got it running.
I was being a moron and expecting GUIAccess gui to
be initialized in a (using a same named LOCAL variable named gui lol)

One thing I noticed is the X box is still active, but the CANCEL button is inactive.

Any clue if this is something editable (from the looks of it, it doesn't look like part of the open IA api.)

Also, the panel (Pre-installation summary) now reads "Next" instead of "Install" because of the custom panel used to do this.

If the last panel returns false on setupUI, you'd think IA would catch this and display "install" on the second to last panel....

A workaround is to put the disableCancelButtonPanel before Pre-installation summary.

~Chris.

ascans
09-20-2011, 04:47 PM
Hi,

I have implemented the solution suggested in this thread. I have confirmed the code is executed in my installer but the "Cancel" button still not being disabled (I think I saw a brief moment the Cancel button being gray out but enabled afterward). The only thing is that I am using IA2010, would it make a different. Please let me know if anyone run into same problem with IA2010 or have a solution for it.

Thanks

pv7721
09-21-2011, 06:07 AM
Maybe this was a regression in IA2010, could you give it a try in the latest version, IA 2011?

moniv22
06-11-2013, 06:44 AM
Is your solution working for InstallAnywhere 2011 too or am I doing something wrong? :(

Thank you