update copyright
[fedora-idea.git] / java / java-impl / src / com / intellij / unscramble / UnscrambleFromClipboardAction.java
blob589c68a0bd153d7309c21db690f423d2917e7e6a
1 /*
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.
16 package com.intellij.unscramble;
18 import com.intellij.openapi.actionSystem.AnAction;
19 import com.intellij.openapi.actionSystem.AnActionEvent;
20 import com.intellij.openapi.actionSystem.PlatformDataKeys;
21 import com.intellij.openapi.actionSystem.Presentation;
22 import com.intellij.openapi.project.Project;
24 public final class UnscrambleFromClipboardAction extends AnAction {
25 public void actionPerformed(AnActionEvent e) {
26 Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
28 // If there's a text in clipboard and log is specified or not needed, unscramble w/o extra questions
30 String text = AnalyzeStacktraceUtil.getTextInClipboard();
31 if (text != null) {
32 String file = UnscrambleDialog.getLastUsedLogUrl();
33 if (file != null && file.trim().length() == 0) {
34 file = null;
36 UnscrambleSupport savedUnscrambler = UnscrambleDialog.getSavedUnscrambler();
37 if (savedUnscrambler == null || file != null) {
38 boolean success = UnscrambleDialog.showUnscrambledText(savedUnscrambler, file, project, text);
39 if (success) {
40 return;
45 // Use regular unscramble dialog
46 UnscrambleDialog dialog = new UnscrambleDialog(project);
47 dialog.show();
50 public void update(AnActionEvent event){
51 Presentation presentation = event.getPresentation();
52 Project project = PlatformDataKeys.PROJECT.getData(event.getDataContext());
53 presentation.setEnabled(project != null);