Example usage for java.awt.dnd DropTarget DropTarget

List of usage examples for java.awt.dnd DropTarget DropTarget

Introduction

In this page you can find the example usage for java.awt.dnd DropTarget DropTarget.

Prototype

public DropTarget(Component c, DropTargetListener dtl) throws HeadlessException 

Source Link

Document

Creates a DropTarget given the Component to associate itself with, and the DropTargetListener to handle event processing.

Usage

From source file:com.pironet.tda.TDA.java

/**
 * initializes tda panel/*from w  w  w .j  a v  a  2s.  c  om*/
 *
 * @param asJConsolePlugin specifies if tda is running as plugin
 */
public void init(boolean asJConsolePlugin, boolean asVisualVMPlugin) {
    // init everything
    tree = new JTree();
    addTreeListener(tree);
    runningAsJConsolePlugin = asJConsolePlugin;
    runningAsVisualVMPlugin = asVisualVMPlugin;

    //Create the HTML viewing pane.
    if (!this.runningAsVisualVMPlugin && !this.runningAsJConsolePlugin) {
        InputStream is = TDA.class.getResourceAsStream("/doc/welcome.html");

        htmlPane = new JEditorPane();

        String welcomeText = parseWelcomeURL(is);
        htmlPane.setContentType("text/html");
        htmlPane.setText(welcomeText);
    } else if (asJConsolePlugin) {
        htmlPane = new JEditorPane("text/html",
                "<html><body bgcolor=\"ffffff\"><i>Press Button above to request a thread dump.</i></body></html>");

    } else {
        htmlPane = new JEditorPane("text/html", "<html><body bgcolor=\"ffffff\"></body></html>");
    }
    htmlPane.putClientProperty(Const.AA_TEXT_INFO_PROPERTY_KEY, Boolean.TRUE);
    htmlPane.setEditable(false);

    if (!asJConsolePlugin && !asVisualVMPlugin) {
        hdt = new DropTarget(htmlPane, new FileDropTargetListener());
    }

    JEditorPane emptyPane = new JEditorPane("text/html", "");
    emptyPane.setEditable(false);

    htmlPane.addHyperlinkListener(evt -> {
        // if a link was clicked
        if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
            if (evt.getDescription().startsWith("monitor")) {
                navigateToMonitor(evt.getDescription());
            } else if (evt.getDescription().startsWith("dump")) {
                navigateToDump();
            } else if (evt.getDescription().startsWith("wait")) {
                navigateToChild("Threads waiting");
            } else if (evt.getDescription().startsWith("sleep")) {
                navigateToChild("Threads sleeping");
            } else if (evt.getDescription().startsWith("dead")) {
                navigateToChild("Deadlocks");
            } else if (evt.getDescription().startsWith("threaddump")) {
                addMXBeanDump();
            } else if (evt.getDescription().startsWith("openlogfile") && !evt.getDescription().endsWith("//")) {
                File[] files = { new File(evt.getDescription().substring(14)) };
                openFiles(files, false);
            } else if (evt.getDescription().startsWith("openlogfile")) {
                chooseFile();
            } else if (evt.getDescription().startsWith("opensession") && !evt.getDescription().endsWith("//")) {
                File file = new File(evt.getDescription().substring(14));
                openSession(file, true);
            } else if (evt.getDescription().startsWith("opensession")) {
                openSession();
            } else if (evt.getDescription().startsWith("preferences")) {
                showPreferencesDialog();
            } else if (evt.getDescription().startsWith("filters")) {
                showFilterDialog();
            } else if (evt.getDescription().startsWith("categories")) {
                showCategoriesDialog();
            } else if (evt.getDescription().startsWith("overview")) {
                showHelp();
            } else if (evt.getURL() != null) {
                try {
                    // launch a browser with the appropriate URL
                    Browser.open(evt.getURL().toString());
                } catch (InterruptedException e) {
                    System.out.println("Error launching external browser.");
                } catch (IOException e) {
                    System.out.println("I/O error launching external browser." + e.getMessage());
                    e.printStackTrace();
                }
            }
        }
    });

    htmlView = new ViewScrollPane(htmlPane, runningAsVisualVMPlugin);
    ViewScrollPane emptyView = new ViewScrollPane(emptyPane, runningAsVisualVMPlugin);

    // create the top split pane
    topSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    topSplitPane.setLeftComponent(emptyView);
    topSplitPane.setDividerSize(Const.DIVIDER_SIZE);
    topSplitPane.setContinuousLayout(true);

    //Add the scroll panes to a split pane.
    splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPane.setBottomComponent(htmlView);
    splitPane.setTopComponent(topSplitPane);
    splitPane.setDividerSize(Const.DIVIDER_SIZE);
    splitPane.setContinuousLayout(true);

    if (this.runningAsVisualVMPlugin) {
        setOpaque(true);
        setBackground(Color.WHITE);
        setBorder(BorderFactory.createEmptyBorder(6, 0, 3, 0));
        topSplitPane.setBorder(BorderFactory.createEmptyBorder());
        topSplitPane.setOpaque(false);
        topSplitPane.setBackground(Color.WHITE);
        htmlPane.setBorder(BorderFactory.createEmptyBorder());
        htmlPane.setOpaque(false);
        htmlPane.setBackground(Color.WHITE);
        splitPane.setBorder(BorderFactory.createEmptyBorder());
        splitPane.setOpaque(false);
        splitPane.setBackground(Color.WHITE);
    }

    Dimension minimumSize = new Dimension(200, 50);
    htmlView.setMinimumSize(minimumSize);
    emptyView.setMinimumSize(minimumSize);

    //Add the split pane to this panel.
    add(htmlView, BorderLayout.CENTER);

    statusBar = new StatusBar(!(asJConsolePlugin || asVisualVMPlugin));
    add(statusBar, BorderLayout.SOUTH);

    firstFile = true;
    setFileOpen(false);

    if (!runningAsVisualVMPlugin) {
        setShowToolbar(PrefManager.get().getShowToolbar());
    }

    if (firstFile && runningAsVisualVMPlugin) {
        // init filechooser
        fc = new JFileChooser();
        fc.setMultiSelectionEnabled(true);
        fc.setCurrentDirectory(PrefManager.get().getSelectedPath());
    }
}

From source file:com.opendoorlogistics.studio.appframe.AppFrame.java

public AppFrame(ActionFactory actionFactory, MenuFactory menuFactory, Image appIcon,
        AppPermissions permissions) {/*w  ww .j a  v a  2  s  . co m*/
    if (appIcon == null) {
        appIcon = Icons.loadFromStandardPath("App logo.png").getImage();
    }

    if (permissions == null) {
        permissions = new AppPermissions() {

            @Override
            public boolean isScriptEditingAllowed() {
                return true;
            }

            @Override
            public boolean isScriptDirectoryLocked() {
                return false;
            }
        };
    }
    this.appPermissions = permissions;

    // then create other objects which might use the components
    tables = new DatastoreTablesPanel(this);

    // create scripts panel after registering components
    scriptManager = new ScriptUIManagerImpl(this);
    File scriptDir;
    if (appPermissions.isScriptDirectoryLocked()) {
        scriptDir = new File(AppConstants.SCRIPTS_DIRECTORY).getAbsoluteFile();
    } else {
        scriptDir = PreferencesManager.getSingleton().getScriptsDirectory();
    }
    scriptsPanel = new ScriptsPanel(getApi(), scriptDir, scriptManager);

    // set my icon
    if (appIcon != null) {
        setIconImage(appIcon);
    }

    // create actions - this assumes that actions live for the lifetime of the app
    List<UIAction> fileActions = actionFactory.createFileActions(this);
    allActions.addAll(fileActions);
    List<UIAction> editActions = actionFactory.createEditActions(this);
    allActions.addAll(editActions);

    // create left-hand panel with scripts and tables
    splitterLeftSide = new JSplitPane(JSplitPane.VERTICAL_SPLIT, tables, scriptsPanel);
    splitterLeftSide.setPreferredSize(new Dimension(200, splitterLeftSide.getPreferredSize().height));
    splitterLeftSide.setResizeWeight(0.5);

    // split center part into tables/scripts browser on the left and desktop
    // pane on the right
    JPanel rightPane = new JPanel();
    rightPane.setLayout(new BorderLayout());
    rightPane.add(getDesktopPane(), BorderLayout.CENTER);
    rightPane.add(getWindowToolBar(), BorderLayout.SOUTH);
    splitterMain = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, splitterLeftSide, rightPane);
    getContentPane().add(splitterMain, BorderLayout.CENTER);

    // add toolbar
    initToolbar(actionFactory, fileActions, editActions);

    initMenus(actionFactory, menuFactory, fileActions, editActions);

    // control close operation to stop changed being lost
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            if (canCloseDatastore()) {
                dispose();
                if (haltJVMOnDispose) {
                    System.exit(0);
                }
            }
        }
    });

    // add myself as a drop target for importing excels etc from file
    new DropTarget(this, new DropFileImporterListener(this));

    setVisible(true);
    updateAppearance();

}

From source file:eu.apenet.dpt.standalone.gui.DataPreparationToolGUI.java

private void setupTool() {
    LoggerJAXB.outputJaxpImplementationInfo();
    Locale currentLocale = Locale.getDefault();

    labels = new ResourceBundlesWrapper(I18N_BASENAMES, currentLocale);

    retrieveFromDb = new RetrieveFromDb();
    apePanel = new APEPanel(labels, getContentPane(), this, retrieveFromDb);

    Utilities.setXsdList(fillXsdList());

    CheckList checkList = new CheckList();
    langList = checkList.getLangList();/*w  w  w  .ja v a  2s.c  o m*/
    levelList = checkList.getLevelList();

    dateNormalization = new DateNormalization();

    super.setTitle(labels.getString("title"));
    Image topLeftIcon = Utilities.icon.getImage();
    setIconImage(topLeftIcon);

    doChecks();

    if (isFileMissing(Utilities.LOG_DIR)) {
        new File(Utilities.LOG_DIR).mkdir();
    }

    File tempDir = new File(Utilities.TEMP_DIR);
    //In case it didn't deleteOnExit at the previous closing of the program, we clean up.
    if (tempDir.exists()) {
        LOG.warn("Probably a problem when deleting the temp files at closure, so we clean up");
        eraseOldTempFiles(tempDir);
        try {
            FileUtils.deleteDirectory(tempDir);
        } catch (IOException e) {
            LOG.error("Could not delete the temp directory. Attempt to delete the directory once more: "
                    + (tempDir.delete() ? "Successful." : "Unsuccessful."));
        }
    }
    tempDir.mkdir();
    tempDir.deleteOnExit();
    //        ListControlaccessTerms listControlaccessTerms = new ListControlaccessTerms("/Users/yoannmoranville/Documents/Work/APE/data/AD78/");
    //        listControlaccessTerms.countTerms();
    //        listControlaccessTerms.displayLogsResults();
    //        CountCLevels countCLevels = new CountCLevels("/Users/yoannmoranville/Work/APEnet/Projects/data/Ready_APEnet/READY/Finland/HeNAF/FA_EAD/");
    //        CountCLevels countCLevels = new CountCLevels("/Users/yoannmoranville/Work/APEnet/Projects/data/BORA/ALL/");
    //        countCLevels.setCopyInAppropriateDirs(true);
    //        countCLevels.changeMainagencycodeForSweden(false);
    //        countCLevels.countLevels();

    //        SeparateFinnishFiles separateFinnishFiles = new SeparateFinnishFiles(new File("/Users/yoannmoranville/Desktop/files_fi"), TEMP_DIR);
    makeDefaultXsdMenuItems();
    makeDefaultXslMenuItems();

    getContentPane().add(apePanel);

    xmlEadListModel = new ProfileListModel(fileInstances, this);
    xmlEadList = new JList(xmlEadListModel);
    xmlEadList.setCellRenderer(new IconListCellRenderer(fileInstances));
    xmlEadList.setDragEnabled(true);

    xmlEadList.setTransferHandler(new ListTransferHandler());

    xmlEadList.setDropTarget(new DropTarget(xmlEadList, new ListDropTargetListener(xmlEadList, from)));
    xmlEadListModel.setList(xmlEadList);

    JMenuBar menuBar = new JMenuBar();
    menuBar.add(fileMenu);
    menuBar.add(optionMenu);
    menuBar.add(actionMenu);
    menuBar.add(windowMenu);
    menuBar.add(helpMenu);
    fileItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    fileMenu.add(fileItem);

    closeSelectedItem.setEnabled(false);
    //        closeSelectedItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    closeSelectedItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_D, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    fileMenu.add(closeSelectedItem);
    saveSelectedItem.setEnabled(false);
    saveSelectedItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    fileMenu.add(saveSelectedItem);
    saveMessageReportItem.setEnabled(false);
    saveMessageReportItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_R, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    fileMenu.add(saveMessageReportItem);
    //        sendFilesWebDAV.setEnabled(false);
    //        fileMenu.add(sendFilesWebDAV);
    fileMenu.addSeparator();
    fileMenu.add(quitItem);

    optionMenu.add(countryCodeItem);
    optionMenu.add(repositoryCodeItem);
    optionMenu.add(digitalObjectTypeItem);
    optionMenu.add(edmGeneralOptionsItem);
    optionMenu.add(listDateConversionRulesItem);
    optionMenu.addSeparator();
    optionMenu.add(xsltItem);
    optionMenu.add(xsdItem);
    optionMenu.add(defaultXslSelectionSubmenu);
    optionMenu.add(defaultXsdSelectionSubmenu);
    optionMenu.addSeparator();
    optionMenu.add(checksLoadingFilesItem);
    optionMenu.add(defaultSaveFolderItem);
    optionMenu.add(languageMenu);
    if (Utilities.isDev) {
        optionMenu.addSeparator();
        optionMenu.add(databaseItem);
    }

    validateItem.setEnabled(false);
    validateItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    actionMenu.add(validateItem);
    convertItem.setEnabled(false);
    convertItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_M, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    actionMenu.add(convertItem);

    actionMenu.addSeparator();

    // TODO: Uncomment when edit will be available.
    //        eacCpfItem.add(this.editEacCpfFile);     //add the different EAC-CPF options menu
    eacCpfItem.add(createEacCpf);
    actionMenu.add(eacCpfItem);

    createEag2012Item.add(createEag2012FromExistingEag2012);
    createEag2012Item.add(createEag2012FromScratch);
    actionMenu.add(createEag2012Item);

    summaryWindowItem.setEnabled(true);
    summaryWindowItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_1, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    windowMenu.add(summaryWindowItem);
    validationWindowItem.setEnabled(true);
    validationWindowItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_2, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    windowMenu.add(validationWindowItem);
    conversionWindowItem.setEnabled(true);
    conversionWindowItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_3, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    windowMenu.add(conversionWindowItem);
    edmConversionWindowItem.setEnabled(true);
    edmConversionWindowItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_4, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    windowMenu.add(edmConversionWindowItem);
    editionWindowItem.setEnabled(true);
    editionWindowItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_5, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    windowMenu.add(editionWindowItem);
    helpMenu.add(internetApexItem);
    helpMenu.addSeparator();
    JMenuItem versionItem = new JMenuItem("APE DPT v" + VERSION_NB);
    versionItem.setEnabled(false);
    helpMenu.add(versionItem);
    createLanguageMenu();
    fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    fileChooser.setMultiSelectionEnabled(true);

    getContentPane().add(menuBar, BorderLayout.NORTH);

    apePanel.setFilename("");

    createHgListener = new CreateHGListener(retrieveFromDb, labels, getContentPane(), fileInstances, xmlEadList,
            this);
    createHGBtn.addActionListener(createHgListener);
    createHGBtn.setEnabled(false);

    analyzeControlaccessListener = new AnalyzeControlaccessListener(labels, getContentPane(), fileInstances);
    analyzeControlaccessBtn.addActionListener(analyzeControlaccessListener);
    analyzeControlaccessBtn.setEnabled(false);

    validateItem.addActionListener(new ConvertAndValidateActionListener(this, apePanel.getApeTabbedPane(),
            ConvertAndValidateActionListener.VALIDATE));
    convertItem.addActionListener(new ConvertAndValidateActionListener(this, apePanel.getApeTabbedPane(),
            ConvertAndValidateActionListener.CONVERT));

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    getContentPane().add(createWest(), BorderLayout.WEST);

    //        convertAndValidateBtn.addActionListener(new ConvertAndValidateActionListener(this, getContentPane()));
    //        validateSelectionBtn.addActionListener(new ValidateSelectionActionListener(this, getContentPane()));
    //        convertEdmSelectionBtn.addActionListener(new ConvertEdmActionListener(labels, this, apePanel));

    nameComponents();
    wireUp();
    setSize(Toolkit.getDefaultToolkit().getScreenSize());
    setMinimumSize(Toolkit.getDefaultToolkit().getScreenSize());
    setExtendedState(JFrame.MAXIMIZED_BOTH);
}

From source file:de.tor.tribes.ui.windows.TribeTribeAttackFrame.java

/**
 * Creates new form TribeTribeAttackFrame
 *//*w  w  w.j  av a 2s. c  o m*/
public TribeTribeAttackFrame() {
    initComponents();
    centerPanel = new GenericTestPanel();
    jMainPanel.add(centerPanel, BorderLayout.CENTER);
    centerPanel.setChildComponent(jxAttackPlanerPanel);
    buildMenu();
    capabilityInfoPanel1.addActionListener(this, jSourcesTable);
    capabilityInfoPanel2.addActionListener(this, jResultsTable);

    KeyStroke copy = KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK, false);
    KeyStroke bbCopy = KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK, false);
    KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK, false);
    KeyStroke cut = KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK, false);
    KeyStroke delete = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0, false);
    jSourcesTable.registerKeyboardAction(TribeTribeAttackFrame.this, "Copy", copy,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jVictimTable.registerKeyboardAction(TribeTribeAttackFrame.this, "Copy", copy,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jResultsTable.registerKeyboardAction(TribeTribeAttackFrame.this, "Copy", copy,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jSourcesTable.registerKeyboardAction(TribeTribeAttackFrame.this, "Paste", paste,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jVictimTable.registerKeyboardAction(TribeTribeAttackFrame.this, "Paste", paste,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jSourcesTable.registerKeyboardAction(TribeTribeAttackFrame.this, "Cut", cut,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jVictimTable.registerKeyboardAction(TribeTribeAttackFrame.this, "Cut", cut,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jSourcesTable.registerKeyboardAction(TribeTribeAttackFrame.this, "Delete", delete,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jVictimTable.registerKeyboardAction(TribeTribeAttackFrame.this, "Delete", delete,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jResultsTable.registerKeyboardAction(TribeTribeAttackFrame.this, "Delete", delete,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    jResultsTable.registerKeyboardAction(TribeTribeAttackFrame.this, "BBCopy", bbCopy,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    Action noFind = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            //no find
        }
    };
    jSourcesTable.getActionMap().put("find", noFind);
    jVictimTable.getActionMap().put("find", noFind);
    jResultsTable.getActionMap().put("find", noFind);

    jSourcesTable.getSelectionModel().addListSelectionListener(TribeTribeAttackFrame.this);
    jVictimTable.getSelectionModel().addListSelectionListener(TribeTribeAttackFrame.this);
    jResultsTable.getSelectionModel().addListSelectionListener(TribeTribeAttackFrame.this);

    jideTabbedPane1.setTabShape(JideTabbedPane.SHAPE_OFFICE2003);
    jideTabbedPane1.setTabColorProvider(JideTabbedPane.ONENOTE_COLOR_PROVIDER);
    jideTabbedPane1.setBoldActiveTab(true);
    TagManager.getSingleton().addManagerListener(TribeTribeAttackFrame.this);
    logPanel = new AlgorithmLogPanel();
    mLogFrame = new JFrame("Informationen zur Berechnung");
    mLogFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    mLogFrame.setLayout(new BorderLayout());
    mLogFrame.add(logPanel);
    mLogFrame.pack();
    mTroopSplitDialog = new TroopSplitDialog(TribeTribeAttackFrame.this, true);
    mSettingsPanel = new SettingsPanel(this);
    jSettingsContentPanel.add(mSettingsPanel, BorderLayout.CENTER);
    jAttackResultDetailsFrame.pack();
    jTargetResultDetailsFrame.pack();
    dragSource = DragSource.getDefaultDragSource();
    dragSource.createDefaultDragGestureRecognizer(TribeTribeAttackFrame.this, DnDConstants.ACTION_COPY_OR_MOVE,
            TribeTribeAttackFrame.this);
    new DropTarget(jSourcesTable, TribeTribeAttackFrame.this);
    new DropTarget(jVictimTable, TribeTribeAttackFrame.this);
    for (MouseListener l : jAllTargetsComboBox.getMouseListeners()) {
        jAllTargetsComboBox.removeMouseListener(l);
    }
    jAllTargetsComboBox.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            fireAddFilteredTargetVillages();
        }
    });

    filterDialog = new TroopFilterDialog(this, true);

    // <editor-fold defaultstate="collapsed" desc="Add selection listeners">
    jVillageGroupList.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                fireFilterSourceVillagesByGroupEvent();
            }
        }
    });
    jSourceContinentList.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                fireFilterSourceContinentEvent();
            }
        }
    });
    jTargetTribeList.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                fireFilterTargetByTribeEvent();
            }
        }
    });
    jTargetContinentList.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                fireFilterTargetByContinentEvent();
            }
        }
    });

    jTargetAllyList.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                fireFilterTargetByAllyEvent();
            }
        }
    });
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc=" Init HelpSystem ">
    if (!Constants.DEBUG) {
        GlobalOptions.getHelpBroker().enableHelp(jSourcePanel, "pages.attack_planer_source",
                GlobalOptions.getHelpBroker().getHelpSet());
        GlobalOptions.getHelpBroker().enableHelp(jTargetPanel, "pages.attack_planer_target",
                GlobalOptions.getHelpBroker().getHelpSet());
        GlobalOptions.getHelpBroker().enableHelp(mSettingsPanel, "pages.attack_planer_settings",
                GlobalOptions.getHelpBroker().getHelpSet());
        GlobalOptions.getHelpBroker().enableHelpKey(jResultFrame.getRootPane(), "pages.attack_planer_results",
                GlobalOptions.getHelpBroker().getHelpSet());
        GlobalOptions.getHelpBroker().enableHelpKey(jTargetResultDetailsFrame.getRootPane(),
                "pages.attack_planer_results_details_targets", GlobalOptions.getHelpBroker().getHelpSet());
        GlobalOptions.getHelpBroker().enableHelpKey(jAttackResultDetailsFrame.getRootPane(),
                "pages.attack_planer_results_details_sources", GlobalOptions.getHelpBroker().getHelpSet());
        GlobalOptions.getHelpBroker().enableHelpKey(getRootPane(), "pages.attack_planer",
                GlobalOptions.getHelpBroker().getHelpSet());
    }
    // </editor-fold>
}

From source file:it.ventuland.ytd.ui.GUIClient.java

private void addComponentsToPane(final Container pane) {
    this.panel = new JPanel();
    this.panel.setLayout(new GridBagLayout());

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(5, 5, 5, 5);
    gbc.anchor = GridBagConstraints.WEST;

    ActionManager lActionManager = new ActionManager();

    dlm = new DefaultListModel<String>();
    this.urllist = new JList<String>(dlm);
    // TODO maybe we add a button to remove added URLs from list?
    //this.userlist.setSelectionMode( ListSelectionModel.MULTIPLE_INTERVAL_SELECTION );
    this.urllist.setFocusable(false);
    textarea = new JTextArea(2, 2);
    textarea.setEditable(true);//from  w  ww  . jav  a  2s . c o  m
    textarea.setFocusable(false);

    JScrollPane leftscrollpane = new JScrollPane(this.urllist);
    JScrollPane rightscrollpane = new JScrollPane(textarea);
    this.middlepane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftscrollpane, rightscrollpane);
    this.middlepane.setOneTouchExpandable(true);
    this.middlepane.setDividerLocation(150);

    Dimension minimumSize = new Dimension(25, 25);
    leftscrollpane.setMinimumSize(minimumSize);
    rightscrollpane.setMinimumSize(minimumSize);

    this.directorybutton = new JButton("", createImageIcon("images/open.png", ""));
    gbc.gridx = 0;
    gbc.gridy = 0;
    this.directorybutton.addActionListener(lActionManager);
    this.panel.add(this.directorybutton, gbc);

    this.saveconfigcheckbox = new JCheckBox("Save config");
    this.saveconfigcheckbox.setSelected(false);

    this.panel.add(this.saveconfigcheckbox);

    this.saveconfigcheckbox.setEnabled(false);

    // TODO check if initial download directory exists
    // assume that at least the users homedir exists
    String shomedir = System.getProperty("user.home").concat(File.separator);

    gbc.gridx = 0;
    gbc.gridy = 2;
    gbc.gridwidth = 2;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.directorytextfield = new JTextField(shomedir, 20 + (mIsDebug ? 48 : 0));
    this.directorytextfield.setEnabled(false);
    this.directorytextfield.setFocusable(true);
    this.directorytextfield.addActionListener(lActionManager);
    this.panel.add(this.directorytextfield, gbc);

    JLabel dirhint = new JLabel("Download to folder:");

    gbc.gridx = 0;
    gbc.gridy = 1;
    this.panel.add(dirhint, gbc);

    this.middlepane.setPreferredSize(new Dimension(Toolkit.getDefaultToolkit().getScreenSize().width / 3,
            Toolkit.getDefaultToolkit().getScreenSize().height / 4 + (mIsDebug ? 200 : 0)));

    gbc.gridx = 0;
    gbc.gridy = 3;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weighty = 2;
    gbc.weightx = 2;
    gbc.gridwidth = 2;
    this.panel.add(this.middlepane, gbc);

    // radio buttons for resolution to download
    mVideoResolutionBtnGrp = new ButtonGroup();
    JPanel lRadioPanel = new JPanel(new GridLayout(1, 0));
    List<Object> lVidQ = mAppContext.getList("youtube-downloader.video-quality");
    JRadioButton lRadioButton = null;
    for (Object obj : lVidQ) {
        String lQuality = (String) obj;
        String lToolTip = mAppContext.getString("youtube-downloader.video-quality." + lQuality + ".tooltip");
        boolean lSelected = mAppContext
                .getBoolean("youtube-downloader.video-quality." + lQuality + ".selected");
        boolean lEnabled = mAppContext.getBoolean("youtube-downloader.video-quality." + lQuality + ".enabled");
        lRadioButton = new JRadioButton(lQuality);
        lRadioButton.setName(lQuality);
        lRadioButton.setActionCommand(lQuality.toLowerCase());
        lRadioButton.addActionListener(lActionManager);
        lRadioButton.setToolTipText(lToolTip);
        lRadioButton.setSelected(lSelected);
        lRadioButton.setEnabled(lEnabled);
        mVideoResolutionBtnGrp.add(lRadioButton);
        lRadioPanel.add(lRadioButton);
    }

    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.gridheight = 0;
    gbc.gridwidth = 0;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.NORTHEAST;
    this.panel.add(lRadioPanel, gbc);

    // radio buttons for video format to download
    mVideoQualityBtnGrp = new ButtonGroup();
    lRadioPanel = new JPanel(new GridLayout(1, 0));
    save3dcheckbox = new JCheckBox("3D");
    save3dcheckbox.setToolTipText("stereoscopic video");
    save3dcheckbox.setSelected(false);
    save3dcheckbox.setEnabled(true);
    lRadioPanel.add(save3dcheckbox);
    List<Object> lVidR = mAppContext.getList("youtube-downloader.video-resolution");
    lRadioButton = null;
    for (Object obj : lVidR) {
        String lResolution = (String) obj;
        String lToolTip = mAppContext
                .getString("youtube-downloader.video-resolution." + lResolution + ".tooltip");
        boolean lSelected = mAppContext
                .getBoolean("youtube-downloader.video-resolution." + lResolution + ".selected");
        boolean lEnabled = mAppContext
                .getBoolean("youtube-downloader.video-resolution." + lResolution + ".enabled");
        lRadioButton = new JRadioButton(lResolution);
        lRadioButton.setName(lResolution);
        lRadioButton.setActionCommand(lResolution.toLowerCase());
        lRadioButton.addActionListener(lActionManager);
        lRadioButton.setToolTipText(lToolTip);
        lRadioButton.setSelected(lSelected);
        lRadioButton.setEnabled(lEnabled);
        mVideoQualityBtnGrp.add(lRadioButton);
        lRadioPanel.add(lRadioButton);
    }

    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.gridheight = 0;
    gbc.gridwidth = 0;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.NORTHEAST;
    this.panel.add(lRadioPanel, gbc);

    JLabel hint = new JLabel("Type, paste or drag'n drop a YouTube video address:");

    gbc.fill = 0;
    gbc.gridwidth = 0;
    gbc.gridheight = 1;
    gbc.weightx = 0;
    gbc.weighty = 0;
    gbc.gridx = 0;
    gbc.gridy = 4;
    gbc.anchor = GridBagConstraints.WEST;
    this.panel.add(hint, gbc);

    textinputfield = new JTextField(20);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.gridx = 0;
    gbc.gridy = 5;
    gbc.gridwidth = 2;
    textinputfield.setEnabled(true);
    textinputfield.setFocusable(true);
    textinputfield.addActionListener(lActionManager);
    textinputfield.getDocument().addDocumentListener(new UrlInsertListener());
    this.panel.add(textinputfield, gbc);

    this.quitbutton = new JButton("", createImageIcon("images/exit.png", ""));
    gbc.gridx = 2;
    gbc.gridy = 5;
    gbc.gridwidth = 0;
    this.quitbutton.addActionListener(lActionManager);
    this.quitbutton.setActionCommand("quit");
    this.quitbutton.setToolTipText("Exit.");

    this.panel.add(this.quitbutton, gbc);

    pane.add(this.panel);
    addWindowListener(new GUIWindowAdapter());

    this.setDropTarget(new DropTarget(this, new DragDropListener()));
    textarea.setTransferHandler(null); // otherwise the dropped text would be inserted

}

From source file:org.jas.gui.MainWindow.java

@PostConstruct
private void setDragAndDrop() {
    MultiLayerDropTargetListener multiLayerDropTargetListener = new MultiLayerDropTargetListener();
    setDropTarget(new DropTarget(this, multiLayerDropTargetListener));
    multiLayerDropTargetListener.addDragListener(this, new MainFrameDragOverListener(this));
    ImageDropListener listener = new ImageDropListener(new ImagePanel());
    listener.onDropped().add(new Observer<ObservValue<ImagePanel>>() {

        public void observe(ObservValue<ImagePanel> t) {
            ImagePanel value = t.getValue();
            Image image = value.getImage();
            List<Metadata> metadatas = controlEngineConfigurator.getControlEngine().get(Model.METADATA);
            Metadata metadata = metadatas.get(selectedRow);
            CoverArt coverArt = new CoverArt(
                    imageUtils.resize(image, ApplicationState.THREE_HUNDRED, ApplicationState.THREE_HUNDRED),
                    CoverArtType.DRAG_AND_DROP);
            metadata.setNewCoverArt(coverArt);
            log.info("sertting image to the row: " + selectedRow);
            updateImage(selectedRow);//  www  . j  av a 2  s .  co  m
            metadataWithAlbum.add(metadata);
            getDescriptionTable().getModel().setValueAt(ActionResult.New, selectedRow,
                    ApplicationState.STATUS_COLUMN);
            getApplyButton().setEnabled(!working);
            log.info("setting applyButton to : " + !working);
        }
    });
    multiLayerDropTargetListener.addDropListener(imagePanel, listener);
}

From source file:net.sf.nmedit.nomad.core.Nomad.java

void setupUI() {
    this.clipBoard = new Clipboard("nomad clipboard");
    ApplicationClipboard.setApplicationClipboard(clipBoard);

    mainWindow.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    mainWindow.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            Nomad.sharedInstance().handleExit();
        }/*from ww w  . j av a2s.  co  m*/
    });
    pageContainer = new DefaultDocumentManager();

    Container contentPane = mainWindow.getContentPane();

    explorerTree = new FileExplorerTree();
    explorerTree.setFont(new Font("Arial", Font.PLAIN, 11));

    explorerTree.createPopup(menuBuilder);

    JScrollPane explorerTreeScroller = new JScrollPane(explorerTree);
    toolPane = new JTabbedPane2();
    toolPane.setCloseActionEnabled(false);

    toolPane.addTab("Explorer", getImage("/icons/eview16/filenav_nav.gif"), explorerTreeScroller);

    new DropTarget(contentPane, new URIListDropHandler() {
        public void uriListDropped(URI[] uriList) {
            for (URI uri : uriList) {
                try {
                    File f = new File(uri);
                    openOrSelect(f);
                } catch (IllegalArgumentException e) {
                    // ignore
                }
            }
        }
    });

    synthPane = new JTabbedPane2();
    synthPane.setCloseActionEnabled(true);

    JSplitPane sidebarSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, false);
    sidebarSplit.setTopComponent(toolPane);
    sidebarSplit.setBottomComponent(synthPane);
    sidebarSplit.setResizeWeight(0.8);
    sidebarSplit.setOneTouchExpandable(true);
    /*
    JComponent sidebar = new JPanel(new BorderLayout());
    sidebar.setBorder(null);
    sidebar.add(sidebarSplit, BorderLayout.CENTER);
    */
    if (!Platform.isFlavor(OS.MacOSFlavor)) {
        /*
        JToolBar tb = createQuickActionToolbar();
        sidebar.add(tb, BorderLayout.NORTH);*/

    } else {
        registerForMacOSXEvents();
    }
    JSplitPane splitLR = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    splitLR.setResizeWeight(0);
    splitLR.setDividerLocation(200);
    splitLR.setRightComponent(pageContainer);
    splitLR.setLeftComponent(sidebarSplit);

    contentPane.setLayout(new BorderLayout());
    contentPane.add(splitLR, BorderLayout.CENTER);
    if (contentPane instanceof JComponent)
        ((JComponent) contentPane).revalidate();
}

From source file:com.pironet.tda.TDA.java

protected void createTree() {
    //Create a tree that allows multiple selection at a time.
    if (topNodes.size() == 1) {
        treeModel = new DefaultTreeModel((DefaultMutableTreeNode) topNodes.get(0));
        tree = new JTree(treeModel);
        tree.setRootVisible(!runningAsJConsolePlugin && !runningAsVisualVMPlugin);
        addTreeListener(tree);//from  w  w  w.  j a  v a 2 s  .  co m
        if (!runningAsJConsolePlugin && !runningAsVisualVMPlugin) {
            frame.setTitle("TDA - Thread Dumps of " + dumpFile);
        }
    } else {
        DefaultMutableTreeNode root = new DefaultMutableTreeNode("Thread Dump Nodes");
        treeModel = new DefaultTreeModel(root);
        for (Object topNode : topNodes) {
            root.add((DefaultMutableTreeNode) topNode);
        }
        tree = new JTree(root);
        tree.setRootVisible(false);
        addTreeListener(tree);
        if (!runningAsJConsolePlugin && !runningAsVisualVMPlugin) {
            if (!frame.getTitle().endsWith("...")) {
                frame.setTitle(frame.getTitle() + " ...");
            }
        }
    }

    tree.setShowsRootHandles(true);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);

    tree.setCellRenderer(new TreeRenderer());

    //Create the scroll pane and add the tree to it.
    ViewScrollPane treeView = new ViewScrollPane(tree, runningAsVisualVMPlugin);

    topSplitPane.setLeftComponent(treeView);

    Dimension minimumSize = new Dimension(200, 50);
    treeView.setMinimumSize(minimumSize);

    //Listen for when the selection changes.
    tree.addTreeSelectionListener(this);

    if (!runningAsJConsolePlugin && !runningAsVisualVMPlugin) {
        dt = new DropTarget(tree, new FileDropTargetListener());
    }

    createPopupMenu();

}

From source file:org.apache.jmeter.gui.MainFrame.java

/**
 * Support for Test Plan Dnd/*from   w w w  . j  av a  2  s .  c  o  m*/
 * see BUG 52281 (when JDK6 will be minimum JDK target)
 */
public void initTopLevelDndHandler() {
    new DropTarget(this, this);
}

From source file:org.broad.igv.hic.MainWindow.java

private MainWindow() throws IOException {

    hic = new HiC(this);

    initComponents();/*from   w w w  . ja  v a 2s  .  c om*/
    createCursors();
    pack();

    DropTarget target = new DropTarget(this, new FileDropTargetListener());
    setDropTarget(target);

    colorRangeSlider.setUpperValue(1200);
}