in taverna-perspective-myexperiment/src/main/java/org/apache/taverna/ui/perspectives/myexperiment/ResourcePreviewBrowser.java [559:681]
public void actionPerformed(ActionEvent e) {
if (e.getSource().equals(this.bBack)) {
// "Back" button clicked
// update position in the history
iCurrentHistoryIdx--;
// enable or disable "back"/"forward" buttons as appropriate
bBack.setEnabled(iCurrentHistoryIdx > 0);
bForward.setEnabled(iCurrentHistoryIdx < alCurrentHistory.size() - 1);
// open requested preview from the history
this.createPreview(alCurrentHistory.get(iCurrentHistoryIdx));
} else if (e.getSource().equals(this.bForward)) {
// "Forward" button clicked
// update position in the history
iCurrentHistoryIdx++;
// enable or disable "back"/"forward" buttons as appropriate
bBack.setEnabled(iCurrentHistoryIdx > 0);
bForward.setEnabled(iCurrentHistoryIdx < alCurrentHistory.size() - 1);
// open requested preview from the history
this.createPreview(alCurrentHistory.get(iCurrentHistoryIdx));
} else if (e.getSource().equals(this.bRefresh)) {
// "Refresh" button clicked
// simply reload the same preview
this.createPreview(alCurrentHistory.get(iCurrentHistoryIdx));
} else if (e.getSource().equals(this.bOpenInMyExp)) {
// "Open in myExperiment" button clicked
try {
Desktop.getDesktop().browse(new URI(this.rpcContent.getResourceURL()));
} catch (Exception ex) {
logger.error("Failed while trying to open the URL in a standard browser; URL was: "
+ this.rpcContent.getResourceURL() + "\nException was: " + ex);
}
} else if (e.getSource().equals(this.bUpload)) {
/* ************************************************************************* */
Resource resource = this.rpcContent.getResource();
if (resource.getItemTypeName().equals("Workflow")) {
UploadWorkflowDialog uploadWorkflowDialog = new UploadWorkflowDialog(this, true, resource, fileManager);
if (uploadWorkflowDialog.launchUploadDialogAndPostIfRequired()) {
// "true" has been returned so update the resource
this.actionPerformed(new ActionEvent(this.bRefresh, 0, ""));
}
}
} else if (e.getSource().equals(this.bEditMetadata)) {
Resource resource = this.rpcContent.getResource();
if (resource.getItemTypeName().equals("Workflow")) {
UploadWorkflowDialog uploadWorkflowDialog = new UploadWorkflowDialog(this, false, resource, fileManager);
if (uploadWorkflowDialog.launchUploadDialogAndPostIfRequired()) {
// "true" has been returned so update the resource
this.actionPerformed(new ActionEvent(this.bRefresh, 0, ""));
}
}
/* ************************************************************************* */
} else if (e.getSource().equals(this.bAddComment)) {
// "Add Comment" button was clicked
String strComment = null;
AddCommentDialog commentDialog = new AddCommentDialog(this, this.rpcContent.getResource(), pluginMainComponent, myExperimentClient, logger);
if ((strComment = commentDialog.launchAddCommentDialogAndPostCommentIfRequired()) != null) {
// comment was added because return value is not null;
// a good option now would be to reload only the comments tab, but
// for now we refresh the whole of the preview
this.actionPerformed(new ActionEvent(this.bRefresh, 0, ""));
// update history of the items that were commented on, making sure that:
// - there's only one occurrence of this item in the history;
// - if this item was in the history before, it is moved to the 'top' now;
// - predefined history size is not exceeded
this.pluginMainComponent.getHistoryBrowser().getCommentedOnItemsHistoryList().remove(this.rpcContent.getResource());
this.pluginMainComponent.getHistoryBrowser().getCommentedOnItemsHistoryList().add(this.rpcContent.getResource());
if (this.pluginMainComponent.getHistoryBrowser().getCommentedOnItemsHistoryList().size() > HistoryBrowserTabContentPanel.COMMENTED_ON_ITEMS_HISTORY) {
this.pluginMainComponent.getHistoryBrowser().getCommentedOnItemsHistoryList().remove(0);
}
// now update the history of the items that were commented on in 'History' tab
if (this.pluginMainComponent.getHistoryBrowser() != null) {
this.pluginMainComponent.getHistoryBrowser().refreshHistoryBox(HistoryBrowserTabContentPanel.COMMENTED_ON_ITEMS_HISTORY);
}
}
} else if (e.getSource().equals(this.bAddRemoveFavourite)) {
boolean bItemIsFavourited = this.rpcContent.getResource().isFavouritedBy(this.myExperimentClient.getCurrentUser());
AddRemoveFavouriteDialog favouriteDialog = new AddRemoveFavouriteDialog(this, !bItemIsFavourited, this.rpcContent.getResource(), pluginMainComponent, myExperimentClient, logger);
int iFavouritingStatus = favouriteDialog.launchAddRemoveFavouriteDialogAndPerformNecessaryActionIfRequired();
// if the operation wasn't cancelled, update status of the
// "add/remove favourite" button and the list of favourites in the user profile
if (iFavouritingStatus != AddRemoveFavouriteDialog.OPERATION_CANCELLED) {
this.updateButtonBarState(this.rpcContent);
this.pluginMainComponent.getMyStuffTab().getSidebar().repopulateFavouritesBox();
this.pluginMainComponent.getMyStuffTab().getSidebar().revalidate();
}
} else if (e.getSource() instanceof JClickableLabel) {
// clicked somewhere on a JClickableLabel; if that's a 'preview' request - launch preview
if (e.getActionCommand().startsWith("preview:")) {
this.preview(e.getActionCommand());
} else if (e.getActionCommand().startsWith("tag:")) {
// pass this event onto the Tag Browser tab
this.pluginMainComponent.getTagBrowserTab().actionPerformed(e);
this.pluginMainComponent.getMainTabs().setSelectedComponent(this.pluginMainComponent.getTagBrowserTab());
} else {
// show the link otherwise
try {
Desktop.getDesktop().browse(new URI(e.getActionCommand()));
} catch (Exception ex) {
logger.error("Failed while trying to open the URL in a standard browser; URL was: "
+ e.getActionCommand() + "\nException was: " + ex);
}
}
} else if (e.getSource() instanceof TagCloudPanel
&& e.getActionCommand().startsWith("tag:")) {
// close the window and pass this event onto the Tag Browser tab
this.setVisible(false);
this.pluginMainComponent.getTagBrowserTab().actionPerformed(e);
this.pluginMainComponent.getMainTabs().setSelectedComponent(this.pluginMainComponent.getTagBrowserTab());
}
}