usr/src/java/vpanels/panels/apache/org/opensolaris/os/vp/panels/apache/client/swing/MimeTypesControl.java
author Stephen Talley <stephen.talley@sun.com>
Tue, 22 Sep 2009 16:46:54 -0400
changeset 360 8943c58ad2f5
parent 349 cb1b71664c9a
child 404 32e9b6a2b5f2
permissions -rw-r--r--
11508 Control, DefaultControl refactoring
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     1
/*
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     2
 * CDDL HEADER START
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     3
 *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     5
 * Common Development and Distribution License (the "License").
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     6
 * You may not use this file except in compliance with the License.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     7
 *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    11
 * and limitations under the License.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    12
 *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    18
 *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    19
 * CDDL HEADER END
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    20
 */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    21
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    22
/*
193
f14789edacaf 6066 Simplify help URL creation
David Powell <David.Powell@sun.com>
parents: 171
diff changeset
    23
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    24
 * Use is subject to license terms.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    25
 */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    26
219
57841c113efe 6788 package names should share o.o.o.vp prefix
Stephen Talley <stephen.talley@sun.com>
parents: 214
diff changeset
    27
package org.opensolaris.os.vp.panels.apache.client.swing;
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    28
276
d8275f1fd45b 8091 apache: empty mime types/modules list should show help text
Stephen Talley <stephen.talley@sun.com>
parents: 274
diff changeset
    29
import java.awt.Image;
196
4aefd5567f1e 4364 sysid: resolve SysIdUtil.createNPException
Stephen Talley <stephen.talley@sun.com>
parents: 193
diff changeset
    30
import java.net.URL;
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
    31
import java.util.List;
318
6fd18ef74a39 9609 apache: virtual host list should show status
Stephen Talley <stephen.talley@sun.com>
parents: 306
diff changeset
    32
import javax.swing.*;
40
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
    33
import org.opensolaris.os.vp.panel.common.control.*;
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
    34
import org.opensolaris.os.vp.panel.common.view.PanelIconUtil;
40
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
    35
import org.opensolaris.os.vp.panel.swing.control.*;
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
    36
import org.opensolaris.os.vp.panel.swing.view.*;
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
    37
import org.opensolaris.os.vp.util.misc.*;
318
6fd18ef74a39 9609 apache: virtual host list should show status
Stephen Talley <stephen.talley@sun.com>
parents: 306
diff changeset
    38
import org.opensolaris.os.vp.util.swing.*;
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    39
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
    40
public class MimeTypesControl extends ListSelectorControl<ApachePanelDescriptor,
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
    41
    ListSelectorPanel, MimeType> implements HasImages {
223
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    42
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    43
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    44
    // Static data
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    45
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    46
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    47
    public static final String ID = "mimetypes";
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
    48
    public static final String NAME = Finder.getString("mimetypes.title");
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
    49
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
    50
    protected static final List<Image> images = IconUtil.getImages(
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
    51
	PanelIconUtil.getGenericMimeIcons());
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    52
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    53
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    54
    // Instance data
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    55
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    56
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
    57
    private HasMimeTypes parent;
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    58
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    59
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    60
    // Constructors
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    61
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    62
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
    63
    public MimeTypesControl(ApachePanelDescriptor descriptor,
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
    64
	HasMimeTypes parent) {
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    65
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
    66
	super(ID, NAME, descriptor);
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
    67
	this.parent = parent;
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    68
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    69
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
    70
    //
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
    71
    // HasImages methods
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
    72
    //
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    73
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
    74
    @Override
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
    75
    public List<? extends Image> getImages() {
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
    76
	return images;
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    77
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    78
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    79
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    80
    // Control methods
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    81
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    82
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    83
    @Override
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
    84
    public Navigable[] getForwardingPath() {
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
    85
	List<MimeType> mimeTypes = parent.getMimeTypes().getChildren();
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
    86
	if (!mimeTypes.isEmpty()) {
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    87
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
    88
	    MimeType mimeType = mimeTypes.get(0);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    89
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
    90
	    return new Navigable[] {
274
4ff6ceb185e6 8085 SimpleNavigable construction could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 264
diff changeset
    91
		new SimpleNavigable(MimeTypeControl.ID, null,
4ff6ceb185e6 8085 SimpleNavigable construction could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 264
diff changeset
    92
		    MimeTypeControl.PARAM_MIMETYPE, mimeType.getId())
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
    93
	    };
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    94
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    95
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
    96
	return null;
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    97
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    98
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 349
diff changeset
    99
    @Override
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 349
diff changeset
   100
    public URL getHelpURL() {
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 349
diff changeset
   101
	return buildHelpURL("help/apache.html", "#apache-mimetypes");
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 349
diff changeset
   102
    }
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 349
diff changeset
   103
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   104
    //
171
ec6f1c5d031c 2537 API and UI should support deep-linking into help text
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   105
    // DefaultControl methods
ec6f1c5d031c 2537 API and UI should support deep-linking into help text
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   106
    //
ec6f1c5d031c 2537 API and UI should support deep-linking into help text
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   107
ec6f1c5d031c 2537 API and UI should support deep-linking into help text
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   108
    @Override
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   109
    protected void ensureChildrenCreated() {
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   110
	if (children.size() == 0) {
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   111
	    ApachePanelDescriptor descriptor = getPanelDescriptor();
276
d8275f1fd45b 8091 apache: empty mime types/modules list should show help text
Stephen Talley <stephen.talley@sun.com>
parents: 274
diff changeset
   112
	    SwingControl child = new MimeTypeControl(descriptor, this);
d8275f1fd45b 8091 apache: empty mime types/modules list should show help text
Stephen Talley <stephen.talley@sun.com>
parents: 274
diff changeset
   113
	    addChildren(child);
d8275f1fd45b 8091 apache: empty mime types/modules list should show help text
Stephen Talley <stephen.talley@sun.com>
parents: 274
diff changeset
   114
	    addToLayout(child);
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   115
	}
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   116
    }
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   117
171
ec6f1c5d031c 2537 API and UI should support deep-linking into help text
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   118
    //
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   119
    // SwingControl methods
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   120
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   121
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   122
    @Override
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   123
    protected ListSelectorPanel createComponent() {
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   124
	ListSelectorPanel panel = new ListSelectorPanel();
340
8bdbfc87f145 10594 sharemgr: new selection-based UI design
Stephen Talley <stephen.talley@sun.com>
parents: 318
diff changeset
   125
	panel.setSelectionTitle(Finder.getString("mimetypes.list.title"));
318
6fd18ef74a39 9609 apache: virtual host list should show status
Stephen Talley <stephen.talley@sun.com>
parents: 306
diff changeset
   126
340
8bdbfc87f145 10594 sharemgr: new selection-based UI design
Stephen Talley <stephen.talley@sun.com>
parents: 318
diff changeset
   127
	JList list = panel.getSelectionComponent();
318
6fd18ef74a39 9609 apache: virtual host list should show status
Stephen Talley <stephen.talley@sun.com>
parents: 306
diff changeset
   128
	SimpleCellRenderer renderer = new ManagedObjectCellRenderer<MimeType>();
6fd18ef74a39 9609 apache: virtual host list should show status
Stephen Talley <stephen.talley@sun.com>
parents: 306
diff changeset
   129
	renderer.configureFor(list);
6fd18ef74a39 9609 apache: virtual host list should show status
Stephen Talley <stephen.talley@sun.com>
parents: 306
diff changeset
   130
	list.setCellRenderer(renderer);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   131
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   132
	addAction(panel, new CreateMimeTypeAction(this), true, true);
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   133
	addAction(panel, new DeleteMimeTypeAction(this), true, true);
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   134
301
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 276
diff changeset
   135
	addDefaultCloseAction(panel, false);
244
b6f1fb4f5a89 7624 SwingControl: createComponent implementations should not be required to call setComponent
Stephen Talley <stephen.talley@sun.com>
parents: 238
diff changeset
   136
	addDefaultHelpAction(panel);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   137
276
d8275f1fd45b 8091 apache: empty mime types/modules list should show help text
Stephen Talley <stephen.talley@sun.com>
parents: 274
diff changeset
   138
	setDefaultContentView(new NoMimeTypePanel());
d8275f1fd45b 8091 apache: empty mime types/modules list should show help text
Stephen Talley <stephen.talley@sun.com>
parents: 274
diff changeset
   139
244
b6f1fb4f5a89 7624 SwingControl: createComponent implementations should not be required to call setComponent
Stephen Talley <stephen.talley@sun.com>
parents: 238
diff changeset
   140
	return panel;
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   141
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   142
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   143
    //
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   144
    // ListSelectorControl methods
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   145
    //
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   146
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   147
    @Override
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   148
    protected int getListIndexOf(Control child) {
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   149
	MimeType mimeType = ((MimeTypeControl)child).getMimeType();
340
8bdbfc87f145 10594 sharemgr: new selection-based UI design
Stephen Talley <stephen.talley@sun.com>
parents: 318
diff changeset
   150
	int index = parent.getMimeTypes().indexOf(mimeType);
8bdbfc87f145 10594 sharemgr: new selection-based UI design
Stephen Talley <stephen.talley@sun.com>
parents: 318
diff changeset
   151
	assert mimeType == getComponent().getSelectionComponent().getModel().
8bdbfc87f145 10594 sharemgr: new selection-based UI design
Stephen Talley <stephen.talley@sun.com>
parents: 318
diff changeset
   152
	    getElementAt(index);
8bdbfc87f145 10594 sharemgr: new selection-based UI design
Stephen Talley <stephen.talley@sun.com>
parents: 318
diff changeset
   153
	return index;
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   154
    }
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   155
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   156
    @Override
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   157
    protected ListModel getListModel() {
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   158
	return new ManagedObjectTableModel<MimeType>(parent.getMimeTypes(),
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   159
	    null);
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   160
    }
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   161
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   162
    @Override
340
8bdbfc87f145 10594 sharemgr: new selection-based UI design
Stephen Talley <stephen.talley@sun.com>
parents: 318
diff changeset
   163
    protected Navigable[] getPathForSelection(List<MimeType> selection) {
8bdbfc87f145 10594 sharemgr: new selection-based UI design
Stephen Talley <stephen.talley@sun.com>
parents: 318
diff changeset
   164
	if (selection.size() != 1) {
8bdbfc87f145 10594 sharemgr: new selection-based UI design
Stephen Talley <stephen.talley@sun.com>
parents: 318
diff changeset
   165
	    return null;
8bdbfc87f145 10594 sharemgr: new selection-based UI design
Stephen Talley <stephen.talley@sun.com>
parents: 318
diff changeset
   166
	}
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   167
349
cb1b71664c9a 11070 SelectorControl should provide a default implementation of Control.getBrowsable
Stephen Talley <stephen.talley@sun.com>
parents: 340
diff changeset
   168
	MimeType selected = selection.get(0);
cb1b71664c9a 11070 SelectorControl should provide a default implementation of Control.getBrowsable
Stephen Talley <stephen.talley@sun.com>
parents: 340
diff changeset
   169
340
8bdbfc87f145 10594 sharemgr: new selection-based UI design
Stephen Talley <stephen.talley@sun.com>
parents: 318
diff changeset
   170
	return new Navigable[] {
349
cb1b71664c9a 11070 SelectorControl should provide a default implementation of Control.getBrowsable
Stephen Talley <stephen.talley@sun.com>
parents: 340
diff changeset
   171
	    new SimpleNavigable(MimeTypeControl.ID, selected.getName(),
cb1b71664c9a 11070 SelectorControl should provide a default implementation of Control.getBrowsable
Stephen Talley <stephen.talley@sun.com>
parents: 340
diff changeset
   172
		MimeTypeControl.PARAM_MIMETYPE, selected.getId())
340
8bdbfc87f145 10594 sharemgr: new selection-based UI design
Stephen Talley <stephen.talley@sun.com>
parents: 318
diff changeset
   173
	};
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   174
    }
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   175
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   176
    //
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   177
    // MimeTypesControl methods
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   178
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   179
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   180
    public HasMimeTypes getHasMimeTypes() {
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 259
diff changeset
   181
	return parent;
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   182
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   183
}