boolean isBasic = ApplicationMode.isBasicMode();
editAction = new LeadSelectionAction("EditMenuItem", browser, true) {
public void actionPerformed(ActionEvent event) {
ImageDatum lead = getLeadDatum();
browser.notifyDoubleClicked(lead);
}
};
copyAction = new LeadSelectionAction(
"CopyMenuItem", browser, ! isBasic
) {
public void actionPerformed(ActionEvent event) {
ImageDatum datum = getLeadDatum();
TemplateClipboard = datum.getFile();
}
void update() {
super.update();
if (isEnabled()) {
ImageDatum lead = getLeadDatum();
ImageDatumType type = lead.getType();
boolean hasLzn = type.hasLznData();
copyAction.setEnabled(hasLzn);
}
}
};
pasteAction = new SelectionAction(
LOCALE.get("PasteMenuItem"), browser, null, true, ! isBasic
) {
public void actionPerformed(ActionEvent event) {
List<ImageDatum> selection = getSelection();
List<File> files = new ArrayList<File>();
for (ImageDatum datum : selection) {
File file = datum.getFile();
files.add(file);
}
TemplateProvider templates = browser.getTemplateProvider();
templates.applyTemplate(
TemplateClipboard, files.toArray(new File[0])
);
}
void update() {
super.update();
if (isEnabled()) {
TemplateProvider templates = browser.getTemplateProvider();
List<ImageDatum> selection = getSelection();
boolean hasTemplates = (templates != null);
boolean hasSelection = ! selection.isEmpty();
boolean hasClipboard = (TemplateClipboard != null);
setEnabled(hasTemplates && hasSelection && hasClipboard);
}
}
};
refreshAction = new SelectionAction(
LOCALE.get("RefreshMenuItem"), browser, null, true, true
) {
public void actionPerformed(ActionEvent e) {
List<ImageDatum> selection = getSelection();
for (ImageDatum datum : selection) {
datum.refresh(false); // don't use caches
}
}
};
ratingActions =
RatingActions.createRatingActions(browser, true);
// ratingAdvanceActions =
// RatingActions.createRatingAdvanceActions(browser, true);
clearRatingAction =
RatingActions.createClearRatingAction(browser, true);
// clearRatingAdvanceAction =
// RatingActions.createClearRatingAdvanceAction(browser, true);
leftAction = RotateActions.createRotateLeftAction(browser, true);
rightAction = RotateActions.createRotateRightAction(browser, true);
renameAction = new LeadSelectionAction(
"RenameMenuItem", browser, ! isBasic
) {
public void actionPerformed(ActionEvent event) {
ImageDatum datum = browser.getLeadSelectedDatum();
FileActions.renameFile(
datum.getFile(), browser
);
}
};
selectLatestAction = new AbstractAction(
LOCALE.get("SelectLatestActionName")
) {
public void actionPerformed(ActionEvent event) {
browser.selectLatest();
}
};
selectLatestAction.setEnabled(! ApplicationMode.isBasicMode());
selectAllAction = new AbstractAction(
LOCALE.get("SelectAllActionName")
) {
public void actionPerformed(ActionEvent event) {
browser.selectAll();
}
};
selectAllAction.setEnabled(! ApplicationMode.isBasicMode());
// This accelerator key setup should be localized and maybe unified
// with the centralized menu configuration in MenuFactory.
String modifier =
Platform.getType() == Platform.MacOSX ? "meta" : "ctrl";
selectAllAction.putValue(
Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(
modifier + " " + "A"
)
);
selectNoneAction = new SelectionAction(
LOCALE.get("SelectNoneActionName"), browser, null, true, true
) {
public void actionPerformed(ActionEvent e) {
browser.clearSelection();
}
};
showHideTypesAction = new ToggleAction(
LOCALE.get("HideImageTypeMenuItem"),
LOCALE.get("ShowImageTypeMenuItem")
) {
protected void onActionPerformed(ActionEvent event) {
ImageDatumRenderer.setShowImageTypes(true);
browser.repaint();
}
protected void offActionPerformed(ActionEvent event) {
ImageDatumRenderer.setShowImageTypes(false);
browser.repaint();
}
};
showHideTypesAction.setState(ImageDatumRenderer.doesShowImageTypes());
// The trash action does get a key binding, defined in
// AbstractImageBrowser instead of here.
trashAction = new SelectionAction(
LOCALE.get("TrashMenuItem"), browser, null, true, ! isBasic
) {
public void actionPerformed(ActionEvent event) {
List<ImageDatum> datums = browser.getSelectedDatums();
List<File> files = new ArrayList<File>();
for (ImageDatum datum : datums) {
File file = datum.getFile();
files.add(file);
}
FileActions.deleteFiles(files.toArray(new File[0]), browser);
}
};
showAction = new SelectionAction(
LOCALE.get("ShowMenuItem"), browser, null, true, true
) {
public void actionPerformed(ActionEvent event) {
List<ImageDatum> datums = browser.getSelectedDatums();
List<File> files = new ArrayList<File>();
for (ImageDatum datum : datums) {
File file = datum.getFile();
files.add(file);
}
Platform platform = Platform.getPlatform();
for (File file : files) {
file = FileUtil.resolveAliasFile(file);