usr/src/java/vpanels/panels/sharemgr/org/opensolaris/os/vp/panels/sharemgr/client/swing/CommonGeneralControl.java
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
*/
package org.opensolaris.os.vp.panels.sharemgr.client.swing;
import java.awt.event.*;
import java.net.URL;
import java.util.*;
import org.opensolaris.os.vp.panel.common.action.*;
import org.opensolaris.os.vp.panel.common.control.*;
import org.opensolaris.os.vp.panel.swing.control.SettingsControl;
import org.opensolaris.os.vp.panels.sharemgr.client.common.*;
import org.opensolaris.os.vp.util.misc.Finder;
public abstract class CommonGeneralControl
<C extends CommonManagedObject<?>, P extends CommonGeneralPanel<C>>
extends SettingsControl<SharemgrPanelDescriptor, P> {
//
// Static data
//
public static final String ID = "general";
public static final String NAME = Finder.getString("common.general.title");
//
// Instance data
//
private CommonTabbedControl<C> parent;
private DeleteShareAndGroupAction deleteAction;
//
// Constructors
//
public CommonGeneralControl(CommonTabbedControl<C> parent) {
super(ID, NAME, parent.getPanelDescriptor());
this.parent = parent;
deleteAction = new DeleteShareAndGroupAction(parent.getParent());
}
//
// Control methods
//
@Override
public URL getHelpURL() {
return buildHelpURL("help/sharemgr-general.html", null);
}
@Override
public void start(Navigator navigator, Map<String, String> parameters)
throws NavigationAbortedException, InvalidParameterException {
C common = parent.getCommon();
setPropertyChangeSource(common);
List<CommonManagedObject> selection =
new ArrayList<CommonManagedObject>(1);
selection.add(common);
deleteAction.setPresetInput(selection);
super.start(navigator, parameters);
}
@Override
public void stop(boolean isCancel) throws NavigationAbortedException {
super.stop(isCancel);
List<CommonManagedObject> selection = Collections.emptyList();
deleteAction.setPresetInput(selection);
}
//
// SwingControl methods
//
@Override
protected P createComponent() {
P panel = createCommonPanel();
panel.getDeleteLink().addActionListener(
new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
deleteAction.asyncExec(
new Runnable() {
@Override
public void run() {
try {
deleteAction.invoke();
getNavigator().goToAsync(false,
CommonGeneralControl.this,
Navigator.PARENT_NAVIGABLE);
} catch (ActionAbortedException e) {
} catch (ActionFailedException e) {
}
}
});
}
});
return panel;
}
@Override
protected void initComponent() {
getComponent().init(getParent().getCommon());
}
//
// CommonGeneralControl methods
//
protected abstract P createCommonPanel();
public CommonTabbedControl<C> getParent() {
return parent;
}
}