Search in sources :

Example 1 with JOptionPaneClickHandler

use of net.sourceforge.processdash.ui.lib.JOptionPaneClickHandler in project processdash by dtuma.

the class TaskListNavigator method chooseTaskListNavigator.

public static boolean chooseTaskListNavigator(Component parent, DashboardContext context, Resources resources) {
    TaskListTreeModel model;
    try {
        model = new TaskListTreeModel(context);
    } catch (NoTaskListsFoundException ntlfe) {
        String title = resources.getString("Task_List.No_Lists.Title");
        String[] msg = resources.getStrings("Task_List.No_Lists.Message");
        JOptionPane.showMessageDialog(parent, msg, title, JOptionPane.ERROR_MESSAGE);
        return false;
    }
    JTree taskLists = new JTree(model);
    taskLists.addTreeWillExpandListener(model);
    taskLists.setRootVisible(false);
    taskLists.setShowsRootHandles(true);
    taskLists.setToggleClickCount(4);
    taskLists.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    new JOptionPaneClickHandler().install(taskLists);
    JScrollPane sp = new JScrollPane(taskLists);
    sp.setPreferredSize(new Dimension(500, 300));
    String title = resources.getString("Task_List.Dialog.Title");
    Object message = new Object[] { resources.getString("Task_List.Dialog.Prompt"), sp, new JOptionPaneTweaker.MakeResizable() };
    if (JOptionPane.showConfirmDialog(parent, message, title, JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
        TreePath path = taskLists.getSelectionPath();
        if (path == null || path.getPathCount() < 2)
            return false;
        String taskListName = model.getValueFromNode(path.getPathComponent(1));
        String fullPath = null;
        if (path.getPathCount() > 2)
            fullPath = model.getValueFromNode(path.getLastPathComponent());
        InternalSettings.set(TASK_LIST_NAME_SETTING, taskListName);
        InternalSettings.set(TASK_LIST_PATH_SETTING, fullPath);
        return true;
    }
    return false;
}
Also used : JScrollPane(javax.swing.JScrollPane) JTree(javax.swing.JTree) TreePath(javax.swing.tree.TreePath) Dimension(java.awt.Dimension) JOptionPaneClickHandler(net.sourceforge.processdash.ui.lib.JOptionPaneClickHandler)

Example 2 with JOptionPaneClickHandler

use of net.sourceforge.processdash.ui.lib.JOptionPaneClickHandler in project processdash by dtuma.

the class TaskScheduleDialog method chooseTaskLists.

private String[] chooseTaskLists() {
    boolean includeImports = Settings.isTeamMode() || Settings.getBool("ev.addImportsToRollups", false);
    String[] taskListNames = EVTaskList.findTaskLists(dash.getData(), false, includeImports);
    taskListNames = insertRemoveElem(taskListNames, resources.getString("Import_Schedule.New_Schedule_Option"), this.taskListName);
    String[] taskListDisplayNames = EVTaskList.getDisplayNames(taskListNames);
    JList taskLists = new JList(taskListDisplayNames);
    new JOptionPaneClickHandler().install(taskLists);
    JScrollPane sp = new JScrollPane(taskLists);
    sp.setPreferredSize(new Dimension(300, 300));
    Object message = new Object[] { new JOptionPaneTweaker.MakeResizable(), resources.getString("Add_Schedule_Dialog.Instructions"), sp };
    if (JOptionPane.showConfirmDialog(frame, message, resources.getString("Add_Schedule_Dialog.Title"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
        int[] indexes = taskLists.getSelectedIndices();
        String[] result = new String[indexes.length];
        for (int i = 0; i < result.length; i++) {
            if (indexes[i] == 0)
                result[i] = importNewSharedSchedule();
            else
                result[i] = taskListNames[indexes[i]];
        }
        return result;
    }
    return null;
}
Also used : JScrollPane(javax.swing.JScrollPane) CachedObject(net.sourceforge.processdash.net.cache.CachedObject) EventObject(java.util.EventObject) CachedURLObject(net.sourceforge.processdash.net.cache.CachedURLObject) Dimension(java.awt.Dimension) JOptionPaneClickHandler(net.sourceforge.processdash.ui.lib.JOptionPaneClickHandler) JList(javax.swing.JList) Point(java.awt.Point)

Example 3 with JOptionPaneClickHandler

use of net.sourceforge.processdash.ui.lib.JOptionPaneClickHandler in project processdash by dtuma.

the class InstanceLauncherFactory method getZipLauncher.

private DashboardInstance getZipLauncher(Component comp, File f) {
    List prefixes;
    try {
        prefixes = CompressedInstanceLauncher.getLaunchTargetsWithinZip(f);
    } catch (IOException e) {
        JOptionPane.showMessageDialog(comp, resources.formatStrings("Errors.Zip.Read_Error_FMT", f.getAbsolutePath(), e.getLocalizedMessage()), resources.getString("Errors.Dialog_Title"), JOptionPane.ERROR_MESSAGE);
        return null;
    }
    if (prefixes == null || prefixes.isEmpty()) {
        JOptionPane.showMessageDialog(comp, resources.formatStrings("Errors.Zip.No_Data_Found_FMT", f.getAbsolutePath()), resources.getString("Errors.No_Data_Found"), JOptionPane.ERROR_MESSAGE);
        return null;
    }
    if (prefixes.size() == 1) {
        String prefix = (String) prefixes.get(0);
        if (DashboardInstance.WBS_DIR_FILE_ITEM.equals(prefix))
            return new WbsZipInstanceLauncher(f);
        else
            return new CompressedInstanceLauncher(f, prefix);
    }
    JList list = new JList(prefixes.toArray());
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    new JOptionPaneClickHandler().install(list);
    Object[] message = new Object[] { resources.formatStrings("Errors.Zip.Multiple_Data_Found_FMT", f.getAbsolutePath()), new JScrollPane(list) };
    if (JOptionPane.OK_OPTION != JOptionPane.showConfirmDialog(comp, message, resources.getString("Multiple_Data_Found_Title"), JOptionPane.OK_CANCEL_OPTION))
        return null;
    String prefix = (String) list.getSelectedValue();
    if (prefix == null)
        return null;
    else {
        DashboardInstance result = new CompressedInstanceLauncher(f, prefix);
        result.setDisplay(resources.format("Launcher.Zip_Display_FMT", prefix, result.getDisplay()));
        return result;
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) List(java.util.List) JList(javax.swing.JList) IOException(java.io.IOException) JOptionPaneClickHandler(net.sourceforge.processdash.ui.lib.JOptionPaneClickHandler) JList(javax.swing.JList)

Example 4 with JOptionPaneClickHandler

use of net.sourceforge.processdash.ui.lib.JOptionPaneClickHandler in project processdash by dtuma.

the class InstanceLauncherFactory method getDirLauncher.

private DashboardInstance getDirLauncher(Component comp, File dir) {
    File testFile = new File(dir, DashboardInstance.DATA_DIR_FILE_ITEM);
    if (testFile.isFile())
        return new DirectoryInstanceLauncher(dir);
    List dirs;
    try {
        dirs = DirectoryInstanceLauncher.getDataDirectoriesWithinDir(dir);
    } catch (IOException e) {
        JOptionPane.showMessageDialog(comp, resources.formatStrings("Errors.Dir.Read_Error_FMT", dir.getAbsolutePath(), e.getLocalizedMessage()), resources.getString("Errors.Dialog_Title"), JOptionPane.ERROR_MESSAGE);
        return null;
    }
    if (dirs == null || dirs.isEmpty()) {
        // No data dirs found?  See if the dir contains any files at all.
        String[] files = dir.list();
        if (files != null && files.length == 0) {
            // new dataset there.
            if (offerToCreateNewDataset(comp, dir))
                return new DirectoryInstanceLauncher(dir);
            else
                return null;
        }
        // If the directory is not empty, show an error message stating
        // that no dashboard data was found.
        JOptionPane.showMessageDialog(comp, resources.formatStrings("Errors.Dir.No_Data_Found_FMT", dir.getAbsolutePath()), resources.getString("Errors.No_Data_Found"), JOptionPane.ERROR_MESSAGE);
        return null;
    }
    if (dirs.size() == 1)
        return new DirectoryInstanceLauncher((File) dirs.get(0));
    JList list = new JList(dirs.toArray());
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    new JOptionPaneClickHandler().install(list);
    Object[] message = new Object[] { resources.formatStrings("Errors.Dir.Multiple_Data_Found_FMT", dir.getAbsolutePath()), new JScrollPane(list) };
    if (JOptionPane.OK_OPTION != JOptionPane.showConfirmDialog(comp, message, resources.getString("Multiple_Data_Found_Title"), JOptionPane.OK_CANCEL_OPTION))
        return null;
    dir = (File) list.getSelectedValue();
    if (dir == null)
        return null;
    else
        return new DirectoryInstanceLauncher(dir);
}
Also used : JScrollPane(javax.swing.JScrollPane) List(java.util.List) JList(javax.swing.JList) IOException(java.io.IOException) File(java.io.File) JOptionPaneClickHandler(net.sourceforge.processdash.ui.lib.JOptionPaneClickHandler) JList(javax.swing.JList)

Example 5 with JOptionPaneClickHandler

use of net.sourceforge.processdash.ui.lib.JOptionPaneClickHandler in project processdash by dtuma.

the class MorePhaseOptionsHandler method buildTree.

private JTree buildTree() {
    // build a tree model to contain the phase options.
    DefaultMutableTreeNode root = new DefaultMutableTreeNode();
    // Add all known workflows to the model.
    for (Workflow workflow : workflowPhases.workflowInfo.getWorkflows()) {
        DefaultMutableTreeNode workflowNode = new DefaultMutableTreeNode(workflow.getWorkflowName());
        root.add(workflowNode);
        for (Phase onePhase : workflow.getPhases()) {
            DefectPhase dp = new DefectPhase(onePhase);
            if (!"Postmortem".equals(dp.legacyPhase))
                workflowNode.add(new DefaultMutableTreeNode(dp));
        }
    }
    // Add MCF phases to the model.
    if (processPhases != null && !processPhases.isEmpty()) {
        String processName = processPhases.get(0).processName;
        if (!StringUtils.hasValue(processName))
            processName = resources.getString("More_Options.Process_Phases");
        DefaultMutableTreeNode mcfNode = new DefaultMutableTreeNode(processName);
        root.add(mcfNode);
        for (DefectPhase onePhase : processPhases) mcfNode.add(new DefaultMutableTreeNode(onePhase));
    }
    // Create a JTree for this model.
    JTree result = new JTree(root);
    result.setRootVisible(false);
    result.setShowsRootHandles(true);
    result.setToggleClickCount(4);
    result.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    result.setVisibleRowCount(10);
    new JOptionPaneClickHandler().install(result);
    return result;
}
Also used : JTree(javax.swing.JTree) DefectPhase(net.sourceforge.processdash.log.defects.DefectPhase) Phase(net.sourceforge.processdash.process.WorkflowInfo.Phase) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Workflow(net.sourceforge.processdash.process.WorkflowInfo.Workflow) DefectPhase(net.sourceforge.processdash.log.defects.DefectPhase) JOptionPaneClickHandler(net.sourceforge.processdash.ui.lib.JOptionPaneClickHandler)

Aggregations

JOptionPaneClickHandler (net.sourceforge.processdash.ui.lib.JOptionPaneClickHandler)5 JScrollPane (javax.swing.JScrollPane)4 JList (javax.swing.JList)3 Dimension (java.awt.Dimension)2 IOException (java.io.IOException)2 List (java.util.List)2 JTree (javax.swing.JTree)2 Point (java.awt.Point)1 File (java.io.File)1 EventObject (java.util.EventObject)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 TreePath (javax.swing.tree.TreePath)1 DefectPhase (net.sourceforge.processdash.log.defects.DefectPhase)1 CachedObject (net.sourceforge.processdash.net.cache.CachedObject)1 CachedURLObject (net.sourceforge.processdash.net.cache.CachedURLObject)1 Phase (net.sourceforge.processdash.process.WorkflowInfo.Phase)1 Workflow (net.sourceforge.processdash.process.WorkflowInfo.Workflow)1