package samples.subsystems; import RSESamples.*; import com.ibm.etools.systems.dftsubsystem.impl.DefaultSubSystemFactoryImpl; import com.ibm.etools.systems.subsystems.impl.*; import com.ibm.etools.systems.subsystems.*; import com.ibm.etools.systems.model.*; import com.ibm.etools.systems.filters.*; import com.ibm.etools.systems.filters.ui.actions.*; import org.eclipse.jface.resource.*; import org.eclipse.jface.action.IAction; import org.eclipse.swt.widgets.Shell; import java.util.*; /** * This is our subsystem factory, which creates instances of our subsystems, * and supplies the subsystem and filter actions to their popup menus. */ public class DeveloperSubSystemFactory extends DefaultSubSystemFactoryImpl { /** * Constructor for DeveloperSubSystemFactory. */ public DeveloperSubSystemFactory() { super(); } /** * Create an instance of our subsystem. */ protected SubSystem createSubSystemInternal(SystemConnection conn) { return new DeveloperSubSystem(); } /** * Intercept of parent method that creates an initial default filter pool. * We intercept so that we can create an initial filter in that pool, which will * list all teams. */ protected SystemFilterPool createDefaultFilterPool(SystemFilterPoolManager mgr) { SystemFilterPool defaultPool = super.createDefaultFilterPool(mgr); Vector strings = new Vector(); strings.add("*"); try { SystemFilter filter = mgr.createSystemFilter(defaultPool, "All teams", strings); filter.setType("team"); } catch (Exception exc) {} return defaultPool; } /** * Intercept of parent method so we can supply our own value shown in the property * sheet for the "type" property when a filter is selected within our subsystem. * * Requires this line in rseSamplesResources.properties: property.type.teamfilter=Team filter */ public String getTranslatedFilterTypeProperty(SystemFilter selectedFilter) { String type = selectedFilter.getType(); if (type == null) type = "team"; if (type.equals("team")) return RSESamplesPlugin.getResourceString("property.type.teamfilter"); else return RSESamplesPlugin.getResourceString("property.type.devrfilter"); } /** * Override of parent method, to affect what is returned for the New Filter-> actions. * We intercept here, versus getNewFilterPoolFilterAction, so that we can return multiple * actions versus just one. */ protected IAction[] getNewFilterPoolFilterActions(SystemFilterPool selectedPool, Shell shell) { SystemNewFilterAction teamAction = (SystemNewFilterAction)super.getNewFilterPoolFilterAction(selectedPool, shell); teamAction.setWizardPageTitle(RSESamplesPlugin.getResourceString("filter.team.pagetitle")); teamAction.setPage1Description(RSESamplesPlugin.getResourceString("filter.team.pagetext")); teamAction.setType("team"); teamAction.setText(RSESamplesPlugin.getResourceString("filter.team.pagetitle") + "..."); SystemNewFilterAction devrAction = (SystemNewFilterAction)super.getNewFilterPoolFilterAction(selectedPool, shell); devrAction.setWizardPageTitle(RSESamplesPlugin.getResourceString("filter.devr.pagetitle")); devrAction.setPage1Description(RSESamplesPlugin.getResourceString("filter.devr.pagetext")); devrAction.setType("devr"); devrAction.setText(RSESamplesPlugin.getResourceString("filter.devr.pagetitle") + "..."); devrAction.setFilterStringEditPane(new DeveloperFilterStringEditPane(shell)); IAction[] actions = new IAction[2]; actions[0] = teamAction; actions[1] = devrAction; return actions; } /** * Override of parent method for returning the change-filter action, so we can affect it. */ protected IAction getChangeFilterAction(SystemFilter selectedFilter, Shell shell) { SystemChangeFilterAction action = (SystemChangeFilterAction)super.getChangeFilterAction(selectedFilter, shell); String type = selectedFilter.getType(); if (type == null) type = "team"; if (type.equals("team")) { action.setDialogTitle(RSESamplesPlugin.getResourceString("filter.team.dlgtitle")); } else { action.setDialogTitle(RSESamplesPlugin.getResourceString("filter.devr.dlgtitle")); action.setFilterStringEditPane(new DeveloperFilterStringEditPane(shell)); } return action; } /** * Override of parent method for returning the image for filters in our subsystem. */ public ImageDescriptor getSystemFilterImage(SystemFilter filter) { String type = filter.getType(); if (type == null) type = "team"; if (type.equals("team")) return RSESamplesPlugin.getDefault().getImageDescriptor("ICON_ID_TEAMFILTER"); else return RSESamplesPlugin.getDefault().getImageDescriptor("ICON_ID_DEVELOPERFILTER"); } }