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();
32 String file
= UnscrambleDialog
.getLastUsedLogUrl();
33 if (file
!= null && file
.trim().length() == 0) {
36 UnscrambleSupport savedUnscrambler
= UnscrambleDialog
.getSavedUnscrambler();
37 if (savedUnscrambler
== null || file
!= null) {
38 boolean success
= UnscrambleDialog
.showUnscrambledText(savedUnscrambler
, file
, project
, text
);
45 // Use regular unscramble dialog
46 UnscrambleDialog dialog
= new UnscrambleDialog(project
);
50 public void update(AnActionEvent event
){
51 Presentation presentation
= event
.getPresentation();
52 Project project
= PlatformDataKeys
.PROJECT
.getData(event
.getDataContext());
53 presentation
.setEnabled(project
!= null);