Navigation Menu

Skip to content

Commit

Permalink
KO buttons state
Browse files Browse the repository at this point in the history
  • Loading branch information
nroduit committed Jun 24, 2014
1 parent 0fdc006 commit c37ae79
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
Expand Up @@ -60,6 +60,7 @@ public class ActionW {
public static final ActionW LUT = new ActionW(Messages.getString("ActionW.lut"), "lut", 0, 0, null); //$NON-NLS-1$ //$NON-NLS-2$
public static final ActionW INVERSELUT = new ActionW("", "inverseLut", 0, 0, null); //$NON-NLS-1$ //$NON-NLS-2$
public static final ActionW RESET = new ActionW(Messages.getString("ActionW.Reset"), "reset", 0, 0, null); //$NON-NLS-1$ //$NON-NLS-2$
public static final ActionW SHOW_HEADER = new ActionW("Open DICOM Information", "reset", 0, 0, null); //$NON-NLS-2$
public static final ActionW PAN =
new ActionW(
Messages.getString("ActionW.pan"), "pan", KeyEvent.VK_T, 0, getCustomCursor("pan.png", Messages.getString("ActionW.pan"), 16, 16)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
Expand All @@ -68,7 +69,8 @@ public class ActionW {
Messages.getString("ActionW.measure"), "measure", KeyEvent.VK_M, 0, null); //$NON-NLS-1$ //$NON-NLS-2$
public static final ActionW DRAW_MEASURE = new ActionW(
Messages.getString("ActionW.measurement"), "measurement", 0, 0, null); //$NON-NLS-1$ //$NON-NLS-2$
public static final ActionW SPATIAL_UNIT = new ActionW(Messages.getString("ActionW.spatial_unit"), "spunit", 0, 0, null); //$NON-NLS-1$//$NON-NLS-2$
public static final ActionW SPATIAL_UNIT = new ActionW(
Messages.getString("ActionW.spatial_unit"), "spunit", 0, 0, null); //$NON-NLS-1$//$NON-NLS-2$
public static final ActionW SORTSTACK = new ActionW("", "sortStack", 0, 0, null); //$NON-NLS-1$ //$NON-NLS-2$
public static final ActionW CONTEXTMENU = new ActionW(
Messages.getString("ActionW.context_menu"), "contextMenu", KeyEvent.VK_Q, 0, null); //$NON-NLS-1$ //$NON-NLS-2$
Expand All @@ -78,10 +80,13 @@ public class ActionW {
public static final ActionW IMAGE_OVERLAY = new ActionW(
Messages.getString("ActionW.overlay"), "overlay", 0, 0, null); //$NON-NLS-1$ //$NON-NLS-2$
public static final ActionW PR_STATE = new ActionW(Messages.getString("ActionW.PR"), "pr_state", 0, 0, null); //$NON-NLS-1$//$NON-NLS-2$
public static final ActionW KO_TOOGLE_STATE = new ActionW(Messages.getString("ActionW.toggle_ko"), "ko_toogle_state", KeyEvent.VK_K, 0, //$NON-NLS-1$ //$NON-NLS-2$
public static final ActionW KO_TOOGLE_STATE = new ActionW(
Messages.getString("ActionW.toggle_ko"), "ko_toogle_state", KeyEvent.VK_K, 0, //$NON-NLS-1$ //$NON-NLS-2$
null);
public static final ActionW KO_SELECTION = new ActionW(Messages.getString("ActionW.select_ko"), "ko_selection", 0, 0, null); //$NON-NLS-1$ //$NON-NLS-2$
public static final ActionW KO_FILTER = new ActionW(Messages.getString("ActionW.filter_ko"), "ko_filter", 0, 0, null); //$NON-NLS-1$ //$NON-NLS-2$
public static final ActionW KO_SELECTION = new ActionW(
Messages.getString("ActionW.select_ko"), "ko_selection", 0, 0, null); //$NON-NLS-1$ //$NON-NLS-2$
public static final ActionW KO_FILTER = new ActionW(
Messages.getString("ActionW.filter_ko"), "ko_filter", 0, 0, null); //$NON-NLS-1$ //$NON-NLS-2$
public static final ActionW IMAGE_PIX_PADDING = new ActionW(
Messages.getString("ActionW.pixpad"), "pixel_padding", 0, 0, null); //$NON-NLS-1$//$NON-NLS-2$
public static final ActionW IMAGE_SHUTTER = new ActionW(
Expand Down
Expand Up @@ -6,6 +6,8 @@
import javax.swing.ImageIcon;
import javax.swing.JButton;

import org.weasis.core.api.gui.util.ActionState;
import org.weasis.core.api.gui.util.ActionW;
import org.weasis.core.ui.editor.image.ImageViewerPlugin;
import org.weasis.core.ui.util.WtoolBar;

Expand All @@ -16,7 +18,7 @@ public DcmHeaderToolBar(int index) {

final JButton metaButton =
new JButton(new ImageIcon(ImageViewerPlugin.class.getResource("/icon/32x32/dcm-header.png"))); //$NON-NLS-1$
metaButton.setToolTipText("Open DICOM Information");
metaButton.setToolTipText(ActionW.SHOW_HEADER.getTitle());
metaButton.addActionListener(new ActionListener() {

@Override
Expand All @@ -28,6 +30,10 @@ public void actionPerformed(ActionEvent e) {
}
});
add(metaButton);
ActionState headerAction = EventManager.getInstance().getAction(ActionW.SHOW_HEADER);
if (headerAction != null) {
headerAction.registerActionState(metaButton);
}
}

}
Expand Up @@ -194,6 +194,7 @@ private EventManager() {
iniAction(panAction = newPanAction());
iniAction(crosshairAction = newCrosshairAction());
iniAction(new BasicActionState(ActionW.RESET));
iniAction(new BasicActionState(ActionW.SHOW_HEADER));

iniAction(koToggleAction = newKOToggleAction());
iniAction(koFilterAction = newKOFilterAction());
Expand Down Expand Up @@ -629,14 +630,16 @@ private void koAction(ActionW action, Object selected) {
filterSelection ? selectedView.getActionValue(ActionW.KO_SELECTION.cmd()) : selected;
Boolean enableFilter =
(Boolean) (filterSelection ? selected : selectedView.getActionValue(ActionW.KO_FILTER.cmd()));
DefaultView2d<DicomImageElement> viewPane = container.getSelectedImagePane();
int frameIndex =
JMVUtils.getNULLtoFalse(enableFilter) ? 0 : viewPane.getFrameIndex() - viewPane.getTileOffset();

for (DefaultView2d<DicomImageElement> view : container.getImagePanels(false)) {
for (DefaultView2d<DicomImageElement> view : container.getImagePanels(true)) {
if ((view.getSeries() instanceof DicomSeries) == false || (view instanceof View2d) == false) {
continue;
}
// Recompute the series filter to let perform updateTileOffset() correctly.
// KOManager.updateKOFilter(view, selectedKO, enableFilter, -1);
KOManager.updateKOFilter(view, selectedKO, enableFilter, -1, false);

KOManager.updateKOFilter(view, selectedKO, enableFilter, frameIndex, false);
}

container.updateTileOffset();
Expand Down
Expand Up @@ -119,7 +119,7 @@ protected JPopupMenu getPopupMenu() {

// final String[] optionsNoSelection = { "Delete KeyObject", "Create a new KeyObject" };
// final String[] optionsWithSelection = { "Delete KeyObject", "Copy selected KeyObject" };

koSelectionAction.registerActionState(koEditSelectionBtn);
koEditSelectionBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Expand Down

0 comments on commit c37ae79

Please sign in to comment.