2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com
.intellij
.ide
.bookmarks
.actions
;
19 import com
.intellij
.ide
.IdeBundle
;
20 import com
.intellij
.openapi
.actionSystem
.AnActionEvent
;
21 import com
.intellij
.openapi
.actionSystem
.DataContext
;
22 import com
.intellij
.openapi
.actionSystem
.PlatformDataKeys
;
23 import com
.intellij
.openapi
.project
.DumbAware
;
24 import com
.intellij
.openapi
.project
.Project
;
26 public class ToggleBookmarkAction
extends BookmarksAction
implements DumbAware
{
27 public ToggleBookmarkAction() {
28 getTemplatePresentation().setText(IdeBundle
.message("action.toggle.bookmark"));
31 public void actionPerformed(AnActionEvent e
) {
32 DataContext dataContext
= e
.getDataContext();
33 Project project
= PlatformDataKeys
.PROJECT
.getData(dataContext
);
34 if (project
== null) return;
35 BookmarkInContextInfo info
= new BookmarkInContextInfo(dataContext
, project
).invoke();
37 if (info
.getBookmarkAtPlace() != null) {
38 new RemoveBookmarkItem(info
.getBookmarkAtPlace()).execute(project
);
41 new SetBookmarkItem(info
.getFile(), info
.getLine()).execute(project
);
45 public void update(AnActionEvent event
) {
48 event
.getPresentation().setText(IdeBundle
.message("action.toggle.bookmark"));