Example usage for java.awt Cursor Cursor

List of usage examples for java.awt Cursor Cursor

Introduction

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

Prototype

protected Cursor(String name) 

Source Link

Document

Creates a new custom cursor object with the specified name.

Note: this constructor should only be used by AWT implementations as part of their support for custom cursors.

Usage

From source file:AST.DesignPatternDetection.java

private void btRunActionPerformed(ActionEvent e)
        throws FileNotFoundException, IOException, InterruptedException {

    if (tfProjectName.getText().equals("") || tfProjectName.getText().equals(null)) {
        JOptionPane.showMessageDialog(null, "You have to enter the Project's name!");
        return;/*from  ww w  .jav  a2  s .co m*/
    }

    overlap = "";
    programPath = "";

    Cursor hourglassCursor = new Cursor(Cursor.WAIT_CURSOR);
    setCursor(hourglassCursor);

    //Baslangic parametreleri, mutlaka gir...
    Boolean sourceCodeGraph = true;
    Boolean sourceCodeGraphDetail = true;
    Boolean designPatternGraph = true;
    Boolean OnlyTerminalCommands = true;
    String designpatternName = cbSelectionDP.getSelectedItem().toString();
    String projectName = tfProjectName.getText();
    Double threshold = Double.parseDouble((tfThreshold.getText()));

    if (chbOverlap.isSelected() == true) {
        overlap = " -overlap ";
    } else {
        overlap = "";
    }

    if (chbInnerClass.isSelected() == true) {
        includeInnerClasses = "Yes";
    } else {
        includeInnerClasses = "No";
    }

    programPath = tfProgramPath.getText();

    //create "project" directory
    String directoryNameProject = programPath + "/Projects/" + projectName + "/";
    File directoryProject = new File(String.valueOf(directoryNameProject));
    if (!directoryProject.exists()) {
        directoryProject.mkdir();
    }

    //create "source" directory
    String directoryName = programPath + "/Projects/" + projectName + "/source/";
    File directory = new File(String.valueOf(directoryName));
    if (!directory.exists()) {
        directory.mkdir();
    } else {
        FileUtils.deleteDirectory(new File(directoryName));
        directory.mkdir();
    }

    //create "inputs" directory
    String directoryName2 = programPath + "/Projects/" + projectName + "/inputs/";
    File directory2 = new File(String.valueOf(directoryName2));
    if (!directory2.exists()) {
        directory2.mkdir();
    }

    //create "outputs" directory
    String directoryName3 = programPath + "/Projects/" + projectName + "/outputs/";
    File directory3 = new File(String.valueOf(directoryName3));
    if (!directory3.exists()) {
        directory3.mkdir();
    }

    //create "batch" directory
    String directoryName4 = programPath + "/Projects/" + projectName + "/batch/";
    File directory4 = new File(String.valueOf(directoryName4));
    if (!directory4.exists()) {
        directory4.mkdir();
    } else {
        FileUtils.deleteDirectory(new File(directoryName4));
        directory4.mkdir();
    }

    //create "designpatternName+inputs" directory
    String directoryName5 = programPath + "/Projects/" + projectName + "/inputs/" + designpatternName
            + "_inputs/";
    File directory5 = new File(String.valueOf(directoryName5));
    if (!directory5.exists()) {
        directory5.mkdir();
    } else {
        FileUtils.deleteDirectory(new File(directoryName5));
        directory5.mkdir();
    }

    //create "designpatternName+outputs" directory
    String directoryName6 = programPath + "/Projects/" + projectName + "/outputs/" + designpatternName
            + "_outputs/";
    File directory6 = new File(String.valueOf(directoryName6));
    if (!directory6.exists()) {
        directory6.mkdir();
    } else {
        FileUtils.deleteDirectory(new File(directoryName6));
        directory6.mkdir();
    }

    File dir = new File(tfPath.getText());
    FileWalker fw = new FileWalker();
    List<String> directoryListing = new ArrayList<String>();
    directoryListing.clear();

    directoryListing = fw.displayDirectoryContents(dir);

    // File[] directoryListing = dir.listFiles();           

    //1. visit 
    if (directoryListing != null) {
        for (String child : directoryListing) {

            if (child.toString().contains(".java") && !child.toString().contains("package-info")) {
                System.out.println(child);

                ANTLRInputStream input = new ANTLRInputStream(new FileInputStream(child));

                // we'll parse this file
                JavaLexer lexer = new JavaLexer(input);
                CommonTokenStream tokens = new CommonTokenStream(lexer);
                JavaParser parser = new JavaParser(tokens);
                ParseTree tree = parser.compilationUnit(); // see the grammar 

                MyVisitorBase visitorbase = new MyVisitorBase(); // extends JavaBaseVisitor<Void>
                // and overrides the methods
                // you're interested
                visitorbase.visit(tree);

            }

        }
    } else {
        JOptionPane.showMessageDialog(null, "Could not find the path...");
        return;
    }

    //2. visit 
    if (directoryListing != null) {
        for (String child : directoryListing) {

            if (child.toString().contains(".java") && !child.toString().contains("package-info")) {
                //System.out.println(child);

                ANTLRInputStream input = new ANTLRInputStream(new FileInputStream(child));

                // we'll parse this file
                JavaLexer lexer = new JavaLexer(input);
                CommonTokenStream tokens = new CommonTokenStream(lexer);
                JavaParser parser = new JavaParser(tokens);
                ParseTree tree = parser.compilationUnit(); // see the grammar 

                MyVisitor visitor = new MyVisitor(); // extends JavaBaseVisitor<Void>
                                                     // and overrides the methods
                                                     // you're interested
                visitor.includeInnerClasses = includeInnerClasses;
                visitor.modifiersSet();
                visitor.visit(tree);

            }

        }
    }

    //3.visit
    if (directoryListing != null) {
        for (String child : directoryListing) {

            if (child.toString().contains(".java") && !child.toString().contains("package-info")) {
                //System.out.println(child);

                ANTLRInputStream input = new ANTLRInputStream(new FileInputStream(child));

                // we'll parse this file
                JavaLexer lexer = new JavaLexer(input);
                CommonTokenStream tokens = new CommonTokenStream(lexer);
                JavaParser parser = new JavaParser(tokens);
                ParseTree tree = parser.compilationUnit(); // see the grammar 

                MyVisitor2 visitor2 = new MyVisitor2();
                visitor2.modifiersSet();
                visitor2.visit(tree);

            }

        }
    }

    try {
        Proba p = new Proba();
        p.start(sourceCodeGraph, sourceCodeGraphDetail, designPatternGraph, designpatternName,
                OnlyTerminalCommands, projectName, threshold, overlap, programPath);

    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    taInfo.setText("----------" + designpatternName + " PATTERN (" + projectName + ")-------------" + "\n");
    taInfo.append("1. Project's classes ASTs created." + "\n");
    taInfo.append(
            "2. After treewalk of ASTs, Graph Model is created.(/Projects/" + projectName + "/source)" + "\n");
    taInfo.append("3. Pool of Desing Pattern Templates is created.(/Projects/" + projectName + "/inputs/"
            + designpatternName + "_inputs)" + "\n");
    taInfo.append("4. Heuristic function of shell script file is created.(/Projects/" + projectName + "/batch)"
            + "\n");

    //p.start2();

    Cursor normalCursor = new Cursor(Cursor.DEFAULT_CURSOR);
    setCursor(normalCursor);

    vertices.clear();
    dugumler.clear();
    methods.clear();

    JOptionPane.showMessageDialog(null, "Graph Model is successfully completed!");
}

From source file:org.pentaho.reporting.designer.extensions.pentaho.repository.actions.PublishToServerTask.java

public void run() {
    final MasterReport report = reportDesignerContext.getActiveContext().getContextRoot();
    final DocumentMetaData metaData = report.getBundle().getMetaData();

    try {/*from w  w w  .  ja  v  a 2  s.  c  om*/
        final String oldName = extractLastFileName(report);

        SelectFileForPublishTask selectFileForPublishTask = new SelectFileForPublishTask(uiContext);
        readBundleMetaData(report, metaData, selectFileForPublishTask);

        final String selectedReport = selectFileForPublishTask.selectFile(loginData, oldName);
        if (selectedReport == null) {
            return;
        }

        loginData.setOption("lastFilename", selectedReport);
        storeBundleMetaData(report, selectedReport, selectFileForPublishTask);

        reportDesignerContext.getActiveContext().getAuthenticationStore().add(loginData, storeUpdates);

        final byte[] data = PublishUtil.createBundleData(report);
        int responseCode = PublishUtil.publish(data, selectedReport, loginData);

        if (responseCode == 200) {
            final Component glassPane = SwingUtilities.getRootPane(uiContext).getGlassPane();
            try {
                glassPane.setVisible(true);
                glassPane.setCursor(new Cursor(Cursor.WAIT_CURSOR));

                FileObject fileSystemRoot = PublishUtil.createVFSConnection(loginData);
                final JCRSolutionFileSystem fileSystem = (JCRSolutionFileSystem) fileSystemRoot.getFileSystem();
                fileSystem.getLocalFileModel().refresh();
            } catch (Exception e1) {
                UncaughtExceptionsModel.getInstance().addException(e1);
            } finally {
                glassPane.setVisible(false);
                glassPane.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
            }
            if (JOptionPane.showConfirmDialog(uiContext,
                    Messages.getInstance().getString("PublishToServerAction.Successful.LaunchNow"),
                    Messages.getInstance().getString("PublishToServerAction.Successful.LaunchTitle"),
                    JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                PublishUtil.launchReportOnServer(loginData.getUrl(), selectedReport);
            }
        } else if (responseCode == 403) {
            logger.error("Publish failed. Server responded with status-code " + responseCode);
            JOptionPane.showMessageDialog(uiContext,
                    Messages.getInstance().getString("PublishToServerAction.FailedAccess"),
                    Messages.getInstance().getString("PublishToServerAction.FailedAccessTitle"),
                    JOptionPane.ERROR_MESSAGE);
        } else {
            logger.error("Publish failed. Server responded with status-code " + responseCode);
            showErrorMessage();
        }
    } catch (Exception exception) {
        logger.error("Publish failed. Unexpected error:", exception);
        showErrorMessage();
    }
}

From source file:es.emergya.ui.base.BasicWindow.java

/**
 * Initialize the window with default values.
 *///  www . j a v  a2  s  .  c o  m
private void inicializar() {
    frame = new JFrame(i18n.getString("title")); //$NON-NLS-1$
    getFrame().setBackground(Color.WHITE);
    getFrame().setIconImage(ICON_IMAGE); //$NON-NLS-1$
    getFrame().addWindowListener(new RemoveClientesConectadosListener());

    getFrame().setMinimumSize(new Dimension(900, 600));
    getFrame().addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            resize();
        }

    });

    busyCursor = new Cursor(Cursor.WAIT_CURSOR);
    defaultCursor = new Cursor(Cursor.DEFAULT_CURSOR);
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Image image = getImageIcon("/images/hand.gif");
    if (image != null)
        handCursor = toolkit.createCustomCursor(image, new Point(0, 0), "hand"); //$NON-NLS-1$
}

From source file:com.ssn.event.controller.SSNShareController.java

@Override
public void mouseClicked(MouseEvent e) {
    Object mouseEventObj = e.getSource();
    if (mouseEventObj != null && mouseEventObj instanceof JLabel) {
        JLabel label = (JLabel) mouseEventObj;
        getShareForm().setCursor(new Cursor(Cursor.WAIT_CURSOR));
        // Tracking this sharing event in Google Analytics
        GoogleAnalyticsUtil.track(SSNConstants.SSN_APP_EVENT_SHARING);
        Thread thread = null;/*from   w  w  w .j  a  v a 2s. c om*/
        switch (label.getName()) {
        case "FacebookSharing":
            thread = new Thread() {
                boolean isAlreadyLoggedIn = false;

                @Override
                public void run() {

                    Set<String> sharedFileList = getFiles();
                    AccessGrant facebookAccessGrant = getHomeModel().getHomeForm().getFacebookAccessGrant();
                    if (facebookAccessGrant == null) {
                        try {
                            LoginWithFacebook loginWithFacebook = new LoginWithFacebook(null);
                            loginWithFacebook.setHomeForm(getHomeModel().getHomeForm());
                            loginWithFacebook.login();

                            boolean processFurther = false;
                            while (!processFurther) {
                                facebookAccessGrant = getHomeModel().getHomeForm().getFacebookAccessGrant();
                                if (facebookAccessGrant == null) {
                                    Thread.sleep(10000);
                                } else {
                                    processFurther = true;
                                    isAlreadyLoggedIn = true;
                                }
                            }
                        } catch (InterruptedException ex) {
                            logger.error(ex);
                        }
                    }

                    FacebookConnectionFactory connectionFactory = new FacebookConnectionFactory(
                            SSNConstants.SSN_FACEBOOK_API_KEY, SSNConstants.SSN_FACEBOOK_SECRET_KEY);
                    Connection<Facebook> connection = connectionFactory.createConnection(facebookAccessGrant);
                    Facebook facebook = connection.getApi();
                    MediaOperations mediaOperations = facebook.mediaOperations();

                    if (!isAlreadyLoggedIn) {
                        // SSNMessageDialogBox messageDialogBox = new SSNMessageDialogBox();
                        SSNConfirmationDialogBox confirmeDialog = new SSNConfirmationDialogBox();
                        FacebookProfile userProfile = facebook.userOperations().getUserProfile();
                        String userName = "";
                        if (userProfile != null) {
                            userName = userProfile.getName() != null ? userProfile.getName()
                                    : userProfile.getFirstName();
                        }
                        confirmeDialog.initDialogBoxUI(SSNDialogChoice.NOTIFICATION_DIALOG.getType(),
                                "Confirmation", "",
                                "You are already logged in with " + userName + ", Click OK to continue.");
                        int result = confirmeDialog.getResult();
                        if (result == JOptionPane.YES_OPTION) {
                            SwingUtilities.invokeLater(new Runnable() {
                                public void run() {
                                    SSNMessageDialogBox messageDialogBox = new SSNMessageDialogBox();
                                    messageDialogBox.initDialogBoxUI(
                                            SSNDialogChoice.NOTIFICATION_DIALOG.getType(), "Message", "",
                                            "Successfully uploaded.");
                                    messageDialogBox.setFocusable(true);

                                }
                            });
                        } else if (result == JOptionPane.NO_OPTION) {

                            AccessGrant facebookAccessGrant1 = null;
                            if (facebookAccessGrant1 == null) {
                                try {
                                    LoginWithFacebook loginWithFacebook = new LoginWithFacebook(null);
                                    loginWithFacebook.setHomeForm(getHomeModel().getHomeForm());
                                    loginWithFacebook.login();

                                    boolean processFurther = false;
                                    while (!processFurther) {
                                        facebookAccessGrant1 = getHomeModel().getHomeForm()
                                                .getFacebookAccessGrant();
                                        if (facebookAccessGrant1 == null) {
                                            Thread.sleep(10000);
                                        } else {
                                            processFurther = true;
                                            //isAlreadyLoggedIn = true;
                                        }
                                    }
                                    connectionFactory = new FacebookConnectionFactory(
                                            SSNConstants.SSN_FACEBOOK_API_KEY,
                                            SSNConstants.SSN_FACEBOOK_SECRET_KEY);
                                    connection = connectionFactory.createConnection(facebookAccessGrant);
                                    facebook = connection.getApi();
                                    mediaOperations = facebook.mediaOperations();
                                } catch (InterruptedException ex) {
                                    logger.error(ex);
                                }
                            }
                        }
                    }

                    String[] videoSupported = SSNConstants.SSN_VIDEO_FORMAT_SUPPORTED;
                    final List<String> videoSupportedList = Arrays.asList(videoSupported);

                    for (String file : sharedFileList) {
                        String fileExtension = file.substring(file.lastIndexOf(".") + 1, file.length());
                        Resource resource = new FileSystemResource(file);

                        if (!videoSupportedList.contains(fileExtension.toUpperCase())) {
                            String output = mediaOperations.postPhoto(resource);
                        } else {
                            String output = mediaOperations.postVideo(resource);
                        }

                    }

                    getShareForm().dispose();
                }
            };
            thread.start();
            break;
        case "TwitterSharing":
            LoginWithTwitter.deniedPermission = false;
            thread = new Thread() {
                boolean isAlreadyLoggedIn = false;

                @Override
                public void run() {
                    Set<String> sharedFileList = getFiles();
                    OAuthToken twitterOAuthToken = getHomeModel().getHomeForm().getTwitterOAuthToken();
                    if (twitterOAuthToken == null) {
                        try {
                            LoginWithTwitter loginWithTwitter = new LoginWithTwitter(null);
                            loginWithTwitter.setHomeForm(getHomeModel().getHomeForm());
                            loginWithTwitter.login();

                            boolean processFurther = false;
                            while (!processFurther) {
                                if (LoginWithTwitter.deniedPermission)
                                    break;

                                twitterOAuthToken = getHomeModel().getHomeForm().getTwitterOAuthToken();
                                if (twitterOAuthToken == null) {
                                    Thread.sleep(10000);
                                } else {
                                    processFurther = true;
                                    isAlreadyLoggedIn = true;
                                }
                            }
                        } catch (IOException | InterruptedException ex) {
                            logger.error(ex);
                        }
                    }
                    if (!LoginWithTwitter.deniedPermission) {
                        Twitter twitter = new TwitterTemplate(SSNConstants.SSN_TWITTER_API_KEY,
                                SSNConstants.SSN_TWITTER_SECRET_KEY, twitterOAuthToken.getValue(),
                                twitterOAuthToken.getSecret());
                        TimelineOperations timelineOperations = twitter.timelineOperations();
                        if (!isAlreadyLoggedIn) {
                            SSNConfirmationDialogBox confirmeDialog = new SSNConfirmationDialogBox();
                            TwitterProfile userProfile = twitter.userOperations().getUserProfile();

                            String userName = "";
                            if (userProfile != null) {
                                userName = twitter.userOperations().getScreenName() != null
                                        ? twitter.userOperations().getScreenName()
                                        : userProfile.getName();
                            }
                            confirmeDialog.initDialogBoxUI(SSNDialogChoice.NOTIFICATION_DIALOG.getType(),
                                    "Confirmation", "",
                                    "You are already logged in with " + userName + ", Click OK to continue.");
                            int result = confirmeDialog.getResult();
                            if (result == JOptionPane.YES_OPTION) {
                                SwingUtilities.invokeLater(new Runnable() {
                                    public void run() {
                                        SSNMessageDialogBox messageDialogBox = new SSNMessageDialogBox();
                                        messageDialogBox.initDialogBoxUI(
                                                SSNDialogChoice.NOTIFICATION_DIALOG.getType(), "Message", "",
                                                "Successfully uploaded.");
                                        messageDialogBox.setFocusable(true);

                                    }
                                });
                            } else if (result == JOptionPane.NO_OPTION) {

                                twitterOAuthToken = null;
                                if (twitterOAuthToken == null) {
                                    try {
                                        LoginWithTwitter loginWithTwitter = new LoginWithTwitter(null);
                                        loginWithTwitter.setHomeForm(getHomeModel().getHomeForm());
                                        loginWithTwitter.login();

                                        boolean processFurther = false;
                                        while (!processFurther) {
                                            twitterOAuthToken = getHomeModel().getHomeForm()
                                                    .getTwitterOAuthToken();
                                            if (twitterOAuthToken == null) {
                                                Thread.sleep(10000);
                                            } else {
                                                processFurther = true;

                                            }
                                        }
                                        twitter = new TwitterTemplate(SSNConstants.SSN_TWITTER_API_KEY,
                                                SSNConstants.SSN_TWITTER_SECRET_KEY,
                                                twitterOAuthToken.getValue(), twitterOAuthToken.getSecret());
                                        timelineOperations = twitter.timelineOperations();
                                    } catch (IOException | InterruptedException ex) {
                                        logger.error(ex);
                                    }
                                }
                            }
                        }

                        for (String file : sharedFileList) {
                            Resource image = new FileSystemResource(file);

                            TweetData tweetData = new TweetData("At " + new Date());
                            tweetData.withMedia(image);
                            timelineOperations.updateStatus(tweetData);
                        }
                    } else {
                        SSNMessageDialogBox messageDialogBox = new SSNMessageDialogBox();
                        messageDialogBox.initDialogBoxUI(SSNDialogChoice.NOTIFICATION_DIALOG.getType(), "Alert",
                                "", "User denied for OurHive App permission on twitter.");
                        messageDialogBox.setFocusable(true);
                    }
                    getShareForm().dispose();
                }

            };
            thread.start();
            break;
        case "InstagramSharing":
            break;
        case "MailSharing":
            try {
                String OS = System.getProperty("os.name").toLowerCase();

                Set<String> sharedFileList = getFiles();
                Set<String> voiceNoteList = new HashSet<String>();
                for (String sharedFile : sharedFileList) {
                    String voiceNote = SSNDao.getVoiceCommandPath(new File(sharedFile).getAbsolutePath());
                    if (voiceNote != null && !voiceNote.isEmpty()) {
                        voiceNoteList.add(voiceNote);
                    }
                }
                sharedFileList.addAll(voiceNoteList);

                String fileFullPath = "";
                String caption = "";
                if (sharedFileList.size() == 1) {
                    fileFullPath = sharedFileList.toArray(new String[0])[0];

                    caption = SSMMediaGalleryPanel.readMetaDataForTitle(new File(fileFullPath));

                } else if (sharedFileList.size() > 1) {
                    fileFullPath = SSNHelper.createZipFileFromMultipleFiles(sharedFileList);
                }

                if (OS.contains("win")) {

                    // String subject = "SSN Subject";
                    String subject = caption.equals("") ? SSNConstants.SSN_SHARE_WITH_MAIL_SUBJECT : caption;
                    String body = "";
                    String m = "&subject=%s&body=%s";

                    String outLookExeDir = "C:\\Program Files\\Microsoft Office\\Office14\\Outlook.exe";
                    String mailCompose = "/c";
                    String note = "ipm.note";
                    String mailBodyContent = "/m";

                    m = String.format(m, subject, body);
                    String slashA = "/a";

                    String mailClientConfigParams[] = null;
                    Process startMailProcess = null;

                    mailClientConfigParams = new String[] { outLookExeDir, mailCompose, note, mailBodyContent,
                            m, slashA, fileFullPath };
                    startMailProcess = Runtime.getRuntime().exec(mailClientConfigParams);
                    OutputStream out = startMailProcess.getOutputStream();
                    File zipFile = new File(fileFullPath);
                    zipFile.deleteOnExit();
                } else if (OS.indexOf("mac") >= 0) {
                    //Process p = Runtime.getRuntime().exec(new String[]{String.format("open -a mail ", fileFullPath)});
                    Desktop desktop = Desktop.getDesktop();
                    String mailTo = caption.equals("") ? "?SUBJECT=" + SSNConstants.SSN_SHARE_WITH_MAIL_SUBJECT
                            : caption;
                    URI uriMailTo = null;
                    uriMailTo = new URI("mailto", mailTo, null);
                    desktop.mail(uriMailTo);
                }

                this.getShareForm().dispose();
            } catch (Exception ex) {
                logger.error(ex);
            }
            break;
        case "moveCopy":
            getShareForm().dispose();
            File album = new File(SSNHelper.getSsnHiveDirPath());
            File[] albumPaths = album.listFiles();
            Vector albumNames = new Vector();
            for (int i = 0; i < albumPaths.length; i++) {
                if (!(albumPaths[i].getName().equals("OurHive")) && SSNHelper.lastAlbum != null
                        && !(albumPaths[i].getName().equals(SSNHelper.lastAlbum)))
                    albumNames.add(albumPaths[i].getName());
            }
            if (SSNHelper.lastAlbum != null && !SSNHelper.lastAlbum.equals("OurHive"))
                albumNames.insertElementAt("OurHive", 0);

            SSNInputDialogBox inputBox = new SSNInputDialogBox(true, albumNames);
            inputBox.initDialogBoxUI(SSNDialogChoice.NOTIFICATION_DIALOG.getType(), "Copy Media",
                    "Please Select Album Name");
            String destAlbumName = inputBox.getTextValue();
            if (StringUtils.isNotBlank(destAlbumName)) {
                homeModel.moveAlbum(destAlbumName, getFiles());
            }

        }
        getShareForm().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }
}

From source file:VrmlPickingTest.java

protected void addCanvas3D(Canvas3D c3d) {
    setLayout(new BorderLayout());
    add(c3d, BorderLayout.CENTER);
    doLayout();//  w ww.ja v  a 2 s .c  om

    if (m_SceneBranchGroup != null) {
        c3d.addMouseListener(this);

        pickCanvas = new PickCanvas(c3d, m_SceneBranchGroup);
        pickCanvas.setMode(PickTool.GEOMETRY_INTERSECT_INFO);
        pickCanvas.setTolerance(4.0f);
    }

    c3d.setCursor(new Cursor(Cursor.HAND_CURSOR));
}

From source file:com.supermap.desktop.icloud.CloudLicenseDialog.java

private void login() {
    userName = textFieldUserName.getText();
    passWord = String.valueOf(fieldPassWord.getPassword());
    this.setCursor(new Cursor(Cursor.WAIT_CURSOR));
    CloseableHttpClient client = LicenseServiceFactory.getClient(userName, passWord);
    if (null == client) {
        this.labelWarning.setForeground(Color.red);
        this.labelWarning.setText(CommonProperties.getString("String_PermissionCheckFailed"));
    } else {//from  ww w  .jav  a2 s .  c o m
        this.labelWarning.setText("");
        try {
            //       CloudLicense.login(userName, passWord);
            //       saveToken();
            //       dialogResult = DIALOGRESULT_OK;
            //       dispose();
            licenseService = LicenseServiceFactory.create(client, ProductType.IDESKTOP);
            licenseId = LicenseManager.getFormalLicenseId(licenseService);
            if (null != licenseId) {
                //??id??
                formalLicenseResponse = LicenseManager.applyFormalLicense(licenseService, licenseId);
                dialogResult = DIALOGRESULT_OK;
                saveToken();
            } else {
                //??id,?
                trialLicenseResponse = LicenseManager.applyTrialLicense(licenseService);
                dialogResult = DIALOGRESULT_OK;
                saveToken();
            }
        } catch (AuthenticationException e1) {
            dialogResult = DIALOGRESULT_CANCEL;
        } finally {
            this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
            removeEvents();
            dispose();
        }
    }
}

From source file:us.paulevans.basicxslt.Utils.java

/**
 * Displays a message dialog/*from w  w  w  .  java2 s  .com*/
 * @param aParent
 * @param aMsg
 * @param aTitle
 * @param aType
 */
public static void showDialog(Frame aParent, String aMsg, String aTitle, int aType) {
    aParent.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    JOptionPane.showMessageDialog(aParent, aMsg, aTitle, aType);
}

From source file:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.fft.impl.AveragingFFTCanvas.java

/***********************************************************************************************
 * Initialise this UIComponent./*from w  w w. j  av  a 2  s . c om*/
 */

public void initialiseUI() {
    final Border compoundBorder;

    super.initialiseUI();
    removeAll();

    setBackground(getBackgroundColour().getColor());
    setOpaque(true);

    // Make sure that the Canvas uses all available space...
    setPreferredSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
    setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));

    // Add a Border to the Canvas panel
    compoundBorder = BorderFactory.createCompoundBorder(BorderFactory.createRaisedBevelBorder(),
            BorderFactory.createLoweredBevelBorder());
    setBorder(compoundBorder);

    // There is only ever one Chart, a special version with no Toolbar
    setChartViewer(new LogLinChartUIComponent(getHostFrameUI().getHostTask(), getHostInstrument(), "FFT", null,
            REGISTRY.getFrameworkResourceKey(), DataUpdateType.PRESERVE,
            REGISTRY.getIntegerProperty(
                    getHostInstrument().getHostAtom().getResourceKey() + KEY_DISPLAY_DATA_MAX),
            -1000.0, 1000.0, -1000.0, 1000.0) {
        final static long serialVersionUID = -2433194350569140263L;

        /**********************************************************************************
         * Customise the XYPlot of a new chart, e.g. for fixed range axes.
         *
         * @param datasettype
         * @param primarydataset
         * @param secondarydatasets
         * @param updatetype
         * @param displaylimit
         * @param channelselector
         * @param debug
         *
         * @return JFreeChart
         */

        public JFreeChart createCustomisedChart(final DatasetType datasettype, final XYDataset primarydataset,
                final List<XYDataset> secondarydatasets, final DataUpdateType updatetype,
                final int displaylimit, final ChannelSelectorUIComponentInterface channelselector,
                final boolean debug) {
            final JFreeChart jFreeChart;

            jFreeChart = super.createCustomisedChart(datasettype, primarydataset, secondarydatasets, updatetype,
                    displaylimit, channelselector, debug);
            // Remove all labels
            jFreeChart.setTitle(EMPTY_STRING);

            if ((jFreeChart.getXYPlot() != null) && (jFreeChart.getXYPlot().getDomainAxis() != null)) {
                jFreeChart.getXYPlot().getDomainAxis().setLabel(EMPTY_STRING);
            }

            if ((jFreeChart.getXYPlot() != null) && (jFreeChart.getXYPlot().getRangeAxis() != null)) {
                jFreeChart.getXYPlot().getRangeAxis().setLabel(EMPTY_STRING);
            }

            return (jFreeChart);
        }

        /**********************************************************************************
         * Initialise the Chart.
         */

        public synchronized void initialiseUI() {
            final String SOURCE = "ChartUIComponent.initialiseUI() ";

            setChannelSelector(false);
            setDatasetDomainControl(false);

            super.initialiseUI();

            // Indicate if the Chart can Autorange, and is currently Autoranging
            setCanAutorange(true);
            setLinearMode(true);

            // Configure the Chart for this specific use
            if (getChannelSelectorOccupant() != null) {
                getChannelSelectorOccupant().setAutoranging(true);
                getChannelSelectorOccupant().setLinearMode(true);
                getChannelSelectorOccupant().setDecimating(false);
                getChannelSelectorOccupant().setLegend(false);
                getChannelSelectorOccupant().setShowChannels(false);
                getChannelSelectorOccupant().debugSelector(LOADER_PROPERTIES.isChartDebug(), SOURCE);
            }
        }
    });

    getChartViewer().initialiseUI();

    add((Component) getChartViewer(), BorderLayout.CENTER);
}

From source file:org.apache.taverna.activities.xpath.ui.contextualview.XPathActivityMainContextualView.java

@Override
public JComponent getMainFrame() {
    jpMainPanel = new JPanel(new GridBagLayout());
    jpMainPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 2, 4, 2),
            BorderFactory.createEmptyBorder()));

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.WEST;
    c.weighty = 0;/*from  ww w  .ja  v a  2s. c  o m*/

    // --- XPath Expression ---

    c.gridx = 0;
    c.gridy = 0;
    c.insets = new Insets(5, 5, 5, 5);
    JLabel jlXPathExpression = new JLabel("XPath Expression:");
    jlXPathExpression.setFont(jlXPathExpression.getFont().deriveFont(Font.BOLD));
    jpMainPanel.add(jlXPathExpression, c);

    c.gridx++;
    c.weightx = 1.0;
    tfXPathExpression = new JTextField();
    tfXPathExpression.setEditable(false);
    jpMainPanel.add(tfXPathExpression, c);

    // --- Label to Show/Hide Mapping Table ---

    final JLabel jlShowHideNamespaceMappings = new JLabel("Show namespace mappings...");
    jlShowHideNamespaceMappings.setForeground(Color.BLUE);
    jlShowHideNamespaceMappings.setCursor(new Cursor(Cursor.HAND_CURSOR));
    jlShowHideNamespaceMappings.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            spXPathNamespaceMappings.setVisible(!spXPathNamespaceMappings.isVisible());
            jlShowHideNamespaceMappings.setText(
                    (spXPathNamespaceMappings.isVisible() ? "Hide" : "Show") + " namespace mappings...");
            thisContextualView.revalidate();
        }
    });

    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    jpMainPanel.add(jlShowHideNamespaceMappings, c);

    // --- Namespace Mapping Table ---

    xpathNamespaceMappingsTableModel = new DefaultTableModel() {
        /**
         * No cells should be editable
         */
        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return (false);
        }
    };
    xpathNamespaceMappingsTableModel.addColumn("Namespace Prefix");
    xpathNamespaceMappingsTableModel.addColumn("Namespace URI");

    jtXPathNamespaceMappings = new JTable();
    jtXPathNamespaceMappings.setModel(xpathNamespaceMappingsTableModel);
    jtXPathNamespaceMappings.setPreferredScrollableViewportSize(new Dimension(200, 90));
    // TODO - next line is to be enabled when Taverna is migrated to Java
    // 1.6; for now it's fine to run without this
    // jtXPathNamespaceMappings.setFillsViewportHeight(true); // makes sure
    // that when the dedicated area is larger than the table, the latter is
    // stretched vertically to fill the empty space

    jtXPathNamespaceMappings.getColumnModel().getColumn(0).setPreferredWidth(20); // set
    // relative
    // sizes of
    // columns
    jtXPathNamespaceMappings.getColumnModel().getColumn(1).setPreferredWidth(300);

    c.gridy++;
    spXPathNamespaceMappings = new JScrollPane(jtXPathNamespaceMappings);
    spXPathNamespaceMappings.setVisible(false);
    jpMainPanel.add(spXPathNamespaceMappings, c);

    // populate the view with values
    refreshView();

    return jpMainPanel;
}

From source file:com.ssn.event.controller.SSNUntaggedMediaController.java

@Override
public void mouseClicked(MouseEvent e) {
    Object mouseEventObj = e.getSource();
    if (mouseEventObj != null && mouseEventObj instanceof JLabel) {
        JLabel label = (JLabel) mouseEventObj;
        JLabel toolbarLabel = SSNHomeController.currentLabel;
        this.getHomeModel().getHomeForm().getHomeController().setIconImage(toolbarLabel,
                "/icon/tagged-untagged-media.png", "allUntagged", SSNConstants.SSN_TOOLBAR_WHITE_FONT_COLOR);
        this.getHomeModel().getHomeForm().getHomeController().setIconImage(SSNToolBar.desktopHomeLabel,
                "/icon/white_icon/home.png", "home", SSNConstants.SSN_TEXT_LABEL_YELLOW_COLOR);
        this.getHomeModel().getHomeForm().setCursor(new Cursor(Cursor.WAIT_CURSOR));
        int timoutCount = 0;
        logger.info("mouseClicked() label " + label.getName());
        switch (label.getName()) {
        case "FacebookMedia":
            untaggedMediaForm.dispose();
            String facebookMessage = "User denied for OurHive App permission on facebook.";
            if ((this.getHomeModel().getHomeForm().getFacebookAccessGrant() != null
                    && !this.getHomeModel().getHomeForm().isLoggedInFromFaceBook()
                    && getFaceBookConnection() != null)
                    && this.getHomeModel().getHomeForm().isIsSocialSearched()) {

                try {
                    File searchFolder = new File(SSNHelper.getFacebookPhotosDirPath());
                    File folder = new File(SSNHelper.getSsnDefaultDirPath());
                    File[] files = searchFolder.listFiles();
                    String defaultAlbumPath = "";
                    if (searchFolder.list().length > 0) {
                        defaultAlbumPath = (searchFolder.listFiles())[0].getAbsolutePath();
                        files = new File(defaultAlbumPath).listFiles();
                    }//from   w  w  w.j  a va 2s.c  om

                    List<File> fileList = new ArrayList<File>();
                    for (File f : files) {
                        fileList.add(f);
                    }
                    Iterator<File> iterator = fileList.iterator();
                    while (iterator.hasNext()) {
                        File f = iterator.next();
                        boolean check = false;
                        try {
                            check = SSNDao
                                    .checkMediaExist(folder.getAbsolutePath() + File.separator + f.getName());
                        } catch (SQLException ex) {
                            //ex.printStackTrace();
                            logger.error(ex);
                        }
                        if (check) {
                            // iterator.remove();
                        }
                    }
                    File[] fileArray = new File[fileList.size()];
                    for (int i = 0; i < fileList.size(); i++) {
                        fileArray[i] = fileList.get(i);
                    }

                    //this.getHomeModel().getHomeForm().ssnFileExplorer.m_display.setText("facebookMedia");
                    // this.getHomeModel().getHomeForm().ssnFileExplorer.m_tree.setSelectionRow(0);
                    this.getHomeModel().getHomeForm().ssnFileExplorer.m_display.setText(defaultAlbumPath);

                    //this.getHomeModel().getHomeForm().ssnFileExplorer.m_tree.setSelectionRow(0);
                    this.getHomeModel().getHomeForm().getFileNamesToBeDeleted().clear();
                    //this.getHomeModel().getHomeForm().setCurrentSelectedFile(null);
                    SSNHelper.toggleDeleteAndShareImages(false, this.getHomeModel().getHomeForm());
                    SSNGalleryHelper contentPane = new SSNGalleryHelper(fileArray,
                            this.getHomeModel().getHomeForm());

                    contentPane.setBackground(SSNConstants.SSN_BLACK_BACKGROUND_COLOR);
                    this.getHomeModel().getHomeForm().getSsnHomeCenterPanel().removeAll();
                    this.getHomeModel().getHomeForm().getSsnHomeCenterMainPanel().removeAll();

                    this.getHomeModel().getHomeForm().getSsnHomeCenterPanel().add(this.getHomeModel()
                            .getHomeForm().getScrollPane(contentPane, SSNHelper.getAlbumNameFromPath(
                                    this.getHomeModel().getHomeForm().ssnFileExplorer.m_display.getText())));
                    this.getHomeModel().getHomeForm().getSsnHomeCenterMainPanel().add(this.getHomeModel()
                            .getHomeForm()
                            .getSortPanel("Date", false, SSNHelper.getAlbumNameFromPath(
                                    this.getHomeModel().getHomeForm().ssnFileExplorer.m_display.getText())),
                            BorderLayout.NORTH);
                    this.getHomeModel().getHomeForm().getSsnHomeCenterMainPanel().add(
                            this.getHomeModel().getHomeForm().getSsnHomeCenterPanel(), BorderLayout.CENTER);
                    this.getHomeModel().getSSNMediaFolderProperties(
                            this.getHomeModel().getHomeForm().ssnFileExplorer.m_display.getText(), fileArray);

                    renderLeftPanel();
                    this.getHomeModel().getHomeForm().revalidate();
                } catch (IOException ex) {
                    //java.util.logging.Logger.getLogger(SSNUntaggedMediaController.class.getName()).log(Level.SEVERE, null, ex);
                    logger.error(ex);
                }

            } else {

                logger.info("Facebook login user not logged in mouseClicked switch case else part");
                LoginWithFacebook.deniedPermission = false;
                AccessGrant facebookAccessGrant = getHomeModel().getHomeForm().getFacebookAccessGrant();
                if (facebookAccessGrant == null) {
                    try {

                        LoginWithFacebook loginWithFacebook = new LoginWithFacebook(null);
                        loginWithFacebook.setHomeForm(getHomeModel().getHomeForm());
                        loginWithFacebook.login();
                        boolean processFurther = false;

                        while (!processFurther) {
                            if (LoginWithFacebook.deniedPermission) {
                                break;
                            }
                            facebookAccessGrant = getHomeModel().getHomeForm().getFacebookAccessGrant();
                            if (facebookAccessGrant == null) {

                                if (timoutCount > (5 * 5000)) {
                                    LoginWithFacebook.deniedPermission = true;
                                    facebookMessage = "No response from Facebook.";
                                    SSNHttpServer.getHttpServer().stop(0);
                                    break;
                                } else {
                                    Thread.sleep(5000);
                                    timoutCount += 5000;
                                }
                            } else {
                                processFurther = true;
                            }
                        }
                    } catch (InterruptedException ex) {
                        logger.error(ex);
                        //ex.printStackTrace();
                    } catch (Exception ex) {
                        logger.error(ex);
                        //ex.printStackTrace();
                    }
                }
                if (!LoginWithFacebook.deniedPermission) {
                    //                            FacebookConnectionFactory connectionFactory = new FacebookConnectionFactory(SSNConstants.SSN_FACEBOOK_API_KEY,
                    //                                    SSNConstants.SSN_FACEBOOK_SECRET_KEY);
                    Connection<Facebook> connection = getFaceBookConnection();
                    Facebook facebook = connection.getApi();
                    MediaOperations mediaOperations = facebook.mediaOperations();

                    PagedList<Album> albums = mediaOperations.getAlbums();

                    if (albums.size() > 0) {
                        Collections.sort(albums, new Comparator<Album>() {
                            @Override
                            public int compare(final Album object1, final Album object2) {
                                return object1.getName().compareTo(object2.getName());
                            }
                        });
                    }

                    if (albums != null && !albums.isEmpty()) {
                        try {
                            List<Photo> completePhotoList = new ArrayList<Photo>();
                            String albumName = "";
                            for (Album album : albums) {
                                List<Photo> listPhoto = new ArrayList<Photo>();
                                int captured = 0;
                                do {

                                    PagingParameters pagingParameters = new PagingParameters(100, captured,
                                            null, Calendar.getInstance().getTimeInMillis());
                                    listPhoto = mediaOperations.getPhotos(album.getId(), pagingParameters);
                                    captured += listPhoto.size();
                                    completePhotoList.addAll(listPhoto);
                                    albumName = album.getName();
                                    File facebookPhotosDir = new File(SSNHelper.getFacebookPhotosDirPath()
                                            + album.getName() + File.separator);
                                    if (!facebookPhotosDir.exists()) {
                                        facebookPhotosDir.mkdir();
                                    }

                                } while (listPhoto.size() > 0);
                                break;
                            }
                            File searchFolder = new File(
                                    SSNHelper.getFacebookPhotosDirPath() + File.separator + albumName);
                            if (!searchFolder.exists()) {
                                searchFolder.mkdirs();
                            } else {
                                //delete whole directory and create new one each time  
                                FileUtils.deleteDirectory(searchFolder);
                                searchFolder.mkdir();
                            }

                            for (Photo photo : completePhotoList) {
                                try {
                                    String imageUrl = "";
                                    for (Photo.Image image : photo.getImages()) {
                                        if (image != null && image.getHeight() <= 500) {
                                            imageUrl = image.getSource();
                                            break;
                                        }
                                    }

                                    if (imageUrl.isEmpty()) {
                                        imageUrl = photo.getSource();
                                    }
                                    URL url = new URL(imageUrl);
                                    File file = new File(searchFolder.getAbsolutePath() + File.separator
                                            + photo.getId() + ".jpg");
                                    if (!file.exists()) {
                                        try {
                                            FileUtils.copyURLToFile(url, file);
                                        } catch (Exception ex) {
                                            ex.printStackTrace();
                                            logger.error(ex);
                                        }
                                    }
                                } catch (MalformedURLException ex) {
                                    //    java.util.logging.Logger.getLogger(SSNUntaggedMediaController.class.getName()).log(Level.SEVERE, null, ex);
                                    logger.error(ex);
                                }

                            }

                            this.getHomeModel().getHomeForm().setIsSocialSearched(true);
                            File[] files = searchFolder.listFiles();
                            File folder = new File(SSNHelper.getSsnDefaultDirPath());
                            List<File> tempFileList = Arrays.asList(files);

                            List<File> fileList = new ArrayList<File>();
                            fileList.addAll(tempFileList);

                            Iterator<File> iterator = fileList.iterator();
                            while (iterator.hasNext()) {
                                File f = iterator.next();
                                boolean check = false;
                                try {
                                    check = SSNDao.checkMediaExist(
                                            folder.getAbsolutePath() + File.separator + f.getName());
                                } catch (SQLException ex) {
                                    ex.printStackTrace();
                                }
                                if (check) {
                                    //iterator.remove();
                                }
                            }
                            File[] fileArray = new File[fileList.size()];
                            for (int j = 0; j < fileList.size(); j++) {
                                fileArray[j] = fileList.get(j);
                            }
                            String rootPath = SSNHelper.getSsnHiveDirPath();
                            //this.getHomeModel().getHomeForm().ssnFileExplorer.m_display.setText("facebookMedia");
                            //this.getHomeModel().getHomeForm().ssnFileExplorer.m_tree.setSelectionRow(0);

                            this.getHomeModel().getHomeForm().ssnFileExplorer.m_display
                                    .setText(searchFolder.getAbsolutePath());
                            // this.getHomeModel().getHomeForm().getFileNamesToBeDeleted().clear();
                            // this.getHomeModel().getHomeForm().setCurrentSelectedFile(null);
                            // this.getHomeModel().getHomeForm().ssnFileExplorer.m_tree.setSelectionRow(0);
                            SSNHelper.toggleDeleteAndShareImages(false, this.getHomeModel().getHomeForm());
                            SSNGalleryHelper contentPane = new SSNGalleryHelper(fileArray,
                                    this.getHomeModel().getHomeForm());

                            contentPane.setBackground(SSNConstants.SSN_BLACK_BACKGROUND_COLOR);
                            this.getHomeModel().getHomeForm().getSsnHomeCenterPanel().removeAll();
                            this.getHomeModel().getHomeForm().getSsnHomeCenterMainPanel().removeAll();

                            this.getHomeModel().getHomeForm().getSsnHomeCenterPanel()
                                    .add(this.getHomeModel().getHomeForm().getScrollPane(contentPane,
                                            SSNHelper.getAlbumNameFromPath(
                                                    this.getHomeModel().getHomeForm().ssnFileExplorer.m_display
                                                            .getText())));
                            this.getHomeModel().getHomeForm().getSsnHomeCenterMainPanel()
                                    .add(this.getHomeModel().getHomeForm().getSortPanel("Date", false,
                                            SSNHelper.getAlbumNameFromPath(
                                                    this.getHomeModel().getHomeForm().ssnFileExplorer.m_display
                                                            .getText())),
                                            BorderLayout.NORTH);
                            this.getHomeModel().getHomeForm().getSsnHomeCenterMainPanel().add(
                                    this.getHomeModel().getHomeForm().getSsnHomeCenterPanel(),
                                    BorderLayout.CENTER);
                            this.getHomeModel().getSSNMediaFolderProperties(
                                    this.getHomeModel().getHomeForm().ssnFileExplorer.m_display.getText(),
                                    fileArray);

                            renderLeftPanel();
                            this.getHomeModel().getHomeForm().revalidate();
                            // System.out.println("Show gallery  " + new Date());
                        } catch (IOException ex) {
                            logger.error(ex);
                        }

                    }
                } else {
                    SSNMessageDialogBox messageDialogBox = new SSNMessageDialogBox();
                    messageDialogBox.initDialogBoxUI(SSNDialogChoice.NOTIFICATION_DIALOG.getType(), "Alert", "",
                            facebookMessage);
                    messageDialogBox.setFocusable(true);
                }
            }
            break;
        case "InstagramMedia":
            untaggedMediaForm.dispose();
            String instagarmMessage = "User denied for OurHive App permission on instagram!";
            if ((this.getHomeModel().getHomeForm().getInstagramAccessGrant() != null
                    && !this.getHomeModel().getHomeForm().isLoggedInFromInstagram())
                    || this.getHomeModel().getHomeForm().isInstagramSearched()) {
                try {
                    // System.out.println("inside ");
                    File searchFolder = new File(
                            SSNHelper.getSsnWorkSpaceDirPath() + File.separator + "Instagram Media");
                    File folder = new File(SSNHelper.getSsnHiveDirPath() + File.separator + "InstagramMedia");
                    File[] files = searchFolder.listFiles();
                    List<File> fileList = new ArrayList<File>();
                    for (File f : files) {
                        fileList.add(f);
                    }
                    Iterator<File> iterator = fileList.iterator();
                    while (iterator.hasNext()) {
                        File f = iterator.next();
                        boolean check = false;
                        try {
                            check = SSNDao
                                    .checkMediaExist(folder.getAbsolutePath() + File.separator + f.getName());
                        } catch (SQLException ex) {
                            ex.printStackTrace();
                        }
                        if (check) {
                            // iterator.remove();
                        }
                    }
                    File[] fileArray = new File[fileList.size()];
                    for (int i = 0; i < fileList.size(); i++) {
                        fileArray[i] = fileList.get(i);
                    }

                    String rootPath = SSNHelper.getSsnHiveDirPath();

                    this.getHomeModel().getHomeForm().setCurrentSelectedFile(null);
                    this.getHomeModel().getHomeForm().ssnFileExplorer.m_tree.setSelectionPath(null);
                    this.getHomeModel().getHomeForm().ssnFileExplorer.m_display.setText("instagramMedia");

                    //this.getHomeModel().getHomeForm().ssnFileExplorer.m_tree.setSelectionRow(0);
                    //this.getHomeModel().getHomeForm().ssnFileExplorer.m_display.setText(searchFolder.getAbsolutePath());
                    this.getHomeModel().getHomeForm().getFileNamesToBeDeleted().clear();
                    this.getHomeModel().getHomeForm().setCurrentSelectedFile(null);
                    SSNHelper.toggleDeleteAndShareImages(false, this.getHomeModel().getHomeForm());
                    SSNGalleryHelper contentPane = new SSNGalleryHelper(fileArray,
                            this.getHomeModel().getHomeForm());

                    contentPane.setBackground(SSNConstants.SSN_BLACK_BACKGROUND_COLOR);
                    this.getHomeModel().getHomeForm().getSsnHomeCenterPanel().removeAll();
                    this.getHomeModel().getHomeForm().getSsnHomeCenterMainPanel().removeAll();

                    this.getHomeModel().getHomeForm().getSsnHomeCenterPanel().add(
                            this.getHomeModel().getHomeForm().getScrollPane(contentPane, "Instagram Media"));
                    this.getHomeModel().getHomeForm().getSsnHomeCenterMainPanel().add(this.getHomeModel()
                            .getHomeForm()
                            .getSortPanel("Date", false, SSNHelper.getAlbumNameFromPath(
                                    this.getHomeModel().getHomeForm().ssnFileExplorer.m_display.getText())),
                            BorderLayout.NORTH);
                    this.getHomeModel().getHomeForm().getSsnHomeCenterMainPanel().add(
                            this.getHomeModel().getHomeForm().getSsnHomeCenterPanel(), BorderLayout.CENTER);
                    this.getHomeModel().getSSNMediaFolderProperties(
                            this.getHomeModel().getHomeForm().ssnFileExplorer.m_display.getText(), fileArray);
                    renderLeftPanel();
                    this.getHomeModel().getHomeForm().revalidate();
                } catch (IOException ex) {
                    logger.error(ex);
                }
            } else {
                try {
                    // System.out.println("cancle " + LoginWithInstagram.deniedInstagramPermission);
                    LoginWithInstagram.deniedInstagramPermission = false;
                    AccessGrant instgramAccessGrant = getHomeModel().getHomeForm().getInstagramAccessGrant();
                    if (instgramAccessGrant == null) {
                        try {

                            LoginWithInstagram loginWithInstagram = new LoginWithInstagram(
                                    getHomeModel().getHomeForm());

                            loginWithInstagram.login();
                            boolean processFurther = false;
                            while (!processFurther) {
                                if (LoginWithInstagram.deniedInstagramPermission) {
                                    break;
                                }
                                instgramAccessGrant = getHomeModel().getHomeForm().getInstagramAccessGrant();
                                if (instgramAccessGrant == null) {
                                    if (timoutCount > (5 * 5000)) {
                                        LoginWithInstagram.deniedInstagramPermission = true;
                                        instagarmMessage = "No response from instagram.";
                                        SSNHttpServer.getHttpServer().stop(0);
                                        break;
                                    } else {
                                        Thread.sleep(5000);
                                        timoutCount += 5000;
                                    }
                                } else {
                                    processFurther = true;
                                }
                            }
                        } catch (InterruptedException ex) {
                            logger.error(ex);
                        }
                    }
                    if (!LoginWithInstagram.deniedInstagramPermission) {
                        String urlString = String.format(
                                "https://api.instagram.com/v1/users/self/media/recent/?access_token=%s",
                                instgramAccessGrant.getAccessToken());
                        List<InstagramMedia> imageList = new ArrayList<>();
                        getMedia(urlString, imageList);
                        File searchFolder = new File(
                                SSNHelper.getSsnWorkSpaceDirPath() + File.separator + "Instagram Media");
                        if (!searchFolder.exists()) {
                            searchFolder.mkdirs();
                        } else {
                            //delete whole directory and create new one each time  
                            FileUtils.deleteDirectory(searchFolder);
                            searchFolder.mkdir();
                        }
                        for (InstagramMedia photo : imageList) {
                            String imageUrl = photo.getImageUrl();

                            URL url = new URL(imageUrl);
                            File file = new File(
                                    searchFolder.getAbsolutePath() + File.separator + photo.getId() + ".jpg");
                            if (!file.exists()) {
                                try {

                                    FileUtils.copyURLToFile(url, file);

                                } catch (Exception ex) {
                                    logger.error(ex);
                                }
                            }
                        }
                        this.getHomeModel().getHomeForm().setInstagramSearched(true);
                        File[] files = searchFolder.listFiles();
                        File folder = new File(SSNHelper.getSsnDefaultDirPath());
                        List<File> fileList = new ArrayList<File>();
                        for (File f : files) {
                            fileList.add(f);
                        }
                        Iterator<File> iterator = fileList.iterator();
                        while (iterator.hasNext()) {
                            File f = iterator.next();
                            boolean check = false;
                            try {
                                check = SSNDao.checkMediaExist(
                                        folder.getAbsolutePath() + File.separator + f.getName());
                            } catch (SQLException ex) {
                                ex.printStackTrace();
                                logger.error(ex);
                            }
                            if (check) {
                                //  iterator.remove();
                            }
                        }
                        File[] fileArray = new File[fileList.size()];
                        for (int j = 0; j < fileList.size(); j++) {
                            fileArray[j] = fileList.get(j);
                        }
                        String rootPath = SSNHelper.getSsnHiveDirPath();

                        this.getHomeModel().getHomeForm().setCurrentSelectedFile(null);
                        this.getHomeModel().getHomeForm().ssnFileExplorer.m_tree.setSelectionPath(null);
                        this.getHomeModel().getHomeForm().ssnFileExplorer.m_display.setText("instagramMedia");

                        //this.getHomeModel().getHomeForm().ssnFileExplorer.m_tree.setSelectionRow(0);
                        // this.getHomeModel().getHomeForm().ssnFileExplorer.m_display.setText(searchFolder.getAbsolutePath());
                        this.getHomeModel().getHomeForm().getFileNamesToBeDeleted().clear();
                        //this.getHomeModel().getHomeForm().setCurrentSelectedFile(null);

                        SSNHelper.toggleDeleteAndShareImages(false, this.getHomeModel().getHomeForm());
                        SSNGalleryHelper contentPane = new SSNGalleryHelper(fileArray,
                                this.getHomeModel().getHomeForm());

                        contentPane.setBackground(SSNConstants.SSN_BLACK_BACKGROUND_COLOR);
                        this.getHomeModel().getHomeForm().getSsnHomeCenterPanel().removeAll();
                        this.getHomeModel().getHomeForm().getSsnHomeCenterMainPanel().removeAll();

                        this.getHomeModel().getHomeForm().getSsnHomeCenterPanel().add(this.getHomeModel()
                                .getHomeForm().getScrollPane(contentPane, "Instagram Media"));
                        this.getHomeModel().getHomeForm().getSsnHomeCenterMainPanel().add(this.getHomeModel()
                                .getHomeForm()
                                .getSortPanel("Date", false, SSNHelper.getAlbumNameFromPath(
                                        this.getHomeModel().getHomeForm().ssnFileExplorer.m_display.getText())),
                                BorderLayout.NORTH);
                        this.getHomeModel().getHomeForm().getSsnHomeCenterMainPanel().add(
                                this.getHomeModel().getHomeForm().getSsnHomeCenterPanel(), BorderLayout.CENTER);
                        this.getHomeModel().getSSNMediaFolderProperties(
                                this.getHomeModel().getHomeForm().ssnFileExplorer.m_display.getText(),
                                fileArray);

                        renderLeftPanel();
                        this.getHomeModel().getHomeForm().revalidate();
                    } else {
                        SSNMessageDialogBox messageDialogBox = new SSNMessageDialogBox();
                        messageDialogBox.initDialogBoxUI(SSNDialogChoice.NOTIFICATION_DIALOG.getType(), "Alert",
                                "", instagarmMessage);
                        messageDialogBox.setFocusable(true);
                    }

                } catch (ProtocolException ex) {
                    // ex.printStackTrace();
                    logger.error(ex);
                    //             java.util.logging.Logger.getLogger(SSNUntaggedMediaController.class.getName()).log(Level.SEVERE, null, ex);
                } catch (IOException ex) {
                    //ex.printStackTrace();
                    logger.error(ex);
                    //         java.util.logging.Logger.getLogger(SSNUntaggedMediaController.class.getName()).log(Level.SEVERE, null, ex);
                }

            }
            break;
        case "deviceMedia":
            untaggedMediaForm.dispose();
            this.getHomeModel().findTagUntaggedMedia();
            break;
        case "Cancel":
            untaggedMediaForm.dispose();
        }
        SSNHomeController.isUnTaggedOpen = false;
        untaggedMediaForm.dispose();
        this.getHomeModel().getHomeForm().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }
}